#29521 - Add DAO and BAO class files. Created skeleton widget creation form.
[com.zyxware.civiwci.git] / CRM / Wci / DAO / ProgressBar.php
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 require_once 'CRM/Core/DAO.php';
33 require_once 'CRM/Utils/Type.php';
34 class CRM_WCI_DAO_ProgressBar extends CRM_Core_DAO
35 {
36 /**
37 * static instance to hold the table name
38 *
39 * @var string
40 * @static
41 */
42 static $_tableName = 'civicrm_wci_progress_bar';
43 /**
44 * static instance to hold the field values
45 *
46 * @var array
47 * @static
48 */
49 static $_fields = null;
50 /**
51 * static instance to hold the keys used in $_fields for each field.
52 *
53 * @var array
54 * @static
55 */
56 static $_fieldKeys = null;
57 /**
58 * static instance to hold the FK relationships
59 *
60 * @var string
61 * @static
62 */
63 static $_links = null;
64 /**
65 * static instance to hold the values that can
66 * be imported
67 *
68 * @var array
69 * @static
70 */
71 static $_import = null;
72 /**
73 * static instance to hold the values that can
74 * be exported
75 *
76 * @var array
77 * @static
78 */
79 static $_export = null;
80 /**
81 * static value to see if we should log any modifications to
82 * this table in the civicrm_log table
83 *
84 * @var boolean
85 * @static
86 */
87 static $_log = true;
88 /**
89 * Progress bar Id
90 *
91 * @var int unsigned
92 */
93 public $id;
94 /**
95 * Name of progress bar
96 *
97 * @var string
98 */
99 public $name;
100 /**
101 * Arbitrary starting amount
102 *
103 * @var float
104 */
105 public $starting_amount;
106 function __construct()
107 {
108 $this->__table = 'civicrm_wci_progress_bar';
109 parent::__construct();
110 }
111 /**
112 * return foreign keys and entity references
113 *
114 * @static
115 * @access public
116 * @return array of CRM_Core_EntityReference
117 */
118 static function getReferenceColumns()
119 {
120 return self::$_links;
121 }
122 /**
123 * returns all the column names of this table
124 *
125 * @access public
126 * @return array
127 */
128 static function &fields()
129 {
130 if (!(self::$_fields)) {
131 self::$_fields = array(
132 'progress_bar_id' => array(
133 'name' => 'id',
134 'type' => CRM_Utils_Type::T_INT,
135 'title' => ts('WCI Progress Bar Id', array('domain' => 'org.civicrm.wci')) ,
136 'required' => true,
137 ) ,
138 'name' => array(
139 'name' => 'name',
140 'type' => CRM_Utils_Type::T_STRING,
141 'title' => ts('Progress Bar Name', array('domain' => 'org.civicrm.wci')) ,
142 'required' => true,
143 'maxlength' => 64,
144 ) ,
145 'starting_amount' => array(
146 'name' => 'starting_amount',
147 'type' => CRM_Utils_Type::T_FLOAT,
148 'required' => false,
149 ) ,
150 );
151 }
152 return self::$_fields;
153 }
154 /**
155 * Returns an array containing, for each field, the arary key used for that
156 * field in self::$_fields.
157 *
158 * @access public
159 * @return array
160 */
161 static function &fieldKeys()
162 {
163 if (!(self::$_fieldKeys)) {
164 self::$_fieldKeys = array(
165 'id' => 'progress_bar_id',
166 'name' => 'name',
167 'starting_amount' => 'starting_amount',
168 );
169 }
170 return self::$_fieldKeys;
171 }
172 /**
173 * returns the names of this table
174 *
175 * @access public
176 * @static
177 * @return string
178 */
179 static function getTableName()
180 {
181 return self::$_tableName;
182 }
183 /**
184 * returns if this table needs to be logged
185 *
186 * @access public
187 * @return boolean
188 */
189 function getLog()
190 {
191 return self::$_log;
192 }
193 /**
194 * returns the list of fields that can be imported
195 *
196 * @access public
197 * return array
198 * @static
199 */
200 static function &import($prefix = false)
201 {
202 if (!(self::$_import)) {
203 self::$_import = array();
204 $fields = self::fields();
205 foreach($fields as $name => $field) {
206 if (CRM_Utils_Array::value('import', $field)) {
207 if ($prefix) {
208 self::$_import['wci_progress_bar'] = & $fields[$name];
209 } else {
210 self::$_import[$name] = & $fields[$name];
211 }
212 }
213 }
214 }
215 return self::$_import;
216 }
217 /**
218 * returns the list of fields that can be exported
219 *
220 * @access public
221 * return array
222 * @static
223 */
224 static function &export($prefix = false)
225 {
226 if (!(self::$_export)) {
227 self::$_export = array();
228 $fields = self::fields();
229 foreach($fields as $name => $field) {
230 if (CRM_Utils_Array::value('export', $field)) {
231 if ($prefix) {
232 self::$_export['wci_progress_bar'] = & $fields[$name];
233 } else {
234 self::$_export[$name] = & $fields[$name];
235 }
236 }
237 }
238 }
239 return self::$_export;
240 }
241 }