.

NotificationsSettings Class Reference

Facade for notofocation settings. More...

List of all members.

Static Public Member Functions

static  collect_sources (DAOUsers $user)
  Collect all sources for given user.
static  create_digest_adapter (DAONotificationssettings $settings)
  Return adapter to collect notifications for digest.
static  create_feed_adapter (DAONotificationssettings $settings)
  Return adapter to collect notifications for feed.
static  create_possible_digest_adapter ()
  Create an adapter to find all settings that may have digests to send.
static  get_for_user ($user_id)
  Get settings for user.

Public Attributes

const  TYPE_DIGEST = 'digest'
const  TYPE_FEED = 'feed'
const  TYPE_MAIL = 'mail'

Detailed Description

Facade for notofocation settings.

Definition at line 5 of file notificationssettings.facade.php.


Member Function Documentation

static NotificationsSettings::collect_sources ( DAOUsers user  )  [static]

Collect all sources for given user.

  • Raise event notifications_collect_sources
  • Select DISTINCT from DB

Definition at line 25 of file notificationssettings.facade.php.

00025                                                                {
00026                 $ret = array(
00027                         Notifications::SOURCE_ALL => tr(Notifications::SOURCE_ALL, 'notifications'),
00028                         Notifications::SOURCE_APP => tr(Notifications::SOURCE_APP, 'notifications'),
00029                 );
00030                 EventSource::Instance()->invoke_event('notifications_collect_sources', $user, $ret);
00031                 
00032                 $dao = new DAONotifications();
00033                 $dao->id_user = $user->id;
00034                 
00035                 $query = $dao->create_select_query();
00036                 $query->set_fields('source');
00037                 $query->set_policy(DBQuerySelect::DISTINCT);
00038                 
00039                 $result = DB::query($query);
00040                 while($row = $result->fetch()) {
00041                         $s = $row['source'];
00042                         if (!array_key_exists($s, $ret)) {
00043                                 $ret[$s] = tr($s);
00044                         }
00045                 }
00046                 
00047                 return $ret;
00048         }
static NotificationsSettings::create_digest_adapter ( DAONotificationssettings settings  )  [static]

Return adapter to collect notifications for digest.

Returns:
DAONotifications

Definition at line 72 of file notificationssettings.facade.php.

00072                                                                                          {
00073                 $dao = self::create_notification_adapter($settings, self::TYPE_DIGEST);
00074                 // Entries as of last sent
00075                 $dao->add_where('creationdate', '>=', $settings->digest_last_sent);
00076                 $dao->sort('creationdate', DataObjectBase::DESC);
00077                 return $dao;            
00078         }       
static NotificationsSettings::create_feed_adapter ( DAONotificationssettings settings  )  [static]

Return adapter to collect notifications for feed.

Returns:
DAONotifications

Definition at line 55 of file notificationssettings.facade.php.

00055                                                                                        {
00056                 $dao = self::create_notification_adapter($settings, self::TYPE_FEED);
00057                 // Entries of last 5 days, but at least 10 entries
00058                 $dao->add_where('creationdate', '>=', time() - GyroDate::ONE_DAY);
00059                 if ($dao->count() < 10) {
00060                         $dao = self::create_notification_adapter($settings, self::TYPE_FEED);
00061                         $dao->limit(10);
00062                 }               
00063                 $dao->sort('creationdate', DataObjectBase::DESC);
00064                 return $dao;            
00065         }
static NotificationsSettings::create_possible_digest_adapter (  )  [static]

Create an adapter to find all settings that may have digests to send.

Returns:
DAONotificationssettings

Definition at line 107 of file notificationssettings.facade.php.

00107                                                                 {
00108                 // SELECT DISTINCT s.*
00109                 // FROM notificationssettings s
00110                 // INNER JOIN notifications n ON (n.id_user = s.id_user AND n.creationdate >= s.digest_last_sent)
00111                 // WHERE s.digest_enable = 'TRUE';
00112                 Load::models('notifications');
00113                 
00114                 $dao = new DAONotificationssettings();
00115                 $dao->digest_enable = true;
00116                 
00117                 $n = new DAONotifications();
00118                 $dao->join($n, array(
00119                         new DBJoinCondition($dao, 'id_user', $n, 'id_user'),
00120                         new DBWhere($dao, 'notifications.creationdate >= notificationssettings.digest_last_sent')                       
00121                 ));
00122                 
00123                 return $dao;
00124         }
static NotificationsSettings::get_for_user ( user_id  )  [static]

Get settings for user.

Returns:
DAONotificationssettings

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

00015                                                       {
00016                 return DB::get_item('notificationssettings', 'id_user', $user_id);
00017         }

Member Data Documentation

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

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

Definition at line 6 of file notificationssettings.facade.php.


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