Detailed Description
Class provides records access routine.
- Author
- Dodonov A.A.
Definition at line 26 of file subscription_algorithms.php.
Constructor & Destructor Documentation
Constructor.
- Author
- Dodonov A.A.
Definition at line 56 of file subscription_algorithms.php.
{
try
{
$this->AutoMarkup =
get_package(
'page::auto_markup' ,
'last' , __FILE__ );
$this->CachedMultyFS =
get_package(
'cached_multy_fs' ,
'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__ );
$this->String =
get_package(
'string' ,
'last' , __FILE__ );
$this->SubscriptionAccess =
get_package(
'subscription::subscription_access' ,
'last' , __FILE__ );
$this->UserAlgorithms =
get_package(
'user::user_algorithms' ,
'last' , __FILE__ );
}
catch( Exception $e )
{
}
}
Member Function Documentation
| calculate_hash |
( |
|
$UserId, |
|
|
|
$SubscriptionId |
|
) |
| |
Function calculates unsibscribe hash.
- Parameters
-
| $UserId | - User id. |
| $SubscriptionId | - Subscription id. |
- Returns
- Unsibscribe hash or false.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 149 of file subscription_algorithms.php.
{
try
{
$UserId = $this->Security->get( $UserId , 'integer' );
$SubscriptionId = $this->Security->get( $SubscriptionId , 'integer' );
$Link = $this->Link->get_links( $UserId , $SubscriptionId ,
'user' ,
'subscription' );
if( isset(
$Link[ 0 ] ) )
{
return( md5( "$UserId.$LinkId" ) );
}
return( false );
}
catch( Exception $e )
{
}
}
| compile_subscription |
( |
|
$User, |
|
|
|
$Subscription |
|
) |
| |
Function unsubscribes user.
- Parameters
-
| $User | - User object. |
| $Subscription | - Subscription object. |
- Returns
- HTML code.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 101 of file subscription_algorithms.php.
{
try
{
$Code = $this->CachedMultyFS->get_template( __FILE__ ,
get_field( $Subscription ,
'template' ).
'.tpl' );
$Code = $this->String->print_record( $Code , $User );
$Subscription =
set_field( $Subscription ,
'subscription_id' ,
get_field( $Subscription ,
'id' ) );
$Code = $this->String->print_record( $Code , $Subscription );
$Code = $this->AutoMarkup->compile_string( $Code );
return( $Code );
}
catch( Exception $e )
{
}
}
Function returns subscription by it's id.
- Parameters
-
| $id | - Id of the searching subscription. |
- Returns
- Subscription.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 285 of file subscription_algorithms.php.
{
try
{
$id = $this->Security->get( $id , 'integer' );
$Subscriptions = $this->SubscriptionAccess->unsafe_select(
$this->SubscriptionAccess->NativeTable.".id = $id"
);
if( count( $Subscriptions ) === 0 || count( $Subscriptions ) > 1 )
{
throw( new Exception( 'Subscription with id '.$id.' was not found' ) );
}
else
{
return( $Subscriptions[ 0 ] );
}
}
catch( Exception $e )
{
}
}
| is_subscribed |
( |
|
$UserId, |
|
|
|
$SubscriptionId |
|
) |
| |
Is user subscribed.
- Parameters
-
| $UserId | - Comma separated list of users's id. |
| $SubscriptionId | - Comma separated list of record's id. |
- Returns
- true/false.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 246 of file subscription_algorithms.php.
{
try
{
$UserId = $this->Security->get( $UserId , 'integer' );
$SubscriptionId = $this->Security->get( $SubscriptionId , 'integer' );
$Links = $this->Link->get_links( $UserId , $SubscriptionId , 'user' , 'subscription' );
return( isset( $Links[ 0 ] ) );
}
catch( Exception $e )
{
}
}
| send_subscription_for_user |
( |
|
$UserId, |
|
|
|
$SubscriptionId |
|
) |
| |
Function sends subscription if necessary.
- Parameters
-
| $UserId | - Comma separated list of users's id. |
| $SubscriptionId | - Comma separated list of record's id. |
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 463 of file subscription_algorithms.php.
{
try
{
$UserId = $this->Security->get( $UserId , 'integer' );
$SubscriptionId = $this->Security->get( $SubscriptionId , 'integer' );
{
$User = $this->UserAlgorithms->get_by_id( $UserId );
$Subscription = $this->
get_by_id( $SubscriptionId );
$this->send_email(
get_field( $User ,
'email' ) , $Message , $Subscription );
}
}
catch( Exception $e )
{
}
}
| unsubscribe_user |
( |
|
$UserId, |
|
|
|
$Hash |
|
) |
| |
Function unsubscribes user.
- Parameters
-
| $UserId | - Comma separated list of users's id. |
| $Hash | - Unsibscribe hash. |
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 194 of file subscription_algorithms.php.
{
try
{
$UserId = $this->Security->get( $UserId , 'integer' );
$Hash = $this->Security->get( $Hash , 'string' );
$Subscriptions = $this->SubscriptionAccess->get_subscriptions_for_user( $UserId );
foreach( $Subscriptions as $i => $Subscription )
{
$SubscriptionId =
get_field( $Subscription ,
'id' );
{
$this->SubscriptionAccess->unsubscribe_user( $UserId , $SubscriptionId );
return;
}
}
}
catch( Exception $e )
{
}
}
Field Documentation
The documentation for this class was generated from the following file: