Diffstat (limited to 'backend/php/src/objects/class.onetimepasswordstatus.php') (more/less context) (ignore whitespace changes)
-rw-r--r-- | backend/php/src/objects/class.onetimepasswordstatus.php | 368 |
1 files changed, 368 insertions, 0 deletions
diff --git a/backend/php/src/objects/class.onetimepasswordstatus.php b/backend/php/src/objects/class.onetimepasswordstatus.php new file mode 100644 index 0000000..f0ef08a --- a/dev/null +++ b/backend/php/src/objects/class.onetimepasswordstatus.php | |||
@@ -0,0 +1,368 @@ | |||
1 | <?php | ||
2 | /* | ||
3 | This SQL query will create the table to store your object. | ||
4 | |||
5 | CREATE TABLE `onetimepasswordstatus` ( | ||
6 | `onetimepasswordstatusid` int(11) NOT NULL auto_increment, | ||
7 | `code` VARCHAR(255) NOT NULL, | ||
8 | `name` VARCHAR(255) NOT NULL, | ||
9 | `description` TEXT NOT NULL, PRIMARY KEY (`onetimepasswordstatusid`)) ENGINE=MyISAM; | ||
10 | */ | ||
11 | |||
12 | /** | ||
13 | * <b>onetimepasswordstatus</b> class with integrated CRUD methods. | ||
14 | * @author Php Object Generator | ||
15 | * @version POG 3.0d / PHP5.1 MYSQL | ||
16 | * @see http://www.phpobjectgenerator.com/plog/tutorials/45/pdo-mysql | ||
17 | * @copyright Free for personal & commercial use. (Offered under the BSD license) | ||
18 | * @link http://www.phpobjectgenerator.com/?language=php5.1&wrapper=pdo&pdoDriver=mysql&objectName=onetimepasswordstatus&attributeList=array+%28%0A++0+%3D%3E+%27onetimepassword%27%2C%0A++1+%3D%3E+%27code%27%2C%0A++2+%3D%3E+%27name%27%2C%0A++3+%3D%3E+%27description%27%2C%0A%29&typeList=array%2B%2528%250A%2B%2B0%2B%253D%253E%2B%2527HASMANY%2527%252C%250A%2B%2B1%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B2%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B3%2B%253D%253E%2B%2527TEXT%2527%252C%250A%2529 | ||
19 | */ | ||
20 | include_once('class.pog_base.php'); | ||
21 | class onetimepasswordstatus extends POG_Base | ||
22 | { | ||
23 | public $onetimepasswordstatusId = ''; | ||
24 | |||
25 | /** | ||
26 | * @var private array of onetimepassword objects | ||
27 | */ | ||
28 | private $_onetimepasswordList = array(); | ||
29 | |||
30 | /** | ||
31 | * @var VARCHAR(255) | ||
32 | */ | ||
33 | public $code; | ||
34 | |||
35 | /** | ||
36 | * @var VARCHAR(255) | ||
37 | */ | ||
38 | public $name; | ||
39 | |||
40 | /** | ||
41 | * @var TEXT | ||
42 | */ | ||
43 | public $description; | ||
44 | |||
45 | public $pog_attribute_type = array( | ||
46 | "onetimepasswordstatusId" => array('db_attributes' => array("NUMERIC", "INT")), | ||
47 | "onetimepassword" => array('db_attributes' => array("OBJECT", "HASMANY")), | ||
48 | "code" => array('db_attributes' => array("TEXT", "VARCHAR", "255")), | ||
49 | "name" => array('db_attributes' => array("TEXT", "VARCHAR", "255")), | ||
50 | "description" => array('db_attributes' => array("TEXT", "TEXT")), | ||
51 | ); | ||
52 | public $pog_query; | ||
53 | |||
54 | |||
55 | /** | ||
56 | * Getter for some private attributes | ||
57 | * @return mixed $attribute | ||
58 | */ | ||
59 | public function __get($attribute) | ||
60 | { | ||
61 | if (isset($this->{"_".$attribute})) | ||
62 | { | ||
63 | return $this->{"_".$attribute}; | ||
64 | } | ||
65 | else | ||
66 | { | ||
67 | return false; | ||
68 | } | ||
69 | } | ||
70 | |||
71 | function onetimepasswordstatus($code='', $name='', $description='') | ||
72 | { | ||
73 | $this->_onetimepasswordList = array(); | ||
74 | $this->code = $code; | ||
75 | $this->name = $name; | ||
76 | $this->description = $description; | ||
77 | } | ||
78 | |||
79 | |||
80 | /** | ||
81 | * Gets object from database | ||
82 | * @param integer $onetimepasswordstatusId | ||
83 | * @return object $onetimepasswordstatus | ||
84 | */ | ||
85 | function Get($onetimepasswordstatusId) | ||
86 | { | ||
87 | $connection = Database::Connect(); | ||
88 | $this->pog_query = "select * from `onetimepasswordstatus` where `onetimepasswordstatusid`='".intval($onetimepasswordstatusId)."' LIMIT 1"; | ||
89 | $cursor = Database::Reader($this->pog_query, $connection); | ||
90 | while ($row = Database::Read($cursor)) | ||
91 | { | ||
92 | $this->onetimepasswordstatusId = $row['onetimepasswordstatusid']; | ||
93 | $this->code = $this->Unescape($row['code']); | ||
94 | $this->name = $this->Unescape($row['name']); | ||
95 | $this->description = $this->Unescape($row['description']); | ||
96 | } | ||
97 | return $this; | ||
98 | } | ||
99 | |||
100 | |||
101 | /** | ||
102 | * Returns a sorted array of objects that match given conditions | ||
103 | * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...} | ||
104 | * @param string $sortBy | ||
105 | * @param boolean $ascending | ||
106 | * @param int limit | ||
107 | * @return array $onetimepasswordstatusList | ||
108 | */ | ||
109 | function GetList($fcv_array = array(), $sortBy='', $ascending=true, $limit='') | ||
110 | { | ||
111 | $connection = Database::Connect(); | ||
112 | $sqlLimit = ($limit != '' ? "LIMIT $limit" : ''); | ||
113 | $this->pog_query = "select * from `onetimepasswordstatus` "; | ||
114 | $onetimepasswordstatusList = Array(); | ||
115 | if (sizeof($fcv_array) > 0) | ||
116 | { | ||
117 | $this->pog_query .= " where "; | ||
118 | for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++) | ||
119 | { | ||
120 | if (sizeof($fcv_array[$i]) == 1) | ||
121 | { | ||
122 | $this->pog_query .= " ".$fcv_array[$i][0]." "; | ||
123 | continue; | ||
124 | } | ||
125 | else | ||
126 | { | ||
127 | if ($i > 0 && sizeof($fcv_array[$i-1]) != 1) | ||
128 | { | ||
129 | $this->pog_query .= " AND "; | ||
130 | } | ||
131 | if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET') | ||
132 | { | ||
133 | if ($GLOBALS['configuration']['db_encoding'] == 1) | ||
134 | { | ||
135 | $value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(".$fcv_array[$i][2].")" : "'".$fcv_array[$i][2]."'"; | ||
136 | $this->pog_query .= "BASE64_DECODE(`".$fcv_array[$i][0]."`) ".$fcv_array[$i][1]." ".$value; | ||
137 | } | ||
138 | else | ||
139 | { | ||
140 | $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$this->Escape($fcv_array[$i][2])."'"; | ||
141 | $this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value; | ||
142 | } | ||
143 | } | ||
144 | else | ||
145 | { | ||
146 | $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$fcv_array[$i][2]."'"; | ||
147 | $this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value; | ||
148 | } | ||
149 | } | ||
150 | } | ||
151 | } | ||
152 | if ($sortBy != '') | ||
153 | { | ||
154 | if (isset($this->pog_attribute_type[$sortBy]['db_attributes']) && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'SET') | ||
155 | { | ||
156 | if ($GLOBALS['configuration']['db_encoding'] == 1) | ||
157 | { | ||
158 | $sortBy = "BASE64_DECODE($sortBy) "; | ||
159 | } | ||
160 | else | ||
161 | { | ||
162 | $sortBy = "$sortBy "; | ||
163 | } | ||
164 | } | ||
165 | else | ||
166 | { | ||
167 | $sortBy = "$sortBy "; | ||
168 | } | ||
169 | } | ||
170 | else | ||
171 | { | ||
172 | $sortBy = "onetimepasswordstatusid"; | ||
173 | } | ||
174 | $this->pog_query .= " order by ".$sortBy." ".($ascending ? "asc" : "desc")." $sqlLimit"; | ||
175 | $thisObjectName = get_class($this); | ||
176 | $cursor = Database::Reader($this->pog_query, $connection); | ||
177 | while ($row = Database::Read($cursor)) | ||
178 | { | ||
179 | $onetimepasswordstatus = new $thisObjectName(); | ||
180 | $onetimepasswordstatus->onetimepasswordstatusId = $row['onetimepasswordstatusid']; | ||
181 | $onetimepasswordstatus->code = $this->Unescape($row['code']); | ||
182 | $onetimepasswordstatus->name = $this->Unescape($row['name']); | ||
183 | $onetimepasswordstatus->description = $this->Unescape($row['description']); | ||
184 | $onetimepasswordstatusList[] = $onetimepasswordstatus; | ||
185 | } | ||
186 | return $onetimepasswordstatusList; | ||
187 | } | ||
188 | |||
189 | |||
190 | /** | ||
191 | * Saves the object to the database | ||
192 | * @return integer $onetimepasswordstatusId | ||
193 | */ | ||
194 | function Save($deep = true) | ||
195 | { | ||
196 | $connection = Database::Connect(); | ||
197 | $this->pog_query = "select `onetimepasswordstatusid` from `onetimepasswordstatus` where `onetimepasswordstatusid`='".$this->onetimepasswordstatusId."' LIMIT 1"; | ||
198 | $rows = Database::Query($this->pog_query, $connection); | ||
199 | if ($rows > 0) | ||
200 | { | ||
201 | $this->pog_query = "update `onetimepasswordstatus` set | ||
202 | `code`='".$this->Escape($this->code)."', | ||
203 | `name`='".$this->Escape($this->name)."', | ||
204 | `description`='".$this->Escape($this->description)."' where `onetimepasswordstatusid`='".$this->onetimepasswordstatusId."'"; | ||
205 | } | ||
206 | else | ||
207 | { | ||
208 | $this->pog_query = "insert into `onetimepasswordstatus` (`code`, `name`, `description` ) values ( | ||
209 | '".$this->Escape($this->code)."', | ||
210 | '".$this->Escape($this->name)."', | ||
211 | '".$this->Escape($this->description)."' )"; | ||
212 | } | ||
213 | $insertId = Database::InsertOrUpdate($this->pog_query, $connection); | ||
214 | if ($this->onetimepasswordstatusId == "") | ||
215 | { | ||
216 | $this->onetimepasswordstatusId = $insertId; | ||
217 | } | ||
218 | if ($deep) | ||
219 | { | ||
220 | foreach ($this->_onetimepasswordList as $onetimepassword) | ||
221 | { | ||
222 | $onetimepassword->onetimepasswordstatusId = $this->onetimepasswordstatusId; | ||
223 | $onetimepassword->Save($deep); | ||
224 | } | ||
225 | } | ||
226 | return $this->onetimepasswordstatusId; | ||
227 | } | ||
228 | |||
229 | |||
230 | /** | ||
231 | * Clones the object and saves it to the database | ||
232 | * @return integer $onetimepasswordstatusId | ||
233 | */ | ||
234 | function SaveNew($deep = false) | ||
235 | { | ||
236 | $this->onetimepasswordstatusId = ''; | ||
237 | return $this->Save($deep); | ||
238 | } | ||
239 | |||
240 | |||
241 | /** | ||
242 | * Deletes the object from the database | ||
243 | * @return boolean | ||
244 | */ | ||
245 | function Delete($deep = false, $across = false) | ||
246 | { | ||
247 | if ($deep) | ||
248 | { | ||
249 | $onetimepasswordList = $this->GetOnetimepasswordList(); | ||
250 | foreach ($onetimepasswordList as $onetimepassword) | ||
251 | { | ||
252 | $onetimepassword->Delete($deep, $across); | ||
253 | } | ||
254 | } | ||
255 | $connection = Database::Connect(); | ||
256 | $this->pog_query = "delete from `onetimepasswordstatus` where `onetimepasswordstatusid`='".$this->onetimepasswordstatusId."'"; | ||
257 | return Database::NonQuery($this->pog_query, $connection); | ||
258 | } | ||
259 | |||
260 | |||
261 | /** | ||
262 | * Deletes a list of objects that match given conditions | ||
263 | * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...} | ||
264 | * @param bool $deep | ||
265 | * @return | ||
266 | */ | ||
267 | function DeleteList($fcv_array, $deep = false, $across = false) | ||
268 | { | ||
269 | if (sizeof($fcv_array) > 0) | ||
270 | { | ||
271 | if ($deep || $across) | ||
272 | { | ||
273 | $objectList = $this->GetList($fcv_array); | ||
274 | foreach ($objectList as $object) | ||
275 | { | ||
276 | $object->Delete($deep, $across); | ||
277 | } | ||
278 | } | ||
279 | else | ||
280 | { | ||
281 | $connection = Database::Connect(); | ||
282 | $pog_query = "delete from `onetimepasswordstatus` where "; | ||
283 | for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++) | ||
284 | { | ||
285 | if (sizeof($fcv_array[$i]) == 1) | ||
286 | { | ||
287 | $pog_query .= " ".$fcv_array[$i][0]." "; | ||
288 | continue; | ||
289 | } | ||
290 | else | ||
291 | { | ||
292 | if ($i > 0 && sizeof($fcv_array[$i-1]) !== 1) | ||
293 | { | ||
294 | $pog_query .= " AND "; | ||
295 | } | ||
296 | if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET') | ||
297 | { | ||
298 | $pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$this->Escape($fcv_array[$i][2])."'"; | ||
299 | } | ||
300 | else | ||
301 | { | ||
302 | $pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$fcv_array[$i][2]."'"; | ||
303 | } | ||
304 | } | ||
305 | } | ||
306 | return Database::NonQuery($pog_query, $connection); | ||
307 | } | ||
308 | } | ||
309 | } | ||
310 | |||
311 | |||
312 | /** | ||
313 | * Gets a list of onetimepassword objects associated to this one | ||
314 | * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...} | ||
315 | * @param string $sortBy | ||
316 | * @param boolean $ascending | ||
317 | * @param int limit | ||
318 | * @return array of onetimepassword objects | ||
319 | */ | ||
320 | function GetOnetimepasswordList($fcv_array = array(), $sortBy='', $ascending=true, $limit='') | ||
321 | { | ||
322 | $onetimepassword = new onetimepassword(); | ||
323 | $fcv_array[] = array("onetimepasswordstatusId", "=", $this->onetimepasswordstatusId); | ||
324 | $dbObjects = $onetimepassword->GetList($fcv_array, $sortBy, $ascending, $limit); | ||
325 | return $dbObjects; | ||
326 | } | ||
327 | |||
328 | |||
329 | /** | ||
330 | * Makes this the parent of all onetimepassword objects in the onetimepassword List array. Any existing onetimepassword will become orphan(s) | ||
331 | * @return null | ||
332 | */ | ||
333 | function SetOnetimepasswordList(&$list) | ||
334 | { | ||
335 | $this->_onetimepasswordList = array(); | ||
336 | $existingOnetimepasswordList = $this->GetOnetimepasswordList(); | ||
337 | foreach ($existingOnetimepasswordList as $onetimepassword) | ||
338 | { | ||
339 | $onetimepassword->onetimepasswordstatusId = ''; | ||
340 | $onetimepassword->Save(false); | ||
341 | } | ||
342 | $this->_onetimepasswordList = $list; | ||
343 | } | ||
344 | |||
345 | |||
346 | /** | ||
347 | * Associates the onetimepassword object to this one | ||
348 | * @return | ||
349 | */ | ||
350 | function AddOnetimepassword(&$onetimepassword) | ||
351 | { | ||
352 | $onetimepassword->onetimepasswordstatusId = $this->onetimepasswordstatusId; | ||
353 | $found = false; | ||
354 | foreach($this->_onetimepasswordList as $onetimepassword2) | ||
355 | { | ||
356 | if ($onetimepassword->onetimepasswordId > 0 && $onetimepassword->onetimepasswordId == $onetimepassword2->onetimepasswordId) | ||
357 | { | ||
358 | $found = true; | ||
359 | break; | ||
360 | } | ||
361 | } | ||
362 | if (!$found) | ||
363 | { | ||
364 | $this->_onetimepasswordList[] = $onetimepassword; | ||
365 | } | ||
366 | } | ||
367 | } | ||
368 | ?> \ No newline at end of file | ||