Merge pull request #18254 from pradpnayak/casetypeselection
[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
929a1c14 9 * (GenCodeChecksum:4b2f292a8196a5dc4a73afc078cd11cb)
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.
85 */
86 public static function getEntityTitle() {
87 return ts('Saved Searches');
88 }
89
e501603b 90 /**
f41f0342 91 * Returns foreign keys and entity references.
e501603b
TO
92 *
93 * @return array
94 * [CRM_Core_Reference_Interface]
95 */
c3fc2621 96 public static function getReferenceColumns() {
346aaaba 97 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 98 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621 99 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'mapping_id', 'civicrm_mapping', 'id');
346aaaba 100 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 101 }
346aaaba 102 return Civi::$statics[__CLASS__]['links'];
e501603b 103 }
c3fc2621 104
e501603b
TO
105 /**
106 * Returns all the column names of this table
107 *
108 * @return array
109 */
c3fc2621 110 public static function &fields() {
346aaaba 111 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
112 Civi::$statics[__CLASS__]['fields'] = [
113 'id' => [
e501603b
TO
114 'name' => 'id',
115 'type' => CRM_Utils_Type::T_INT,
c3fc2621 116 'title' => ts('Saved Search ID'),
215b423e 117 'description' => ts('Saved Search ID'),
c3fc2621 118 'required' => TRUE,
a36434b9 119 'where' => 'civicrm_saved_search.id',
522a26c9 120 'table_name' => 'civicrm_saved_search',
121 'entity' => 'SavedSearch',
122 'bao' => 'CRM_Contact_BAO_SavedSearch',
6a7e5e5d 123 'localizable' => 0,
a9d0587b 124 'add' => '1.1',
c3fc2621
CW
125 ],
126 'form_values' => [
e501603b
TO
127 'name' => 'form_values',
128 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 129 'title' => ts('Submitted Form Values'),
215b423e 130 'description' => ts('Submitted form values for this search'),
c3fc2621 131 'import' => TRUE,
e501603b 132 'where' => 'civicrm_saved_search.form_values',
c3fc2621 133 'export' => TRUE,
522a26c9 134 'table_name' => 'civicrm_saved_search',
135 'entity' => 'SavedSearch',
136 'bao' => 'CRM_Contact_BAO_SavedSearch',
6a7e5e5d 137 'localizable' => 0,
2a5c9b4d 138 'serialize' => self::SERIALIZE_PHP,
a9d0587b 139 'add' => '1.1',
c3fc2621
CW
140 ],
141 'mapping_id' => [
e501603b
TO
142 'name' => 'mapping_id',
143 'type' => CRM_Utils_Type::T_INT,
c3fc2621 144 'title' => ts('Mapping ID'),
215b423e 145 'description' => ts('Foreign key to civicrm_mapping used for saved search-builder searches.'),
a36434b9 146 'where' => 'civicrm_saved_search.mapping_id',
522a26c9 147 'table_name' => 'civicrm_saved_search',
148 'entity' => 'SavedSearch',
149 'bao' => 'CRM_Contact_BAO_SavedSearch',
6a7e5e5d 150 'localizable' => 0,
e501603b 151 'FKClassName' => 'CRM_Core_DAO_Mapping',
a9d0587b 152 'add' => '1.5',
c3fc2621
CW
153 ],
154 'search_custom_id' => [
e501603b
TO
155 'name' => 'search_custom_id',
156 'type' => CRM_Utils_Type::T_INT,
c3fc2621 157 'title' => ts('Option Value ID'),
215b423e 158 'description' => ts('Foreign key to civicrm_option value table used for saved custom searches.'),
a36434b9 159 'where' => 'civicrm_saved_search.search_custom_id',
522a26c9 160 'table_name' => 'civicrm_saved_search',
161 'entity' => 'SavedSearch',
162 'bao' => 'CRM_Contact_BAO_SavedSearch',
6a7e5e5d 163 'localizable' => 0,
a9d0587b 164 'add' => '2.0',
c3fc2621 165 ],
0d7216d3
CW
166 'api_entity' => [
167 'name' => 'api_entity',
168 'type' => CRM_Utils_Type::T_STRING,
169 'title' => ts('Entity Name'),
170 'description' => ts('Entity name for API based search'),
171 'maxlength' => 255,
172 'size' => CRM_Utils_Type::HUGE,
173 'where' => 'civicrm_saved_search.api_entity',
174 'table_name' => 'civicrm_saved_search',
175 'entity' => 'SavedSearch',
176 'bao' => 'CRM_Contact_BAO_SavedSearch',
177 'localizable' => 0,
a9d0587b 178 'add' => '5.24',
0d7216d3
CW
179 ],
180 'api_params' => [
181 'name' => 'api_params',
182 'type' => CRM_Utils_Type::T_TEXT,
183 'title' => ts('API Parameters'),
184 'description' => ts('Parameters for API based search'),
185 'where' => 'civicrm_saved_search.api_params',
186 'table_name' => 'civicrm_saved_search',
187 'entity' => 'SavedSearch',
188 'bao' => 'CRM_Contact_BAO_SavedSearch',
189 'localizable' => 0,
190 'serialize' => self::SERIALIZE_JSON,
a9d0587b 191 'add' => '5.24',
0d7216d3 192 ],
c3fc2621 193 ];
346aaaba 194 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 195 }
346aaaba 196 return Civi::$statics[__CLASS__]['fields'];
e501603b 197 }
c3fc2621 198
e501603b 199 /**
bd8e0b14 200 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
201 *
202 * @return array
bd8e0b14 203 * Array(string $name => string $uniqueName).
e501603b 204 */
c3fc2621 205 public static function &fieldKeys() {
bd8e0b14
TO
206 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
207 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 208 }
bd8e0b14 209 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 210 }
c3fc2621 211
e501603b
TO
212 /**
213 * Returns the names of this table
214 *
215 * @return string
216 */
c3fc2621 217 public static function getTableName() {
e501603b
TO
218 return self::$_tableName;
219 }
c3fc2621 220
e501603b
TO
221 /**
222 * Returns if this table needs to be logged
223 *
c3fc2621 224 * @return bool
e501603b 225 */
c3fc2621 226 public function getLog() {
e501603b
TO
227 return self::$_log;
228 }
c3fc2621 229
e501603b
TO
230 /**
231 * Returns the list of fields that can be imported
232 *
233 * @param bool $prefix
234 *
235 * @return array
236 */
c3fc2621
CW
237 public static function &import($prefix = FALSE) {
238 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'saved_search', $prefix, []);
60808919 239 return $r;
e501603b 240 }
c3fc2621 241
e501603b
TO
242 /**
243 * Returns the list of fields that can be exported
244 *
245 * @param bool $prefix
246 *
247 * @return array
248 */
c3fc2621
CW
249 public static function &export($prefix = FALSE) {
250 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'saved_search', $prefix, []);
60808919 251 return $r;
e501603b 252 }
c3fc2621 253
e7a6b91a
AS
254 /**
255 * Returns the list of indices
c3fc2621
CW
256 *
257 * @param bool $localize
258 *
259 * @return array
e7a6b91a
AS
260 */
261 public static function indices($localize = TRUE) {
c3fc2621 262 $indices = [];
e7a6b91a
AS
263 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
264 }
c3fc2621 265
e501603b 266}