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


PHP Subscriber::mutedOf方法代码示例

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


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

示例1: find

 /**
  * Get matched users with limit 10
  * @param string $qry
  * @return array
  */
 public function find($qry, $catid, $tid)
 {
     $cid = (int) $catid;
     $tid = (int) $tid;
     $selector = '';
     if ($cid) {
         $selector = ', MAX(p.granted) AS allowed';
     }
     $users = \DB::table(PREFIX . 'codo_users AS u');
     $users->select(\DB::raw('u.id, u.username, u.avatar' . $selector))->where('u.username', 'LIKE', "{$qry}%")->where('u.mail', '<>', 'anonymous@localhost');
     if ($cid) {
         $users->leftJoin(PREFIX . 'codo_user_roles AS r', 'r.uid', '=', 'u.id')->leftJoin(PREFIX . 'codo_permissions AS p', function ($join) use($cid) {
             $join->on('p.permission', '=', \DB::raw('\'view all topics\''))->on('p.rid', '=', 'r.rid')->on('p.cid', '=', \DB::raw($cid))->on('p.tid', '=', \DB::raw(0));
         })->groupBy('u.id');
     }
     $users = $users->take(10)->get();
     $type = '';
     if ($cid) {
         $type = 'new_topic';
     }
     if ($tid) {
         $type = 'new_reply';
     }
     $mutedIds = array();
     if ($type != '' && count($users)) {
         $uids = array_column($users, 'id');
         $subscriber = new Subscriber();
         $mutedIds = $subscriber->mutedOf($type, $cid, $tid, $uids);
     }
     $_users = array();
     $i = 0;
     foreach ($users as $user) {
         $_users[$i]["username"] = $user['username'];
         $_users[$i]["avatar"] = \CODOF\Util::get_avatar_path($user['avatar'], $user['id'], false);
         if ($cid) {
             //if $cid is not provided can't say whether user is mentionable or not
             $notMentionable = in_array($user['id'], $mutedIds) || $user['allowed'] === 0;
             $_users[$i]["mentionable"] = !$notMentionable ? 'yes' : 'no';
             //better for js -> y/n
         }
         $i++;
     }
     return $_users;
 }
开发者ID:kertkulp,项目名称:php-ruhmatoo-projekt,代码行数:49,代码来源:Mention.php

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