57 $this->Database =
get_package(
'database' ,
'last' , __FILE__ );
58 $this->PmsgAccess =
get_package(
'pmsg::pmsg_access' ,
'last' , __FILE__ );
59 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
60 $this->UserAlgorithms =
get_package(
'user::user_algorithms' ,
'last' , __FILE__ );
107 $Order =
false , $Condition =
false )
111 $Login = $this->UserAlgorithms->get_login();
114 $this->PmsgAccess->select(
115 $Start , $Limit , $Field , $Order ,
"( $Condition ) AND recipient LIKE '$Login' AND deleted = 0"
119 catch( Exception $e )
164 $Order =
false , $Options =
false )
168 $Login = $this->UserAlgorithms->get_login();
171 $this->PmsgAccess->select(
172 $Start , $Limit , $Field , $Order ,
173 "author LIKE '$Login' AND NOT ( author LIKE recipient AND deleted IN ( 1 , 2 ) )"
177 catch( Exception $e )
222 $Order =
false , $Options =
false )
226 $Login = $this->UserAlgorithms->get_login();
229 $this->PmsgAccess->select(
230 $Start , $Limit , $Field , $Order ,
"recipient LIKE '$Login' AND deleted = 1"
234 catch( Exception $e )
270 $id = $this->Security->get( $id ,
'integer_list' );
272 $Login = $this->UserAlgorithms->get_login();
274 $Messages = $this->PmsgAccess->unsafe_select(
"recipient LIKE '$Login' AND id IN ( $id )" );
276 $id = implode(
',' ,
get_field_ex( $Messages ,
'id' ) );
278 $this->PmsgAccess->update( $id , array(
'deleted' => 1 ) );
280 catch( Exception $e )
312 if( is_array( $id ) )
314 $id = $this->Security->get( $id ,
'integer' );
315 $id = implode(
' , ' , $id );
319 $id = $this->Security->get( $id ,
'integer_list' );
322 $Login = $this->UserAlgorithms->get_login();
324 $Messages = $this->PmsgAccess->unsafe_select(
"recipient LIKE '$Login' AND id IN ( $id )" );
326 $id = implode(
',' ,
get_field_ex( $Messages ,
'id' ) );
328 $this->PmsgAccess->update( $id , array(
'deleted' => 2 ) );
330 catch( Exception $e )
362 $Login = $this->UserAlgorithms->get_login();
363 set_field( $Record ,
'author' , $Login );
365 $AllRecipients = $this->Security->get(
get_field( $Record ,
'recipient' ) ,
'string' );
366 $AllRecipients = explode(
',' , $AllRecipients );
368 foreach( $AllRecipients as $k => $Recipient )
370 $Recipient = trim( $Recipient ,
" \t\r\n," );
371 if( $Recipient !=
'' )
373 set_field( $Record ,
'recipient' , $Recipient );
374 $this->PmsgAccess->create( $Record );
378 catch( Exception $e )
406 $Login = $this->UserAlgorithms->get_login();
407 $Count = count( $this->PmsgAccess->unsafe_select(
"recipient LIKE '$Login' AND `read` = 0" ) );
410 catch( Exception $e )
442 $id = $this->Security->get( $id ,
'integer' );
444 $Records = $this->unsafe_select( $this->NativeTable.
".id = $id" );
446 if( count( $Records ) == 0 )
448 throw(
new Exception(
'Record was not found' ) );
451 return( $Records[ 0 ] );
453 catch( Exception $e )
481 $id = $this->Security->get( $id ,
'integer' );
482 $Login = $this->UserAlgorithms->get_login();
484 $Record = $this->PmsgAccess->unsafe_select(
"id = $id AND recipient LIKE '$Login'" );
485 if( count( $Record ) > 0 )
487 $this->PmsgAccess->update( $id , array(
'`read`' => 1 ) );
490 catch( Exception $e )