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