ultimix
gallery_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 
27 
38  var $NativeTable = '`umx_gallery`';
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  return(
158  $this->Database->select( '*' , $this->NativeTable , "( $this->AddLimitations ) AND $Condition" )
159  );
160  }
161  catch( Exception $e )
162  {
163  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
164  }
165  }
166 
205  function select( $Start = false , $Limit = false ,
206  $Field = false , $Order = false , $Condition = '1 = 1' )
207  {
208  try
209  {
210  $Condition = $this->DatabaseAlgorithms->select_condition(
211  $Start , $Limit , $Field , $Order , $Condition , $this->NativeTable
212  );
213 
214  return( $this->unsafe_select( $Condition ) );
215  }
216  catch( Exception $e )
217  {
218  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
219  }
220  }
221 
244  function delete( $id , $Options = ' 1 = 1' )
245  {
246  try
247  {
248  $id = $this->Security->get( $id , 'integer_list' );
249  $this->Database->delete( $this->NativeTable , "( $this->AddLimitations ) AND id IN ( $id )" );
250  $this->Database->commit();
251  }
252  catch( Exception $e )
253  {
254  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
255  }
256  }
257 
280  function create( $Record )
281  {
282  try
283  {
284  $Record = $this->SecurityParser->parse_parameters(
285  $Record , 'title:string;description:string,allow_no_set'
286  );
287 
288  list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
289 
290  $id = $this->DatabaseAlgorithms->create( $this->NativeTable , $Fields , $Values );
291 
292  $EventManager = get_package( 'event_manager' , 'last' , __FILE__ );
293  $EventManager->trigger_event( 'on_after_create_gallery' , array( 'id' => $id ) );
294 
295  return( $id );
296  }
297  catch( Exception $e )
298  {
299  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
300  }
301  }
302 
325  function update( $id , $Record )
326  {
327  try
328  {
329  $id = $this->Security->get( $id , 'integer_list' );
330  $Record = $this->SecurityParser->parse_parameters(
331  $Record , 'title:string;description:string' , 'allow_no_set'
332  );
333 
334  list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
335 
336  if( isset( $Fields[ 0 ] ) )
337  {
338  $this->Database->update(
339  $this->NativeTable , $Fields , $Values , "( $this->AddLimitations ) AND id IN ( $id )"
340  );
341  $this->Database->commit();
342  }
343  }
344  catch( Exception $e )
345  {
346  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
347  }
348  }
349 
372  function select_list( $id )
373  {
374  try
375  {
376  $id = $this->Security->get( $id , 'integer_list' );
377 
378  return( $this->unsafe_select( $this->NativeTable.".id IN ( $id )" ) );
379  }
380  catch( Exception $e )
381  {
382  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
383  }
384  }
385  }
386 
387 ?>