xml/templates/dao.tpl - Simplify fieldKeys()
[civicrm-core.git] / CRM / Core / DAO / SystemLog.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
6| Copyright CiviCRM LLC (c) 2004-2016 |
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-2016
30 *
31 * Generated from xml/schema/CRM/Core/SystemLog.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
437fafcf 33 * (GenCodeChecksum:de437db587f1fb4d7f90320e3e42db2c)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
37class CRM_Core_DAO_SystemLog extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_system_log';
44 /**
45 * static instance to hold the field values
46 *
47 * @var array
48 */
49 static $_fields = null;
50 /**
51 * static instance to hold the keys used in $_fields for each field.
52 *
53 * @var array
54 */
55 static $_fieldKeys = null;
56 /**
57 * static instance to hold the FK relationships
58 *
59 * @var string
60 */
61 static $_links = null;
e501603b
TO
62 /**
63 * static value to see if we should log any modifications to
64 * this table in the civicrm_log table
65 *
66 * @var boolean
67 */
68 static $_log = false;
69 /**
70 * Primary key ID
71 *
72 * @var int unsigned
73 */
74 public $id;
75 /**
76 * Standardized message
77 *
78 * @var string
79 */
80 public $message;
81 /**
82 * JSON encoded data
83 *
84 * @var longtext
85 */
86 public $context;
87 /**
88 * error level per PSR3
89 *
90 * @var string
91 */
92 public $level;
93 /**
94 * Timestamp of when event occurred.
95 *
96 * @var timestamp
97 */
98 public $timestamp;
99 /**
100 * Optional Contact ID that created the log. Not an FK as we keep this regardless
101 *
102 * @var int unsigned
103 */
104 public $contact_id;
105 /**
106 * Optional Name of logging host
107 *
108 * @var string
109 */
110 public $hostname;
111 /**
112 * class constructor
113 *
114 * @return civicrm_system_log
115 */
116 function __construct() {
117 $this->__table = 'civicrm_system_log';
118 parent::__construct();
119 }
120 /**
121 * Returns all the column names of this table
122 *
123 * @return array
124 */
125 static function &fields() {
126 if (!(self::$_fields)) {
127 self::$_fields = array(
128 'id' => array(
129 'name' => 'id',
130 'type' => CRM_Utils_Type::T_INT,
131 'title' => ts('System Log ID') ,
132 'description' => 'Primary key ID',
133 'required' => true,
134 ) ,
135 'message' => array(
136 'name' => 'message',
137 'type' => CRM_Utils_Type::T_STRING,
138 'title' => ts('System Log Message') ,
139 'description' => 'Standardized message',
140 'required' => true,
141 'maxlength' => 128,
142 'size' => CRM_Utils_Type::HUGE,
143 ) ,
144 'context' => array(
145 'name' => 'context',
146 'type' => CRM_Utils_Type::T_LONGTEXT,
147 'title' => ts('Detailed Log Data') ,
148 'description' => 'JSON encoded data',
149 ) ,
150 'level' => array(
151 'name' => 'level',
152 'type' => CRM_Utils_Type::T_STRING,
153 'title' => ts('Detailed Log Data') ,
154 'description' => 'error level per PSR3',
155 'maxlength' => 9,
156 'size' => CRM_Utils_Type::TWELVE,
157 'default' => 'info',
158 ) ,
159 'timestamp' => array(
160 'name' => 'timestamp',
161 'type' => CRM_Utils_Type::T_TIMESTAMP,
162 'title' => ts('Log Timestamp') ,
163 'description' => 'Timestamp of when event occurred.',
164 'default' => 'CURRENT_TIMESTAMP',
165 ) ,
166 'contact_id' => array(
167 'name' => 'contact_id',
168 'type' => CRM_Utils_Type::T_INT,
169 'title' => ts('Log Contact ID') ,
170 'description' => 'Optional Contact ID that created the log. Not an FK as we keep this regardless',
171 ) ,
172 'hostname' => array(
173 'name' => 'hostname',
174 'type' => CRM_Utils_Type::T_STRING,
175 'title' => ts('Log Host') ,
176 'description' => 'Optional Name of logging host',
177 'maxlength' => 128,
178 'size' => CRM_Utils_Type::HUGE,
179 ) ,
180 );
181 }
182 return self::$_fields;
183 }
184 /**
185 * Returns an array containing, for each field, the arary key used for that
186 * field in self::$_fields.
187 *
188 * @return array
189 */
190 static function &fieldKeys() {
191 if (!(self::$_fieldKeys)) {
192 self::$_fieldKeys = array(
193 'id' => 'id',
194 'message' => 'message',
195 'context' => 'context',
196 'level' => 'level',
197 'timestamp' => 'timestamp',
198 'contact_id' => 'contact_id',
199 'hostname' => 'hostname',
200 );
201 }
202 return self::$_fieldKeys;
203 }
204 /**
205 * Returns the names of this table
206 *
207 * @return string
208 */
209 static function getTableName() {
210 return self::$_tableName;
211 }
212 /**
213 * Returns if this table needs to be logged
214 *
215 * @return boolean
216 */
217 function getLog() {
218 return self::$_log;
219 }
220 /**
221 * Returns the list of fields that can be imported
222 *
223 * @param bool $prefix
224 *
225 * @return array
226 */
227 static function &import($prefix = false) {
60808919
TO
228 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'system_log', $prefix, array());
229 return $r;
e501603b
TO
230 }
231 /**
232 * Returns the list of fields that can be exported
233 *
234 * @param bool $prefix
235 *
236 * @return array
237 */
238 static function &export($prefix = false) {
60808919
TO
239 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'system_log', $prefix, array());
240 return $r;
e501603b
TO
241 }
242}