Merge pull request #23213 from eileenmcnaughton/post
[civicrm-core.git] / CRM / Core / DAO / Log.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/Log.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
28979d65 9 * (GenCodeChecksum:b2552b667e074cb7bb4132eac8153df2)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the Log entity.
f41f0342 14 */
e501603b 15class CRM_Core_DAO_Log extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.5';
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_log';
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 * Log ID
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 table where item being referenced is stored.
44 *
45 * @var string
28979d65
CW
46 * (SQL type: varchar(64))
47 * Note that values will be retrieved from the database as a string.
e501603b
TO
48 */
49 public $entity_table;
c3fc2621 50
e501603b
TO
51 /**
52 * Foreign key to the referenced item.
53 *
28979d65
CW
54 * @var int|string
55 * (SQL type: int unsigned)
56 * Note that values will be retrieved from the database as a string.
e501603b
TO
57 */
58 public $entity_id;
c3fc2621 59
e501603b
TO
60 /**
61 * Updates does to this object if any.
62 *
28979d65
CW
63 * @var string|null
64 * (SQL type: text)
65 * Note that values will be retrieved from the database as a string.
e501603b
TO
66 */
67 public $data;
c3fc2621 68
e501603b
TO
69 /**
70 * FK to Contact ID of person under whose credentials this data modification was made.
71 *
28979d65
CW
72 * @var int|string|null
73 * (SQL type: int unsigned)
74 * Note that values will be retrieved from the database as a string.
e501603b
TO
75 */
76 public $modified_id;
c3fc2621 77
e501603b
TO
78 /**
79 * When was the referenced entity created or modified or deleted.
80 *
28979d65
CW
81 * @var string|null
82 * (SQL type: datetime)
83 * Note that values will be retrieved from the database as a string.
e501603b
TO
84 */
85 public $modified_date;
c3fc2621 86
e501603b 87 /**
f41f0342 88 * Class constructor.
e501603b 89 */
c3fc2621 90 public function __construct() {
e501603b
TO
91 $this->__table = 'civicrm_log';
92 parent::__construct();
93 }
c3fc2621 94
449c4e6b
CW
95 /**
96 * Returns localized title of this entity.
7b66c3b5
AH
97 *
98 * @param bool $plural
99 * Whether to return the plural version of the title.
449c4e6b 100 */
7b66c3b5
AH
101 public static function getEntityTitle($plural = FALSE) {
102 return $plural ? ts('Logs') : ts('Log');
449c4e6b
CW
103 }
104
e501603b 105 /**
f41f0342 106 * Returns foreign keys and entity references.
e501603b
TO
107 *
108 * @return array
109 * [CRM_Core_Reference_Interface]
110 */
c3fc2621 111 public static function getReferenceColumns() {
346aaaba 112 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 113 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
114 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'modified_id', 'civicrm_contact', 'id');
115 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
346aaaba 116 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 117 }
346aaaba 118 return Civi::$statics[__CLASS__]['links'];
e501603b 119 }
c3fc2621 120
e501603b
TO
121 /**
122 * Returns all the column names of this table
123 *
124 * @return array
125 */
c3fc2621 126 public static function &fields() {
346aaaba 127 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
128 Civi::$statics[__CLASS__]['fields'] = [
129 'id' => [
e501603b
TO
130 'name' => 'id',
131 'type' => CRM_Utils_Type::T_INT,
c3fc2621 132 'title' => ts('Log ID'),
215b423e 133 'description' => ts('Log ID'),
c3fc2621 134 'required' => TRUE,
a36434b9 135 'where' => 'civicrm_log.id',
522a26c9 136 'table_name' => 'civicrm_log',
137 'entity' => 'Log',
138 'bao' => 'CRM_Core_BAO_Log',
6a7e5e5d 139 'localizable' => 0,
2cbbebe8
A
140 'html' => [
141 'type' => 'Number',
142 ],
1fe423d6 143 'readonly' => TRUE,
a9d0587b 144 'add' => '1.5',
c3fc2621
CW
145 ],
146 'entity_table' => [
e501603b
TO
147 'name' => 'entity_table',
148 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 149 'title' => ts('Entity Table'),
215b423e 150 'description' => ts('Name of table where item being referenced is stored.'),
c3fc2621 151 'required' => TRUE,
e501603b
TO
152 'maxlength' => 64,
153 'size' => CRM_Utils_Type::BIG,
a36434b9 154 'where' => 'civicrm_log.entity_table',
522a26c9 155 'table_name' => 'civicrm_log',
156 'entity' => 'Log',
157 'bao' => 'CRM_Core_BAO_Log',
6a7e5e5d 158 'localizable' => 0,
a9d0587b 159 'add' => '1.5',
c3fc2621
CW
160 ],
161 'entity_id' => [
e501603b
TO
162 'name' => 'entity_id',
163 'type' => CRM_Utils_Type::T_INT,
c3fc2621 164 'title' => ts('Entity ID '),
215b423e 165 'description' => ts('Foreign key to the referenced item.'),
c3fc2621 166 'required' => TRUE,
a36434b9 167 'where' => 'civicrm_log.entity_id',
522a26c9 168 'table_name' => 'civicrm_log',
169 'entity' => 'Log',
170 'bao' => 'CRM_Core_BAO_Log',
6a7e5e5d 171 'localizable' => 0,
a9d0587b 172 'add' => '1.5',
c3fc2621
CW
173 ],
174 'data' => [
e501603b
TO
175 'name' => 'data',
176 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 177 'title' => ts('Data'),
215b423e 178 'description' => ts('Updates does to this object if any.'),
a36434b9 179 'where' => 'civicrm_log.data',
522a26c9 180 'table_name' => 'civicrm_log',
181 'entity' => 'Log',
182 'bao' => 'CRM_Core_BAO_Log',
6a7e5e5d 183 'localizable' => 0,
a9d0587b 184 'add' => '1.5',
c3fc2621
CW
185 ],
186 'modified_id' => [
e501603b
TO
187 'name' => 'modified_id',
188 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 189 'title' => ts('Modified By Contact ID'),
215b423e 190 'description' => ts('FK to Contact ID of person under whose credentials this data modification was made.'),
a36434b9 191 'where' => 'civicrm_log.modified_id',
522a26c9 192 'table_name' => 'civicrm_log',
193 'entity' => 'Log',
194 'bao' => 'CRM_Core_BAO_Log',
6a7e5e5d 195 'localizable' => 0,
e501603b 196 'FKClassName' => 'CRM_Contact_DAO_Contact',
2cbbebe8
A
197 'html' => [
198 'label' => ts("Modified By"),
199 ],
a9d0587b 200 'add' => '1.5',
c3fc2621
CW
201 ],
202 'modified_date' => [
e501603b
TO
203 'name' => 'modified_date',
204 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 205 'title' => ts('Modified Date'),
215b423e 206 'description' => ts('When was the referenced entity created or modified or deleted.'),
a36434b9 207 'where' => 'civicrm_log.modified_date',
522a26c9 208 'table_name' => 'civicrm_log',
209 'entity' => 'Log',
210 'bao' => 'CRM_Core_BAO_Log',
6a7e5e5d 211 'localizable' => 0,
a9d0587b 212 'add' => '1.5',
c3fc2621
CW
213 ],
214 ];
346aaaba 215 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 216 }
346aaaba 217 return Civi::$statics[__CLASS__]['fields'];
e501603b 218 }
c3fc2621 219
e501603b 220 /**
bd8e0b14 221 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
222 *
223 * @return array
bd8e0b14 224 * Array(string $name => string $uniqueName).
e501603b 225 */
c3fc2621 226 public static function &fieldKeys() {
bd8e0b14
TO
227 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
228 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 229 }
bd8e0b14 230 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 231 }
c3fc2621 232
e501603b
TO
233 /**
234 * Returns the names of this table
235 *
236 * @return string
237 */
c3fc2621 238 public static function getTableName() {
e501603b
TO
239 return self::$_tableName;
240 }
c3fc2621 241
e501603b
TO
242 /**
243 * Returns if this table needs to be logged
244 *
c3fc2621 245 * @return bool
e501603b 246 */
c3fc2621 247 public function getLog() {
e501603b
TO
248 return self::$_log;
249 }
c3fc2621 250
e501603b
TO
251 /**
252 * Returns the list of fields that can be imported
253 *
254 * @param bool $prefix
255 *
256 * @return array
257 */
c3fc2621
CW
258 public static function &import($prefix = FALSE) {
259 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'log', $prefix, []);
60808919 260 return $r;
e501603b 261 }
c3fc2621 262
e501603b
TO
263 /**
264 * Returns the list of fields that can be exported
265 *
266 * @param bool $prefix
267 *
268 * @return array
269 */
c3fc2621
CW
270 public static function &export($prefix = FALSE) {
271 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'log', $prefix, []);
60808919 272 return $r;
e501603b 273 }
c3fc2621 274
e7a6b91a
AS
275 /**
276 * Returns the list of indices
c3fc2621
CW
277 *
278 * @param bool $localize
279 *
280 * @return array
e7a6b91a
AS
281 */
282 public static function indices($localize = TRUE) {
c3fc2621
CW
283 $indices = [
284 'index_entity' => [
e7a6b91a 285 'name' => 'index_entity',
c3fc2621 286 'field' => [
e7a6b91a
AS
287 0 => 'entity_table',
288 1 => 'entity_id',
c3fc2621
CW
289 ],
290 'localizable' => FALSE,
e7a6b91a 291 'sig' => 'civicrm_log::0::entity_table::entity_id',
c3fc2621
CW
292 ],
293 ];
e7a6b91a
AS
294 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
295 }
c3fc2621 296
e501603b 297}