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