70 $this->Database =
get_package(
'database' ,
'last' , __FILE__ );
71 $this->DatabaseAlgorithms =
get_package(
'database::database_algorithms' ,
'last' , __FILE__ );
72 $this->Link =
get_package(
'link' ,
'last' , __FILE__ );
73 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
74 $this->SecurityParser =
get_package(
'security::security_parser' ,
'last' , __FILE__ );
116 if( $this->AddLimitations ===
'1 = 1' )
118 $this->AddLimitations = $theAddLimitation;
122 throw(
new Exception(
'"AddLimitations" was already set' ) );
125 catch( Exception $e )
160 $this->Database->select(
161 $this->NativeTable.
'.*' , $this->NativeTable ,
162 "( $this->AddLimitations ) AND $Condition"
166 catch( Exception $e )
210 function select( $Start =
false , $Limit =
false , $Field =
false ,
211 $Order =
false , $Condition =
'1 = 1' )
215 $Condition = $this->DatabaseAlgorithms->select_condition(
216 $Start , $Limit , $Field , $Order , $Condition , $this->NativeTable
221 catch( Exception $e )
249 function delete( $id , $Options =
' 1 = 1' )
253 $id = $this->Security->get( $id ,
'integer_list' );
255 $this->Database->delete( $this->NativeTable ,
"( $this->AddLimitations ) AND id IN ( $id )" );
257 $this->Database->commit();
259 catch( Exception $e )
291 $Record = $this->SecurityParser->parse_parameters(
292 $Record ,
'title:string;description:string;template:string'
295 list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
297 $id = $this->DatabaseAlgorithms->create( $this->NativeTable , $Fields , $Values );
299 $EventManager =
get_package(
'event_manager' ,
'last' , __FILE__ );
300 $EventManager->trigger_event(
'on_after_create_subscription' , array(
'id' => $id ) );
304 catch( Exception $e )
336 $id = $this->Security->get( $id ,
'integer_list' );
337 $Record = $this->SecurityParser->parse_parameters(
338 $Record ,
'title:string;description:string;template:string' ,
'allow_not_set'
341 list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
343 if( isset( $Fields[ 0 ] ) )
345 $this->Database->update(
346 $this->NativeTable , $Fields , $Values ,
"( $this->AddLimitations ) AND id IN ( $id )"
348 $this->Database->commit();
351 catch( Exception $e )
383 $id = $this->Security->get( $id ,
'integer_list' );
385 return( $this->
unsafe_select( $this->NativeTable.
".id IN ( $id ) ORDER BY id ASC" ) );
387 catch( Exception $e )
419 $UserId = explode(
',' , $this->Security->get( $UserId ,
'integer_list' ) );
420 $SubscriptionId = explode(
',' , $this->Security->get( $SubscriptionId ,
'integer_list' ) );
422 foreach( $UserId as $i => $User )
424 foreach( $SubscriptionId as $j => $Subscription )
426 $this->Link->create_link( $User , $Subscription ,
'user' ,
'subscription' ,
true );
430 catch( Exception $e )
462 $UserId = explode(
',' , $this->Security->get( $UserId ,
'integer_list' ) );
463 $SubscriptionId = explode(
',' , $this->Security->get( $SubscriptionId ,
'integer_list' ) );
465 foreach( $UserId as $i => $User )
467 foreach( $SubscriptionId as $j => $Subscription )
469 $this->Link->delete_link( $User , $Subscription ,
'user' ,
'subscription' );
473 catch( Exception $e )
505 $UserId = $this->Security->get( $UserId ,
'integer' );
507 $SubscriptionLinks = $this->Link->get_links( $UserId ,
false ,
'user' ,
'subscription' );
509 if( isset( $SubscriptionLinks[ 0 ] ) )
511 $Subscriptions = implode(
',' ,
get_field_ex( $SubscriptionLinks ,
'object2_id' ) );
513 return( $this->
unsafe_select(
"id IN ( $Subscriptions )" ) );
518 catch( Exception $e )