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) |
Detailed Description
Class provides private messages manipulation routine.
- Author
- Dodonov A.A.
Definition at line 26 of file pmsg_algorithms.php.
Constructor & Destructor Documentation
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 )
{
}
}
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 )" );
$this->PmsgAccess->update( $id , array( 'deleted' => 2 ) );
}
catch( Exception $e )
{
}
}
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();
$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 )
{
}
}
| 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 )" );
$this->PmsgAccess->update( $id , array( 'deleted' => 1 ) );
}
catch( Exception $e )
{
}
}
Function returns record by it's id.
- Parameters
-
- 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 )
{
}
}
| 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 )
{
}
}
| 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 )
{
}
}
| 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 )
{
}
}
| 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 )
{
}
}
Setting 'read' mark.
- Parameters
-
- 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 )
{
}
}
Field Documentation
The documentation for this class was generated from the following file: