89 $this->CachedMultyFS =
get_package(
'cached_multy_fs' ,
'last' , __FILE__ );
90 $this->Database =
get_package(
'database' ,
'last' , __FILE__ );
91 $this->DatabaseAlgorithms =
get_package(
'database::database_algorithms' ,
'last' , __FILE__ );
92 $this->Link =
get_package(
'link' ,
'last' , __FILE__ );
93 $this->LinkDictionary =
get_package(
'link::link_dictionary' ,
'last' , __FILE__ );
94 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
95 $this->SecurityParser =
get_package(
'security::security_parser' ,
'last' , __FILE__ );
96 $this->UserAlgorithms =
get_package(
'user::user_algorithms' ,
'last' , __FILE__ );
130 if( $this->AddLimitations ===
'1 = 1' )
132 $this->AddLimitations = $theAddLimitation;
136 throw(
new Exception(
'"AddLimitations" was already set' ) );
139 catch( Exception $e )
173 $Condition =
"( $this->AddLimitations ) AND $Condition";
174 $Records = $this->Database->select(
'*' , $this->NativeTable , $Condition );
176 foreach( $Records as $k => $v )
178 $Records[ $k ]->permit = htmlspecialchars_decode( $Records[ $k ]->permit , ENT_QUOTES );
179 $Records[ $k ]->comment = htmlspecialchars_decode( $Records[ $k ]->comment , ENT_QUOTES );
184 catch( Exception $e )
216 $Permit = $this->Security->get( $Permit ,
'command' );
218 $Items = $this->
unsafe_select(
"( $this->AddLimitations ) AND permit LIKE '$Permit'" );
220 if( count( $Items ) == 0 )
222 throw(
new Exception(
"Permit $Permit was not found" ) );
225 return( $Items[ 0 ] );
227 catch( Exception $e )
271 function select( $Start =
false , $Limit =
false ,
272 $Field =
false , $Order =
false , $Condition =
'1 = 1' )
276 $Condition = $this->DatabaseAlgorithms->select_condition(
277 $Start , $Limit , $Field , $Order , $Condition , $this->NativeTable
282 catch( Exception $e )
310 $Record = $this->SecurityParser->parse_parameters( $Record ,
'permit:command;comment:string' );
312 list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
314 $id = $this->DatabaseAlgorithms->create( $this->NativeTable , $Fields , $Values );
316 catch( Exception $e )
340 function delete( $id )
344 $id = $this->Security->get( $id ,
'integer_list' );
346 $this->Database->delete( $this->NativeTable ,
"( $this->AddLimitations ) AND id IN ( $id )" );
348 $this->Database->commit();
350 catch( Exception $e )
382 $id = $this->Security->get( $id ,
'integer_list' );
384 return( $this->
unsafe_select( $this->NativeTable.
".id IN ( $id )" ) );
386 catch( Exception $e )
418 $id = $this->Security->get( $id ,
'integer_list' );
420 $Record = $this->SecurityParser->parse_parameters(
421 $Record ,
'permit:command;comment:string' ,
'allow_not_set'
424 list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
426 if( isset( $Fields[ 0 ] ) )
428 $Condition =
"( $this->AddLimitations ) AND id IN ( $id )";
430 $this->Database->update( $this->NativeTable , $Fields , $Values , $Condition );
432 $this->Database->commit();
435 catch( Exception $e )
480 $id = $this->Security->get( $id ,
'integer' );
481 $Type = $this->Security->get( $Type ,
'command' );
483 $Links = $this->Link->get_links( $id ,
false , $Type ,
'permit' );
485 if( isset( $Links[ 0 ] ) ===
false )
493 $Permits = $this->
select_list( implode(
',' , $ids ) );
498 catch( Exception $e )
530 $uid = ( $uid === false ) ? $this->UserAlgorithms->get_id() : $this->Security->get( $uid ,
'integer' );
532 $Type = $this->LinkDictionary->get_link_type(
'user' ,
'group' );
534 $Items = $this->Database->select(
535 '`umx_group`.id' ,
'`umx_group` , umx_link' ,
536 "umx_group.id = umx_link.object2_id AND umx_link.object1_id = $uid AND type = $Type"
541 foreach( $Items as $i )
546 return( array_unique( $Permits ) );
548 catch( Exception $e )
584 $this->PermitsCache = array();
586 $Permit = $this->Security->get( $Permit ,
'command' );
587 $Object = $this->Security->get( $Object ,
'string' );
588 $ObjectType = $this->Security->get( $ObjectType ,
'command' );
592 if( $ObjectType ==
'user' || $ObjectType ==
'group' || $ObjectType ==
'page' )
595 $Permit = $Permit[ 0 ];
596 $this->Link->create_link( $Object , $Permit->id , $ObjectType ,
'permit' ,
true );
600 throw(
new Exception(
"Undefined \"$ObjectType\"" ) );
602 catch( Exception $e )
638 $this->PermitsCache = array();
640 $Permit = $this->Security->get( $Permit ,
'command' );
642 if( isset( $Permit[ 0 ] ) ===
false )
644 throw(
new Exception(
"Permit \"$Permit\" was not found" ) );
647 $Permit = $Permit[ 0 ];
648 $Object = $this->Security->get( $Object ,
'string' );
649 $ObjectType = $this->Security->get( $ObjectType ,
'command' );
651 $this->Link->create_link( $Object ,
get_field( $Permit ,
'id' ) , $ObjectType ,
'permit' ,
true );
653 catch( Exception $e )
689 $this->PermitsCache = array();
691 $Permit = $this->Security->get( $Permit ,
'command' );
693 if( isset( $Permit[ 0 ] ) ===
false )
695 throw(
new Exception(
"Permit \"$Permit\" was not found" ) );
698 $Permit = $Permit[ 0 ];
699 $Object = $this->Security->get( $Object ,
'string' );
700 $ObjectType = $this->Security->get( $ObjectType ,
'command' );
702 if( is_array( $Object ) ===
false )
704 $Object = array( $Object );
707 $this->PermitAccessUtilities->toggle_permits();
709 catch( Exception $e )
745 $this->PermitsCache = array();
747 $Permit = $this->Security->get( $Permit ,
'command' );
749 if( isset( $Permit[ 0 ] ) ===
false )
751 throw(
new Exception(
"Permit \"$Permit\" was not found" ) );
754 $Permit = $Permit[ 0 ];
755 $Object = $this->Security->get( $Object ,
'string' );
756 $ObjectType = $this->Security->get( $ObjectType ,
'command' );
758 $this->Link->delete_link( $Object ,
get_field( $Permit ,
'id' ) , $ObjectType ,
'permit' );
760 catch( Exception $e )
792 $Object = $this->Security->get( $Object ,
'string' );
794 if( $this->CachedMultyFS->file_exists( dirname( __FILE__ ).
"/data/p$Object" ) )
796 $Permits = $this->CachedMultyFS->file_get_contents( dirname( __FILE__ ).
"/data/p$Object" );
797 return( explode(
',' , $Permits ) );
801 return( array(
'admin' ) );
804 catch( Exception $e )