71 $this->Database =
get_package(
'database' ,
'last' , __FILE__ );
72 $this->DatabaseAlgorithms =
get_package(
'database::database_algorithms' ,
'last' , __FILE__ );
73 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
74 $this->SecurityParser =
get_package(
'security::security_parser' ,
'last' , __FILE__ );
75 $this->UserAccess =
get_package(
'user::user_access' ,
'last' , __FILE__ );
76 $this->UserAlgorithms =
get_package(
'user::user_algorithms' ,
'last' , __FILE__ );
118 if( $this->AddLimitations ===
'1 = 1' )
120 $this->AddLimitations = $theAddLimitation;
124 throw(
new Exception(
'"AddLimitations" was already set' ) );
127 catch( Exception $e )
162 $this->Database->select(
163 $this->UserAccess->NativeTable.
'.* , '.$this->NativeTable.
'.*' ,
164 $this->NativeTable.
' , '.$this->UserAccess->NativeTable ,
165 $this->NativeTable.
'.author = '.$this->UserAccess->NativeTable.
".id
166 AND ( $this->AddLimitations ) AND $Condition"
170 catch( Exception $e )
214 function select( $Start =
false , $Limit =
false , $Field =
false ,
215 $Order =
false , $Condition =
'1 = 1' )
219 $Condition = $this->DatabaseAlgorithms->select_condition(
220 $Start , $Limit , $Field , $Order , $Condition , $this->NativeTable
225 catch( Exception $e )
253 function delete( $id , $Options =
' 1 = 1' )
258 $Link->delete_link(
false , $id ,
false ,
'comment' );
260 $id = $this->Security->get( $id ,
'integer_list' );
261 $this->Database->delete( $this->NativeTable ,
"( $this->AddLimitations ) AND id IN ( $id )" );
262 $this->Database->commit();
264 catch( Exception $e )
292 private function compile_record( &$Record )
296 $MasterLink = $this->SecurityParser->parse_parameters(
297 $Record ,
'master_type:command;master_id:integer'
300 $Record = $this->SecurityParser->parse_parameters( $Record ,
'comment:string' );
301 set_field( $Record ,
'author' , $this->UserAlgorithms->get_id() );
302 set_field( $Record ,
'page' , $this->Security->get_srv(
'REQUEST_URI' ,
'string' ,
'./index.html' ) );
306 catch( Exception $e )
338 $Record = $this->compile_record( $Record );
340 list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record ,
CREATION_DATE );
342 $id = $this->DatabaseAlgorithms->create( $this->NativeTable , $Fields , $Values );
346 get_field( $MasterLink ,
'master_id' ) , $id ,
347 get_field( $MasterLink ,
'master_type' ) ,
'comment'
350 $EventManager =
get_package(
'event_manager' ,
'last' , __FILE__ );
351 $EventManager->trigger_event(
'on_after_create_comment' , array(
'id' => $id ) );
355 catch( Exception $e )
387 $id = $this->Security->get( $id ,
'integer_list' );
388 $Record = $this->SecurityParser->parse_parameters( $Record ,
'comment:string' ,
'allow_not_set' );
390 list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
392 if( isset( $Fields[ 0 ] ) )
394 $this->Database->update(
395 $this->NativeTable , $Fields , $Values ,
"( $this->AddLimitations ) AND id IN ( $id )"
397 $this->Database->commit();
400 catch( Exception $e )
432 $id = $this->Security->get( $id ,
'integer_list' );
434 return( $this->
unsafe_select( $this->NativeTable.
".id IN ( $id ) ORDER BY creation_date ASC" ) );
436 catch( Exception $e )