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