本文整理汇总了PHP中DiscussHelper::isSiteAdmin方法的典型用法代码示例。如果您正苦于以下问题:PHP DiscussHelper::isSiteAdmin方法的具体用法?PHP DiscussHelper::isSiteAdmin怎么用?PHP DiscussHelper::isSiteAdmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiscussHelper
的用法示例。
在下文中一共展示了DiscussHelper::isSiteAdmin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(DiscussPost $post, DiscussCategory $category)
{
$this->my = JFactory::getUser();
$this->config = DiscussHelper::getConfig();
// Creator of the post
$this->creator = DiscussHelper::getTable('Profile');
$this->creator->load($post->user_id);
$this->post = $post;
$this->parent = null;
if (!empty($this->post->parent_id)) {
// we now this item is a reply. let get the parent;
$parentPost = DiscussHelper::getTable('Post');
$parentPost->load($this->post->parent_id);
$this->parent = $parentPost;
}
$this->isSiteAdmin = DiscussHelper::isSiteAdmin();
$this->category = $category;
$this->acl = DiscussHelper::getHelper('ACL');
$this->isModerator = DiscussHelper::getHelper('Moderator')->isModerator($this->post->category_id);
}
示例2: isAdmin
/**
* Determines if the user is an admin on the site.
*
* @since 3.0
* @access public
*/
public function isAdmin()
{
return DiscussHelper::isSiteAdmin($this->id);
}
示例3: edit
public function edit($tpl = null)
{
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$my = JFactory::getUser();
$acl = DiscussHelper::getHelper('ACL');
$config = DiscussHelper::getConfig();
// Load post item
$id = JRequest::getInt('id', 0);
if (empty($id)) {
DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_POST_ID'));
return;
}
$post = DiscussHelper::getTable('Post');
$post->load($id);
$post->content_raw = $post->content;
$editing = (bool) $post->id;
if (!$editing) {
// try to get from session if there are any.
$this->getSessionData($post);
}
$categoryId = JRequest::getInt('category', $post->category_id);
// Load category item.
$category = DiscussHelper::getTable('Category');
$category->load($categoryId);
// Check if user is allowed to post a discussion, we also need to check against the category acl
if (empty($my->id) && !$acl->allowed('add_question', 0)) {
DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_PLEASE_KINDLY_LOGIN_TO_CREATE_A_POST'));
$app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index', false));
$app->close();
return;
}
if ($my->id != 0 && !$acl->allowed('add_question', '0') && !$category->canPost()) {
$app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index', false), JText::_('COM_EASYDISCUSS_SYSTEM_INSUFFICIENT_PERMISSIONS'));
$app->close();
return;
}
// Set the breadcrumbs.
$this->setPathway(JText::_('COM_EASYDISCUSS_BREADCRUMBS_ASK'));
// Set the page title.
$title = JText::_('COM_EASYDISCUSS_TITLE_ASK');
if ($id && $post->id) {
$title = JText::sprintf('COM_EASYDISCUSS_TITLE_EDIT_QUESTION', $post->getTitle());
}
// Set the page title
DiscussHelper::setPageTitle($title);
if ($editing) {
$isModerator = DiscussHelper::getHelper('Moderator')->isModerator($post->category_id);
if (!DiscussHelper::isMine($post->user_id) && !DiscussHelper::isSiteAdmin() && !$acl->allowed('edit_question') && !$isModerator) {
$app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=post&id=' . $postid, false), JText::_('COM_EASYDISCUSS_SYSTEM_INSUFFICIENT_PERMISSIONS'));
$app->close();
}
$tagsModel = DiscussHelper::getModel('PostsTags');
$post->tags = $tagsModel->getPostTags($post->id);
} else {
if ($categoryId) {
// set the default category
$post->category_id = $categoryId;
}
}
$attachments = $post->getAttachments();
if (isset($post->sessiondata)) {
$attachments = '';
}
$model = DiscussHelper::getModel('Posts');
$postCount = count($model->getPostsBy('user', $my->id));
$onlyPublished = empty($post->id) ? true : false;
// @rule: If there is a category id passed through the query, respect it first.
$showPrivateCat = empty($post->id) && $my->id == 0 ? false : true;
// [model:category]
$categoryModel = $this->getModel('Category');
$defaultCategory = $categoryModel->getDefaultCategory();
if ($categoryId == 0 && $defaultCategory !== false) {
$categoryId = $defaultCategory->id;
}
$nestedCategories = '';
$categories = '';
if ($config->get('layout_category_selection') == 'multitier') {
$categoriesModel = $this->getModel('Categories');
$categories = $categoriesModel->getCategories(array('acl_type' => DISCUSS_CATEGORY_ACL_ACTION_SELECT));
} else {
$nestedCategories = DiscussHelper::populateCategories('', '', 'select', 'category_id', $categoryId, true, $onlyPublished, $showPrivateCat, true);
}
if ($config->get('layout_reply_editor') == 'bbcode') {
// Legacy fix when switching from WYSIWYG editor to bbcode.
$post->content = EasyDiscussParser::html2bbcode($post->content);
}
$editor = '';
if ($config->get('layout_editor') != 'bbcode') {
$editor = JFactory::getEditor($config->get('layout_editor'));
}
// Get list of moderators from the site.
$moderatorList = array();
if ($config->get('main_assign_user')) {
$moderatorList = DiscussHelper::getHelper('Moderator')->getSelectOptions($post->category_id);
}
$composer = new DiscussComposer("editing", $post);
// Set the discussion object.
$access = $post->getAccess($category);
$theme = new DiscussThemes();
//.........这里部分代码省略.........
示例4: defined
<?php
/**
* @package EasyDiscuss
* @copyright Copyright (C) 2010 Stack Ideas Private Limited. All rights reserved.
* @license GNU/GPL, see LICENSE.php
*
* EasyDiscuss is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
defined('_JEXEC') or die('Restricted access');
if ((!$system->config->get('attachment_questions') || !$acl->allowed('add_attachment', '0')) && !DiscussHelper::isSiteAdmin()) {
return;
}
$app = JFactory::getApplication();
$config = DiscussHelper::getConfig();
$attachments = $post ? $post->getAttachments() : null;
$hasAttachments = !empty($attachments);
$hasAttachmentLimit = $config->get('enable_attachment_limit');
$attachmentLimit = $config->get('attachment_limit');
$attachmentLimitExceeded = $hasAttachmentLimit && count($attachments) >= $attachmentLimit && $attachmentLimit != 0;
?>
<script type="text/javascript">
EasyDiscuss.require()
.script('attachments')
.done(function($){
示例5:
<a class="butt butt-default" href="<?php
echo DiscussRouter::_('index.php?option=com_easydiscuss&view=profile&layout=edit');
?>
">
<i class="i i-pencil muted"></i>
<?php
echo JText::_('COM_EASYDISCUSS_USER_EDIT_PROFILE');
?>
</a>
<?php
}
?>
<?php
if ($system->my->id != $profile->id && DiscussHelper::isSiteAdmin($system->my->id)) {
?>
<a class="butt butt-default" href="<?php
echo DiscussRouter::_('index.php?option=com_easydiscuss&controller=profile&task=disableUser&id=' . $profile->id);
?>
">
<i class="i i-minus muted"></i>
<?php
echo JText::_('COM_EASYDISCUSS_DISABLE_USER');
?>
</a>
<?php
}
?>
</header>
示例6: deleteable
public function deleteable()
{
$config = DiscussHelper::getConfig();
$storage = DISCUSS_MEDIA . '/' . rtrim($config->get('attachment_path'), '/');
$file = $storage . '/' . $this->path;
// @rule: Test for file existance
if (!JFile::exists($file)) {
return false;
}
$acl = DiscussHelper::getHelper('ACL');
$postHelper = DiscussHelper::getHelper('Post');
$my = JFactory::getUser();
$deleteOwn = $my->id == $postHelper->getAttachmentOwner($this->id);
$postId = $postHelper->getAttachmentPostId($this->id);
$post = DiscussHelper::getTable('Post');
$post->load($postId);
$isModerator = DiscussHelper::getHelper('Moderator')->isModerator($post->category_id);
// @rule: Test if the user is allowed to delete attachments.
// if( $my->id &&
// ( DiscussHelper::isSiteAdmin()
// || $acl->allowed( 'delete_attachment')
// || $deleteOwn
// || $isModerator
// )
// )
// {
// return true;
// }
if ($my->id && ($acl->allowed('delete_attachment') && $deleteOwn) || DiscussHelper::isSiteAdmin() || $isModerator) {
return true;
}
return false;
}
示例7: ajaxReadmoreReplies
function ajaxReadmoreReplies($limitstart = null, $sorting = null, $type = 'questions', $parentId = null, $filter = null, $category = null)
{
$ajax = new Disjax();
$model = $this->getModel('Posts');
$limitstart = (int) $limitstart;
$mainframe = JFactory::getApplication();
$config = DiscussHelper::getConfig();
$posts = $model->getReplies($parentId, $sorting, $limitstart);
$pagination = $model->getPagination($parentId, $sorting);
$my = JFactory::getUser();
$posts = DiscussHelper::formatPost($posts);
$parent = DiscussHelper::getTable('Post');
$parent->load($parentId);
//check all the 'can' or 'canot' here.
$acl = DiscussHelper::getHelper('ACL');
$isMainLocked = $parent->islock ? true : false;
$canDelete = false;
$canTag = false;
$canReply = $acl->allowed('add_reply', '0');
if ($config->get('main_allowdelete', 2) == 2) {
$canDelete = $isSiteAdmin ? true : false;
} else {
if ($config->get('main_allowdelete', 2) == 1) {
$canDelete = $acl->allowed('delete_reply', '0');
}
}
$category = DiscussHelper::getTable('Category');
$category->load($category);
$posts = DiscussHelper::formatReplies($posts, $category);
$template = new DiscussThemes();
$template->set('replies', $posts);
$template->set('config', $config);
$template->set('canReply', $canReply);
$template->set('canDelete', $canDelete);
$template->set('isMainLocked', $isMainLocked);
//$template->set( 'isMine' , false );
//$template->set( 'isAdmin' , false );
$template->set('isMine', DiscussHelper::isMine($parent->user_id));
$template->set('isAdmin', DiscussHelper::isSiteAdmin());
$html = $template->fetch('reply.item.php');
$nextLimit = $limitstart + DiscussHelper::getListLimit();
if ($nextLimit >= $pagination->total) {
$ajax->remove('dc_pagination a');
}
$ajax->value('pagination-start', $nextLimit);
$ajax->script('EasyDiscuss.$("#dc_response").children().children( ":last").addClass( "separator" );');
$ajax->append('dc_response tbody', $html);
$ajax->send();
}
示例8: ajaxNoStatusPost
public function ajaxNoStatusPost($id = null)
{
$ajax = new Disjax();
$config = DiscussHelper::getConfig();
if (!$id) {
$ajax->assign('dc_main_notifications', JText::_('COM_EASYDISCUSS_SYSTEM_INVALID_ID'));
$ajax->script('EasyDiscuss.$( "#dc_main_notifications" ).addClass( "alert alert-error" );');
$ajax->send();
return;
}
$post = DiscussHelper::getTable('Post');
$post->load($id);
$isMine = DiscussHelper::isMine($post->user_id);
$isAdmin = DiscussHelper::isSiteAdmin();
$acl = DiscussHelper::getHelper('ACL');
$isModerator = DiscussHelper::getHelper('Moderator')->isModerator($post->category_id);
if (!$isMine && !$isAdmin && !$acl->allowed('mark_no_status', '0')) {
if (!$isModerator) {
$ajax->assign('dc_main_notifications', JText::_('COM_EASYDISCUSS_SYSTEM_INSUFFICIENT_PERMISSIONS'));
$ajax->script('EasyDiscuss.$( "#dc_main_notifications" ).addClass( "alert alert-error" );');
$ajax->send();
return;
}
}
// Turn on the on-hold status,
// DISCUSS_POST_STATUS_OFF = 0
$post->post_status = DISCUSS_POST_STATUS_OFF;
if (!$post->store()) {
$ajax->assign('dc_main_notifications', $post->getError());
$ajax->script('EasyDiscuss.$( "#dc_main_notifications" ).addClass( "alert alert-error" );');
$ajax->send();
return;
}
// @rule: Add notifications for the thread starter
$my = JFactory::getUser();
if ($post->get('user_id') != $my->id) {
$notification = DiscussHelper::getTable('Notifications');
$notification->bind(array('title' => JText::sprintf('COM_EASYDISCUSS_NO_STATUS_DISCUSSION_NOTIFICATION_TITLE', $post->title), 'cid' => $post->get('id'), 'type' => 'unhold', 'target' => $post->get('user_id'), 'author' => $my->id, 'permalink' => 'index.php?option=com_easydiscuss&view=post&id=' . $post->get('id')));
$notification->store();
}
// Remove other status
$ajax->script('EasyDiscuss.$( ".discuss-item" ).removeClass( "is-resolved" );');
$ajax->script('EasyDiscuss.$( ".postStatus" ).removeClass( "label-post_status" );');
$ajax->script('EasyDiscuss.$( ".postStatus" ).removeClass( "label-post_status-on-hold" );');
$ajax->script('EasyDiscuss.$( ".postStatus" ).removeClass( "label-post_status-accept" );');
$ajax->script('EasyDiscuss.$( ".postStatus" ).removeClass( "label-post_status-working-on" );');
$ajax->script('EasyDiscuss.$( ".postStatus" ).removeClass( "label-post_status-reject" );');
$ajax->assign('dc_main_notifications', JText::_('COM_EASYDISCUSS_POST_NO_STATUS'));
$ajax->script('EasyDiscuss.$( "#dc_main_notifications" ).addClass( "alert alert-success" );');
$ajax->script('EasyDiscuss.$( ".postStatus" ).html("");');
$ajax->send();
return;
}
示例9: canDelete
public function canDelete($pk = null, $joins = null)
{
$aclHelper = DiscussHelper::getHelper('ACL');
$canDelete = DiscussHelper::isSiteAdmin() || $aclHelper->allowed('delete_comment') || $aclHelper->isOwner($this->user_id);
return $canDelete;
}
示例10: canPost
/**
* Determines if the user can start a new discussion in this category.
*
* @since 3.0
* @access public
*/
public function canPost()
{
static $canPost = null;
// Admin is always allowed
if (DiscussHelper::isSiteAdmin()) {
return true;
}
if ($this->private == DISCUSS_PRIVACY_PUBLIC) {
return true;
}
if (!isset($canPost[$this->id])) {
$my = JFactory::getUser();
$config = DiscussHelper::getConfig();
$allowed = false;
// If this is a private category, we need to do additional checks here.
$excludeCats = DiscussHelper::getPrivateCategories(DISCUSS_CATEGORY_ACL_ACTION_SELECT);
if (in_array($this->id, $excludeCats)) {
$allowed = false;
} else {
$allowed = true;
}
$canPost[$this->id] = $allowed;
}
return $canPost[$this->id];
}
示例11: isModerator
public static function isModerator($categoryId = null, $userId = null)
{
static $result = array();
if (!$userId) {
$userId = JFactory::getUser()->id;
}
// If user id is 0, we know for sure they are not a moderator.
if (!$userId) {
return false;
}
// Site admin is always a moderator.
if (DiscussHelper::isSiteAdmin($userId)) {
return true;
}
// If category is not supplied, caller might just want to check if
// the user is a moderator of any category.
if (is_null($categoryId)) {
if (isset($result['isModerator'])) {
return $result['isModerator'];
}
$db = DiscussHelper::getDBO();
// Get the user's groups first.
$gids = DiscussHelper::getUserGids($userId);
// Now, check if the current user has any assignments to this acl id or not.
$query = array();
$query[] = 'SELECT COUNT(1) FROM ' . $db->nameQuote('#__discuss_category_acl_map');
$query[] = 'WHERE ' . $db->nameQuote('acl_id') . ' = ' . $db->Quote(DISCUSS_CATEGORY_ACL_MODERATOR);
if ($userId) {
$query[] = 'AND (';
if ($gids) {
$query[] = $db->nameQuote('type') . '=' . $db->Quote('group');
$query[] = 'AND ' . $db->nameQuote('content_id') . ' IN(';
for ($i = 0; $i < count($gids); $i++) {
$query[] = $db->Quote($gids[$i]);
if (next($gids) !== false) {
$query[] = ',';
}
}
$query[] = ')';
}
$query[] = ')';
$query[] = 'OR';
$query[] = '(' . $db->nameQuote('type') . ' = ' . $db->Quote('user');
$query[] = 'AND ' . $db->nameQuote('content_id') . '=' . $db->Quote($userId);
$query[] = ')';
}
$query = implode(' ', $query);
$db->setQuery($query);
$count = $db->loadResult();
$isModerator = $count > 0;
$result['isModerator'] = $isModerator;
return $result['isModerator'];
}
if (!array_key_exists('groupId', $result)) {
$table = DiscussHelper::getTable('Category');
$table->load($categoryId);
$result[$categoryId] = $table->getModerators();
}
$isModerator = in_array($userId, $result[$categoryId]);
return $isModerator;
}
示例12: defined
* @package EasyDiscuss
* @copyright Copyright (C) 2010 Stack Ideas Private Limited. All rights reserved.
* @license GNU/GPL, see LICENSE.php
*
* EasyDiscuss is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
defined('_JEXEC') or die('Restricted access');
// Get current logged in user id
$my = JFactory::getUser();
// Get current question post owner user id
$questionOwner = $question->getOwner()->id;
if ($reply->access->canMarkAnswered() && !$question->islock && $my->id == $questionOwner || DiscussHelper::isSiteAdmin()) {
?>
<?php
if (!$question->isresolve && $reply->access->canMarkAnswered()) {
?>
<div class="discuss-accept-answer">
<span id="accept-button-<?php
echo $reply->id;
?>
">
<a href="javascript:void(0);" onclick="discuss.reply.accept('<?php
echo $reply->id;
?>
');" class=" discuss-accept btn btn-small">
<?php
echo JText::_('COM_EASYDISCUSS_REPLY_ACCEPT');
示例13: saveReply
//.........这里部分代码省略.........
}
if (!empty($postTable->id)) {
//Clear off previous records before storing
$ruleModel = DiscussHelper::getModel('CustomFields');
$ruleModel->deleteCustomFieldsValue($postTable->id, 'update');
// Process custom fields.
$fieldIds = JRequest::getVar('customFields');
if (!empty($fieldIds)) {
foreach ($fieldIds as $fieldId) {
$fields = JRequest::getVar('customFieldValue_' . $fieldId);
if (!empty($fields)) {
// Cater for custom fields select list
// To detect if there is no value selected for the select list custom fields
if (in_array('defaultList', $fields)) {
$tempKey = array_search('defaultList', $fields);
$fields[$tempKey] = '';
}
}
$postTable->bindCustomFields($fields, $fieldId);
}
}
}
// @trigger: onAfterSave
DiscussEventsHelper::onContentAfterSave('post', $postTable, $isNew);
//get parent post
$parentId = $postTable->parent_id;
$parentTable = DiscussHelper::getTable('Post');
$parentTable->load($parentId);
// filtering badwords
$postTable->title = DiscussHelper::wordFilter($postTable->title);
$postTable->content = DiscussHelper::wordFilter($postTable->content);
//all access control goes here.
$canDelete = false;
if (DiscussHelper::isSiteAdmin() || $acl->allowed('delete_reply', '0') || $postTable->user_id == $user->id) {
$canDelete = true;
}
// @rule: URL References
$postTable->references = $postTable->getReferences();
// set for vote status
$voteModel = DiscussHelper::getModel('Votes');
$postTable->voted = $voteModel->hasVoted($postTable->id);
// get total vote for this reply
$postTable->totalVote = $postTable->sum_totalvote;
//load porfile info and auto save into table if user is not already exist in discuss's user table.
$creator = DiscussHelper::getTable('Profile');
$creator->load($postTable->user_id);
$postTable->user = $creator;
//default value
$postTable->isVoted = 0;
$postTable->total_vote_cnt = 0;
$postTable->likesAuthor = '';
$postTable->minimize = 0;
if ($config->get('main_content_trigger_replies')) {
// process content plugins
DiscussEventsHelper::importPlugin('content');
DiscussEventsHelper::onContentPrepare('reply', $postTable);
$postTable->event = new stdClass();
$results = DiscussEventsHelper::onContentBeforeDisplay('reply', $postTable);
$postTable->event->beforeDisplayContent = trim(implode("\n", $results));
$results = DiscussEventsHelper::onContentAfterDisplay('reply', $postTable);
$postTable->event->afterDisplayContent = trim(implode("\n", $results));
}
$theme = new DiscussThemes();
$question = DiscussHelper::getTable('Post');
$question->load($postTable->parent_id);
$recaptcha = '';
示例14:
echo $post->id;
?>
', 'reply' , '' );" class="btn btn-mini">
<?php
}
?>
<i class="icon-remove"></i> <?php
echo JText::_('COM_EASYDISCUSS_ENTRY_DELETE');
?>
</a>
<?php
}
?>
<?php
if ($access->canResolve() && $post->isQuestion() && !DiscussHelper::isSiteAdmin($my->id) && !DiscussHelper::isModerator($post->category_id, $my->id) && DiscussHelper::isMine($my->id)) {
?>
<a class="admin-unresolve btn btn-mini" href="javascript:void(0);" onclick="discuss.post.unresolve('<?php
echo $post->id;
?>
');">
<i class="icon-remove-sign"></i> <?php
echo JText::_('COM_EASYDISCUSS_ENTRY_MARK_UNRESOLVED');
?>
</a>
<a class="admin-resolve btn btn-mini" href="javascript:void(0);" onclick="discuss.post.resolve('<?php
echo $post->id;
?>
');">
<i class="icon-ok-sign"></i> <?php
示例15: disableUser
public function disableUser()
{
// Only allow site admin to disable this.
if (!DiscussHelper::isSiteAdmin()) {
return $this->setRedirect(DiscussRouter::_('index.php?option=com_easydiscuss', false));
}
$userId = JRequest::getInt('id');
$db = DiscussHelper::getDBO();
$query = 'UPDATE ' . $db->nameQuote('#__users') . ' SET ' . $db->nameQuote('block') . '=' . $db->quote(1) . ' WHERE ' . $db->nameQuote('id') . '=' . $db->quote($userId);
$db->setQuery($query);
$result = $db->query();
if (!$result) {
return $this->setRedirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=profile&id=' . $userId, false));
}
$message = JText::_('COM_EASYDISCUSS_USER_DISABLED');
DiscussHelper::setMessageQueue($message, DISCUSS_QUEUE_SUCCESS);
$this->setRedirect(DiscussRouter::_('index.php?option=com_easydiscuss', false));
}