Merge pull request #18493 from mlutfy/campaignReportDefaults
[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:d863f8b0b8659633bc84578e1d6cbf10)
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 * Submitted form values for this search
42 *
43 * @var text
44 */
45 public $form_values;
46
47 /**
48 * Foreign key to civicrm_mapping used for saved search-builder searches.
49 *
50 * @var int
51 */
52 public $mapping_id;
53
54 /**
55 * Foreign key to civicrm_option value table used for saved custom searches.
56 *
57 * @var int
58 */
59 public $search_custom_id;
60
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
75 /**
76 * Class constructor.
77 */
78 public function __construct() {
79 $this->__table = 'civicrm_saved_search';
80 parent::__construct();
81 }
82
83 /**
84 * Returns localized title of this entity.
85 *
86 * @param bool $plural
87 * Whether to return the plural version of the title.
88 */
89 public static function getEntityTitle($plural = FALSE) {
90 return $plural ? ts('Saved Searches') : ts('Saved Search');
91 }
92
93 /**
94 * Returns foreign keys and entity references.
95 *
96 * @return array
97 * [CRM_Core_Reference_Interface]
98 */
99 public static function getReferenceColumns() {
100 if (!isset(Civi::$statics[__CLASS__]['links'])) {
101 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
102 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'mapping_id', 'civicrm_mapping', 'id');
103 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
104 }
105 return Civi::$statics[__CLASS__]['links'];
106 }
107
108 /**
109 * Returns all the column names of this table
110 *
111 * @return array
112 */
113 public static function &fields() {
114 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
115 Civi::$statics[__CLASS__]['fields'] = [
116 'id' => [
117 'name' => 'id',
118 'type' => CRM_Utils_Type::T_INT,
119 'title' => ts('Saved Search ID'),
120 'description' => ts('Saved Search ID'),
121 'required' => TRUE,
122 'where' => 'civicrm_saved_search.id',
123 'table_name' => 'civicrm_saved_search',
124 'entity' => 'SavedSearch',
125 'bao' => 'CRM_Contact_BAO_SavedSearch',
126 'localizable' => 0,
127 'add' => '1.1',
128 ],
129 'form_values' => [
130 'name' => 'form_values',
131 'type' => CRM_Utils_Type::T_TEXT,
132 'title' => ts('Submitted Form Values'),
133 'description' => ts('Submitted form values for this search'),
134 'import' => TRUE,
135 'where' => 'civicrm_saved_search.form_values',
136 'export' => TRUE,
137 'table_name' => 'civicrm_saved_search',
138 'entity' => 'SavedSearch',
139 'bao' => 'CRM_Contact_BAO_SavedSearch',
140 'localizable' => 0,
141 'serialize' => self::SERIALIZE_PHP,
142 'add' => '1.1',
143 ],
144 'mapping_id' => [
145 'name' => 'mapping_id',
146 'type' => CRM_Utils_Type::T_INT,
147 'title' => ts('Mapping ID'),
148 'description' => ts('Foreign key to civicrm_mapping used for saved search-builder searches.'),
149 'where' => 'civicrm_saved_search.mapping_id',
150 'table_name' => 'civicrm_saved_search',
151 'entity' => 'SavedSearch',
152 'bao' => 'CRM_Contact_BAO_SavedSearch',
153 'localizable' => 0,
154 'FKClassName' => 'CRM_Core_DAO_Mapping',
155 'add' => '1.5',
156 ],
157 'search_custom_id' => [
158 'name' => 'search_custom_id',
159 'type' => CRM_Utils_Type::T_INT,
160 'title' => ts('Option Value ID'),
161 'description' => ts('Foreign key to civicrm_option value table used for saved custom searches.'),
162 'where' => 'civicrm_saved_search.search_custom_id',
163 'table_name' => 'civicrm_saved_search',
164 'entity' => 'SavedSearch',
165 'bao' => 'CRM_Contact_BAO_SavedSearch',
166 'localizable' => 0,
167 'add' => '2.0',
168 ],
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,
181 'add' => '5.24',
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,
194 'add' => '5.24',
195 ],
196 ];
197 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
198 }
199 return Civi::$statics[__CLASS__]['fields'];
200 }
201
202 /**
203 * Return a mapping from field-name to the corresponding key (as used in fields()).
204 *
205 * @return array
206 * Array(string $name => string $uniqueName).
207 */
208 public static function &fieldKeys() {
209 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
210 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
211 }
212 return Civi::$statics[__CLASS__]['fieldKeys'];
213 }
214
215 /**
216 * Returns the names of this table
217 *
218 * @return string
219 */
220 public static function getTableName() {
221 return self::$_tableName;
222 }
223
224 /**
225 * Returns if this table needs to be logged
226 *
227 * @return bool
228 */
229 public function getLog() {
230 return self::$_log;
231 }
232
233 /**
234 * Returns the list of fields that can be imported
235 *
236 * @param bool $prefix
237 *
238 * @return array
239 */
240 public static function &import($prefix = FALSE) {
241 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'saved_search', $prefix, []);
242 return $r;
243 }
244
245 /**
246 * Returns the list of fields that can be exported
247 *
248 * @param bool $prefix
249 *
250 * @return array
251 */
252 public static function &export($prefix = FALSE) {
253 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'saved_search', $prefix, []);
254 return $r;
255 }
256
257 /**
258 * Returns the list of indices
259 *
260 * @param bool $localize
261 *
262 * @return array
263 */
264 public static function indices($localize = TRUE) {
265 $indices = [];
266 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
267 }
268
269 }