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