ultimix
ownership_access_1_0_0 Class Reference

Public Member Functions

 __construct ()
 add_owner ($Object1Id, $Object2Id, $Object1Type, $Object2Type)
 delete_owner ($Object1Id, $Object2Id, $Object1Type, $Object2Type)
 register_owner ($OwnerId, $OwnerType)
 object_has_owner ($ObjectId, $ObjectType)
 owner_was_registered ($ObjectId, $ObjectType)

Data Fields

 $Link = false
 $Owners = false

Detailed Description

Class provides routine for ownership relations.

Author
Dodonov A.A.

Definition at line 29 of file ownership_access.php.

Constructor & Destructor Documentation

__construct ( )

Constructor.

Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 69 of file ownership_access.php.

{
try
{
$this->Link = get_package( 'link' , 'last' , __FILE__ );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Member Function Documentation

add_owner (   $Object1Id,
  $Object2Id,
  $Object1Type,
  $Object2Type 
)

Creation of the relationship.

Parameters
$Object1Id- Id of the first object.
$Object2Id- Id of the second object.
$Object1Type- Type of the first object.
$Object2Type- Type of the second object.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 111 of file ownership_access.php.

{
try
{
$this->Link->create_link( $Object1Id , $Object2Id , $Object1Type , $Object2Type , true );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
delete_owner (   $Object1Id,
  $Object2Id,
  $Object1Type,
  $Object2Type 
)

Function deletes relationship.

Parameters
$Object1Id- Id of the first object.
$Object2Id- Id of the second object.
$Object1Type- Type of the first object.
$Object2Type- Type of the second object.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 153 of file ownership_access.php.

{
try
{
$this->Link->delete_link( $Object1Id , $Object2Id , $Object1Type , $Object2Type , true );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
object_has_owner (   $ObjectId,
  $ObjectType 
)

Function validates relationship.

Parameters
$ObjectId- Id of the object.
$ObjectType- Type of the object.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 234 of file ownership_access.php.

{
try
{
if( $this->Owners === false )
{
throw( new Exception( "No owners were registered" ) );
}
foreach( $this->Owners as $i => $Owner )
{
if( $this->Link->link_exists( $Owner[ 'id' ] , $ObjectId , $Owner[ 'type' ] , $ObjectType ) )
{
return( true );
}
}
return( false );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
owner_was_registered (   $ObjectId,
  $ObjectType 
)

Function validates owner existence.

Parameters
$ObjectId- Id of the object.
$ObjectType- Type of the object.
Returns
true if the owner was registered.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 285 of file ownership_access.php.

{
try
{
if( $this->Owners === false )
{
return( false );
}
foreach( $this->Owners as $i => $Owner )
{
if( $Owner[ 'id' ] == $ObjectId && $Owner[ 'type' ] == $ObjectType )
{
return( true );
}
}
return( false );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
register_owner (   $OwnerId,
  $OwnerType 
)

Function registers owner.

Parameters
$OwnerId- Id of the owner.
$OwnerType- Type of the owner.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 187 of file ownership_access.php.

{
try
{
if( $this->Owners === false )
{
$this->Owners = array();
}
foreach( $this->Owners as $i => $Owner )
{
if( $Owner[ 'id' ] == $OwnerId && $Owner[ 'type' ] == $OwnerType )
{
return;
}
}
$this->Owners [] = array( 'id' => $OwnerId , 'type' => $OwnerType );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Field Documentation

$Link = false

Cached objects.

Author
Dodonov A.A.

Definition at line 41 of file ownership_access.php.

$Owners = false

List of owners.

Author
Dodonov A.A.

Definition at line 53 of file ownership_access.php.


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