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