Merge pull request #19296 from eileenmcnaughton/fbool
[civicrm-core.git] / CRM / Contact / DAO / SavedSearch.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Contact/SavedSearch.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:73251f9c4af0127e2e9fc2770f21869d)
10 */
11
12 /**
13 * Database access object for the SavedSearch entity.
14 */
15 class CRM_Contact_DAO_SavedSearch extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.1';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_saved_search';
25
26 /**
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
28 *
29 * @var bool
30 */
31 public static $_log = FALSE;
32
33 /**
34 * Saved Search ID
35 *
36 * @var int
37 */
38 public $id;
39
40 /**
41 * Unique name of saved search
42 *
43 * @var string
44 */
45 public $name;
46
47 /**
48 * Administrative label for search
49 *
50 * @var string
51 */
52 public $label;
53
54 /**
55 * Submitted form values for this search
56 *
57 * @var text
58 */
59 public $form_values;
60
61 /**
62 * Foreign key to civicrm_mapping used for saved search-builder searches.
63 *
64 * @var int
65 */
66 public $mapping_id;
67
68 /**
69 * Foreign key to civicrm_option value table used for saved custom searches.
70 *
71 * @var int
72 */
73 public $search_custom_id;
74
75 /**
76 * Entity name for API based search
77 *
78 * @var string
79 */
80 public $api_entity;
81
82 /**
83 * Parameters for API based search
84 *
85 * @var text
86 */
87 public $api_params;
88
89 /**
90 * Class constructor.
91 */
92 public function __construct() {
93 $this->__table = 'civicrm_saved_search';
94 parent::__construct();
95 }
96
97 /**
98 * Returns localized title of this entity.
99 *
100 * @param bool $plural
101 * Whether to return the plural version of the title.
102 */
103 public static function getEntityTitle($plural = FALSE) {
104 return $plural ? ts('Saved Searches') : ts('Saved Search');
105 }
106
107 /**
108 * Returns foreign keys and entity references.
109 *
110 * @return array
111 * [CRM_Core_Reference_Interface]
112 */
113 public static function getReferenceColumns() {
114 if (!isset(Civi::$statics[__CLASS__]['links'])) {
115 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
116 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'mapping_id', 'civicrm_mapping', 'id');
117 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
118 }
119 return Civi::$statics[__CLASS__]['links'];
120 }
121
122 /**
123 * Returns all the column names of this table
124 *
125 * @return array
126 */
127 public static function &fields() {
128 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
129 Civi::$statics[__CLASS__]['fields'] = [
130 'id' => [
131 'name' => 'id',
132 'type' => CRM_Utils_Type::T_INT,
133 'title' => ts('Saved Search ID'),
134 'description' => ts('Saved Search ID'),
135 'required' => TRUE,
136 'where' => 'civicrm_saved_search.id',
137 'table_name' => 'civicrm_saved_search',
138 'entity' => 'SavedSearch',
139 'bao' => 'CRM_Contact_BAO_SavedSearch',
140 'localizable' => 0,
141 'add' => '1.1',
142 ],
143 'name' => [
144 'name' => 'name',
145 'type' => CRM_Utils_Type::T_STRING,
146 'title' => ts('Saved Search Name'),
147 'description' => ts('Unique name of saved search'),
148 'maxlength' => 255,
149 'size' => CRM_Utils_Type::HUGE,
150 'where' => 'civicrm_saved_search.name',
151 'default' => 'NULL',
152 'table_name' => 'civicrm_saved_search',
153 'entity' => 'SavedSearch',
154 'bao' => 'CRM_Contact_BAO_SavedSearch',
155 'localizable' => 0,
156 'html' => [
157 'type' => 'Text',
158 ],
159 'add' => '1.0',
160 ],
161 'label' => [
162 'name' => 'label',
163 'type' => CRM_Utils_Type::T_STRING,
164 'title' => ts('Saved Search Label'),
165 'description' => ts('Administrative label for search'),
166 'maxlength' => 255,
167 'size' => CRM_Utils_Type::HUGE,
168 'where' => 'civicrm_saved_search.label',
169 'default' => 'NULL',
170 'table_name' => 'civicrm_saved_search',
171 'entity' => 'SavedSearch',
172 'bao' => 'CRM_Contact_BAO_SavedSearch',
173 'localizable' => 0,
174 'html' => [
175 'type' => 'Text',
176 ],
177 'add' => '5.32',
178 ],
179 'form_values' => [
180 'name' => 'form_values',
181 'type' => CRM_Utils_Type::T_TEXT,
182 'title' => ts('Submitted Form Values'),
183 'description' => ts('Submitted form values for this search'),
184 'import' => TRUE,
185 'where' => 'civicrm_saved_search.form_values',
186 'export' => TRUE,
187 'table_name' => 'civicrm_saved_search',
188 'entity' => 'SavedSearch',
189 'bao' => 'CRM_Contact_BAO_SavedSearch',
190 'localizable' => 0,
191 'serialize' => self::SERIALIZE_PHP,
192 'add' => '1.1',
193 ],
194 'mapping_id' => [
195 'name' => 'mapping_id',
196 'type' => CRM_Utils_Type::T_INT,
197 'title' => ts('Mapping ID'),
198 'description' => ts('Foreign key to civicrm_mapping used for saved search-builder searches.'),
199 'where' => 'civicrm_saved_search.mapping_id',
200 'table_name' => 'civicrm_saved_search',
201 'entity' => 'SavedSearch',
202 'bao' => 'CRM_Contact_BAO_SavedSearch',
203 'localizable' => 0,
204 'FKClassName' => 'CRM_Core_DAO_Mapping',
205 'add' => '1.5',
206 ],
207 'search_custom_id' => [
208 'name' => 'search_custom_id',
209 'type' => CRM_Utils_Type::T_INT,
210 'title' => ts('Option Value ID'),
211 'description' => ts('Foreign key to civicrm_option value table used for saved custom searches.'),
212 'where' => 'civicrm_saved_search.search_custom_id',
213 'table_name' => 'civicrm_saved_search',
214 'entity' => 'SavedSearch',
215 'bao' => 'CRM_Contact_BAO_SavedSearch',
216 'localizable' => 0,
217 'add' => '2.0',
218 ],
219 'api_entity' => [
220 'name' => 'api_entity',
221 'type' => CRM_Utils_Type::T_STRING,
222 'title' => ts('Entity Name'),
223 'description' => ts('Entity name for API based search'),
224 'maxlength' => 255,
225 'size' => CRM_Utils_Type::HUGE,
226 'where' => 'civicrm_saved_search.api_entity',
227 'table_name' => 'civicrm_saved_search',
228 'entity' => 'SavedSearch',
229 'bao' => 'CRM_Contact_BAO_SavedSearch',
230 'localizable' => 0,
231 'add' => '5.24',
232 ],
233 'api_params' => [
234 'name' => 'api_params',
235 'type' => CRM_Utils_Type::T_TEXT,
236 'title' => ts('API Parameters'),
237 'description' => ts('Parameters for API based search'),
238 'where' => 'civicrm_saved_search.api_params',
239 'table_name' => 'civicrm_saved_search',
240 'entity' => 'SavedSearch',
241 'bao' => 'CRM_Contact_BAO_SavedSearch',
242 'localizable' => 0,
243 'serialize' => self::SERIALIZE_JSON,
244 'add' => '5.24',
245 ],
246 ];
247 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
248 }
249 return Civi::$statics[__CLASS__]['fields'];
250 }
251
252 /**
253 * Return a mapping from field-name to the corresponding key (as used in fields()).
254 *
255 * @return array
256 * Array(string $name => string $uniqueName).
257 */
258 public static function &fieldKeys() {
259 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
260 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
261 }
262 return Civi::$statics[__CLASS__]['fieldKeys'];
263 }
264
265 /**
266 * Returns the names of this table
267 *
268 * @return string
269 */
270 public static function getTableName() {
271 return self::$_tableName;
272 }
273
274 /**
275 * Returns if this table needs to be logged
276 *
277 * @return bool
278 */
279 public function getLog() {
280 return self::$_log;
281 }
282
283 /**
284 * Returns the list of fields that can be imported
285 *
286 * @param bool $prefix
287 *
288 * @return array
289 */
290 public static function &import($prefix = FALSE) {
291 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'saved_search', $prefix, []);
292 return $r;
293 }
294
295 /**
296 * Returns the list of fields that can be exported
297 *
298 * @param bool $prefix
299 *
300 * @return array
301 */
302 public static function &export($prefix = FALSE) {
303 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'saved_search', $prefix, []);
304 return $r;
305 }
306
307 /**
308 * Returns the list of indices
309 *
310 * @param bool $localize
311 *
312 * @return array
313 */
314 public static function indices($localize = TRUE) {
315 $indices = [
316 'UI_name' => [
317 'name' => 'UI_name',
318 'field' => [
319 0 => 'name',
320 ],
321 'localizable' => FALSE,
322 'unique' => TRUE,
323 'sig' => 'civicrm_saved_search::1::name',
324 ],
325 ];
326 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
327 }
328
329 }