Merge pull request #11433 from octo-happiness/CRM-20866
[civicrm-core.git] / CRM / Core / DAO / SystemLog.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
0f03f337 6| Copyright CiviCRM LLC (c) 2004-2017 |
e501603b
TO
7+--------------------------------------------------------------------+
8| This file is a part of CiviCRM. |
9| |
10| CiviCRM is free software; you can copy, modify, and distribute it |
11| under the terms of the GNU Affero General Public License |
12| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13| |
14| CiviCRM is distributed in the hope that it will be useful, but |
15| WITHOUT ANY WARRANTY; without even the implied warranty of |
16| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17| See the GNU Affero General Public License for more details. |
18| |
19| You should have received a copy of the GNU Affero General Public |
20| License and the CiviCRM Licensing Exception along |
21| with this program; if not, contact CiviCRM LLC |
22| at info[AT]civicrm[DOT]org. If you have questions about the |
23| GNU Affero General Public License or the licensing of CiviCRM, |
24| see the CiviCRM license FAQ at http://civicrm.org/licensing |
25+--------------------------------------------------------------------+
26*/
27/**
28 * @package CRM
0f03f337 29 * @copyright CiviCRM LLC (c) 2004-2017
e501603b
TO
30 *
31 * Generated from xml/schema/CRM/Core/SystemLog.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
022785d8 33 * (GenCodeChecksum:74683682d7114abb261677b351cd8711)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
f41f0342 37/**
38 * CRM_Core_DAO_SystemLog constructor.
39 */
e501603b
TO
40class CRM_Core_DAO_SystemLog extends CRM_Core_DAO {
41 /**
f41f0342 42 * Static instance to hold the table name.
e501603b
TO
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_system_log';
e501603b 47 /**
f41f0342 48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b
TO
49 *
50 * @var boolean
51 */
52 static $_log = false;
53 /**
54 * Primary key ID
55 *
56 * @var int unsigned
57 */
58 public $id;
59 /**
60 * Standardized message
61 *
62 * @var string
63 */
64 public $message;
65 /**
66 * JSON encoded data
67 *
68 * @var longtext
69 */
70 public $context;
71 /**
72 * error level per PSR3
73 *
74 * @var string
75 */
76 public $level;
77 /**
78 * Timestamp of when event occurred.
79 *
80 * @var timestamp
81 */
82 public $timestamp;
83 /**
84 * Optional Contact ID that created the log. Not an FK as we keep this regardless
85 *
86 * @var int unsigned
87 */
88 public $contact_id;
89 /**
90 * Optional Name of logging host
91 *
92 * @var string
93 */
94 public $hostname;
95 /**
f41f0342 96 * Class constructor.
e501603b
TO
97 */
98 function __construct() {
99 $this->__table = 'civicrm_system_log';
100 parent::__construct();
101 }
102 /**
103 * Returns all the column names of this table
104 *
105 * @return array
106 */
107 static function &fields() {
346aaaba
TO
108 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
109 Civi::$statics[__CLASS__]['fields'] = array(
e501603b
TO
110 'id' => array(
111 'name' => 'id',
112 'type' => CRM_Utils_Type::T_INT,
113 'title' => ts('System Log ID') ,
114 'description' => 'Primary key ID',
115 'required' => true,
522a26c9 116 'table_name' => 'civicrm_system_log',
117 'entity' => 'SystemLog',
118 'bao' => 'CRM_Core_DAO_SystemLog',
6a7e5e5d 119 'localizable' => 0,
e501603b
TO
120 ) ,
121 'message' => array(
122 'name' => 'message',
123 'type' => CRM_Utils_Type::T_STRING,
124 'title' => ts('System Log Message') ,
125 'description' => 'Standardized message',
126 'required' => true,
127 'maxlength' => 128,
128 'size' => CRM_Utils_Type::HUGE,
522a26c9 129 'table_name' => 'civicrm_system_log',
130 'entity' => 'SystemLog',
131 'bao' => 'CRM_Core_DAO_SystemLog',
6a7e5e5d 132 'localizable' => 0,
e501603b
TO
133 ) ,
134 'context' => array(
135 'name' => 'context',
136 'type' => CRM_Utils_Type::T_LONGTEXT,
137 'title' => ts('Detailed Log Data') ,
138 'description' => 'JSON encoded data',
522a26c9 139 'table_name' => 'civicrm_system_log',
140 'entity' => 'SystemLog',
141 'bao' => 'CRM_Core_DAO_SystemLog',
6a7e5e5d 142 'localizable' => 0,
e501603b
TO
143 ) ,
144 'level' => array(
145 'name' => 'level',
146 'type' => CRM_Utils_Type::T_STRING,
147 'title' => ts('Detailed Log Data') ,
148 'description' => 'error level per PSR3',
149 'maxlength' => 9,
150 'size' => CRM_Utils_Type::TWELVE,
151 'default' => 'info',
522a26c9 152 'table_name' => 'civicrm_system_log',
153 'entity' => 'SystemLog',
154 'bao' => 'CRM_Core_DAO_SystemLog',
6a7e5e5d 155 'localizable' => 0,
e501603b
TO
156 ) ,
157 'timestamp' => array(
158 'name' => 'timestamp',
159 'type' => CRM_Utils_Type::T_TIMESTAMP,
160 'title' => ts('Log Timestamp') ,
161 'description' => 'Timestamp of when event occurred.',
162 'default' => 'CURRENT_TIMESTAMP',
522a26c9 163 'table_name' => 'civicrm_system_log',
164 'entity' => 'SystemLog',
165 'bao' => 'CRM_Core_DAO_SystemLog',
6a7e5e5d 166 'localizable' => 0,
e501603b
TO
167 ) ,
168 'contact_id' => array(
169 'name' => 'contact_id',
170 'type' => CRM_Utils_Type::T_INT,
171 'title' => ts('Log Contact ID') ,
172 'description' => 'Optional Contact ID that created the log. Not an FK as we keep this regardless',
522a26c9 173 'table_name' => 'civicrm_system_log',
174 'entity' => 'SystemLog',
175 'bao' => 'CRM_Core_DAO_SystemLog',
6a7e5e5d 176 'localizable' => 0,
e501603b
TO
177 ) ,
178 'hostname' => array(
179 'name' => 'hostname',
180 'type' => CRM_Utils_Type::T_STRING,
181 'title' => ts('Log Host') ,
182 'description' => 'Optional Name of logging host',
183 'maxlength' => 128,
184 'size' => CRM_Utils_Type::HUGE,
522a26c9 185 'table_name' => 'civicrm_system_log',
186 'entity' => 'SystemLog',
187 'bao' => 'CRM_Core_DAO_SystemLog',
6a7e5e5d 188 'localizable' => 0,
e501603b
TO
189 ) ,
190 );
346aaaba 191 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 192 }
346aaaba 193 return Civi::$statics[__CLASS__]['fields'];
e501603b
TO
194 }
195 /**
bd8e0b14 196 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
197 *
198 * @return array
bd8e0b14 199 * Array(string $name => string $uniqueName).
e501603b
TO
200 */
201 static function &fieldKeys() {
bd8e0b14
TO
202 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
203 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 204 }
bd8e0b14 205 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b
TO
206 }
207 /**
208 * Returns the names of this table
209 *
210 * @return string
211 */
212 static function getTableName() {
213 return self::$_tableName;
214 }
215 /**
216 * Returns if this table needs to be logged
217 *
218 * @return boolean
219 */
220 function getLog() {
221 return self::$_log;
222 }
223 /**
224 * Returns the list of fields that can be imported
225 *
226 * @param bool $prefix
227 *
228 * @return array
229 */
230 static function &import($prefix = false) {
60808919
TO
231 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'system_log', $prefix, array());
232 return $r;
e501603b
TO
233 }
234 /**
235 * Returns the list of fields that can be exported
236 *
237 * @param bool $prefix
238 *
239 * @return array
240 */
241 static function &export($prefix = false) {
60808919
TO
242 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'system_log', $prefix, array());
243 return $r;
e501603b 244 }
e7a6b91a
AS
245 /**
246 * Returns the list of indices
247 */
248 public static function indices($localize = TRUE) {
249 $indices = array();
250 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
251 }
e501603b 252}