ultimix

- Main Page
- Data Structures
- Files
- Examples

- Data Structures
- Data Structure Index
- Data Fields

Public Member Functions | Data Fields
group_access_1_0_0 Class Reference

## 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')

## Data Fields
| $NativeTable = '`umx_group`'
| $Database = false
| $DatabaseAlgorithms = false
| $Link = false
| $LinkDictionary = false
| $Security = false
| $SecurityParser = false
| $UserAccess = false
| $AddLimitations = '1 = 1'

## Detailed Description

Class provides routine for permits.

Author
  Dodonov A.A.

Definition at line 26 of file group_access.php.

## Constructor & Destructor Documentation

__construct | ( |  | ) |

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 )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $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 )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

create | ( |  | $Record | ) |

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 )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

delete | ( |  | $id | ) |

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' );
$Database = get_package( 'database' , 'last' , __FILE__ );
$this->Database->delete( $this->NativeTable , "( $this->AddLimitations ) AND id IN ( $id )" );
$this->Database->commit();
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $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 )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_group_by_id | ( |  | $id | ) |

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' );
$Items = $this->unsafe_select( "id = $id" );
if( count( $Items ) == 0 )
{
throw( new Exception( "Group $id was not found" ) );
}
return( $Items[ 0 ] );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_group_by_name | ( |  | $Group | ) |

Selecting record.

Parameters

  $Group | Group's title.

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 )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $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 )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $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
);
return( $this->unsafe_select( $Condition ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

select_list | ( |  | $id | ) |

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 )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $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 )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $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
{
/* dropping local cache */
$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 )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $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();
$Group = $this->get_group_by_name( $Group );
$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 )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $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
{
$this->Database->query_as( DB_OBJECT );
$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 )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

update | ( |  | $id,
|  |  | $Record
| ) |  |

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 )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Field Documentation

$AddLimitations = '1 = 1'

Definition at line 96 of file group_access.php.

$Database = false

Cached objects.

Author
  Dodonov A.A.

Definition at line 50 of file group_access.php.

$DatabaseAlgorithms = false

Definition at line 51 of file group_access.php.

$Link = false

Definition at line 52 of file group_access.php.

$LinkDictionary = false

Definition at line 53 of file group_access.php.

$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.

$Security = false

Definition at line 54 of file group_access.php.

$SecurityParser = false

Definition at line 55 of file group_access.php.

$UserAccess = false

Definition at line 56 of file group_access.php.

The documentation for this class was generated from the following file:

- packages/permit/packages/group_access/group_access.php