canView() публичный Метод

Tests whether a user has permission to view a specific discussion.
public canView ( object | array | integer $discussion, integer $userID ) : boolean
$discussion object | array | integer The discussion ID or the discussion to test.
$userID integer The ID of the user to test permission for. If empty, it defaults to Session user.
Результат boolean Whether the user can view the discussion.
Пример #1
0
 /**
  * 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);
     }
 }