ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

site_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 site_access_1_0_0{
27
38 var $NativeTable = '`umx_site`';
39
50 var $Database = false;
51 var $DatabaseAlgorithms = false;
52 var $EventManager = false;
53 var $Security = false;
54 var $SecurityParser = false;
55
66 function __construct()
67 {
68 try
69 {
70 $this->Database = get_package( 'database' , 'last' , __FILE__ );
71 $this->DatabaseAlgorithms = get_package( 'database::database_algorithms' , 'last' , __FILE__ );
72 $this->EventManager = get_package( 'event_manager' , 'last' , __FILE__ );
73 $this->Security = get_package( 'security' , 'last' , __FILE__ );
74 $this->SecurityParser = get_package( 'security::security_parser' , 'last' , __FILE__ );
75 }
76 catch( Exception $e )
77 {
78 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
79 }
80 }
81
92 var $AddLimitations = '1 = 1';
93
112 function set_add_limitations( $theAddLimitation )
113 {
114 try
115 {
116 if( $this->AddLimitations === '1 = 1' )
117 {
118 $this->AddLimitations = $theAddLimitation;
119 }
120 else
121 {
122 throw( new Exception( '"AddLimitations" was already set' ) );
123 }
124 }
125 catch( Exception $e )
126 {
127 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
128 }
129 }
130
153 function unsafe_select( $Condition )
154 {
155 try
156 {
157 $this->Database->query_as( DB_OBJECT );
158
159 return(
160 $this->Database->select(
161 $this->NativeTable.'.*' , $this->NativeTable , "( $this->AddLimitations ) AND $Condition"
162 )
163 );
164 }
165 catch( Exception $e )
166 {
167 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
168 }
169 }
170
209 function select( $Start = false , $Limit = false , $Field = false ,
210 $Order = false , $Condition = '1 = 1' )
211 {
212 try
213 {
214 $Condition = $this->DatabaseAlgorithms->select_condition(
215 $Start , $Limit , $Field , $Order , $Condition , $this->NativeTable
216 );
217
218 return( $this->unsafe_select( $Condition ) );
219 }
220 catch( Exception $e )
221 {
222 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
223 }
224 }
225
248 function delete( $id , $Options = ' 1 = 1' )
249 {
250 try
251 {
252 $this->EventManager->trigger_event( 'on_before_delete_site' , array( 'id' => $id ) );
253
254 $id = $this->Security->get( $id , 'integer_list' );
255 $this->Database->delete( $this->NativeTable , "( $this->AddLimitations ) AND id IN ( $id )" );
256 $this->Database->commit();
257
258 $this->EventManager->trigger_event( 'on_after_delete_site' , array( 'id' => $id ) );
259 }
260 catch( Exception $e )
261 {
262 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
263 }
264 }
265
288 function create( $Record )
289 {
290 try
291 {
292 $Record = $this->SecurityParser->parse_parameters(
293 $Record , 'domain:string;comment:string,allow_not_set'
294 );
295
296 list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record , CREATION_DATE );
297
298 $id = $this->DatabaseAlgorithms->create( $this->NativeTable , $Fields , $Values );
299
300 $EventManager = get_package( 'event_manager' , 'last' , __FILE__ );
301 $EventManager->trigger_event( 'on_after_create_site' , array( 'id' => $id ) );
302
303 return( $id );
304 }
305 catch( Exception $e )
306 {
307 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
308 }
309 }
310
333 function update( $id , $Record )
334 {
335 try
336 {
337 $id = $this->Security->get( $id , 'integer_list' );
338 $Record = $this->SecurityParser->parse_parameters(
339 $Record , 'domain:string;comment:string' , 'allow_not_set'
340 );
341
342 list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
343
344 if( isset( $Fields[ 0 ] ) )
345 {
346 $this->Database->update(
347 $this->NativeTable , $Fields , $Values , "( $this->AddLimitations ) AND id IN ( $id )"
348 );
349 $this->Database->commit();
350 }
351 }
352 catch( Exception $e )
353 {
354 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
355 }
356 }
357
380 function select_list( $id )
381 {
382 try
383 {
384 $id = $this->Security->get( $id , 'integer_list' );
385
386 return( $this->unsafe_select( $this->NativeTable.".id IN ( $id ) ORDER BY creation_date ASC" ) );
387 }
388 catch( Exception $e )
389 {
390 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
391 }
392 }
393 }
394
395 ?>