ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

schedule_access.php
Go to the documentation of this file.
1 <?php
2
3 /*
4 * This source code is a part of the Ultimix Project.
5 * It is distributed under BSD license. All other third side source code (like tinyMCE) is distributed under
6 * it's own license wich could be found from the corresponding files or sources.
7 * This source code is provided "as is" without any warranties or garanties.
8 *
9 * Have a nice day!
10 *
11 * @url http://ultimix.sorceforge.net
12 *
13 * @author Alexey "gdever" Dodonov
14 */
15
26 class schedule_access_1_0_0{
27
38 var $NativeTable = '`umx_schedule`';
39
50 var $Database = false;
51 var $DatabaseAlgorithms = false;
52 var $Security = false;
53 var $SecurityParser = false;
54
65 function __construct()
66 {
67 try
68 {
69 $this->Database = get_package( 'database' , 'last' , __FILE__ );
70 $this->DatabaseAlgorithms = get_package( 'database::database_algorithms' , 'last' , __FILE__ );
71 $this->Security = get_package( 'security' , 'last' , __FILE__ );
72 $this->SecurityParser = get_package( 'security::security_parser' , 'last' , __FILE__ );
73 }
74 catch( Exception $e )
75 {
76 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
77 }
78 }
79
90 var $AddLimitations = '1 = 1';
91
110 function set_add_limitations( $theAddLimitation )
111 {
112 try
113 {
114 if( $this->AddLimitations === '1 = 1' )
115 {
116 $this->AddLimitations = $theAddLimitation;
117 }
118 else
119 {
120 throw( new Exception( '"AddLimitations" was already set' ) );
121 }
122 }
123 catch( Exception $e )
124 {
125 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
126 }
127 }
128
151 function unsafe_select( $Condition )
152 {
153 try
154 {
155 $this->Database->query_as( DB_OBJECT );
156
157 $Records = $this->Database->select(
158 '*' , $this->NativeTable , "( $this->AddLimitations ) AND $Condition"
159 );
160
161 return( $Records );
162 }
163 catch( Exception $e )
164 {
165 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
166 }
167 }
168
207 function select( $Start = false , $Limit = false , $Field = false ,
208 $Order = false , $Condition = '1 = 1' )
209 {
210 try
211 {
212 $Condition = $this->DatabaseAlgorithms->select_condition(
213 $Start , $Limit , $Field , $Order , $Condition , $this->NativeTable
214 );
215
216 return( $this->unsafe_select( $Condition ) );
217 }
218 catch( Exception $e )
219 {
220 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
221 }
222 }
223
242 function create( $Record )
243 {
244 try
245 {
246 $Record = $this->SecurityParser->parse_parameters(
247 $Record ,
248 'package_name:string;package_version:string,allow_not_set;type:integer,allow_not_set;'.
249 'time_step:integer,allow_not_set;archived:integer,allow_not_set;'.
250 'parameters:string,allow_not_set;next_processing_time:integer,allow_not_set'
251 );
252
253 list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
254
255 $id = $this->DatabaseAlgorithms->create( $this->NativeTable , $Fields , $Values );
256
257 return( $id );
258 }
259 catch( Exception $e )
260 {
261 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
262 }
263 }
264
283 function delete( $id )
284 {
285 try
286 {
287 $id = $this->Security->get( $id , 'integer_list' );
288
291 $this->Database->delete( $this->NativeTable , "( $this->AddLimitations ) AND id IN ( $id )" );
292 $this->Database->commit();
293 }
294 catch( Exception $e )
295 {
296 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
297 }
298 }
299
322 function select_list( $id )
323 {
324 try
325 {
326 $id = $this->Security->get( $id , 'integer_list' );
327
328 return( $this->unsafe_select( $this->NativeTable.".id IN ( $id )" ) );
329 }
330 catch( Exception $e )
331 {
332 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
333 }
334 }
335
354 function simple_select()
355 {
356 try
357 {
358 $Records = $this->unsafe_select( '1 = 1' );
359
360 foreach( $Records as $k => $v )
361 {
362 $Records[ $k ]->title = $v->package_name.'.'.$v->package_version.$v->parameters;
363 }
364
365 return( $Records );
366 }
367 catch( Exception $e )
368 {
369 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
370 }
371 }
372
395 function update( $id , $Record )
396 {
397 try
398 {
399 $id = $this->Security->get( $id , 'integer_list' );
400 $Record = $this->SecurityParser->parse_parameters(
401 $Record ,
402 'package_name:string;package_version:string;type:integer;time_step:integer;archived:integer;'.
403 'parameters:string;next_processing_time:integer;processing:integer' , 'allow_not_set'
404 );
405
406 list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
407
408 if( isset( $Fields[ 0 ] ) )
409 {
410 $this->Database->update(
411 $this->NativeTable , $Fields , $Values , "( $this->AddLimitations ) AND id IN ( $id )"
412 );
413 $this->Database->commit();
414 }
415 }
416 catch( Exception $e )
417 {
418 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
419 }
420 }
421 }
422
423 ?>