Merge pull request #18316 from civicrm/5.29
[civicrm-core.git] / CRM / Core / DAO / SystemLog.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/SystemLog.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:46d7f317ffb5d01d9cb22898ce38abb3)
10 */
11
12 /**
13 * Database access object for the SystemLog entity.
14 */
15 class CRM_Core_DAO_SystemLog extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '4.5';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_system_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 * Primary key ID
35 *
36 * @var int
37 */
38 public $id;
39
40 /**
41 * Standardized message
42 *
43 * @var string
44 */
45 public $message;
46
47 /**
48 * JSON encoded data
49 *
50 * @var longtext
51 */
52 public $context;
53
54 /**
55 * error level per PSR3
56 *
57 * @var string
58 */
59 public $level;
60
61 /**
62 * Timestamp of when event occurred.
63 *
64 * @var timestamp
65 */
66 public $timestamp;
67
68 /**
69 * Optional Contact ID that created the log. Not an FK as we keep this regardless
70 *
71 * @var int
72 */
73 public $contact_id;
74
75 /**
76 * Optional Name of logging host
77 *
78 * @var string
79 */
80 public $hostname;
81
82 /**
83 * Class constructor.
84 */
85 public function __construct() {
86 $this->__table = 'civicrm_system_log';
87 parent::__construct();
88 }
89
90 /**
91 * Returns localized title of this entity.
92 */
93 public static function getEntityTitle() {
94 return ts('System Logs');
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('System Log ID'),
109 'description' => ts('Primary key ID'),
110 'required' => TRUE,
111 'where' => 'civicrm_system_log.id',
112 'table_name' => 'civicrm_system_log',
113 'entity' => 'SystemLog',
114 'bao' => 'CRM_Core_DAO_SystemLog',
115 'localizable' => 0,
116 'add' => '4.4',
117 ],
118 'message' => [
119 'name' => 'message',
120 'type' => CRM_Utils_Type::T_STRING,
121 'title' => ts('System Log Message'),
122 'description' => ts('Standardized message'),
123 'required' => TRUE,
124 'maxlength' => 128,
125 'size' => CRM_Utils_Type::HUGE,
126 'where' => 'civicrm_system_log.message',
127 'table_name' => 'civicrm_system_log',
128 'entity' => 'SystemLog',
129 'bao' => 'CRM_Core_DAO_SystemLog',
130 'localizable' => 0,
131 'add' => '4.5',
132 ],
133 'context' => [
134 'name' => 'context',
135 'type' => CRM_Utils_Type::T_LONGTEXT,
136 'title' => ts('Detailed Log Data'),
137 'description' => ts('JSON encoded data'),
138 'where' => 'civicrm_system_log.context',
139 'table_name' => 'civicrm_system_log',
140 'entity' => 'SystemLog',
141 'bao' => 'CRM_Core_DAO_SystemLog',
142 'localizable' => 0,
143 'add' => '4.5',
144 ],
145 'level' => [
146 'name' => 'level',
147 'type' => CRM_Utils_Type::T_STRING,
148 'title' => ts('Detailed Log Data'),
149 'description' => ts('error level per PSR3'),
150 'maxlength' => 9,
151 'size' => CRM_Utils_Type::TWELVE,
152 'where' => 'civicrm_system_log.level',
153 'default' => 'info',
154 'table_name' => 'civicrm_system_log',
155 'entity' => 'SystemLog',
156 'bao' => 'CRM_Core_DAO_SystemLog',
157 'localizable' => 0,
158 'add' => '4.5',
159 ],
160 'timestamp' => [
161 'name' => 'timestamp',
162 'type' => CRM_Utils_Type::T_TIMESTAMP,
163 'title' => ts('Log Timestamp'),
164 'description' => ts('Timestamp of when event occurred.'),
165 'where' => 'civicrm_system_log.timestamp',
166 'default' => 'CURRENT_TIMESTAMP',
167 'table_name' => 'civicrm_system_log',
168 'entity' => 'SystemLog',
169 'bao' => 'CRM_Core_DAO_SystemLog',
170 'localizable' => 0,
171 'add' => '4.5',
172 ],
173 'contact_id' => [
174 'name' => 'contact_id',
175 'type' => CRM_Utils_Type::T_INT,
176 'title' => ts('Log Contact ID'),
177 'description' => ts('Optional Contact ID that created the log. Not an FK as we keep this regardless'),
178 'where' => 'civicrm_system_log.contact_id',
179 'table_name' => 'civicrm_system_log',
180 'entity' => 'SystemLog',
181 'bao' => 'CRM_Core_DAO_SystemLog',
182 'localizable' => 0,
183 'add' => '4.5',
184 ],
185 'hostname' => [
186 'name' => 'hostname',
187 'type' => CRM_Utils_Type::T_STRING,
188 'title' => ts('Log Host'),
189 'description' => ts('Optional Name of logging host'),
190 'maxlength' => 128,
191 'size' => CRM_Utils_Type::HUGE,
192 'where' => 'civicrm_system_log.hostname',
193 'table_name' => 'civicrm_system_log',
194 'entity' => 'SystemLog',
195 'bao' => 'CRM_Core_DAO_SystemLog',
196 'localizable' => 0,
197 'add' => '4.5',
198 ],
199 ];
200 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
201 }
202 return Civi::$statics[__CLASS__]['fields'];
203 }
204
205 /**
206 * Return a mapping from field-name to the corresponding key (as used in fields()).
207 *
208 * @return array
209 * Array(string $name => string $uniqueName).
210 */
211 public static function &fieldKeys() {
212 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
213 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
214 }
215 return Civi::$statics[__CLASS__]['fieldKeys'];
216 }
217
218 /**
219 * Returns the names of this table
220 *
221 * @return string
222 */
223 public static function getTableName() {
224 return self::$_tableName;
225 }
226
227 /**
228 * Returns if this table needs to be logged
229 *
230 * @return bool
231 */
232 public function getLog() {
233 return self::$_log;
234 }
235
236 /**
237 * Returns the list of fields that can be imported
238 *
239 * @param bool $prefix
240 *
241 * @return array
242 */
243 public static function &import($prefix = FALSE) {
244 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'system_log', $prefix, []);
245 return $r;
246 }
247
248 /**
249 * Returns the list of fields that can be exported
250 *
251 * @param bool $prefix
252 *
253 * @return array
254 */
255 public static function &export($prefix = FALSE) {
256 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'system_log', $prefix, []);
257 return $r;
258 }
259
260 /**
261 * Returns the list of indices
262 *
263 * @param bool $localize
264 *
265 * @return array
266 */
267 public static function indices($localize = TRUE) {
268 $indices = [];
269 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
270 }
271
272 }