72 $this->Database =
get_package(
'database' ,
'last' , __FILE__ );
73 $this->DatabaseAlgorithms =
get_package(
'database::database_algorithms' ,
'last' , __FILE__ );
74 $this->Link =
get_package(
'link' ,
'last' , __FILE__ );
75 $this->LinkDictionary =
get_package(
'link::link_dictionary' ,
'last' , __FILE__ );
76 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
77 $this->SecurityParser =
get_package(
'security::security_parser' ,
'last' , __FILE__ );
78 $this->UserAccess =
get_package(
'user::user_access' ,
'last' , __FILE__ );
120 if( $this->AddLimitations ===
'1 = 1' )
122 $this->AddLimitations = $theAddLimitation;
126 throw(
new Exception(
'"AddLimitations" was already set' ) );
129 catch( Exception $e )
163 $Records = $this->Database->select(
164 '*' , $this->NativeTable ,
"( $this->AddLimitations ) AND $Condition"
167 foreach( $Records as $k => $v )
169 $Records[ $k ]->title = htmlspecialchars_decode( $Records[ $k ]->title , ENT_QUOTES );
170 $Records[ $k ]->comment = htmlspecialchars_decode( $Records[ $k ]->comment , ENT_QUOTES );
175 catch( Exception $e )
207 $Group = $this->Security->get( $Group ,
'command' );
209 $Items = $this->
unsafe_select(
"( $this->AddLimitations ) AND title LIKE '$Group'" );
211 if( isset( $Items[ 0 ] ) ===
false )
213 throw(
new Exception(
"Group \"$Group\" was not found" ) );
216 return( $Items[ 0 ] );
218 catch( Exception $e )
250 $id = $this->Security->get( $id ,
'integer' );
254 if( count( $Items ) == 0 )
256 throw(
new Exception(
"Group $id was not found" ) );
259 return( $Items[ 0 ] );
261 catch( Exception $e )
305 function select( $Start =
false , $Limit =
false , $Field =
false ,
306 $Order =
false , $Condition =
'1 = 1' )
310 $Condition = $this->DatabaseAlgorithms->select_condition(
311 $Start , $Limit , $Field , $Order , $Condition , $this->NativeTable
316 catch( Exception $e )
344 $Record = $this->SecurityParser->parse_parameters( $Record ,
'title:command;comment:string' );
346 list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
348 $id = $this->DatabaseAlgorithms->create( $this->NativeTable , $Fields , $Values );
352 catch( Exception $e )
376 function delete( $id )
380 $id = $this->Security->get( $id ,
'integer_list' );
385 $this->Database->delete( $this->NativeTable ,
"( $this->AddLimitations ) AND id IN ( $id )" );
386 $this->Database->commit();
388 catch( Exception $e )
420 $id = $this->Security->get( $id ,
'integer_list' );
422 return( $this->
unsafe_select( $this->NativeTable.
".id IN ( $id )" ) );
424 catch( Exception $e )
456 $id = $this->Security->get( $id ,
'integer_list' );
457 $Record = $this->SecurityParser->parse_parameters(
458 $Record ,
'title:command;comment:string' ,
'allow_not_set'
461 list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
463 if( isset( $Fields[ 0 ] ) )
465 $this->Database->update(
466 $this->NativeTable , $Fields , $Values ,
"( $this->AddLimitations ) AND id IN ( $id )"
468 $this->Database->commit();
471 catch( Exception $e )
511 $Object = $this->Security->get( $Object ,
'integer' );
512 $LinkType = $this->LinkDictionary->get_link_type( $ObjectType ,
'group' );
514 $Items = $this->Database->select(
515 'title' , $this->NativeTable.
' , umx_link' ,
516 "( $this->AddLimitations ) AND ".$this->NativeTable.
517 ".id = umx_link.object2_id AND umx_link.object1_id = $Object AND type = $LinkType"
521 if( count( $Items ) > 0 )
523 foreach( $Items as $i )
525 $Content [] = $i->title;
528 $Content = array_unique( $Content );
533 catch( Exception $e )
569 $Group = $this->Security->get( $Group ,
'command' );
570 $Object = $this->Security->get( $Object ,
'string' );
571 $ObjectType = $this->Security->get( $ObjectType ,
'command' );
573 $Group = $this->
unsafe_select(
"( $this->AddLimitations ) AND title LIKE '$Group'" );
574 if( isset( $Group[ 0 ] ) )
576 $Group = $Group[ 0 ];
577 $this->Link->create_link( $Object ,
get_field( $Group ,
'id' ) , $ObjectType ,
'group' ,
true );
581 throw(
new Exception(
"Group \"$Group\" was not found" ) );
584 catch( Exception $e )
620 $Object = $this->Security->get( $Object ,
'string' );
621 $ObjectType = $this->Security->get( $ObjectType ,
'command' );
623 if( $Group ===
false )
625 $this->Link->delete_link( $Object ,
false , $ObjectType ,
'group' ,
true );
629 $Group = $this->Security->get( $Group ,
'command' );
630 $Group = $this->
unsafe_select(
"( $this->AddLimitations ) AND title LIKE '$Group'" );
631 if( isset( $Group[ 0 ] ) )
633 $this->Link->delete_link(
634 $Object ,
get_field( $Group[ 0 ] ,
'id' ) , $ObjectType ,
'group' ,
true
639 catch( Exception $e )
675 $this->PermitsCache = array();
679 $Object = $this->Security->get( $Object ,
'string' );
680 $ObjectType = $this->Security->get( $ObjectType ,
'command' );
682 if( $this->Link->link_exists( $Object ,
get_field( $Group ,
'id' ) , $ObjectType ,
'group' ) )
684 $this->Link->delete_link( $Object ,
get_field( $Group ,
'id' ) , $ObjectType ,
'group' );
688 $this->Link->create_link( $Object ,
get_field( $Group ,
'id' ) , $ObjectType ,
'group' ,
true );
691 catch( Exception $e )
728 $this->PermitsCache = array();
730 $Group = $this->Security->get( $Group ,
'command' );
731 $Group = $this->GroupAccess->unsafe_select(
"title LIKE '$Group'" );
732 if( isset( $Group[ 0 ] ) ===
false )
734 throw(
new Exception(
"Group \"$Group\" was not found" ) );
737 $Group = $Group[ 0 ];
738 $Object = $this->Security->get( $Object ,
'string' );
739 $ObjectType = $this->Security->get( $ObjectType ,
'command' );
741 $this->Link->create_link( $Object ,
get_field( $Group ,
'id' ) , $ObjectType ,
'group' ,
true );
743 catch( Exception $e )