Merge pull request #19000 from civicrm/5.32
[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:ca34da7770ea481ca165e648c5b456f0)
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 * @param bool $plural
94 * Whether to return the plural version of the title.
95 */
96 public static function getEntityTitle($plural = FALSE) {
97 return $plural ? ts('System Logs') : ts('System Log');
98 }
99
100 /**
101 * Returns all the column names of this table
102 *
103 * @return array
104 */
105 public static function &fields() {
106 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
107 Civi::$statics[__CLASS__]['fields'] = [
108 'id' => [
109 'name' => 'id',
110 'type' => CRM_Utils_Type::T_INT,
111 'title' => ts('System Log ID'),
112 'description' => ts('Primary key ID'),
113 'required' => TRUE,
114 'where' => 'civicrm_system_log.id',
115 'table_name' => 'civicrm_system_log',
116 'entity' => 'SystemLog',
117 'bao' => 'CRM_Core_DAO_SystemLog',
118 'localizable' => 0,
119 'add' => '4.4',
120 ],
121 'message' => [
122 'name' => 'message',
123 'type' => CRM_Utils_Type::T_STRING,
124 'title' => ts('System Log Message'),
125 'description' => ts('Standardized message'),
126 'required' => TRUE,
127 'maxlength' => 128,
128 'size' => CRM_Utils_Type::HUGE,
129 'where' => 'civicrm_system_log.message',
130 'table_name' => 'civicrm_system_log',
131 'entity' => 'SystemLog',
132 'bao' => 'CRM_Core_DAO_SystemLog',
133 'localizable' => 0,
134 'add' => '4.5',
135 ],
136 'context' => [
137 'name' => 'context',
138 'type' => CRM_Utils_Type::T_LONGTEXT,
139 'title' => ts('Detailed Log Data'),
140 'description' => ts('JSON encoded data'),
141 'where' => 'civicrm_system_log.context',
142 'table_name' => 'civicrm_system_log',
143 'entity' => 'SystemLog',
144 'bao' => 'CRM_Core_DAO_SystemLog',
145 'localizable' => 0,
146 'add' => '4.5',
147 ],
148 'level' => [
149 'name' => 'level',
150 'type' => CRM_Utils_Type::T_STRING,
151 'title' => ts('Detailed Log Data'),
152 'description' => ts('error level per PSR3'),
153 'maxlength' => 9,
154 'size' => CRM_Utils_Type::TWELVE,
155 'where' => 'civicrm_system_log.level',
156 'default' => 'info',
157 'table_name' => 'civicrm_system_log',
158 'entity' => 'SystemLog',
159 'bao' => 'CRM_Core_DAO_SystemLog',
160 'localizable' => 0,
161 'add' => '4.5',
162 ],
163 'timestamp' => [
164 'name' => 'timestamp',
165 'type' => CRM_Utils_Type::T_TIMESTAMP,
166 'title' => ts('Log Timestamp'),
167 'description' => ts('Timestamp of when event occurred.'),
168 'where' => 'civicrm_system_log.timestamp',
169 'default' => 'CURRENT_TIMESTAMP',
170 'table_name' => 'civicrm_system_log',
171 'entity' => 'SystemLog',
172 'bao' => 'CRM_Core_DAO_SystemLog',
173 'localizable' => 0,
174 'add' => '4.5',
175 ],
176 'contact_id' => [
177 'name' => 'contact_id',
178 'type' => CRM_Utils_Type::T_INT,
179 'title' => ts('Log Contact ID'),
180 'description' => ts('Optional Contact ID that created the log. Not an FK as we keep this regardless'),
181 'where' => 'civicrm_system_log.contact_id',
182 'table_name' => 'civicrm_system_log',
183 'entity' => 'SystemLog',
184 'bao' => 'CRM_Core_DAO_SystemLog',
185 'localizable' => 0,
186 'add' => '4.5',
187 ],
188 'hostname' => [
189 'name' => 'hostname',
190 'type' => CRM_Utils_Type::T_STRING,
191 'title' => ts('Log Host'),
192 'description' => ts('Optional Name of logging host'),
193 'maxlength' => 128,
194 'size' => CRM_Utils_Type::HUGE,
195 'where' => 'civicrm_system_log.hostname',
196 'table_name' => 'civicrm_system_log',
197 'entity' => 'SystemLog',
198 'bao' => 'CRM_Core_DAO_SystemLog',
199 'localizable' => 0,
200 'add' => '4.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__, 'system_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__, 'system_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 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
273 }
274
275 }