示例#1
0
 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
0
 /**
  * Determines if the user is an admin on the site.
  *
  * @since	3.0
  * @access	public
  */
 public function isAdmin()
 {
     return DiscussHelper::isSiteAdmin($this->id);
 }
示例#3
0
 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();
     // Test if reference is passed in query string.
     $reference = JRequest::getWord('reference');
     $referenceId = JRequest::getInt('reference_id', 0);
     $redirect = JRequest::getVar('redirect', '');
     $theme->set('redirect', $redirect);
     $theme->set('reference', $reference);
     $theme->set('referenceId', $referenceId);
     $theme->set('isEditMode', $editing);
     $theme->set('post', $post);
     $theme->set('composer', $composer);
     $theme->set('parent', $composer->parent);
     $theme->set('nestedCategories', $nestedCategories);
     $theme->set('attachments', $attachments);
     $theme->set('editor', $editor);
     $theme->set('moderatorList', $moderatorList);
     $theme->set('categories', $categories);
     $theme->set('access', $access);
     // Deprecated since 3.0. Will be removed in 4.0
     $theme->set('config', $config);
     echo $theme->fetch('form.reply.wysiwyg.php');
 }
<?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
0
			<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>
				&nbsp;
				<?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>
				&nbsp;
				<?php 
    echo JText::_('COM_EASYDISCUSS_DISABLE_USER');
    ?>
			</a>
			<?php 
}
?>
		</header>
示例#6
0
 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
0
 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
0
 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
0
 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
0
 /**
  * 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
0
 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
0
 * @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
0
 /**
  * Saves an edited reply if the site is configured to use a WYSIWYG editor
  *
  * @since	3.2
  * @access	public
  * @param	string
  * @return	
  */
 public function saveReply()
 {
     //JRequest::checkToken('request') or jexit( 'Invalid Token' );
     $config = DiscussHelper::getConfig();
     $acl = DiscussHelper::getHelper('ACL');
     $my = JFactory::getUser();
     $app = JFactory::getApplication();
     $post = JRequest::get('POST');
     $output = array();
     $output['id'] = $post['post_id'];
     $postTable = DiscussHelper::getTable('Post');
     $postTable->load($post['post_id']);
     $categoryTable = DiscussHelper::getTable('category');
     $categoryTable->load($postTable->category_id);
     $postAccess = DiscussHelper::getPostAccess($postTable, $categoryTable);
     if (!$postAccess->canEdit()) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_SYSTEM_INSUFFICIENT_PERMISSIONS'), DISCUSS_QUEUE_ERROR);
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=ask&id=' . $post['post_id'], false));
         return $app->close();
     }
     // do checking here!
     if (empty($post['dc_reply_content'])) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_ERROR_REPLY_EMPTY'), DISCUSS_QUEUE_ERROR);
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=ask&id=' . $post['post_id'], false));
         return $app->close();
     }
     // Rebind the post data
     $post['dc_reply_content'] = JRequest::getVar('dc_reply_content', '', 'post', 'none', JREQUEST_ALLOWRAW);
     $post['content'] = $post['dc_reply_content'];
     $data['content_type'] = DiscussHelper::getEditorType('reply');
     $postTable->bind($post);
     $recaptcha = $config->get('antispam_recaptcha');
     $public = $config->get('antispam_recaptcha_public');
     $private = $config->get('antispam_recaptcha_private');
     if (!$config->get('antispam_recaptcha_registered_members') && $my->id > 0) {
         $recaptcha = false;
     }
     if ($recaptcha && $public && $private) {
         require_once DISCUSS_CLASSES . '/recaptcha.php';
         $obj = DiscussRecaptcha::recaptcha_check_answer($private, $_SERVER['REMOTE_ADDR'], $post['recaptcha_challenge_field'], $post['recaptcha_response_field']);
         if (!$obj->is_valid) {
             $ajax->reloadCaptcha();
             $ajax->reject('error', JText::_('COM_EASYDISCUSS_POST_INVALID_RECAPTCHA_RESPONSE'));
             $ajax->send();
         }
     } else {
         if ($config->get('antispam_easydiscuss_captcha')) {
             $runCaptcha = DiscussHelper::getHelper('Captcha')->showCaptcha();
             if ($runCaptcha) {
                 $response = JRequest::getVar('captcha-response');
                 $captchaId = JRequest::getInt('captcha-id');
                 $discussCaptcha = new stdClass();
                 $discussCaptcha->captchaResponse = $response;
                 $discussCaptcha->captchaId = $captchaId;
                 $state = DiscussHelper::getHelper('Captcha')->verify($discussCaptcha);
                 if (!$state) {
                     DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_CAPTCHA'), DISCUSS_QUEUE_ERROR);
                     $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=post&layout=edit&id=' . $postTable->id, false));
                     return $app->close();
                 }
             }
         }
     }
     // @rule: Bind parameters
     if ($config->get('reply_field_references')) {
         $postTable->bindParams($post);
     }
     // Bind file attachments
     if ($acl->allowed('add_attachment', '0')) {
         $postTable->bindAttachments();
     }
     $isNew = false;
     // @trigger: onBeforeSave
     DiscussEventsHelper::importPlugin('content');
     DiscussEventsHelper::onContentBeforeSave('post', $postTable, $isNew);
     if (!$postTable->store()) {
         $ajax->reject('error', JText::_('COM_EASYDISCUSS_ERROR'));
         $ajax->send();
     }
     // Process poll items
     $includePolls = JRequest::getBool('pollitems', false);
     // Process poll items here.
     if ($includePolls && $config->get('main_polls')) {
         $pollItems = JRequest::getVar('pollitems');
         $pollItemsOri = JRequest::getVar('pollitemsOri');
         // Delete polls if necessary since this post doesn't contain any polls.
         //if( !$isNew && !$includePolls )
         if (count($pollItems) == 1 && empty($pollItems[0]) && !$isNew) {
             $postTable->removePoll();
         }
         // Check if the multiple polls checkbox is it checked?
         $multiplePolls = JRequest::getVar('multiplePolls', '0');
         if ($pollItems) {
             // As long as we need to create the poll answers, we need to create the main question.
             $pollTitle = JRequest::getVar('poll_question', '');
             // Since poll question are entirely optional.
             $pollQuestion = DiscussHelper::getTable('PollQuestion');
             $pollQuestion->loadByPost($postTable->id);
             $pollQuestion->post_id = $postTable->id;
             $pollQuestion->title = $pollTitle;
             $pollQuestion->multiple = $config->get('main_polls_multiple') ? $multiplePolls : false;
             $pollQuestion->store();
             if (!$isNew) {
                 // Try to detect which poll items needs to be removed.
                 $remove = JRequest::getVar('pollsremove');
                 if (!empty($remove)) {
                     $remove = explode(',', $remove);
                     foreach ($remove as $id) {
                         $id = (int) $id;
                         $poll = DiscussHelper::getTable('Poll');
                         $poll->load($id);
                         $poll->delete();
                     }
                 }
             }
             for ($i = 0; $i < count($pollItems); $i++) {
                 $item = $pollItems[$i];
                 $itemOri = isset($pollItemsOri[$i]) ? $pollItemsOri[$i] : '';
                 $value = (string) $item;
                 $valueOri = (string) $itemOri;
                 if (trim($value) == '') {
                     continue;
                 }
                 $poll = DiscussHelper::getTable('Poll');
                 if (empty($valueOri) && !empty($value)) {
                     // this is a new item.
                     $poll->set('value', $value);
                     $poll->set('post_id', $postTable->get('id'));
                     $poll->store();
                 } else {
                     if (!empty($valueOri) && !empty($value)) {
                         // update existing value.
                         if (!$poll->loadByValue($valueOri, $postTable->get('id'))) {
                             $poll->set('value', $value);
                             $poll->store();
                         }
                     }
                 }
             }
         }
     }
     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 = '';
     $enableRecaptcha = $config->get('antispam_recaptcha');
     $publicKey = $config->get('antispam_recaptcha_public');
     $skipRecaptcha = $config->get('antispam_skip_recaptcha');
     $model = DiscussHelper::getModel('Posts');
     $postCount = count($model->getPostsBy('user', $my->id));
     if ($enableRecaptcha && !empty($publicKey) && $postCount < $skipRecaptcha) {
         require_once DISCUSS_CLASSES . '/recaptcha.php';
         $recaptcha = getRecaptchaData($publicKey, $config->get('antispam_recaptcha_theme'), $config->get('antispam_recaptcha_lang'), null, $config->get('antispam_recaptcha_ssl'), 'edit-reply-recaptcha' . $postTable->id);
     }
     // Get the post access object here.
     $category = DiscussHelper::getTable('Category');
     $category->load($postTable->category_id);
     $access = $postTable->getAccess($category);
     $postTable->access = $access;
     // Get comments for the post
     $commentLimit = $config->get('main_comment_pagination') ? $config->get('main_comment_pagination_count') : null;
     $comments = $postTable->getComments($commentLimit);
     $postTable->comments = DiscussHelper::formatComments($comments);
     $theme->set('question', $question);
     $theme->set('post', $postTable);
     $theme->set('category', $category);
     $html = $theme->fetch('post.reply.item.php');
     if ($recaptcha && $public && $private) {
         $output['type'] = 'success.captcha';
     }
     if (!$parentTable->islock) {
         $output['type'] = 'locked';
     }
     $message = $isNew ? JText::_('COM_EASYDISCUSS_POST_STORED') : JText::_('COM_EASYDISCUSS_EDIT_SUCCESS');
     $state = 'success';
     // Let's set our custom message here.
     DiscussHelper::setMessageQueue($message, $state);
     $redirect = JRequest::getVar('redirect', '');
     if (!empty($redirect)) {
         $redirect = base64_decode($redirect);
         return $this->setRedirect($redirect);
     }
     $this->setRedirect(DiscussRouter::getPostRoute($post['parent_id'], false));
 }
示例#14
0
            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
0
 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));
 }
示例#16
0
		<li>
			<a class="my-subscriptions" href="<?php 
        echo DiscussRouter::_('index.php?option=com_easydiscuss&view=profile' . $menuURL . '#Subscriptions');
        ?>
"><span><?php 
        echo JText::_('MOD_EASYDISCUSS_WELCOME_VIEW_SUBSCRIPTIONS');
        ?>
</span></a>
		</li>
	<?php 
    }
    ?>


	<?php 
    if (DiscussHelper::isSiteAdmin($my->id)) {
        ?>
	<?php 
        if ($params->get('show_assigned_posts', 1)) {
            ?>
		<li>
			<a class="my-assigned" href="<?php 
            echo DiscussRouter::_('index.php?option=com_easydiscuss&view=assigned' . $menuURL);
            ?>
"><span><?php 
            echo JText::_('MOD_EASYDISCUSS_WELCOME_VIEW_ASSIGNED_POST');
            ?>
</span></a>
		</li>
	<?php 
        }