コード例 #1
0
ファイル: QvitterPlugin.php プロジェクト: allmende/qvitter
 /**
  * Add unread notification count to all API responses, when logged in
  *
  * @return boolean hook flag
  */
 public function onEndSetApiUser($user)
 {
     if (!$user instanceof User) {
         return true;
     }
     $user_id = $user->id;
     $notification = new QvitterNotification();
     $notification->selectAdd();
     $notification->selectAdd('ntype');
     $notification->selectAdd('count(id) as count');
     $notification->whereAdd("(to_profile_id = '" . $user_id . "')");
     $notification->groupBy('ntype');
     $notification->whereAdd("(is_seen = '0')");
     $notification->whereAdd("(notice_id IS NOT NULL)");
     // sometimes notice_id is NULL, those notifications are corrupt and should be discarded
     $notification->find();
     $new_notifications = array();
     while ($notification->fetch()) {
         $new_notifications[$notification->ntype] = $notification->count;
     }
     header('Qvitter-Notifications: ' . json_encode($new_notifications));
     return true;
 }
コード例 #2
0
ファイル: QvitterPlugin.php プロジェクト: GreenLunar/qvitter
 /**
  * Add unread notification count to all API responses, when logged in
  *
  * @return boolean hook flag
  */
 public function onEndSetApiUser($user)
 {
     // cleanup sessions, to allow for simultaneous http-requests,
     // e.g. if posting a notice takes a very long time
     Session::cleanup();
     if (!$user instanceof User) {
         return true;
     }
     $user_id = $user->id;
     $notification = new QvitterNotification();
     $notification->selectAdd();
     $notification->selectAdd('ntype');
     $notification->selectAdd('count(id) as count');
     $notification->whereAdd("(to_profile_id = '" . $user_id . "')");
     // the user might have opted out from certain notification types
     $current_profile = $user->getProfile();
     $disable_notify_replies_and_mentions = Profile_prefs::getConfigData($current_profile, 'qvitter', 'disable_notify_replies_and_mentions');
     $disable_notify_favs = Profile_prefs::getConfigData($current_profile, 'qvitter', 'disable_notify_favs');
     $disable_notify_repeats = Profile_prefs::getConfigData($current_profile, 'qvitter', 'disable_notify_repeats');
     $disable_notify_follows = Profile_prefs::getConfigData($current_profile, 'qvitter', 'disable_notify_follows');
     if ($disable_notify_replies_and_mentions == '1') {
         $notification->whereAdd('qvitternotification.ntype != "mention"');
         $notification->whereAdd('qvitternotification.ntype != "reply"');
     }
     if ($disable_notify_favs == '1') {
         $notification->whereAdd('qvitternotification.ntype != "like"');
     }
     if ($disable_notify_repeats == '1') {
         $notification->whereAdd('qvitternotification.ntype != "repeat"');
     }
     if ($disable_notify_follows == '1') {
         $notification->whereAdd('qvitternotification.ntype != "follow"');
     }
     $notification->groupBy('ntype');
     $notification->whereAdd("(is_seen = '0')");
     $notification->whereAdd("(notice_id IS NOT NULL)");
     // sometimes notice_id is NULL, those notifications are corrupt and should be discarded
     $notification->find();
     $new_notifications = array();
     while ($notification->fetch()) {
         $new_notifications[$notification->ntype] = $notification->count;
     }
     header('Qvitter-Notifications: ' . json_encode($new_notifications));
     return true;
 }
コード例 #3
0
ファイル: QvitterPlugin.php プロジェクト: singpolyma/qvitter
 /**
  * Add unread notification count to all API responses, when logged in
  *
  * @return boolean hook flag
  */
 public function onEndSetApiUser($user)
 {
     // cleanup sessions, to allow for simultaneous http-requests,
     // e.g. if posting a notice takes a very long time
     Session::cleanup();
     if (!$user instanceof User) {
         return true;
     }
     $user_id = $user->id;
     $notification = new QvitterNotification();
     $notification->selectAdd();
     $notification->selectAdd('ntype');
     $notification->selectAdd('count(id) as count');
     $notification->whereAdd("(to_profile_id = '" . $user_id . "')");
     $notification->groupBy('ntype');
     $notification->whereAdd("(is_seen = '0')");
     $notification->whereAdd("(notice_id IS NOT NULL)");
     // sometimes notice_id is NULL, those notifications are corrupt and should be discarded
     $notification->find();
     $new_notifications = array();
     while ($notification->fetch()) {
         $new_notifications[$notification->ntype] = $notification->count;
     }
     header('Qvitter-Notifications: ' . json_encode($new_notifications));
     return true;
 }