Merge pull request #11433 from octo-happiness/CRM-20866
[civicrm-core.git] / CRM / Core / DAO / SystemLog.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
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
29 * @copyright CiviCRM LLC (c) 2004-2017
30 *
31 * Generated from xml/schema/CRM/Core/SystemLog.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:74683682d7114abb261677b351cd8711)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 /**
38 * CRM_Core_DAO_SystemLog constructor.
39 */
40 class CRM_Core_DAO_SystemLog extends CRM_Core_DAO {
41 /**
42 * Static instance to hold the table name.
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_system_log';
47 /**
48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
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 /**
96 * Class constructor.
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() {
108 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
109 Civi::$statics[__CLASS__]['fields'] = array(
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,
116 'table_name' => 'civicrm_system_log',
117 'entity' => 'SystemLog',
118 'bao' => 'CRM_Core_DAO_SystemLog',
119 'localizable' => 0,
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,
129 'table_name' => 'civicrm_system_log',
130 'entity' => 'SystemLog',
131 'bao' => 'CRM_Core_DAO_SystemLog',
132 'localizable' => 0,
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',
139 'table_name' => 'civicrm_system_log',
140 'entity' => 'SystemLog',
141 'bao' => 'CRM_Core_DAO_SystemLog',
142 'localizable' => 0,
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',
152 'table_name' => 'civicrm_system_log',
153 'entity' => 'SystemLog',
154 'bao' => 'CRM_Core_DAO_SystemLog',
155 'localizable' => 0,
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',
163 'table_name' => 'civicrm_system_log',
164 'entity' => 'SystemLog',
165 'bao' => 'CRM_Core_DAO_SystemLog',
166 'localizable' => 0,
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',
173 'table_name' => 'civicrm_system_log',
174 'entity' => 'SystemLog',
175 'bao' => 'CRM_Core_DAO_SystemLog',
176 'localizable' => 0,
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,
185 'table_name' => 'civicrm_system_log',
186 'entity' => 'SystemLog',
187 'bao' => 'CRM_Core_DAO_SystemLog',
188 'localizable' => 0,
189 ) ,
190 );
191 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
192 }
193 return Civi::$statics[__CLASS__]['fields'];
194 }
195 /**
196 * Return a mapping from field-name to the corresponding key (as used in fields()).
197 *
198 * @return array
199 * Array(string $name => string $uniqueName).
200 */
201 static function &fieldKeys() {
202 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
203 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
204 }
205 return Civi::$statics[__CLASS__]['fieldKeys'];
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) {
231 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'system_log', $prefix, array());
232 return $r;
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) {
242 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'system_log', $prefix, array());
243 return $r;
244 }
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 }
252 }