Commit | Line | Data |
---|---|---|
1008246f J |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.4 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
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 | * | |
29 | * @package CRM | |
30 | * @copyright CiviCRM LLC (c) 2004-2013 | |
31 | */ | |
32 | class CRM_Wci_DAO_WidgetCache extends CRM_Core_DAO | |
33 | { | |
34 | /** | |
35 | * static instance to hold the table name | |
36 | * | |
37 | * @var string | |
38 | * @static | |
39 | */ | |
40 | static $_tableName = 'civicrm_wci_widget_cache'; | |
41 | /** | |
42 | * static instance to hold the field values | |
43 | * | |
44 | * @var array | |
45 | * @static | |
46 | */ | |
47 | static $_fields = null; | |
48 | /** | |
49 | * static instance to hold the keys used in $_fields for each field. | |
50 | * | |
51 | * @var array | |
52 | * @static | |
53 | */ | |
54 | static $_fieldKeys = null; | |
55 | /** | |
56 | * static instance to hold the FK relationships | |
57 | * | |
58 | * @var string | |
59 | * @static | |
60 | */ | |
61 | static $_links = null; | |
62 | /** | |
63 | * static instance to hold the values that can | |
64 | * be imported | |
65 | * | |
66 | * @var array | |
67 | * @static | |
68 | */ | |
69 | static $_import = null; | |
70 | /** | |
71 | * static instance to hold the values that can | |
72 | * be exported | |
73 | * | |
74 | * @var array | |
75 | * @static | |
76 | */ | |
77 | static $_export = null; | |
78 | /** | |
79 | * static value to see if we should log any modifications to | |
80 | * this table in the civicrm_log table | |
81 | * | |
82 | * @var boolean | |
83 | * @static | |
84 | */ | |
85 | static $_log = true; | |
86 | /** | |
87 | * cache id | |
88 | * | |
89 | * @var int unsigned | |
90 | */ | |
91 | public $id; | |
92 | /** | |
93 | * widget code | |
94 | * | |
95 | * @var string | |
96 | */ | |
97 | public $widget_code; | |
98 | /** | |
99 | * widget id | |
100 | * | |
101 | * @var float | |
102 | */ | |
103 | public $widget_id; | |
104 | /** | |
105 | * time stamp | |
106 | * | |
107 | * @var float | |
108 | */ | |
109 | public $ts; | |
110 | ||
111 | function __construct() | |
112 | { | |
113 | $this->__table = 'civicrm_wci_widget_cache'; | |
114 | parent::__construct(); | |
115 | } | |
116 | /** | |
117 | * return foreign keys and entity references | |
118 | * | |
119 | * @static | |
120 | * @access public | |
121 | * @return array of CRM_Core_EntityReference | |
122 | */ | |
123 | static function getReferenceColumns() | |
124 | { | |
125 | return self::$_links; | |
126 | } | |
127 | /** | |
128 | * returns all the column names of this table | |
129 | * | |
130 | * @access public | |
131 | * @return array | |
132 | */ | |
133 | static function &fields() | |
134 | { | |
135 | if (!(self::$_fields)) { | |
136 | self::$_fields = array( | |
137 | 'widget_cache_id' => array( | |
138 | 'name' => 'id', | |
139 | 'type' => CRM_Utils_Type::T_INT, | |
140 | 'title' => ts('cahce Id', array('domain' => 'org.civicrm.wci')) , | |
141 | 'required' => true, | |
142 | ) , | |
143 | 'widget_id' => array( | |
144 | 'name' => 'widget_id', | |
145 | 'type' => CRM_Utils_Type::T_INT, | |
146 | 'required' => false, | |
147 | ) , | |
148 | 'widget_code' => array( | |
149 | 'name' => 'widget_code', | |
150 | 'type' => CRM_Utils_Type::T_TEXT, | |
151 | 'title' => ts('widget code', array('domain' => 'org.civicrm.wci')) , | |
152 | 'required' => false, | |
153 | ) , | |
154 | 'ts' => array( | |
155 | 'name' => 'ts', | |
156 | 'type' => CRM_Utils_Type::T_TIMESTAMP, | |
157 | 'title' => ts('timestamp', array('domain' => 'org.civicrm.wci')) , | |
158 | 'required' => false, | |
159 | 'maxlength' => 64, | |
160 | ) , | |
161 | ||
162 | ||
163 | ); | |
164 | } | |
165 | return self::$_fields; | |
166 | } | |
167 | /** | |
168 | * Returns an array containing, for each field, the arary key used for that | |
169 | * field in self::$_fields. | |
170 | * | |
171 | * @access public | |
172 | * @return array | |
173 | */ | |
174 | static function &fieldKeys() | |
175 | { | |
176 | if (!(self::$_fieldKeys)) { | |
177 | self::$_fieldKeys = array( | |
178 | 'id' => 'widget_cache_id', | |
179 | 'widget_id' => 'widget_id', | |
180 | 'widget_code' => 'widget_code', | |
181 | 'ts' => 'ts', | |
182 | ); | |
183 | } | |
184 | return self::$_fieldKeys; | |
185 | } | |
186 | /** | |
187 | * returns the names of this table | |
188 | * | |
189 | * @access public | |
190 | * @static | |
191 | * @return string | |
192 | */ | |
193 | static function getTableName() | |
194 | { | |
195 | return self::$_tableName; | |
196 | } | |
197 | /** | |
198 | * returns if this table needs to be logged | |
199 | * | |
200 | * @access public | |
201 | * @return boolean | |
202 | */ | |
203 | function getLog() | |
204 | { | |
205 | return self::$_log; | |
206 | } | |
207 | /** | |
208 | * returns the list of fields that can be imported | |
209 | * | |
210 | * @access public | |
211 | * return array | |
212 | * @static | |
213 | */ | |
214 | static function &import($prefix = false) | |
215 | { | |
216 | if (!(self::$_import)) { | |
217 | self::$_import = array(); | |
218 | $fields = self::fields(); | |
219 | foreach($fields as $name => $field) { | |
220 | if (CRM_Utils_Array::value('import', $field)) { | |
221 | if ($prefix) { | |
222 | self::$_import['wci_progress_bar'] = & $fields[$name]; | |
223 | } else { | |
224 | self::$_import[$name] = & $fields[$name]; | |
225 | } | |
226 | } | |
227 | } | |
228 | } | |
229 | return self::$_import; | |
230 | } | |
231 | /** | |
232 | * returns the list of fields that can be exported | |
233 | * | |
234 | * @access public | |
235 | * return array | |
236 | * @static | |
237 | */ | |
238 | static function &export($prefix = false) | |
239 | { | |
240 | if (!(self::$_export)) { | |
241 | self::$_export = array(); | |
242 | $fields = self::fields(); | |
243 | foreach($fields as $name => $field) { | |
244 | if (CRM_Utils_Array::value('export', $field)) { | |
245 | if ($prefix) { | |
246 | self::$_export['wci_progress_bar'] = & $fields[$name]; | |
247 | } else { | |
248 | self::$_export[$name] = & $fields[$name]; | |
249 | } | |
250 | } | |
251 | } | |
252 | } | |
253 | return self::$_export; | |
254 | } | |
255 | } |