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