ultimix
subscription_access_1_0_0 Class Reference

Public Member Functions

 __construct ()
 set_add_limitations ($theAddLimitation)
 unsafe_select ($Condition)
 select ($Start=false, $Limit=false, $Field=false, $Order=false, $Condition= '1=1')
 delete ($id, $Options= '1=1')
 create ($Record)
 update ($id, $Record)
 select_list ($id)
 subscribe_user ($UserId, $SubscriptionId)
 unsubscribe_user ($UserId, $SubscriptionId)
 get_subscriptions_for_user ($UserId)

Data Fields

 $NativeTable = '`umx_subscription`'
 $Database = false
 $DatabaseAlgorithms = false
 $Link = false
 $Security = false
 $SecurityParser = false
 $AddLimitations = '1 = 1'

Detailed Description

Class provides records access routine.

Author
Dodonov A.A.

Definition at line 26 of file subscription_access.php.

Constructor & Destructor Documentation

__construct ( )

Constructor.

Author
Dodonov A.A.

Definition at line 66 of file subscription_access.php.

{
try
{
$this->Database = get_package( 'database' , 'last' , __FILE__ );
$this->DatabaseAlgorithms = get_package( 'database::database_algorithms' , 'last' , __FILE__ );
$this->Link = get_package( 'link' , 'last' , __FILE__ );
$this->Security = get_package( 'security' , 'last' , __FILE__ );
$this->SecurityParser = get_package( 'security::security_parser' , 'last' , __FILE__ );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Member Function Documentation

create (   $Record)

Creating record.

Parameters
$RecordExample for creation.
Returns
id of the created record.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 287 of file subscription_access.php.

{
try
{
$Record = $this->SecurityParser->parse_parameters(
$Record , 'title:string;description:string;template:string'
);
list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
$id = $this->DatabaseAlgorithms->create( $this->NativeTable , $Fields , $Values );
$EventManager = get_package( 'event_manager' , 'last' , __FILE__ );
$EventManager->trigger_event( 'on_after_create_subscription' , array( 'id' => $id ) );
return( $id );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
delete (   $id,
  $Options = ' 1 = 1' 
)

Deleting records.

Parameters
$id- Record's identificator.
$Options- Additional options.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 249 of file subscription_access.php.

{
try
{
$id = $this->Security->get( $id , 'integer_list' );
$this->Database->delete( $this->NativeTable , "( $this->AddLimitations ) AND id IN ( $id )" );
$this->Database->commit();
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_subscriptions_for_user (   $UserId)

Function unsubscribes user.

Parameters
$UserId- User's id.
Returns
List of subscriptions.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 501 of file subscription_access.php.

{
try
{
$UserId = $this->Security->get( $UserId , 'integer' );
$SubscriptionLinks = $this->Link->get_links( $UserId , false , 'user' , 'subscription' );
if( isset( $SubscriptionLinks[ 0 ] ) )
{
$Subscriptions = implode( ',' , get_field_ex( $SubscriptionLinks , 'object2_id' ) );
return( $this->unsafe_select( "id IN ( $Subscriptions )" ) );
}
return( array() );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
select (   $Start = false,
  $Limit = false,
  $Field = false,
  $Order = false,
  $Condition = '1 = 1' 
)

Function returns list of records.

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
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 210 of file subscription_access.php.

{
try
{
$Condition = $this->DatabaseAlgorithms->select_condition(
$Start , $Limit , $Field , $Order , $Condition , $this->NativeTable
);
return( $this->unsafe_select( $Condition ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
select_list (   $id)

Function selects list of objects.

Parameters
$id- Comma separated list of record's id.
Returns
Array of records.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 379 of file subscription_access.php.

{
try
{
$id = $this->Security->get( $id , 'integer_list' );
return( $this->unsafe_select( $this->NativeTable.".id IN ( $id ) ORDER BY id ASC" ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
set_add_limitations (   $theAddLimitation)

Function sets additional limitations.

Parameters
$theAddLimitation- Additional limitations.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 112 of file subscription_access.php.

{
try
{
if( $this->AddLimitations === '1 = 1' )
{
$this->AddLimitations = $theAddLimitation;
}
else
{
throw( new Exception( '"AddLimitations" was already set' ) );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
subscribe_user (   $UserId,
  $SubscriptionId 
)

Function subscribes user.

Parameters
$UserId- Comma separated list of users's id.
$SubscriptionId- Comma separated list of record's id.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 415 of file subscription_access.php.

{
try
{
$UserId = explode( ',' , $this->Security->get( $UserId , 'integer_list' ) );
$SubscriptionId = explode( ',' , $this->Security->get( $SubscriptionId , 'integer_list' ) );
foreach( $UserId as $i => $User )
{
foreach( $SubscriptionId as $j => $Subscription )
{
$this->Link->create_link( $User , $Subscription , 'user' , 'subscription' , true );
}
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
unsafe_select (   $Condition)

Selecting records.

Parameters
$Condition- Records selection condition.
Returns
Array of objects.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 153 of file subscription_access.php.

{
try
{
$this->Database->query_as( DB_OBJECT );
return(
$this->Database->select(
$this->NativeTable.'.*' , $this->NativeTable ,
"( $this->AddLimitations ) AND $Condition"
)
);
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
unsubscribe_user (   $UserId,
  $SubscriptionId 
)

Function unsubscribes user.

Parameters
$UserId- Comma separated list of users's id.
$SubscriptionId- Comma separated list of record's id.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 458 of file subscription_access.php.

{
try
{
$UserId = explode( ',' , $this->Security->get( $UserId , 'integer_list' ) );
$SubscriptionId = explode( ',' , $this->Security->get( $SubscriptionId , 'integer_list' ) );
foreach( $UserId as $i => $User )
{
foreach( $SubscriptionId as $j => $Subscription )
{
$this->Link->delete_link( $User , $Subscription , 'user' , 'subscription' );
}
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
update (   $id,
  $Record 
)

Updating record.

Parameters
$id- Comma separated list of record's id.
$Record- Example for update.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 332 of file subscription_access.php.

{
try
{
$id = $this->Security->get( $id , 'integer_list' );
$Record = $this->SecurityParser->parse_parameters(
$Record , 'title:string;description:string;template:string' , 'allow_not_set'
);
list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
if( isset( $Fields[ 0 ] ) )
{
$this->Database->update(
$this->NativeTable , $Fields , $Values , "( $this->AddLimitations ) AND id IN ( $id )"
);
$this->Database->commit();
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Field Documentation

$AddLimitations = '1 = 1'

Definition at line 92 of file subscription_access.php.

$Database = false

Cached objects.

Author
Dodonov A.A.

Definition at line 50 of file subscription_access.php.

$DatabaseAlgorithms = false

Definition at line 51 of file subscription_access.php.

$Link = false

Definition at line 52 of file subscription_access.php.

$NativeTable = '`umx_subscription`'

Table name in wich objects of this entity are stored.

Author
Dodonov A.A.

Definition at line 38 of file subscription_access.php.

$Security = false

Definition at line 53 of file subscription_access.php.

$SecurityParser = false

Definition at line 54 of file subscription_access.php.


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