本文整理汇总了PHP中XenForo_Permission::hasContentPermission方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Permission::hasContentPermission方法的具体用法?PHP XenForo_Permission::hasContentPermission怎么用?PHP XenForo_Permission::hasContentPermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Permission
的用法示例。
在下文中一共展示了XenForo_Permission::hasContentPermission方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getVisibleReportsForUser
/**
* Gets the visible reports of this content type for the viewing user.
*
* @see XenForo_ReportHandler_Abstract:getVisibleReportsForUser()
*/
public function getVisibleReportsForUser(array $reports, array $viewingUser)
{
$reportsByForum = array();
foreach ($reports as $reportId => $report) {
$info = unserialize($report['content_info']);
$reportsByForum[$info['node_id']][] = $reportId;
}
/* @var $forumModel XenForo_Model_Forum */
$forumModel = XenForo_Model::create('XenForo_Model_Forum');
$forums = $forumModel->getForumsByIds(array_keys($reportsByForum), array('permissionCombinationId' => $viewingUser['permission_combination_id']));
$forums = $forumModel->unserializePermissionsInList($forums, 'node_permission_cache');
foreach ($reportsByForum as $forumId => $forumReports) {
$remove = false;
if (!isset($forums[$forumId])) {
$remove = true;
} else {
$forum = $forums[$forumId];
if (!XenForo_Permission::hasContentPermission($forum['permissions'], 'editAnyPost') && !XenForo_Permission::hasContentPermission($forum['permissions'], 'deleteAnyPost')) {
$remove = true;
}
}
if ($remove) {
foreach ($forumReports as $reportId) {
unset($reports[$reportId]);
}
}
}
return $reports;
}
示例2: getPermissionsFromContext
public function getPermissionsFromContext(array $context, array $parentContext = null)
{
if (isset($context['thread_id'])) {
$thread = $context;
$forum = $parentContext;
} else {
$thread = null;
$forum = $context;
}
if (!$forum || !isset($forum['node_id'])) {
throw new Exception("Context must be a thread and a forum or just a forum");
}
$visitor = XenForo_Visitor::getInstance();
// creating a new thread (all tags would be by us)
$nodePermissions = $visitor->getNodePermissions($forum['node_id']);
if ($thread) {
if ($thread['user_id'] == $visitor['user_id'] && XenForo_Permission::hasContentPermission($nodePermissions, 'manageOthersTagsOwnThread')) {
$removeOthers = true;
} else {
$removeOthers = XenForo_Permission::hasContentPermission($nodePermissions, 'manageAnyTag');
}
} else {
$removeOthers = false;
}
return array('edit' => $this->_getThreadModel()->canEditTags($thread, $forum), 'removeOthers' => $removeOthers, 'minTotal' => $forum['min_tags']);
}
示例3: getPushableDataForNode
/**
* Gets the effective data that can be pushed up to a parent node.
*
* @param array $node Current node info
* @param array $childPushable List of pushable data from all child nodes: [node id] => pushable data
* @param array $permissions Permissions for this node
*
* @return array List of pushable data (key-value pairs)
*/
public function getPushableDataForNode(array $node, array $childPushable, array $permissions)
{
if (!XenForo_Permission::hasContentPermission($permissions, 'viewOthers')) {
return $this->_compileForumLikePushableData(array('privateInfo' => true), $childPushable);
}
return $this->_getForumLikePushableData($node, $childPushable);
}
示例4: getVisibleModerationQueueEntriesForUser
/**
* Gets visible moderation queue entries for specified user.
*
* @see XenForo_ModerationQueueHandler_Abstract::getVisibleModerationQueueEntriesForUser()
*/
public function getVisibleModerationQueueEntriesForUser(array $contentIds, array $viewingUser)
{
/* @var $resourceModel XenResource_Model_Resource */
$resourceModel = XenForo_Model::create('XenResource_Model_Resource');
$resources = $resourceModel->getResourcesByIds($contentIds, array('join' => XenResource_Model_Resource::FETCH_DESCRIPTION));
$categories = XenForo_Model::create('XenResource_Model_Category')->getAllCategories(array('permissionCombinationId' => $viewingUser['permission_combination_id']));
$output = array();
foreach ($resources as $resource) {
if (!isset($categories[$resource['resource_category_id']])) {
continue;
}
$category = $categories[$resource['resource_category_id']];
$categoryPermissions = XenForo_Permission::unserializePermissions($category['category_permission_cache']);
$canManage = true;
if (!$resourceModel->canViewResourceAndContainer($resource, $category, $null, $viewingUser, $categoryPermissions)) {
$canManage = false;
} else {
if (!XenForo_Permission::hasContentPermission($categoryPermissions, 'editAny') || !XenForo_Permission::hasContentPermission($categoryPermissions, 'deleteAny') || !XenForo_Permission::hasContentPermission($categoryPermissions, 'approveUnapprove')) {
$canManage = false;
}
}
if ($canManage) {
$output[$resource['resource_id']] = array('message' => $resource['description'], 'user' => array('user_id' => $resource['user_id'], 'username' => $resource['username']), 'title' => $resource['title'], 'link' => XenForo_Link::buildPublicLink('resources', $resource), 'contentTypeTitle' => new XenForo_Phrase('resource'), 'titleEdit' => true);
}
}
return $output;
}
示例5: Tinhte_XenTag_getMaximumHashtags
public function Tinhte_XenTag_getMaximumHashtags(array $forum, array $nodePermissions = null, array $viewingUser = null)
{
if (!Tinhte_XenTag_Option::get('useHashtag')) {
return 0;
}
$this->standardizeViewingUserReferenceForNode($forum['node_id'], $viewingUser, $nodePermissions);
return XenForo_Permission::hasContentPermission($nodePermissions, 'Tinhte_XenTag_maximumHts');
}
示例6: _canMakeAnonymousPost
protected function _canMakeAnonymousPost($userId, $nodeId)
{
$userFetchOptions = array('join' => XenForo_Model_User::FETCH_USER_PERMISSIONS);
$user = $this->_getUserModel()->getUserById($userId, $userFetchOptions);
$user['permissions'] = @unserialize($user['global_permission_cache']);
$nodePermissions = $this->_getNodeModel()->getNodePermissionsForPermissionCombination($user['permission_combination_id']);
return XenForo_Permission::hasContentPermission($nodePermissions[$nodeId], 'postAnonymousReply');
}
示例7: canViewForum
public function canViewForum(array $forum, &$errorPhraseKey = '', array $nodePermissions = null, array $viewingUser = null)
{
$canView = parent::canViewForum($forum, $errorPhraseKey, $nodePermissions, $viewingUser);
if ($canView && isset($GLOBALS['BRETI_ExtraThreadItem'])) {
$this->standardizeViewingUserReferenceForNode($forum['node_id'], $viewingUser, $nodePermissions);
$canView = XenForo_Permission::hasContentPermission($nodePermissions, 'viewOthers');
}
return $canView;
}
示例8: canEnableDisableModerateRepliesInForum
/**
* Determines if a moderation of replies in a thread can be enabled or
* disabled in the specified forum with the given permissions.
*
* @param array $forum
* @param string $errorPhraseKey
* @param array|null $nodePermissions
* @param array|null $viewingUser
*
* @return boolean
*/
public function canEnableDisableModerateRepliesInForum(array $forum, &$errorPhraseKey = '', array $nodePermissions = null, array $viewingUser = null)
{
$this->standardizeViewingUserReferenceForNode($forum['node_id'], $viewingUser, $nodePermissions);
if (!$viewingUser['user_id']) {
return false;
}
if ($forum['moderate_replies']) {
return false;
}
return XenForo_Permission::hasContentPermission($nodePermissions, 'enableModerateReplies');
}
示例9: canWatchForum
/**
* Determines if the forum can be watched with the given permissions.
* This does not check forum viewing permissions.
*
* @param array $forum
* @param string $errorPhraseKey
* @param array|null $nodePermissions
* @param array|null $viewingUser
*
* @return boolean
*/
public function canWatchForum(array $forum, &$errorPhraseKey = '', array $nodePermissions = null, array $viewingUser = null)
{
$this->standardizeViewingUserReferenceForNode($forum['node_id'], $viewingUser, $nodePermissions);
if (!parent::canWatchForum($forum, $errorPhraseKey, $nodePermissions, $viewingUser)) {
return false;
}
if (!empty($forum['forum_is_watched'])) {
return true;
}
return XenForo_Permission::hasContentPermission($nodePermissions, 'watchForum');
}
示例10: canAddResource
public function canAddResource(array $category = null, &$errorPhraseKey = '', array $viewingUser = null, array $categoryPermissions = null)
{
$canAddResource = parent::canAddResource($category, $errorPhraseKey, $viewingUser, $categoryPermissions);
if ($category and !$canAddResource) {
if (!empty($category['bdpaygate_allow_commercial_local'])) {
$this->standardizeViewingUserReferenceForCategory($category, $viewingUser, $categoryPermissions);
if (XenForo_Permission::hasContentPermission($categoryPermissions, 'add')) {
$canAddResource = true;
}
}
}
return $canAddResource;
}
示例11: getPostInsertMessageState
public function getPostInsertMessageState(array $thread, array $forum, array $nodePermissions = null, array $viewingUser = null)
{
$this->standardizeViewingUserReferenceForNode($forum['node_id'], $viewingUser, $nodePermissions);
if ($viewingUser['user_id'] && XenForo_Permission::hasContentPermission($nodePermissions, 'approveUnapprove')) {
// do nothing
} elseif ($viewingUser['user_id'] && XenForo_Permission::hasContentPermission($nodePermissions, 'enableModerateReplies')) {
// do nothing
} elseif (XenForo_Permission::hasPermission($viewingUser['permissions'], 'general', 'followModerationRules')) {
if (!empty($thread['thread_id']) && $thread['moderate_replies_th']) {
return 'moderated';
}
}
return parent::getPostInsertMessageState($thread, $forum, $nodePermissions, $viewingUser);
}
示例12: save
public function save()
{
$response = parent::save();
if (!empty($this->_newData['xf_post']['thread_id']) && !empty($this->_newData['xf_post']['post_id'])) {
$options = XenForo_Application::get('options');
if ($options->dark_taigachat_activity != 'None') {
$visitor = XenForo_Visitor::getInstance();
$isThread = $this->_newData['xf_post']['position'] == 0;
/** @var XenForo_Model_Thread */
$threadModel = XenForo_Model::create("XenForo_Model_Thread");
$thread = $threadModel->getThreadById($this->_newData['xf_post']['thread_id']);
/** @var XenForo_Model_Node */
$nodeModel = XenForo_Model::create("XenForo_Model_Node");
$node = $nodeModel->getNodeById($thread['node_id']);
$ok = false;
// making the not-too-risky assumption that 1 will be guest group
$permissionCombinationId = 1;
if ($options->dark_taigachat_activity_userid > 0) {
/** @var XenForo_Model_User */
$userModel = XenForo_Model::create("XenForo_Model_User");
$activityUser = $userModel->getUserById($options->dark_taigachat_activity_userid);
$permissionCombinationId = $activityUser['permission_combination_id'];
}
$nodePermissions = $nodeModel->getNodePermissionsForPermissionCombination($permissionCombinationId);
foreach ($nodePermissions as $nodeId => $nodePermission) {
if ($nodeId == $node['node_id'] && XenForo_Permission::hasContentPermission($nodePermission, 'view') && XenForo_Permission::hasContentPermission($nodePermission, 'viewOthers')) {
$ok = true;
}
}
if ($ok) {
if ($isThread) {
$activityMessage = new XenForo_Phrase('dark_posted_new_thread_in_x_x', array('forum' => "[url='" . XenForo_Link::convertUriToAbsoluteUri(XenForo_Link::buildPublicLink("forums", $node), true) . "']" . $node['title'] . "[/url]", 'thread' => "[url='" . XenForo_Link::convertUriToAbsoluteUri(XenForo_Link::buildPublicLink("threads", $thread), true) . "']" . $thread['title'] . "[/url]"), false);
} else {
$activityMessage = new XenForo_Phrase('dark_replied_to_x', array('thread' => "[url='" . XenForo_Link::convertUriToAbsoluteUri(XenForo_Link::buildPublicLink("posts", $this->_newData['xf_post']), true) . "']" . $thread['title'] . "[/url]"), false);
}
if ($isThread || $options->dark_taigachat_activity == 'Both') {
$dw = XenForo_DataWriter::create('Dark_TaigaChat_DataWriter_Message');
$dw->setOption(Dark_TaigaChat_DataWriter_Message::OPTION_IS_AUTOMATED, true);
$dw->set('user_id', $visitor['user_id']);
$dw->set('username', $visitor['user_id'] > 0 ? $visitor['username'] : new XenForo_Phrase('guest'));
$dw->set('message', $activityMessage);
$dw->set('activity', 1);
$dw->save();
}
}
}
}
return $response;
}
示例13: getAttachmentConstraints
public function getAttachmentConstraints()
{
$constraints = parent::getAttachmentConstraints();
$visitor = XenForo_Visitor::getInstance();
if (SV_AttachmentImprovements_Globals::$nodePermissionsForAttachments) {
$nodePermissions = SV_AttachmentImprovements_Globals::$nodePermissionsForAttachments;
$size = XenForo_Permission::hasContentPermission($nodePermissions, 'attach_size');
if ($size > 0 && $size < $constraints['size']) {
$constraints['size'] = $size * 1024;
}
$count = XenForo_Permission::hasContentPermission($nodePermissions, 'attach_count');
if ($count > 0 && $count < $constraints['count']) {
$constraints['count'] = $count;
}
}
return $constraints;
}
示例14: canReplyToThread
public function canReplyToThread(array $thread, array $forum, &$errorPhraseKey = '', array $nodePermissions = null, array $viewingUser = null)
{
$canReplyToThread = parent::canReplyToThread($thread, $forum, $errorPhraseKey, $nodePermissions, $viewingUser);
if ($canReplyToThread and !empty($thread['discussion_type']) and $thread['discussion_type'] === 'resource') {
// check for resource permission
$resource = $this->_bdPaygate_getResourceByThreadId($thread['thread_id']);
if (!empty($resource) and $this->_bdPaygate_getResourceModel()->bdPaygate_mustPurchaseToDownload($resource, $viewingUser)) {
// this is a paid resource, check for discussion permission
$this->standardizeViewingUserReferenceForNode($thread['node_id'], $viewingUser, $nodePermissions);
if (XenForo_Permission::hasContentPermission($nodePermissions, 'bdPaygate_allThreads')) {
return true;
} elseif (!$this->_bdPaygate_getResourceModel()->canDownloadResource($resource, $resource, $null, $viewingUser)) {
return false;
}
}
}
return $canReplyToThread;
}
示例15: getVisibleModerationQueueEntriesForUser
/**
* Gets visible moderation queue entries for specified user.
*
* @see XenForo_ModerationQueueHandler_Abstract::getVisibleModerationQueueEntriesForUser()
*/
public function getVisibleModerationQueueEntriesForUser(array $contentIds, array $viewingUser)
{
$socialForumModel = ThemeHouse_SocialGroups_SocialForum::getSocialForumModel();
$socialForums = $socialForumModel->getSocialForumsByIds($contentIds, array('join' => ThemeHouse_SocialGroups_Model_SocialForum::FETCH_FORUM | ThemeHouse_SocialGroups_Model_SocialForum::FETCH_USER, 'permissionCombinationId' => $viewingUser['permission_combination_id']));
$output = array();
foreach ($socialForums as $socialForum) {
$socialForum['permissions'] = XenForo_Permission::unserializePermissions($socialForum['node_permission_cache']);
$canManage = true;
if (!$socialForumModel->canViewSocialForum($socialForum, $null, $socialForum['permissions'], $viewingUser)) {
$canManage = false;
} elseif (!XenForo_Permission::hasContentPermission($socialForum['permissions'], 'editSocialForum') || !XenForo_Permission::hasContentPermission($socialForum['permissions'], 'deleteSocialForum')) {
$canManage = false;
}
if ($canManage) {
$output[$socialForum['social_forum_id']] = array('message' => $socialForum['description'], 'user' => array('user_id' => $socialForum['user_id'], 'username' => $socialForum['username']), 'title' => $socialForum['title'], 'link' => XenForo_Link::buildPublicLink('social-forums', $socialForum), 'contentTypeTitle' => new XenForo_Phrase('th_social_forum_socialgroups'), 'titleEdit' => true);
}
}
return $output;
}