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