Merge pull request #23942 from tschuettler/3717-sort-mapping-page
[civicrm-core.git] / CRM / Core / DAO / Managed.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/Core/Managed.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
28979d65 9 * (GenCodeChecksum:54b79cae396d1c5044406fc97ae60352)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the Managed entity.
f41f0342 14 */
e501603b 15class CRM_Core_DAO_Managed extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '4.2';
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_managed';
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 * Surrogate Key
35 *
28979d65
CW
36 * @var int|string|null
37 * (SQL type: int unsigned)
38 * Note that values will be retrieved from the database as a string.
e501603b
TO
39 */
40 public $id;
c3fc2621 41
e501603b
TO
42 /**
43 * Name of the module which declared this object
44 *
45 * @var string
28979d65
CW
46 * (SQL type: varchar(127))
47 * Note that values will be retrieved from the database as a string.
e501603b
TO
48 */
49 public $module;
c3fc2621 50
e501603b
TO
51 /**
52 * Symbolic name used by the module to identify the object
53 *
28979d65
CW
54 * @var string|null
55 * (SQL type: varchar(127))
56 * Note that values will be retrieved from the database as a string.
e501603b
TO
57 */
58 public $name;
c3fc2621 59
e501603b
TO
60 /**
61 * API entity type
62 *
63 * @var string
28979d65
CW
64 * (SQL type: varchar(64))
65 * Note that values will be retrieved from the database as a string.
e501603b
TO
66 */
67 public $entity_type;
c3fc2621 68
e501603b
TO
69 /**
70 * Foreign key to the referenced item.
71 *
28979d65
CW
72 * @var int|string
73 * (SQL type: int unsigned)
74 * Note that values will be retrieved from the database as a string.
e501603b
TO
75 */
76 public $entity_id;
c3fc2621 77
e501603b
TO
78 /**
79 * Policy on when to cleanup entity (always, never, unused)
80 *
28979d65
CW
81 * @var string|null
82 * (SQL type: varchar(32))
83 * Note that values will be retrieved from the database as a string.
e501603b
TO
84 */
85 public $cleanup;
c3fc2621 86
69e13f9b
CW
87 /**
88 * When the managed entity was changed from its original settings.
89 *
28979d65
CW
90 * @var string
91 * (SQL type: timestamp)
92 * Note that values will be retrieved from the database as a string.
69e13f9b
CW
93 */
94 public $entity_modified_date;
95
e501603b 96 /**
f41f0342 97 * Class constructor.
e501603b 98 */
c3fc2621 99 public function __construct() {
e501603b
TO
100 $this->__table = 'civicrm_managed';
101 parent::__construct();
102 }
c3fc2621 103
449c4e6b
CW
104 /**
105 * Returns localized title of this entity.
7b66c3b5
AH
106 *
107 * @param bool $plural
108 * Whether to return the plural version of the title.
449c4e6b 109 */
7b66c3b5
AH
110 public static function getEntityTitle($plural = FALSE) {
111 return $plural ? ts('Manageds') : ts('Managed');
449c4e6b
CW
112 }
113
e501603b
TO
114 /**
115 * Returns all the column names of this table
116 *
117 * @return array
118 */
c3fc2621 119 public static function &fields() {
346aaaba 120 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
121 Civi::$statics[__CLASS__]['fields'] = [
122 'id' => [
e501603b
TO
123 'name' => 'id',
124 'type' => CRM_Utils_Type::T_INT,
c3fc2621 125 'title' => ts('Managed ID'),
215b423e 126 'description' => ts('Surrogate Key'),
c3fc2621 127 'required' => TRUE,
a36434b9 128 'where' => 'civicrm_managed.id',
522a26c9 129 'table_name' => 'civicrm_managed',
130 'entity' => 'Managed',
69e13f9b 131 'bao' => 'CRM_Core_BAO_Managed',
6a7e5e5d 132 'localizable' => 0,
2cbbebe8
A
133 'html' => [
134 'type' => 'Number',
135 ],
1fe423d6 136 'readonly' => TRUE,
a9d0587b 137 'add' => '4.2',
c3fc2621
CW
138 ],
139 'module' => [
e501603b
TO
140 'name' => 'module',
141 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 142 'title' => ts('Module'),
215b423e 143 'description' => ts('Name of the module which declared this object'),
c3fc2621 144 'required' => TRUE,
e501603b
TO
145 'maxlength' => 127,
146 'size' => CRM_Utils_Type::HUGE,
a36434b9 147 'where' => 'civicrm_managed.module',
522a26c9 148 'table_name' => 'civicrm_managed',
149 'entity' => 'Managed',
69e13f9b 150 'bao' => 'CRM_Core_BAO_Managed',
6a7e5e5d 151 'localizable' => 0,
a9d0587b 152 'add' => '4.2',
c3fc2621
CW
153 ],
154 'name' => [
e501603b
TO
155 'name' => 'name',
156 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 157 'title' => ts('Name'),
215b423e 158 'description' => ts('Symbolic name used by the module to identify the object'),
e501603b
TO
159 'maxlength' => 127,
160 'size' => CRM_Utils_Type::HUGE,
a36434b9 161 'where' => 'civicrm_managed.name',
522a26c9 162 'table_name' => 'civicrm_managed',
163 'entity' => 'Managed',
69e13f9b 164 'bao' => 'CRM_Core_BAO_Managed',
6a7e5e5d 165 'localizable' => 0,
a9d0587b 166 'add' => '4.2',
c3fc2621
CW
167 ],
168 'entity_type' => [
e501603b
TO
169 'name' => 'entity_type',
170 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 171 'title' => ts('Entity Type'),
215b423e 172 'description' => ts('API entity type'),
c3fc2621 173 'required' => TRUE,
e501603b
TO
174 'maxlength' => 64,
175 'size' => CRM_Utils_Type::BIG,
a36434b9 176 'where' => 'civicrm_managed.entity_type',
522a26c9 177 'table_name' => 'civicrm_managed',
178 'entity' => 'Managed',
69e13f9b 179 'bao' => 'CRM_Core_BAO_Managed',
6a7e5e5d 180 'localizable' => 0,
a9d0587b 181 'add' => '4.2',
c3fc2621
CW
182 ],
183 'entity_id' => [
e501603b
TO
184 'name' => 'entity_id',
185 'type' => CRM_Utils_Type::T_INT,
c3fc2621 186 'title' => ts('Entity ID'),
215b423e 187 'description' => ts('Foreign key to the referenced item.'),
c3fc2621 188 'required' => TRUE,
a36434b9 189 'where' => 'civicrm_managed.entity_id',
522a26c9 190 'table_name' => 'civicrm_managed',
191 'entity' => 'Managed',
69e13f9b 192 'bao' => 'CRM_Core_BAO_Managed',
6a7e5e5d 193 'localizable' => 0,
a9d0587b 194 'add' => '4.2',
c3fc2621
CW
195 ],
196 'cleanup' => [
e501603b
TO
197 'name' => 'cleanup',
198 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 199 'title' => ts('Cleanup Setting'),
215b423e 200 'description' => ts('Policy on when to cleanup entity (always, never, unused)'),
e501603b
TO
201 'maxlength' => 32,
202 'size' => CRM_Utils_Type::MEDIUM,
a36434b9 203 'where' => 'civicrm_managed.cleanup',
522a26c9 204 'table_name' => 'civicrm_managed',
205 'entity' => 'Managed',
69e13f9b 206 'bao' => 'CRM_Core_BAO_Managed',
6a7e5e5d 207 'localizable' => 0,
c3fc2621 208 'html' => [
e501603b 209 'type' => 'Select',
c3fc2621
CW
210 ],
211 'pseudoconstant' => [
e501603b 212 'callback' => 'CRM_Core_ManagedEntities::getCleanupOptions',
e6ca0a57 213 ],
a9d0587b 214 'add' => '4.5',
c3fc2621 215 ],
69e13f9b
CW
216 'entity_modified_date' => [
217 'name' => 'entity_modified_date',
218 'type' => CRM_Utils_Type::T_TIMESTAMP,
219 'title' => ts('Entity Modified Date'),
220 'description' => ts('When the managed entity was changed from its original settings.'),
221 'required' => FALSE,
222 'where' => 'civicrm_managed.entity_modified_date',
223 'default' => NULL,
224 'table_name' => 'civicrm_managed',
225 'entity' => 'Managed',
226 'bao' => 'CRM_Core_BAO_Managed',
227 'localizable' => 0,
228 'add' => '5.45',
229 ],
c3fc2621 230 ];
346aaaba 231 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 232 }
346aaaba 233 return Civi::$statics[__CLASS__]['fields'];
e501603b 234 }
c3fc2621 235
e501603b 236 /**
bd8e0b14 237 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
238 *
239 * @return array
bd8e0b14 240 * Array(string $name => string $uniqueName).
e501603b 241 */
c3fc2621 242 public static function &fieldKeys() {
bd8e0b14
TO
243 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
244 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 245 }
bd8e0b14 246 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 247 }
c3fc2621 248
e501603b
TO
249 /**
250 * Returns the names of this table
251 *
252 * @return string
253 */
c3fc2621 254 public static function getTableName() {
e501603b
TO
255 return self::$_tableName;
256 }
c3fc2621 257
e501603b
TO
258 /**
259 * Returns if this table needs to be logged
260 *
c3fc2621 261 * @return bool
e501603b 262 */
c3fc2621 263 public function getLog() {
e501603b
TO
264 return self::$_log;
265 }
c3fc2621 266
e501603b
TO
267 /**
268 * Returns the list of fields that can be imported
269 *
270 * @param bool $prefix
271 *
272 * @return array
273 */
c3fc2621
CW
274 public static function &import($prefix = FALSE) {
275 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'managed', $prefix, []);
60808919 276 return $r;
e501603b 277 }
c3fc2621 278
e501603b
TO
279 /**
280 * Returns the list of fields that can be exported
281 *
282 * @param bool $prefix
283 *
284 * @return array
285 */
c3fc2621
CW
286 public static function &export($prefix = FALSE) {
287 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'managed', $prefix, []);
60808919 288 return $r;
e501603b 289 }
c3fc2621 290
e7a6b91a
AS
291 /**
292 * Returns the list of indices
c3fc2621
CW
293 *
294 * @param bool $localize
295 *
296 * @return array
e7a6b91a
AS
297 */
298 public static function indices($localize = TRUE) {
c3fc2621
CW
299 $indices = [
300 'UI_managed_module_name' => [
e7a6b91a 301 'name' => 'UI_managed_module_name',
c3fc2621 302 'field' => [
e7a6b91a
AS
303 0 => 'module',
304 1 => 'name',
c3fc2621
CW
305 ],
306 'localizable' => FALSE,
e7a6b91a 307 'sig' => 'civicrm_managed::0::module::name',
c3fc2621
CW
308 ],
309 'UI_managed_entity' => [
e7a6b91a 310 'name' => 'UI_managed_entity',
c3fc2621 311 'field' => [
e7a6b91a
AS
312 0 => 'entity_type',
313 1 => 'entity_id',
c3fc2621
CW
314 ],
315 'localizable' => FALSE,
e7a6b91a 316 'sig' => 'civicrm_managed::0::entity_type::entity_id',
c3fc2621
CW
317 ],
318 ];
e7a6b91a
AS
319 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
320 }
c3fc2621 321
e501603b 322}