Public Member Functions |
| | __construct () |
| | set_add_limitations ($theAddLimitation) |
| | unsafe_select ($Condition) |
| | get_group_by_name ($Group) |
| | get_group_by_id ($id) |
| | select ($Start=false, $Limit=false, $Field=false, $Order=false, $Condition= '1=1') |
| | create ($Record) |
| | delete ($id) |
| | select_list ($id) |
| | update ($id, $Record) |
| | get_groups_for_object ($Object, $ObjectType= 'user') |
| | add_group_for_object ($Group, $Object, $ObjectType= 'user') |
| | delete_group_for_object ($Group, $Object, $ObjectType= 'user') |
| | toggle_group_for_object ($Group, $Object, $ObjectType= 'page') |
| | set_group_for_object ($Group, $Object, $ObjectType= 'page') |
Detailed Description
Class provides routine for permits.
- Author
- Dodonov A.A.
Definition at line 26 of file group_access.php.
Constructor & Destructor Documentation
Constructor.
- Author
- Dodonov A.A.
Definition at line 68 of file group_access.php.
{
try
{
$this->Database =
get_package(
'database' ,
'last' , __FILE__ );
$this->DatabaseAlgorithms =
get_package(
'database::database_algorithms' ,
'last' , __FILE__ );
$this->Link =
get_package(
'link' ,
'last' , __FILE__ );
$this->LinkDictionary =
get_package(
'link::link_dictionary' ,
'last' , __FILE__ );
$this->Security =
get_package(
'security' ,
'last' , __FILE__ );
$this->SecurityParser =
get_package(
'security::security_parser' ,
'last' , __FILE__ );
$this->UserAccess =
get_package(
'user::user_access' ,
'last' , __FILE__ );
}
catch( Exception $e )
{
}
}
Member Function Documentation
| add_group_for_object |
( |
|
$Group, |
|
|
|
$Object, |
|
|
|
$ObjectType = 'user' |
|
) |
| |
Function adds group of permits for object.
- Parameters
-
| $Group | - Group's title. |
| $Object | - Object. |
| $ObjectType | - Type of the object (user). |
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 565 of file group_access.php.
{
try
{
$Group = $this->Security->get( $Group , 'command' );
$Object = $this->Security->get( $Object , 'string' );
$ObjectType = $this->Security->get( $ObjectType , 'command' );
$Group = $this->
unsafe_select(
"( $this->AddLimitations ) AND title LIKE '$Group'" );
if( isset( $Group[ 0 ] ) )
{
$Group = $Group[ 0 ];
$this->Link->create_link( $Object ,
get_field( $Group ,
'id' ) , $ObjectType ,
'group' ,
true );
}
else
{
throw( new Exception( "Group \"$Group\" was not found" ) );
}
}
catch( Exception $e )
{
}
}
Creating record.
- Parameters
-
| $Record | - Example for creation. |
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 340 of file group_access.php.
{
try
{
$Record = $this->SecurityParser->parse_parameters( $Record , 'title:command;comment:string' );
list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
$id = $this->DatabaseAlgorithms->create( $this->NativeTable , $Fields , $Values );
return( $id );
}
catch( Exception $e )
{
}
}
Deleting record from database.
- Parameters
-
| $id | - Comma separated list of record's id. |
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
deleting record
Definition at line 376 of file group_access.php.
{
try
{
$id = $this->Security->get( $id , 'integer_list' );
$this->Database->delete( $this->NativeTable , "( $this->AddLimitations ) AND id IN ( $id )" );
$this->Database->commit();
}
catch( Exception $e )
{
}
}
| delete_group_for_object |
( |
|
$Group, |
|
|
|
$Object, |
|
|
|
$ObjectType = 'user' |
|
) |
| |
Function adds group of permits for object.
- Parameters
-
| $Group | - Group's title. |
| $Object | - object. |
| $ObjectType | - type of the object (user). |
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 616 of file group_access.php.
{
try
{
$Object = $this->Security->get( $Object , 'string' );
$ObjectType = $this->Security->get( $ObjectType , 'command' );
if( $Group === false )
{
$this->Link->delete_link( $Object , false , $ObjectType , 'group' , true );
}
else
{
$Group = $this->Security->get( $Group , 'command' );
$Group = $this->
unsafe_select(
"( $this->AddLimitations ) AND title LIKE '$Group'" );
if( isset( $Group[ 0 ] ) )
{
$this->Link->delete_link(
$Object ,
get_field( $Group[ 0 ] ,
'id' ) , $ObjectType ,
'group' ,
true
);
}
}
}
catch( Exception $e )
{
}
}
Selecting record.
- Parameters
-
| $id | - Group's identificator. |
- Returns
- Object.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 246 of file group_access.php.
{
try
{
$id = $this->Security->get( $id , 'integer' );
if( count( $Items ) == 0 )
{
throw( new Exception( "Group $id was not found" ) );
}
return( $Items[ 0 ] );
}
catch( Exception $e )
{
}
}
| get_group_by_name |
( |
|
$Group | ) |
|
Selecting record.
- Parameters
-
- Returns
- Object.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 203 of file group_access.php.
{
try
{
$Group = $this->Security->get( $Group , 'command' );
$Items = $this->
unsafe_select(
"( $this->AddLimitations ) AND title LIKE '$Group'" );
if( isset( $Items[ 0 ] ) === false )
{
throw( new Exception( "Group \"$Group\" was not found" ) );
}
return( $Items[ 0 ] );
}
catch( Exception $e )
{
}
}
| get_groups_for_object |
( |
|
$Object, |
|
|
|
$ObjectType = 'user' |
|
) |
| |
Function returns groups for object.
- Parameters
-
| $Object | - Object to be accessed. |
| $ObjectType | - Type of the accessed object (may be menu, user, page). |
- Note
- Array of groups.
- Returns
- List of permits.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 507 of file group_access.php.
{
try
{
$Object = $this->Security->get( $Object , 'integer' );
$LinkType = $this->LinkDictionary->get_link_type( $ObjectType , 'group' );
$Items = $this->Database->select(
'title' , $this->NativeTable.' , umx_link' ,
"( $this->AddLimitations ) AND ".$this->NativeTable.
".id = umx_link.object2_id AND umx_link.object1_id = $Object AND type = $LinkType"
);
$Content = array();
if( count( $Items ) > 0 )
{
foreach( $Items as $i )
{
$Content [] = $i->title;
}
$Content = array_unique( $Content );
}
return( $Content );
}
catch( Exception $e )
{
}
}
| select |
( |
|
$Start = false, |
|
|
|
$Limit = false, |
|
|
|
$Field = false, |
|
|
|
$Order = false, |
|
|
|
$Condition = '1 = 1' |
|
) |
| |
Function returns list of records.
- Parameters
-
| $Start | - Number of the first record. |
| $Limit | - Count of records limitation. |
| $Field | - Field to sort by. |
| $Order | - Sorting order. |
| $Condition | - Records selection condition. |
- Returns
- List of records.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 305 of file group_access.php.
{
try
{
$Condition = $this->DatabaseAlgorithms->select_condition(
$Start , $Limit , $Field , $Order , $Condition , $this->NativeTable
);
}
catch( Exception $e )
{
}
}
Function selects list of objects.
- Parameters
-
| $id | - Comma separated list of record's id. |
- Returns
- Array of records.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 416 of file group_access.php.
{
try
{
$id = $this->Security->get( $id , 'integer_list' );
return( $this->
unsafe_select( $this->NativeTable.
".id IN ( $id )" ) );
}
catch( Exception $e )
{
}
}
| set_add_limitations |
( |
|
$theAddLimitation | ) |
|
Function sets additional limitations.
- Parameters
-
| $theAddLimitation | - Additional limitations. |
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 116 of file group_access.php.
{
try
{
if( $this->AddLimitations === '1 = 1' )
{
$this->AddLimitations = $theAddLimitation;
}
else
{
throw( new Exception( '"AddLimitations" was already set' ) );
}
}
catch( Exception $e )
{
}
}
| set_group_for_object |
( |
|
$Group, |
|
|
|
$Object, |
|
|
|
$ObjectType = 'page' |
|
) |
| |
Function set group for object.
- Parameters
-
| $Group | - Group to add. |
| $Object | - Object. |
| $ObjectType | - Type of the object (may be menu, user, page). |
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 723 of file group_access.php.
{
try
{
$this->PermitsCache = array();
$Group = $this->Security->get( $Group , 'command' );
$Group = $this->GroupAccess->unsafe_select( "title LIKE '$Group'" );
if( isset( $Group[ 0 ] ) === false )
{
throw( new Exception( "Group \"$Group\" was not found" ) );
}
$Group = $Group[ 0 ];
$Object = $this->Security->get( $Object , 'string' );
$ObjectType = $this->Security->get( $ObjectType , 'command' );
$this->Link->create_link( $Object ,
get_field( $Group ,
'id' ) , $ObjectType ,
'group' ,
true );
}
catch( Exception $e )
{
}
}
| toggle_group_for_object |
( |
|
$Group, |
|
|
|
$Object, |
|
|
|
$ObjectType = 'page' |
|
) |
| |
Function toggles group of permits for object.
- Parameters
-
| $Group | - Group's title. |
| $Object | - Object. |
| $ObjectType | - Type of the object (user). |
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 671 of file group_access.php.
{
try
{
$this->PermitsCache = array();
$Object = $this->Security->get( $Object , 'string' );
$ObjectType = $this->Security->get( $ObjectType , 'command' );
if( $this->Link->link_exists( $Object ,
get_field( $Group ,
'id' ) , $ObjectType ,
'group' ) )
{
$this->Link->delete_link( $Object ,
get_field( $Group ,
'id' ) , $ObjectType ,
'group' );
}
else
{
$this->Link->create_link( $Object ,
get_field( $Group ,
'id' ) , $ObjectType ,
'group' ,
true );
}
}
catch( Exception $e )
{
}
}
| unsafe_select |
( |
|
$Condition | ) |
|
Selecting records.
- Parameters
-
| $Condition | - Records selection condition. |
- Returns
- Array of objects.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 157 of file group_access.php.
{
try
{
$Records = $this->Database->select(
'*' , $this->NativeTable , "( $this->AddLimitations ) AND $Condition"
);
foreach( $Records as $k => $v )
{
$Records[ $k ]->title = htmlspecialchars_decode( $Records[ $k ]->title , ENT_QUOTES );
$Records[ $k ]->comment = htmlspecialchars_decode( $Records[ $k ]->comment , ENT_QUOTES );
}
return( $Records );
}
catch( Exception $e )
{
}
}
Updating record.
- Parameters
-
| $id | - Comma separated list of record's id. |
| $Record | - Example for update. |
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 452 of file group_access.php.
{
try
{
$id = $this->Security->get( $id , 'integer_list' );
$Record = $this->SecurityParser->parse_parameters(
$Record , 'title:command;comment:string' , 'allow_not_set'
);
list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
if( isset( $Fields[ 0 ] ) )
{
$this->Database->update(
$this->NativeTable , $Fields , $Values , "( $this->AddLimitations ) AND id IN ( $id )"
);
$this->Database->commit();
}
}
catch( Exception $e )
{
}
}
Field Documentation
| $AddLimitations = '1 = 1' |
| $DatabaseAlgorithms = false |
| $NativeTable = '`umx_group`' |
Table name in wich objects of this entity are stored.
- Author
- Dodonov A.A.
Definition at line 38 of file group_access.php.
The documentation for this class was generated from the following file: