ultimix
pmsg_algorithms_1_0_0 Class Reference

Public Member Functions

 __construct ()
 select_incoming_messages ($Start=false, $Limit=false, $Field=false, $Order=false, $Condition=false)
 select_outgoing_messages ($Start=false, $Limit=false, $Field=false, $Order=false, $Options=false)
 select_deleted_messages ($Start=false, $Limit=false, $Field=false, $Order=false, $Options=false)
 delete_message_for_user ($id, $Options)
 cleanup_message_for_user ($id)
 create ($Record)
 get_not_read_messages_count ()
 get_by_id ($id)
 set_read ($id)

Data Fields

 $Database = false
 $PmsgAccess = false
 $Security = false
 $UserAlgorithms = false

Detailed Description

Class provides private messages manipulation routine.

Author
Dodonov A.A.

Definition at line 26 of file pmsg_algorithms.php.

Constructor & Destructor Documentation

__construct ( )

Constructor.

Author
Dodonov A.A.

Definition at line 53 of file pmsg_algorithms.php.

{
try
{
$this->Database = get_package( 'database' , 'last' , __FILE__ );
$this->PmsgAccess = get_package( 'pmsg::pmsg_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

cleanup_message_for_user (   $id)

Final deleting messages.

Parameters
$id- Message's identificator.
Returns
Array of objects.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 308 of file pmsg_algorithms.php.

{
try
{
if( is_array( $id ) )
{
$id = $this->Security->get( $id , 'integer' );
$id = implode( ' , ' , $id );
}
else
{
$id = $this->Security->get( $id , 'integer_list' );
}
$Login = $this->UserAlgorithms->get_login();
$Messages = $this->PmsgAccess->unsafe_select( "recipient LIKE '$Login' AND id IN ( $id )" );
$id = implode( ',' , get_field_ex( $Messages , 'id' ) );
$this->PmsgAccess->update( $id , array( 'deleted' => 2 ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
create (   $Record)

Creating record.

Parameters
$Record- Example for creation.
Returns
id of the created record.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 358 of file pmsg_algorithms.php.

{
try
{
$Login = $this->UserAlgorithms->get_login();
set_field( $Record , 'author' , $Login );
$AllRecipients = $this->Security->get( get_field( $Record , 'recipient' ) , 'string' );
$AllRecipients = explode( ',' , $AllRecipients );
foreach( $AllRecipients as $k => $Recipient )
{
$Recipient = trim( $Recipient , " \t\r\n," );
if( $Recipient != '' )
{
set_field( $Record , 'recipient' , $Recipient );
$this->PmsgAccess->create( $Record );
}
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
delete_message_for_user (   $id,
  $Options 
)

Deleting messages.

Parameters
$id- Message's identificator.
$Options- Additional settings.
Returns
Array of objects.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 266 of file pmsg_algorithms.php.

{
try
{
$id = $this->Security->get( $id , 'integer_list' );
$Login = $this->UserAlgorithms->get_login();
$Messages = $this->PmsgAccess->unsafe_select( "recipient LIKE '$Login' AND id IN ( $id )" );
$id = implode( ',' , get_field_ex( $Messages , 'id' ) );
$this->PmsgAccess->update( $id , array( 'deleted' => 1 ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_by_id (   $id)

Function returns record by it's id.

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

Definition at line 438 of file pmsg_algorithms.php.

{
try
{
$id = $this->Security->get( $id , 'integer' );
$Records = $this->unsafe_select( $this->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_not_read_messages_count ( )

Function returns count of the not read messages.

Returns
Count of the not read messages.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 402 of file pmsg_algorithms.php.

{
try
{
$Login = $this->UserAlgorithms->get_login();
$Count = count( $this->PmsgAccess->unsafe_select( "recipient LIKE '$Login' AND `read` = 0" ) );
return( $Count );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
select_deleted_messages (   $Start = false,
  $Limit = false,
  $Field = false,
  $Order = false,
  $Options = false 
)

Selecting outgoing messages.

Parameters
$Start- Number of the first record.
$Limit- Count of records limitation.
$Field- Field to sort by.
$Order- Sorting order.
$Options- Additional settings.
Returns
List of records.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 221 of file pmsg_algorithms.php.

{
try
{
$Login = $this->UserAlgorithms->get_login();
return(
$this->PmsgAccess->select(
$Start , $Limit , $Field , $Order , "recipient LIKE '$Login' AND deleted = 1"
)
);
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
select_incoming_messages (   $Start = false,
  $Limit = false,
  $Field = false,
  $Order = false,
  $Condition = false 
)

Selecting incoming messages.

Parameters
$Start- Number of the first record.
$Limit- Count of records limitation.
$Field- Field to sort by.
$Order- Sorting order.
$Condition- Additional conditions.
Returns
List of records.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 106 of file pmsg_algorithms.php.

{
try
{
$Login = $this->UserAlgorithms->get_login();
return(
$this->PmsgAccess->select(
$Start , $Limit , $Field , $Order , "( $Condition ) AND recipient LIKE '$Login' AND deleted = 0"
)
);
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
select_outgoing_messages (   $Start = false,
  $Limit = false,
  $Field = false,
  $Order = false,
  $Options = false 
)

Selecting outgoing messages.

Parameters
$Start- Number of the first record.
$Limit- Count of records limitation.
$Field- Field to sort by.
$Order- Sorting order.
$Options- Additional settings.
Returns
List of records.
Exceptions
Exception- An exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 163 of file pmsg_algorithms.php.

{
try
{
$Login = $this->UserAlgorithms->get_login();
return(
$this->PmsgAccess->select(
$Start , $Limit , $Field , $Order ,
"author LIKE '$Login' AND NOT ( author LIKE recipient AND deleted IN ( 1 , 2 ) )"
)
);
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
set_read (   $id)

Setting 'read' mark.

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

Definition at line 477 of file pmsg_algorithms.php.

{
try
{
$id = $this->Security->get( $id , 'integer' );
$Login = $this->UserAlgorithms->get_login();
$Record = $this->PmsgAccess->unsafe_select( "id = $id AND recipient LIKE '$Login'" );
if( count( $Record ) > 0 )
{
$this->PmsgAccess->update( $id , array( '`read`' => 1 ) );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Field Documentation

$Database = false

Cached objects.

Author
Dodonov A.A.

Definition at line 38 of file pmsg_algorithms.php.

$PmsgAccess = false

Definition at line 39 of file pmsg_algorithms.php.

$Security = false

Definition at line 40 of file pmsg_algorithms.php.

$UserAlgorithms = false

Definition at line 41 of file pmsg_algorithms.php.


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