本文整理汇总了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);
}
}