xml/templates/dao.tpl - Centralize export() / import() logic
[civicrm-core.git] / CRM / Dedupe / DAO / Rule.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
6| Copyright CiviCRM LLC (c) 2004-2016 |
7+--------------------------------------------------------------------+
8| This file is a part of CiviCRM. |
9| |
10| CiviCRM is free software; you can copy, modify, and distribute it |
11| under the terms of the GNU Affero General Public License |
12| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13| |
14| CiviCRM is distributed in the hope that it will be useful, but |
15| WITHOUT ANY WARRANTY; without even the implied warranty of |
16| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17| See the GNU Affero General Public License for more details. |
18| |
19| You should have received a copy of the GNU Affero General Public |
20| License and the CiviCRM Licensing Exception along |
21| with this program; if not, contact CiviCRM LLC |
22| at info[AT]civicrm[DOT]org. If you have questions about the |
23| GNU Affero General Public License or the licensing of CiviCRM, |
24| see the CiviCRM license FAQ at http://civicrm.org/licensing |
25+--------------------------------------------------------------------+
26*/
27/**
28 * @package CRM
29 * @copyright CiviCRM LLC (c) 2004-2016
30 *
31 * Generated from xml/schema/CRM/Dedupe/Rule.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
437fafcf 33 * (GenCodeChecksum:083bfadf2e54fb13a6875d14f2e52b5a)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
37class CRM_Dedupe_DAO_Rule extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_dedupe_rule';
44 /**
45 * static instance to hold the field values
46 *
47 * @var array
48 */
49 static $_fields = null;
50 /**
51 * static instance to hold the keys used in $_fields for each field.
52 *
53 * @var array
54 */
55 static $_fieldKeys = null;
56 /**
57 * static instance to hold the FK relationships
58 *
59 * @var string
60 */
61 static $_links = null;
62 /**
63 * static instance to hold the values that can
64 * be imported
65 *
66 * @var array
67 */
68 static $_import = null;
69 /**
70 * static instance to hold the values that can
71 * be exported
72 *
73 * @var array
74 */
75 static $_export = null;
76 /**
77 * static value to see if we should log any modifications to
78 * this table in the civicrm_log table
79 *
80 * @var boolean
81 */
82 static $_log = false;
83 /**
84 * Unique dedupe rule id
85 *
86 * @var int unsigned
87 */
88 public $id;
89 /**
90 * The id of the rule group this rule belongs to
91 *
92 * @var int unsigned
93 */
94 public $dedupe_rule_group_id;
95 /**
96 * The name of the table this rule is about
97 *
98 * @var string
99 */
100 public $rule_table;
101 /**
102 * The name of the field of the table referenced in rule_table
103 *
104 * @var string
105 */
106 public $rule_field;
107 /**
108 * The length of the matching substring
109 *
110 * @var int unsigned
111 */
112 public $rule_length;
113 /**
114 * The weight of the rule
115 *
116 * @var int
117 */
118 public $rule_weight;
119 /**
120 * class constructor
121 *
122 * @return civicrm_dedupe_rule
123 */
124 function __construct() {
125 $this->__table = 'civicrm_dedupe_rule';
126 parent::__construct();
127 }
128 /**
129 * Returns foreign keys and entity references
130 *
131 * @return array
132 * [CRM_Core_Reference_Interface]
133 */
134 static function getReferenceColumns() {
135 if (!self::$_links) {
136 self::$_links = static ::createReferenceColumns(__CLASS__);
137 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'dedupe_rule_group_id', 'civicrm_dedupe_rule_group', 'id');
138 }
139 return self::$_links;
140 }
141 /**
142 * Returns all the column names of this table
143 *
144 * @return array
145 */
146 static function &fields() {
147 if (!(self::$_fields)) {
148 self::$_fields = array(
149 'id' => array(
150 'name' => 'id',
151 'type' => CRM_Utils_Type::T_INT,
152 'title' => ts('Dedupe Rule ID') ,
153 'description' => 'Unique dedupe rule id',
154 'required' => true,
155 ) ,
156 'dedupe_rule_group_id' => array(
157 'name' => 'dedupe_rule_group_id',
158 'type' => CRM_Utils_Type::T_INT,
159 'title' => ts('Dedupe Rule Group') ,
160 'description' => 'The id of the rule group this rule belongs to',
161 'required' => true,
162 'FKClassName' => 'CRM_Dedupe_DAO_RuleGroup',
163 ) ,
164 'rule_table' => array(
165 'name' => 'rule_table',
166 'type' => CRM_Utils_Type::T_STRING,
167 'title' => ts('Rule Table') ,
168 'description' => 'The name of the table this rule is about',
169 'required' => true,
170 'maxlength' => 64,
171 'size' => CRM_Utils_Type::BIG,
172 ) ,
173 'rule_field' => array(
174 'name' => 'rule_field',
175 'type' => CRM_Utils_Type::T_STRING,
176 'title' => ts('Rule Field') ,
177 'description' => 'The name of the field of the table referenced in rule_table',
178 'required' => true,
179 'maxlength' => 64,
180 'size' => CRM_Utils_Type::BIG,
181 ) ,
182 'rule_length' => array(
183 'name' => 'rule_length',
184 'type' => CRM_Utils_Type::T_INT,
185 'title' => ts('Rule Length') ,
186 'description' => 'The length of the matching substring',
187 'html' => array(
188 'type' => 'Text',
189 ) ,
190 ) ,
191 'rule_weight' => array(
192 'name' => 'rule_weight',
193 'type' => CRM_Utils_Type::T_INT,
194 'title' => ts('Order') ,
195 'description' => 'The weight of the rule',
196 'required' => true,
197 'html' => array(
198 'type' => 'Text',
199 ) ,
200 ) ,
201 );
202 }
203 return self::$_fields;
204 }
205 /**
206 * Returns an array containing, for each field, the arary key used for that
207 * field in self::$_fields.
208 *
209 * @return array
210 */
211 static function &fieldKeys() {
212 if (!(self::$_fieldKeys)) {
213 self::$_fieldKeys = array(
214 'id' => 'id',
215 'dedupe_rule_group_id' => 'dedupe_rule_group_id',
216 'rule_table' => 'rule_table',
217 'rule_field' => 'rule_field',
218 'rule_length' => 'rule_length',
219 'rule_weight' => 'rule_weight',
220 );
221 }
222 return self::$_fieldKeys;
223 }
224 /**
225 * Returns the names of this table
226 *
227 * @return string
228 */
229 static function getTableName() {
230 return self::$_tableName;
231 }
232 /**
233 * Returns if this table needs to be logged
234 *
235 * @return boolean
236 */
237 function getLog() {
238 return self::$_log;
239 }
240 /**
241 * Returns the list of fields that can be imported
242 *
243 * @param bool $prefix
244 *
245 * @return array
246 */
247 static function &import($prefix = false) {
248 if (!(self::$_import)) {
249 self::$_import = array();
250 $fields = self::fields();
251 foreach($fields as $name => $field) {
252 if (CRM_Utils_Array::value('import', $field)) {
253 if ($prefix) {
254 self::$_import['dedupe_rule'] = & $fields[$name];
255 } else {
256 self::$_import[$name] = & $fields[$name];
257 }
258 }
259 }
260 }
261 return self::$_import;
262 }
263 /**
264 * Returns the list of fields that can be exported
265 *
266 * @param bool $prefix
267 *
268 * @return array
269 */
270 static function &export($prefix = false) {
271 if (!(self::$_export)) {
272 self::$_export = array();
273 $fields = self::fields();
274 foreach($fields as $name => $field) {
275 if (CRM_Utils_Array::value('export', $field)) {
276 if ($prefix) {
277 self::$_export['dedupe_rule'] = & $fields[$name];
278 } else {
279 self::$_export[$name] = & $fields[$name];
280 }
281 }
282 }
283 }
284 return self::$_export;
285 }
286}