Merge pull request #19075 from colemanw/searchable
[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
d31fb4e3 9 * (GenCodeChecksum:816b07245cf23f330f371b32bc278d17)
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 *
e6ca0a57 36 * @var int
e501603b
TO
37 */
38 public $id;
c3fc2621 39
e501603b
TO
40 /**
41 * Name of table where item being referenced is stored.
42 *
43 * @var string
44 */
45 public $entity_table;
c3fc2621 46
e501603b
TO
47 /**
48 * Foreign key to the referenced item.
49 *
e6ca0a57 50 * @var int
e501603b
TO
51 */
52 public $entity_id;
c3fc2621 53
e501603b
TO
54 /**
55 * Updates does to this object if any.
56 *
57 * @var text
58 */
59 public $data;
c3fc2621 60
e501603b
TO
61 /**
62 * FK to Contact ID of person under whose credentials this data modification was made.
63 *
e6ca0a57 64 * @var int
e501603b
TO
65 */
66 public $modified_id;
c3fc2621 67
e501603b
TO
68 /**
69 * When was the referenced entity created or modified or deleted.
70 *
71 * @var datetime
72 */
73 public $modified_date;
c3fc2621 74
e501603b 75 /**
f41f0342 76 * Class constructor.
e501603b 77 */
c3fc2621 78 public function __construct() {
e501603b
TO
79 $this->__table = 'civicrm_log';
80 parent::__construct();
81 }
c3fc2621 82
449c4e6b
CW
83 /**
84 * Returns localized title of this entity.
7b66c3b5
AH
85 *
86 * @param bool $plural
87 * Whether to return the plural version of the title.
449c4e6b 88 */
7b66c3b5
AH
89 public static function getEntityTitle($plural = FALSE) {
90 return $plural ? ts('Logs') : ts('Log');
449c4e6b
CW
91 }
92
e501603b 93 /**
f41f0342 94 * Returns foreign keys and entity references.
e501603b
TO
95 *
96 * @return array
97 * [CRM_Core_Reference_Interface]
98 */
c3fc2621 99 public static function getReferenceColumns() {
346aaaba 100 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 101 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
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');
346aaaba 104 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 105 }
346aaaba 106 return Civi::$statics[__CLASS__]['links'];
e501603b 107 }
c3fc2621 108
e501603b
TO
109 /**
110 * Returns all the column names of this table
111 *
112 * @return array
113 */
c3fc2621 114 public static function &fields() {
346aaaba 115 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
116 Civi::$statics[__CLASS__]['fields'] = [
117 'id' => [
e501603b
TO
118 'name' => 'id',
119 'type' => CRM_Utils_Type::T_INT,
c3fc2621 120 'title' => ts('Log ID'),
215b423e 121 'description' => ts('Log ID'),
c3fc2621 122 'required' => TRUE,
a36434b9 123 'where' => 'civicrm_log.id',
522a26c9 124 'table_name' => 'civicrm_log',
125 'entity' => 'Log',
126 'bao' => 'CRM_Core_BAO_Log',
6a7e5e5d 127 'localizable' => 0,
a9d0587b 128 'add' => '1.5',
c3fc2621
CW
129 ],
130 'entity_table' => [
e501603b
TO
131 'name' => 'entity_table',
132 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 133 'title' => ts('Entity Table'),
215b423e 134 'description' => ts('Name of table where item being referenced is stored.'),
c3fc2621 135 'required' => TRUE,
e501603b
TO
136 'maxlength' => 64,
137 'size' => CRM_Utils_Type::BIG,
a36434b9 138 'where' => 'civicrm_log.entity_table',
522a26c9 139 'table_name' => 'civicrm_log',
140 'entity' => 'Log',
141 'bao' => 'CRM_Core_BAO_Log',
6a7e5e5d 142 'localizable' => 0,
a9d0587b 143 'add' => '1.5',
c3fc2621
CW
144 ],
145 'entity_id' => [
e501603b
TO
146 'name' => 'entity_id',
147 'type' => CRM_Utils_Type::T_INT,
c3fc2621 148 'title' => ts('Entity ID '),
215b423e 149 'description' => ts('Foreign key to the referenced item.'),
c3fc2621 150 'required' => TRUE,
a36434b9 151 'where' => 'civicrm_log.entity_id',
522a26c9 152 'table_name' => 'civicrm_log',
153 'entity' => 'Log',
154 'bao' => 'CRM_Core_BAO_Log',
6a7e5e5d 155 'localizable' => 0,
a9d0587b 156 'add' => '1.5',
c3fc2621
CW
157 ],
158 'data' => [
e501603b
TO
159 'name' => 'data',
160 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 161 'title' => ts('Data'),
215b423e 162 'description' => ts('Updates does to this object if any.'),
a36434b9 163 'where' => 'civicrm_log.data',
522a26c9 164 'table_name' => 'civicrm_log',
165 'entity' => 'Log',
166 'bao' => 'CRM_Core_BAO_Log',
6a7e5e5d 167 'localizable' => 0,
a9d0587b 168 'add' => '1.5',
c3fc2621
CW
169 ],
170 'modified_id' => [
e501603b
TO
171 'name' => 'modified_id',
172 'type' => CRM_Utils_Type::T_INT,
c3fc2621 173 'title' => ts('Modified By'),
215b423e 174 'description' => ts('FK to Contact ID of person under whose credentials this data modification was made.'),
a36434b9 175 'where' => 'civicrm_log.modified_id',
522a26c9 176 'table_name' => 'civicrm_log',
177 'entity' => 'Log',
178 'bao' => 'CRM_Core_BAO_Log',
6a7e5e5d 179 'localizable' => 0,
e501603b 180 'FKClassName' => 'CRM_Contact_DAO_Contact',
a9d0587b 181 'add' => '1.5',
c3fc2621
CW
182 ],
183 'modified_date' => [
e501603b
TO
184 'name' => 'modified_date',
185 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 186 'title' => ts('Modified Date'),
215b423e 187 'description' => ts('When was the referenced entity created or modified or deleted.'),
a36434b9 188 'where' => 'civicrm_log.modified_date',
522a26c9 189 'table_name' => 'civicrm_log',
190 'entity' => 'Log',
191 'bao' => 'CRM_Core_BAO_Log',
6a7e5e5d 192 'localizable' => 0,
a9d0587b 193 'add' => '1.5',
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__, 'log', $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__, 'log', $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
CW
264 $indices = [
265 'index_entity' => [
e7a6b91a 266 'name' => 'index_entity',
c3fc2621 267 'field' => [
e7a6b91a
AS
268 0 => 'entity_table',
269 1 => 'entity_id',
c3fc2621
CW
270 ],
271 'localizable' => FALSE,
e7a6b91a 272 'sig' => 'civicrm_log::0::entity_table::entity_id',
c3fc2621
CW
273 ],
274 ];
e7a6b91a
AS
275 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
276 }
c3fc2621 277
e501603b 278}