ultimix

- Main Page
- Data Structures
- Files
- Examples

- Data Structures
- Data Structure Index
- Data Fields

Public Member Functions | Data Fields
permit_algorithms_1_0_0 Class Reference

## Public Member Functions
| __construct ()
| fetch_permits_for_object ($Object, $ObjectType= 'page', $AddGroupPermits=true)
| get_permits_for_object ($Object, $ObjectType= 'page', $AddGroupPermits=true)
| object_has_permit ($Object, $ObjectType, $Permit)
| object_has_all_permits ($Object, $ObjectType, $Permits)
| validate_permits_ex ($Object1, $ObjectType1, $Object2, $ObjectType2)
| get_users_for_permit ($PermitName)

## Data Fields
| $Database = false
| $Link = false
| $PermitAccess = false
| $Security = false
| $String = false
| $UserAlgorithms = false

## Detailed Description

Working with worker's registry cards.

Author
  Dodonov A.A.

Definition at line 26 of file permit_algorithms.php.

## Constructor & Destructor Documentation

__construct | ( |  | ) |

Constructor.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 59 of file permit_algorithms.php.

{
try
{
$this->Database = get_package( 'database' , 'last' , __FILE__ );
$this->Link = get_package( 'link' , 'last' , __FILE__ );
$this->PermitAccess = get_package( 'permit::permit_access' , 'last' , __FILE__ );
$this->Security = get_package( 'security' , 'last' , __FILE__ );
$this->UserAlgorithms = get_package( 'user::user_algorithms' , 'last' , __FILE__ );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Member Function Documentation

fetch_permits_for_object | ( |  | $Object,
|  |  | $ObjectType = `'page'`,
|  |  | $AddGroupPermits = `true`
| ) |  |

Function returns permits for object not using cache.

Parameters

  $Object | - Object to be accessed.
  $ObjectType | - Type of the accessed object (may be menu, user, page).
  $AddGroupPermits | - Should be group permits processed.

Note
  if the file with permits was not found, all permits for that object are defaulted to 'admin'.

Returns
  List of permits.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 164 of file permit_algorithms.php.

{
try
{
switch( $ObjectType )
{
case( 'group' ):
$Permits = $this->PermitAccess->get_permits_for_object( $Object , 'group' , array() );
break;
case( 'menu' ):
$Permits = $this->PermitAccess->get_permits_for_object( $Object , 'menu' , array( 'admin' ) );
break;
case( 'page' ):$Permits = $this->PermitAccess->get_permits_for_page( $Object );break;
case( 'user' ):$Permits = $this->get_permits_for_user( $Object , $AddGroupPermits );break;
}
return( $Permits );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_permits_for_object | ( |  | $Object,
|  |  | $ObjectType = `'page'`,
|  |  | $AddGroupPermits = `true`
| ) |  |

Function returns permits for object.

Parameters

  $Object | - Object to be accessed.
  $ObjectType | - Type of the accessed object (may be menu, user, page).
  $AddGroupPermits | - Should be group permits processed.

Note
  if the file with permits was not found, all permits for that object are defaulted to 'admin'.

Returns
  List of permits.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 223 of file permit_algorithms.php.

{
try
{
$Key = md5( $Object.$ObjectType.$AddGroupPermits );
if( isset( $this->PermitAccess->PermitsCache[ $Key ] ) )
{
return( $this->PermitAccess->PermitsCache[ $Key ] );
}
$Permits = $this->fetch_permits_for_object( $Object , $ObjectType , $AddGroupPermits );
$this->PermitAccess->PermitsCache[ $Key ] = $Permits;
return( $this->PermitAccess->PermitsCache[ $Key ] );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_users_for_permit | ( |  | $PermitName | ) |

Function returns all users who have permit $PermitName.

Parameters

  $PermitName | - Permit's title.

Returns
  List of the user objects wuch have permit $PermitName.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 430 of file permit_algorithms.php.

{
try
{
$PermitName = $this->Security->get( $PermitName , 'command' );
$PermitObject = $this->PermitAccess->get_permit_by_name( $PermitName );
$Links1 = $this->Link->get_links( false , get_field( $PermitObject , 'id' ) , 'user' , 'permit' );
$Links2 = $this->Link->get_links( false , get_field( $PermitObject , 'id' ) , 'group' , 'permit' );
$Links3 = $this->Link->get_links( false , get_field_ex( $Links2 , 'object1_id' ) , 'user' , 'group' );
$Users = array_merge( get_field_ex( $Links1 , 'object1_id' ) , get_field_ex( $Links3 , 'object1_id' ) );
$Users = array_unique( $Users );
return( $Users );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

object_has_all_permits | ( |  | $Object,
|  |  | $ObjectType,
|  |  | $Permits
| ) |  |

Function validates permit's existance for object.

Parameters

  $Object | - Name of the validating object.
  $ObjectType | - Type of the object.
  $Permits | - List of permits, for example "public,admin,reader".

Returns
  true if validation was passed, false otherwise

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 325 of file permit_algorithms.php.

{
try
{
$ObjectsPermits = $this->get_permits_for_object( $Object , $ObjectType );
if( is_array( $Permits ) === false )
{
$Permits = explode( "," , $Permits );
}
if( count( $Permits ) === count( array_intersect( $ObjectsPermits , $Permits ) ) )
{
return( true );
}
else
{
return( false );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

object_has_permit | ( |  | $Object,
|  |  | $ObjectType,
|  |  | $Permit
| ) |  |

Function validates permit's existance for object.

Parameters

  $Object | - Name of the validating object.
  $ObjectType | - Type of the object.
  $Permit | - Permit's title.

Returns
  true if validation was passed, false otherwise

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 276 of file permit_algorithms.php.

{
try
{
if( $Object === false && $ObjectType == 'user' )
{
$Object = $this->UserAlgorithms->get_id();
}
$ObjectsPermits = $this->get_permits_for_object( $Object , $ObjectType );
return( in_array( $Permit , $ObjectsPermits ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

validate_permits_ex | ( |  | $Object1,
|  |  | $ObjectType1,
|  |  | $Object2,
|  |  | $ObjectType2
| ) |  |

Validate if the first object has access to the second object.

Parameters

  $Object1 | - This object requests for permits.
  $ObjectType1 | - Type of the object (may be menu, user, page).
  $Object2 | - Object to be accessed.
  $ObjectType2 | - Type of the accessed object (may be menu, user, page).

Returns
  true if validation was passed, false otherwise

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 385 of file permit_algorithms.php.

{
try
{
$Permits1 = $this->get_permits_for_object( $Object1 , $ObjectType1 );
$Permits2 = $this->get_permits_for_object( $Object2 , $ObjectType2 );
if( count( $Permits2 ) === count( array_intersect( $Permits1 , $Permits2 ) ) )
{
return( true );
}
else
{
return( false );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Field Documentation

$Database = false

Cached packages.

Author
  Dodonov A.A.

Definition at line 38 of file permit_algorithms.php.

$Link = false

Definition at line 39 of file permit_algorithms.php.

$PermitAccess = false

Definition at line 40 of file permit_algorithms.php.

$Security = false

Definition at line 41 of file permit_algorithms.php.

$String = false

Definition at line 42 of file permit_algorithms.php.

$UserAlgorithms = false

Definition at line 43 of file permit_algorithms.php.

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

- packages/permit/packages/permit_algorithms/permit_algorithms.php