.

DAONotificationssettings Class Reference

Manage norification subcriptions. More...

Inheritance diagram for DAONotificationssettings:
DataObjectCached DataObjectBase IDataObject IActionSource ISearchAdapter IDBTable IDBWhereHolder

List of all members.

Public Member Functions

  get_settings_for_type ($type)
  Returns settings for given type.
  get_user ()
  is_feed_enabled ()
  Returns true, if feed is enabled and valid.
  is_type_enabled ($type)
  Returns wether a given type of notiofications is enabled.
  should_notification_be_processed (DAONotifications $n, $type)
  Returns true if given notifications should be processed for given type (FEED, MAIL, DIGEST).
  source_matches ($source, $type)
  Returns true if given source is part of settings for given type.
  validate ()
  Check if everything is OK.

Public Attributes

  $digest_enable
  $digest_last_sent
  $digest_settings
  $feed_enable
  $feed_settings
  $feed_token
  $id
  $id_user
  $mail_enable
  $mail_settings

Protected Member Functions

  create_feed_token ()
  Create a feed token.
  create_table_object ()
  Create the table object describing this dataobejcts table.

Detailed Description

Manage norification subcriptions.

Definition at line 7 of file notificationssettings.model.php.


Member Function Documentation

DAONotificationssettings::create_feed_token (  )  [protected]

Create a feed token.

Returns:
string

Definition at line 141 of file notificationssettings.model.php.

00141                                                {
00142                 $user = Users::get($this->id_user);
00143                 $seed = rand(1000000, 9999999);
00144                 if ($user) {
00145                         $seed .= $user->password . $user->creationdate;
00146                 }
00147                 return Common::create_token($seed);                     
00148         }
DAONotificationssettings::create_table_object (  )  [protected]

Create the table object describing this dataobejcts table.

Reimplemented from DataObjectBase.

Definition at line 22 of file notificationssettings.model.php.

00022                                                  {
00023                 return new DBTable(
00024                         'notificationssettings',
00025                         array(
00026                                 new DBFieldInt('id', null, DBFieldInt::AUTOINCREMENT | DBFieldInt::UNSIGNED | DBField::NOT_NULL),
00027                                 new DBFieldInt('id_user', null, DBFieldInt::UNSIGNED), // Null allowed!
00028                                 new DBFieldBool('mail_enable', true, DBField::NOT_NULL),
00029                                 new DBFieldSerialized('mail_settings', DBFieldSerialized::BLOB_LENGTH_SMALL, array(Notifications::SOURCE_ALL), DBField::NONE),
00030                                 new DBFieldBool('digest_enable', false, DBField::NOT_NULL),
00031                                 new DBFieldSerialized('digest_settings', DBFieldSerialized::BLOB_LENGTH_SMALL, array(Notifications::SOURCE_ALL), DBField::NONE),
00032                                 new DBFieldDateTime('digest_last_sent', null, DBField::INTERNAL),
00033                                 new DBFieldBool('feed_enable', false, DBField::NOT_NULL),
00034                                 new DBFieldSerialized('feed_settings', DBFieldSerialized::BLOB_LENGTH_SMALL, array(Notifications::SOURCE_ALL), DBField::NONE),
00035                                 new DBFieldText('feed_token', 40, null, DBField::INTERNAL)
00036                         ),
00037                         'id',
00038                         new DBRelation('users', new DBFieldRelation('id_user', 'id'))
00039                 );              
00040         }       
DAONotificationssettings::get_settings_for_type ( type  ) 

Returns settings for given type.

Definition at line 93 of file notificationssettings.model.php.

00093                                                      {
00094                 $ret = array();
00095                 switch($type) {
00096                         case NotificationsSettings::TYPE_FEED:
00097                                 $ret = Arr::force($this->feed_settings, false);
00098                                 break; 
00099                         case NotificationsSettings::TYPE_MAIL:
00100                                 $ret = Arr::force($this->mail_settings, false);
00101                                 break; 
00102                         case NotificationsSettings::TYPE_DIGEST:
00103                                 $ret = Arr::force($this->digest_settings, false);
00104                                 break; 
00105                 }
00106                 return $ret;
00107         }
DAONotificationssettings::get_user (  ) 

Definition at line 67 of file notificationssettings.model.php.

00067                                    {
00068                 return Users::get($this->id_user);
00069         }
DAONotificationssettings::is_feed_enabled (  ) 

Returns true, if feed is enabled and valid.

Returns:
bool

Definition at line 155 of file notificationssettings.model.php.

00155                                           {
00156                 return $this->feed_enable && $this->feed_token;
00157         }
DAONotificationssettings::is_type_enabled ( type  ) 

Returns wether a given type of notiofications is enabled.

Definition at line 74 of file notificationssettings.model.php.

00074                                                {
00075                 $ret = false;
00076                 switch($type) {
00077                         case NotificationsSettings::TYPE_FEED:
00078                                 $ret = $this->feed_enable;
00079                                 break; 
00080                         case NotificationsSettings::TYPE_MAIL:
00081                                 $ret = $this->mail_enable;
00082                                 break; 
00083                         case NotificationsSettings::TYPE_DIGEST:
00084                                 $ret = $this->digest_enable;
00085                                 break; 
00086                 }
00087                 return $ret;
00088         }
DAONotificationssettings::should_notification_be_processed ( DAONotifications n,
type  
)

Returns true if given notifications should be processed for given type (FEED, MAIL, DIGEST).

Definition at line 113 of file notificationssettings.model.php.

00113                                                                                      {
00114                 $ret = $this->source_matches($n->source, $type);
00115                 
00116                 return $ret;
00117         }
DAONotificationssettings::source_matches ( source,
type  
)

Returns true if given source is part of settings for given type.

Definition at line 122 of file notificationssettings.model.php.

00122                                                        {
00123                 $ret = false;
00124                 if ($this->is_type_enabled($type)) {
00125                         $settings = $this->get_settings_for_type($type);
00126                         if (in_array(Notifications::SOURCE_ALL, $settings)) {
00127                                 $ret = true;
00128                         }
00129                         else {
00130                                 $ret = in_array($source, $settings);
00131                         }
00132                 }
00133                 return $ret;
00134         }
DAONotificationssettings::validate (  ) 

Check if everything is OK.

See also:
gyro/core/model/base/DataObjectBasevalidate()

Reimplemented from DataObjectBase.

Definition at line 47 of file notificationssettings.model.php.

00047                                    {
00048                 // Create a feed token if feed was enbaled
00049                 if ($this->feed_enable === false) {
00050                         $this->feed_token = new DBNull();
00051                 } 
00052                 else if ($this->feed_enable === true && (empty($this->feed_token) || $this->feed_token instanceof DBNull)) {
00053                         $this->feed_token = $this->create_feed_token();
00054                 }
00055                 // Set last sent date to now, if digest is enabled
00056                 if ($this->digest_enable === false) {
00057                         $this->digest_last_sent = new DBNull();
00058                 } 
00059                 else if ($this->digest_enable === true && (empty($this->digest_last_sent) || $this->digest_last_sent instanceof DBNull)) {
00060                         $this->digest_last_sent = time();
00061                 }
00062                 // Set last sent date to now, if digest is enabled              
00063                  
00064                 return parent::validate();
00065         }

Member Data Documentation

DAONotificationssettings::$digest_enable

Definition at line 12 of file notificationssettings.model.php.

DAONotificationssettings::$digest_last_sent

Definition at line 14 of file notificationssettings.model.php.

DAONotificationssettings::$digest_settings

Definition at line 13 of file notificationssettings.model.php.

DAONotificationssettings::$feed_enable

Definition at line 15 of file notificationssettings.model.php.

DAONotificationssettings::$feed_settings

Definition at line 16 of file notificationssettings.model.php.

DAONotificationssettings::$feed_token

Definition at line 17 of file notificationssettings.model.php.

DAONotificationssettings::$id

Definition at line 8 of file notificationssettings.model.php.

DAONotificationssettings::$id_user

Definition at line 9 of file notificationssettings.model.php.

DAONotificationssettings::$mail_enable

Definition at line 10 of file notificationssettings.model.php.

DAONotificationssettings::$mail_settings

Definition at line 11 of file notificationssettings.model.php.


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