當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DiscussionModel::canView方法代碼示例

本文整理匯總了PHP中DiscussionModel::canView方法的典型用法代碼示例。如果您正苦於以下問題:PHP DiscussionModel::canView方法的具體用法?PHP DiscussionModel::canView怎麽用?PHP DiscussionModel::canView使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DiscussionModel的用法示例。


在下文中一共展示了DiscussionModel::canView方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: recordAdvancedNotications

 /**
  * Record advanced notifications for users.
  *
  * @param ActivityModel $ActivityModel
  * @param array $Activity
  * @param array $Discussion
  * @param array $NotifiedUsers
  */
 public function recordAdvancedNotications($ActivityModel, $Activity, $Discussion)
 {
     if (is_numeric($Discussion)) {
         $Discussion = $this->getID($Discussion);
     }
     $CategoryID = val('CategoryID', $Discussion);
     // Figure out the category that governs this notification preference.
     $i = 0;
     $Category = CategoryModel::categories($CategoryID);
     if (!$Category) {
         return;
     }
     while ($Category['Depth'] > 2 && $i < 20) {
         if (!$Category || $Category['Archived']) {
             return;
         }
         $i++;
         $Category = CategoryModel::categories($Category['ParentCategoryID']);
     }
     // Grab all of the users that need to be notified.
     $Data = $this->SQL->whereIn('Name', array('Preferences.Email.NewComment.' . $Category['CategoryID'], 'Preferences.Popup.NewComment.' . $Category['CategoryID']))->get('UserMeta')->resultArray();
     $NotifyUsers = array();
     foreach ($Data as $Row) {
         if (!$Row['Value']) {
             continue;
         }
         $UserID = $Row['UserID'];
         // Check user can still see the discussion.
         $discussionModel = new DiscussionModel();
         if (!$discussionModel->canView($Discussion, $UserID)) {
             continue;
         }
         $Name = $Row['Name'];
         if (strpos($Name, '.Email.') !== false) {
             $NotifyUsers[$UserID]['Emailed'] = ActivityModel::SENT_PENDING;
         } elseif (strpos($Name, '.Popup.') !== false) {
             $NotifyUsers[$UserID]['Notified'] = ActivityModel::SENT_PENDING;
         }
     }
     foreach ($NotifyUsers as $UserID => $Prefs) {
         $Activity['NotifyUserID'] = $UserID;
         $Activity['Emailed'] = val('Emailed', $Prefs, false);
         $Activity['Notified'] = val('Notified', $Prefs, false);
         $ActivityModel->Queue($Activity);
     }
 }
開發者ID:vanilla,項目名稱:vanilla,代碼行數:54,代碼來源:class.commentmodel.php


注:本文中的DiscussionModel::canView方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。