Merge pull request #14322 from AlainBenbassat/5.14
[civicrm-core.git] / CRM / Contact / DAO / SavedSearch.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2019
6 *
7 * Generated from xml/schema/CRM/Contact/SavedSearch.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:ff337d9810d6c4d6225f77b6b3007729)
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 unsigned
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 unsigned
49 */
50 public $mapping_id;
51
52 /**
53 * Foreign key to civicrm_option value table used for saved custom searches.
54 *
55 * @var int unsigned
56 */
57 public $search_custom_id;
58
59 /**
60 * the sql where clause if a saved search acl
61 *
62 * @var text
63 */
64 public $where_clause;
65
66 /**
67 * the tables to be included in a select data
68 *
69 * @var text
70 */
71 public $select_tables;
72
73 /**
74 * the tables to be included in the count statement
75 *
76 * @var text
77 */
78 public $where_tables;
79
80 /**
81 * Class constructor.
82 */
83 public function __construct() {
84 $this->__table = 'civicrm_saved_search';
85 parent::__construct();
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 'where_clause' => [
161 'name' => 'where_clause',
162 'type' => CRM_Utils_Type::T_TEXT,
163 'title' => ts('Where Clause'),
164 'description' => ts('the sql where clause if a saved search acl'),
165 'where' => 'civicrm_saved_search.where_clause',
166 'table_name' => 'civicrm_saved_search',
167 'entity' => 'SavedSearch',
168 'bao' => 'CRM_Contact_BAO_SavedSearch',
169 'localizable' => 0,
170 ],
171 'select_tables' => [
172 'name' => 'select_tables',
173 'type' => CRM_Utils_Type::T_TEXT,
174 'title' => ts('Select Tables'),
175 'description' => ts('the tables to be included in a select data'),
176 'where' => 'civicrm_saved_search.select_tables',
177 'table_name' => 'civicrm_saved_search',
178 'entity' => 'SavedSearch',
179 'bao' => 'CRM_Contact_BAO_SavedSearch',
180 'localizable' => 0,
181 'serialize' => self::SERIALIZE_PHP,
182 ],
183 'where_tables' => [
184 'name' => 'where_tables',
185 'type' => CRM_Utils_Type::T_TEXT,
186 'title' => ts('Where Tables'),
187 'description' => ts('the tables to be included in the count statement'),
188 'where' => 'civicrm_saved_search.where_tables',
189 'table_name' => 'civicrm_saved_search',
190 'entity' => 'SavedSearch',
191 'bao' => 'CRM_Contact_BAO_SavedSearch',
192 'localizable' => 0,
193 'serialize' => self::SERIALIZE_PHP,
194 ],
195 ];
196 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
197 }
198 return Civi::$statics[__CLASS__]['fields'];
199 }
200
201 /**
202 * Return a mapping from field-name to the corresponding key (as used in fields()).
203 *
204 * @return array
205 * Array(string $name => string $uniqueName).
206 */
207 public static function &fieldKeys() {
208 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
209 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
210 }
211 return Civi::$statics[__CLASS__]['fieldKeys'];
212 }
213
214 /**
215 * Returns the names of this table
216 *
217 * @return string
218 */
219 public static function getTableName() {
220 return self::$_tableName;
221 }
222
223 /**
224 * Returns if this table needs to be logged
225 *
226 * @return bool
227 */
228 public function getLog() {
229 return self::$_log;
230 }
231
232 /**
233 * Returns the list of fields that can be imported
234 *
235 * @param bool $prefix
236 *
237 * @return array
238 */
239 public static function &import($prefix = FALSE) {
240 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'saved_search', $prefix, []);
241 return $r;
242 }
243
244 /**
245 * Returns the list of fields that can be exported
246 *
247 * @param bool $prefix
248 *
249 * @return array
250 */
251 public static function &export($prefix = FALSE) {
252 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'saved_search', $prefix, []);
253 return $r;
254 }
255
256 /**
257 * Returns the list of indices
258 *
259 * @param bool $localize
260 *
261 * @return array
262 */
263 public static function indices($localize = TRUE) {
264 $indices = [];
265 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
266 }
267
268 }