API/DAO Metadata - Retain versioning metadata for possible usage in runtime+tooling
[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
a9d0587b 9 * (GenCodeChecksum:a102ecbdf345a1df748ea11fdd997b9e)
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 {
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_log';
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 * Log ID
33 *
e6ca0a57 34 * @var int
e501603b
TO
35 */
36 public $id;
c3fc2621 37
e501603b
TO
38 /**
39 * Name of table where item being referenced is stored.
40 *
41 * @var string
42 */
43 public $entity_table;
c3fc2621 44
e501603b
TO
45 /**
46 * Foreign key to the referenced item.
47 *
e6ca0a57 48 * @var int
e501603b
TO
49 */
50 public $entity_id;
c3fc2621 51
e501603b
TO
52 /**
53 * Updates does to this object if any.
54 *
55 * @var text
56 */
57 public $data;
c3fc2621 58
e501603b
TO
59 /**
60 * FK to Contact ID of person under whose credentials this data modification was made.
61 *
e6ca0a57 62 * @var int
e501603b
TO
63 */
64 public $modified_id;
c3fc2621 65
e501603b
TO
66 /**
67 * When was the referenced entity created or modified or deleted.
68 *
69 * @var datetime
70 */
71 public $modified_date;
c3fc2621 72
e501603b 73 /**
f41f0342 74 * Class constructor.
e501603b 75 */
c3fc2621 76 public function __construct() {
e501603b
TO
77 $this->__table = 'civicrm_log';
78 parent::__construct();
79 }
c3fc2621 80
449c4e6b
CW
81 /**
82 * Returns localized title of this entity.
83 */
84 public static function getEntityTitle() {
85 return ts('Logs');
86 }
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
CW
97 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'modified_id', 'civicrm_contact', 'id');
98 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
346aaaba 99 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 100 }
346aaaba 101 return Civi::$statics[__CLASS__]['links'];
e501603b 102 }
c3fc2621 103
e501603b
TO
104 /**
105 * Returns all the column names of this table
106 *
107 * @return array
108 */
c3fc2621 109 public static function &fields() {
346aaaba 110 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
111 Civi::$statics[__CLASS__]['fields'] = [
112 'id' => [
e501603b
TO
113 'name' => 'id',
114 'type' => CRM_Utils_Type::T_INT,
c3fc2621 115 'title' => ts('Log ID'),
215b423e 116 'description' => ts('Log ID'),
c3fc2621 117 'required' => TRUE,
a36434b9 118 'where' => 'civicrm_log.id',
522a26c9 119 'table_name' => 'civicrm_log',
120 'entity' => 'Log',
121 'bao' => 'CRM_Core_BAO_Log',
6a7e5e5d 122 'localizable' => 0,
a9d0587b 123 'add' => '1.5',
c3fc2621
CW
124 ],
125 'entity_table' => [
e501603b
TO
126 'name' => 'entity_table',
127 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 128 'title' => ts('Entity Table'),
215b423e 129 'description' => ts('Name of table where item being referenced is stored.'),
c3fc2621 130 'required' => TRUE,
e501603b
TO
131 'maxlength' => 64,
132 'size' => CRM_Utils_Type::BIG,
a36434b9 133 'where' => 'civicrm_log.entity_table',
522a26c9 134 'table_name' => 'civicrm_log',
135 'entity' => 'Log',
136 'bao' => 'CRM_Core_BAO_Log',
6a7e5e5d 137 'localizable' => 0,
a9d0587b 138 'add' => '1.5',
c3fc2621
CW
139 ],
140 'entity_id' => [
e501603b
TO
141 'name' => 'entity_id',
142 'type' => CRM_Utils_Type::T_INT,
c3fc2621 143 'title' => ts('Entity ID '),
215b423e 144 'description' => ts('Foreign key to the referenced item.'),
c3fc2621 145 'required' => TRUE,
a36434b9 146 'where' => 'civicrm_log.entity_id',
522a26c9 147 'table_name' => 'civicrm_log',
148 'entity' => 'Log',
149 'bao' => 'CRM_Core_BAO_Log',
6a7e5e5d 150 'localizable' => 0,
a9d0587b 151 'add' => '1.5',
c3fc2621
CW
152 ],
153 'data' => [
e501603b
TO
154 'name' => 'data',
155 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 156 'title' => ts('Data'),
215b423e 157 'description' => ts('Updates does to this object if any.'),
a36434b9 158 'where' => 'civicrm_log.data',
522a26c9 159 'table_name' => 'civicrm_log',
160 'entity' => 'Log',
161 'bao' => 'CRM_Core_BAO_Log',
6a7e5e5d 162 'localizable' => 0,
a9d0587b 163 'add' => '1.5',
c3fc2621
CW
164 ],
165 'modified_id' => [
e501603b
TO
166 'name' => 'modified_id',
167 'type' => CRM_Utils_Type::T_INT,
c3fc2621 168 'title' => ts('Modified By'),
215b423e 169 'description' => ts('FK to Contact ID of person under whose credentials this data modification was made.'),
a36434b9 170 'where' => 'civicrm_log.modified_id',
522a26c9 171 'table_name' => 'civicrm_log',
172 'entity' => 'Log',
173 'bao' => 'CRM_Core_BAO_Log',
6a7e5e5d 174 'localizable' => 0,
e501603b 175 'FKClassName' => 'CRM_Contact_DAO_Contact',
a9d0587b 176 'add' => '1.5',
c3fc2621
CW
177 ],
178 'modified_date' => [
e501603b
TO
179 'name' => 'modified_date',
180 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 181 'title' => ts('Modified Date'),
215b423e 182 'description' => ts('When was the referenced entity created or modified or deleted.'),
a36434b9 183 'where' => 'civicrm_log.modified_date',
522a26c9 184 'table_name' => 'civicrm_log',
185 'entity' => 'Log',
186 'bao' => 'CRM_Core_BAO_Log',
6a7e5e5d 187 'localizable' => 0,
a9d0587b 188 'add' => '1.5',
c3fc2621
CW
189 ],
190 ];
346aaaba 191 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 192 }
346aaaba 193 return Civi::$statics[__CLASS__]['fields'];
e501603b 194 }
c3fc2621 195
e501603b 196 /**
bd8e0b14 197 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
198 *
199 * @return array
bd8e0b14 200 * Array(string $name => string $uniqueName).
e501603b 201 */
c3fc2621 202 public static function &fieldKeys() {
bd8e0b14
TO
203 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
204 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 205 }
bd8e0b14 206 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 207 }
c3fc2621 208
e501603b
TO
209 /**
210 * Returns the names of this table
211 *
212 * @return string
213 */
c3fc2621 214 public static function getTableName() {
e501603b
TO
215 return self::$_tableName;
216 }
c3fc2621 217
e501603b
TO
218 /**
219 * Returns if this table needs to be logged
220 *
c3fc2621 221 * @return bool
e501603b 222 */
c3fc2621 223 public function getLog() {
e501603b
TO
224 return self::$_log;
225 }
c3fc2621 226
e501603b
TO
227 /**
228 * Returns the list of fields that can be imported
229 *
230 * @param bool $prefix
231 *
232 * @return array
233 */
c3fc2621
CW
234 public static function &import($prefix = FALSE) {
235 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'log', $prefix, []);
60808919 236 return $r;
e501603b 237 }
c3fc2621 238
e501603b
TO
239 /**
240 * Returns the list of fields that can be exported
241 *
242 * @param bool $prefix
243 *
244 * @return array
245 */
c3fc2621
CW
246 public static function &export($prefix = FALSE) {
247 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'log', $prefix, []);
60808919 248 return $r;
e501603b 249 }
c3fc2621 250
e7a6b91a
AS
251 /**
252 * Returns the list of indices
c3fc2621
CW
253 *
254 * @param bool $localize
255 *
256 * @return array
e7a6b91a
AS
257 */
258 public static function indices($localize = TRUE) {
c3fc2621
CW
259 $indices = [
260 'index_entity' => [
e7a6b91a 261 'name' => 'index_entity',
c3fc2621 262 'field' => [
e7a6b91a
AS
263 0 => 'entity_table',
264 1 => 'entity_id',
c3fc2621
CW
265 ],
266 'localizable' => FALSE,
e7a6b91a 267 'sig' => 'civicrm_log::0::entity_table::entity_id',
c3fc2621
CW
268 ],
269 ];
e7a6b91a
AS
270 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
271 }
c3fc2621 272
e501603b 273}