ultimix
comment_algorithms_1_0_0 Class Reference

Public Member Functions

 __construct ()
 object_exists ($id)
 get_by_id ($id)
 get_records_for_object ($MasterId, $MasterType)
 get_comments_newer_than ($Author, $Time)

Data Fields

 $CommentAccess = false
 $Link = false
 $LinkUtilities = false
 $Security = false
 $Cache = array()

Detailed Description

Class provides algorithms.

Author
Dodonov A.A.

Definition at line 26 of file comment_algorithms.php.

Constructor & Destructor Documentation

__construct ( )

Constructor.

Author
Dodonov A.A.

Definition at line 55 of file comment_algorithms.php.

{
try
{
$this->CommentAccess = get_package( 'comment::comment_access' , 'last' , __FILE__ );
$this->Link = get_package( 'link' , 'last' , __FILE__ );
$this->LinkUtilities = get_package( 'link::link_utilities' , 'last' , __FILE__ );
$this->Security = get_package( 'security' , 'last' , __FILE__ );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Member Function Documentation

get_by_id (   $id)

Function returns record by it's id.

Parameters
$id- Record's id.
Returns
Record.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 130 of file comment_algorithms.php.

{
try
{
$id = $this->Security->get( $id , 'integer' );
$Records = $this->CommentAccess->unsafe_select( $this->CommentAccess->NativeTable.".id = $id" );
if( count( $Records ) == 0 )
{
throw( new Exception( 'Record was not found' ) );
}
return( $Records[ 0 ] );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_comments_newer_than (   $Author,
  $Time 
)

Function fetches comments.

Parameters
$Author- Author.
$Time- Period limit (in seconds).
Returns
Records.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 224 of file comment_algorithms.php.

{
try
{
$Author = $this->Security->get( $Author , 'integer' );
$Time = $this->Security->get( $Time , 'integer' );
$Records = $this->CommentAccess->unsafe_select(
$this->CommentAccess->NativeTable.".author = $Author AND ".
"DATE_ADD( creation_date , INTERVAL $Time SECOND ) > NOW()"
);
return( $Records );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_records_for_object (   $MasterId,
  $MasterType 
)

Function fetches comments.

Parameters
$MasterId- Master object's id.
$MasterType- Master object's type.
Returns
Records.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 177 of file comment_algorithms.php.

{
try
{
if( isset( $this->Cache[ "$MasterId.$MasterType" ] ) )
{
return( $this->Cache[ "$MasterId.$MasterType" ] );
}
$this->Cache[ "$MasterId.$MasterType" ] = $this->LinkUtilities->get_dependent_objects(
$MasterId , $MasterType , 'comment' , $this->CommentAccess
);
return( $this->Cache[ "$MasterId.$MasterType" ] );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
object_exists (   $id)

Function validates object's existense.

Parameters
$id- Record's id.
Returns
true if the object exists.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 92 of file comment_algorithms.php.

{
try
{
$id = $this->Security->get( $id , 'integer' );
$Records = $this->CommentAccess->unsafe_select( $this->CommentAccess->NativeTable.".id = $id" );
return( count( $Records ) === 1 );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Field Documentation

$Cache = array()

Definition at line 43 of file comment_algorithms.php.

$CommentAccess = false

Cached objects.

Author
Dodonov A.A.

Definition at line 38 of file comment_algorithms.php.

$Link = false

Definition at line 39 of file comment_algorithms.php.

$LinkUtilities = false

Definition at line 40 of file comment_algorithms.php.

$Security = false

Definition at line 41 of file comment_algorithms.php.


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