当前位置: 首页>>代码示例>>PHP>>正文


PHP Subscriber::of方法代码示例

本文整理汇总了PHP中Subscriber::of方法的典型用法代码示例。如果您正苦于以下问题:PHP Subscriber::of方法的具体用法?PHP Subscriber::of怎么用?PHP Subscriber::of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Subscriber的用法示例。


在下文中一共展示了Subscriber::of方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dequeueNotify

 /**
  *  Dequeues notification queue and enqueues email queue
  *  Table codo_notify
  *  type           id data              is_read
  *  new_reply      1  {tid: 4, pid: 5}  0      --> depends on subscription
  *  new_topic      2  {tid: 4}          1      --> depends on subscription
  *  new_badge      2  {bid: 3}          0      --> system notification
  *  vote_up        2  {pid: 5}          1      --> depend on user settings
  *  new_like       1  {pid: 7}          1      --> depend on user settings
  *  mention        4  {pid: 3}          0      --> depends on subscription
  */
 public function dequeueNotify()
 {
     $qry = 'SELECT q.id,q.type,q.nid,t.data FROM ' . PREFIX . 'codo_notify_queue AS q' . ' INNER JOIN codo_notify_text AS t ON q.nid=t.id';
     $res = $this->db->query($qry);
     if (!$res) {
         return false;
     }
     $maxID = 0;
     $queue = $res->fetchAll();
     $subscriber = new Subscriber();
     $user = \CODOF\User\User::get();
     $frequency = $user->prefers('notification_frequency');
     foreach ($queue as $queuedNotification) {
         $maxID = max($queuedNotification['id'], $maxID);
         $type = $queuedNotification['type'];
         $nid = $queuedNotification['nid'];
         $data = json_decode($queuedNotification['data']);
         $mentions = $data->mentions;
         $cid = $data->cid;
         $tid = $data->tid;
         $pid = $data->pid;
         if (!empty($mentions)) {
             $mutedIds = $subscriber->mutedOf($type, $cid, $tid, $mentions);
             $notMuted = array_diff($mentions, $mutedIds);
             $this->notify($notMuted, 'mention', $nid);
         }
         $offset = 0;
         //get all types of subscribers of this category/topic
         while ($subscribers = $subscriber->of($type, $cid, $tid, $offset)) {
             //we do not need anyone subscribed to this topic since it
             //is a new topic and so the creator will be the first subscriber
             //segregate subscribers into different groups based on type
             $idTypes = $subscriber->groupBySubscriptionType($subscribers);
             //add notifications for FOLLOWING & NOTIFIED that a new topic is created
             $this->notify(array_merge($idTypes['FOLLOWING'], $idTypes['NOTIFIED']), $type, $nid);
             $offset += Subscriber::$maxRows;
         }
         //if ($frequency == 'immediate') {
         //queue all emails which will be sent in different cron run
         \CODOF\Hook::call('after_notify_insert', array("cid" => $cid, "tid" => $tid, "pid" => $pid, "type" => $type));
         //}
     }
     //delete old queued notifications
     $qry = 'DELETE FROM ' . PREFIX . 'codo_notify_queue WHERE id <= ' . $maxID;
     $this->db->query($qry);
 }
开发者ID:kertkulp,项目名称:php-ruhmatoo-projekt,代码行数:57,代码来源:Notifier.php


注:本文中的Subscriber::of方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。