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