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