Esempio n. 1
0
 /**
  * Remove a location from a post.
  *
  * @since	3.0
  * @access	public
  */
 public function removeLocation($id)
 {
     $ajax = new Disjax();
     $post = DiscussHelper::getTable('Post');
     $state = $post->load($id);
     $my = JFactory::getUser();
     if (!$id || !$state) {
         echo JText::_('COM_EASYDISCUSS_INVALID_ID');
         return $ajax->send();
     }
     if ($post->user_id != $my->id && !DiscussHelper::isModerator($post->category_id)) {
         echo JText::_('COM_EASYDISCUSS_NOT_ALLOWED_TO_REMOVE_LOCATION_FOR_POST');
         return $ajax->send();
     }
     // Update the address, latitude and longitude of the post.
     $post->address = '';
     $post->latitude = '';
     $post->longitude = '';
     $post->store();
     $content = JText::_('COM_EASYDISCUSS_LOCATION_IS_REMOVED');
     $options = new stdClass();
     $options->content = $content;
     $options->title = JText::_('COM_EASYDISCUSS_DELETE_LOCATION_TITLE');
     $buttons = array();
     $button = new stdClass();
     $button->title = JText::_('COM_EASYDISCUSS_BUTTON_CLOSE');
     $button->action = 'disjax.closedlg();';
     $buttons[] = $button;
     $options->buttons = $buttons;
     $ajax->script('discuss.location.removeHTML("' . $id . '");');
     $ajax->dialog($options);
     return $ajax->send();
 }
		</div>

	</div>

	<!-- Discussion left side bar -->


	<!-- Discussion content area -->
	<div class="discuss-item-right">
		<div class="discuss-story">

			<div class="discuss-story-bd">
				<div class="ph-10">

					<?php 
if (!$post->isProtected() || DiscussHelper::isModerator($post->category_id)) {
    ?>
						<div class="discuss-content">
							<?php 
    if ($system->config->get('main_allowquestionvote')) {
        ?>
								<?php 
        echo $this->loadTemplate('post.vote.php', array('access' => $access, 'post' => $post));
        ?>
							<?php 
    }
    ?>

							<div class="discuss-content-item">
								<?php 
    echo DiscussHelper::bbcodeHtmlSwitcher($post, 'question', false);
Esempio n. 3
0
				<span class="ml-10">
				[ <a href="http://www.google.com/maps?q=<?php 
echo urlencode($post->address);
?>
&amp;hl=en" target="_blank" class="map-link"><?php 
echo JText::_('COM_EASYDISCUSS_VIEW_LARGER_MAP');
?>
</a> ]
				</span>
			</h3>
			<div class="pull-right">
				<a href="javascript:void(0);" class="removeLocation"><i class="icon-remove" rel="ed-tooltip"></i></a>
			</div>
		</div>
		<?php 
if (DiscussHelper::isModerator($post->category_id)) {
    ?>
		<div><i class="icon-map-marker"></i> <?php 
    echo $post->address;
    ?>
</div>
		<?php 
}
?>

		<?php 
if ($system->config->get('main_location_static')) {
    ?>
			<div class="map-images">
				<img src="http://maps.googleapis.com/maps/api/staticmap?center=<?php 
    echo $post->latitude;
		<?php 
    } else {
        ?>
			<?php 
        echo JText::_('COM_EASYDISCUSS_POST_IS_CURRENTLY_LOCKED');
        ?>
		<?php 
    }
    ?>
	</div>
<?php 
}
?>

<?php 
if (!$post->islock || DiscussHelper::isModerator($post->category_id)) {
    ?>
	<div class="discuss-user-reply" >
		<div class="fd-cf">
			<a name="respond" id="respond"></a>

			<div class="discuss-component-title"><?php 
    echo JText::_('COM_EASYDISCUSS_ENTRY_YOUR_RESPONSE');
    ?>
</div>
			<hr class="mv-5" style="margin-bottom: 20px;">

			<!-- Note: please update form user_type = twitter | facebook | linkedin -->
			<!-- div class="control-group">
				<a href="javascript:void(0);" class="btn btn-mini btn-facebook"><i class="icon-facebook"></i> Reply with Facebook</a>
				<a href="javascript:void(0);" class="btn btn-mini btn-twitter"><i class="icon-twitter"></i> Reply with Twitter</a>
Esempio n. 5
0
												<?php 
        }
        ?>

												<li>
													<a href="<?php 
        echo DiscussRouter::_('index.php?option=com_easydiscuss&view=profile');
        ?>
#Subscriptions">
														<i class="icon-inbox"></i> <?php 
        echo JText::_('COM_EASYDISCUSS_VIEW_MY_SUBSCRIPTIONS');
        ?>
													</a>
												</li>
												<?php 
        if (DiscussHelper::isModerator()) {
            ?>
												<li>
													<a href="<?php 
            echo DiscussRouter::_('index.php?option=com_easydiscuss&view=assigned');
            ?>
">
														<i class="icon-check"></i> <?php 
            echo JText::_('COM_EASYDISCUSS_VIEW_MY_TICKETS');
            ?>
													</a>
												</li>
												<?php 
        }
        ?>
											</ul>
Esempio n. 6
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $doc = JFactory::getDocument();
     $config = DiscussHelper::getConfig();
     // Sorting and filters.
     $sort = JRequest::getString('sort', DiscussHelper::getDefaultRepliesSorting());
     $filteractive = JRequest::getString('filter', 'allposts');
     $id = JRequest::getInt('id');
     $acl = DiscussHelper::getHelper('ACL');
     // Add noindex for print view by default.
     if (JRequest::getInt('print') == 1) {
         $doc->setMetadata('robots', 'noindex,follow');
     }
     // Get current logged in user.
     $my = JFactory::getUser();
     // Determine if the logged in user is an admin.
     $isAdmin = DiscussHelper::isSiteAdmin();
     // Load the post table out.
     $post = DiscussHelper::getTable('Post');
     $state = $post->load($id);
     // Need raw content for later use
     $post->content_raw = $post->content;
     // If id is not found, we need to redirect gracefully.
     if (!$state || !$post->published || !$id) {
         return JError::raiseError(404, JText::_('COM_EASYDISCUSS_SYSTEM_POST_NOT_FOUND'));
     }
     if ($post->private && $my->id != $post->user_id && !$isAdmin && !DiscussHelper::isModerator($post->category_id, $my->id)) {
         return JError::raiseError(404, JText::_('COM_EASYDISCUSS_SYSTEM_POST_NOT_FOUND'));
     }
     // Check whether this is a valid discussion
     if ($post->parent_id != 0 || $post->published == DISCUSS_ID_PENDING && (!$isAdmin && $post->user_id != $my->id)) {
         return JError::raiseError(404, JText::_('COM_EASYDISCUSS_SYSTEM_POST_NOT_FOUND'));
     }
     // check the discussion is under moderation
     if ($post->published == 4 && !DiscussHelper::isModerator($post->category_id, $my->id) && !$isAdmin) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_NOTICE_POST_SUBMITTED_UNDER_MODERATION'), 'error');
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index', false));
         $app->close();
     }
     // Load the category.
     $category = DiscussHelper::getTable('Category');
     $category->load((int) $post->category_id);
     if ($post->category_id && !$category->canAccess()) {
         return JError::raiseError(404, JText::_('COM_EASYDISCUSS_SYSTEM_POST_NOT_FOUND'));
     }
     // Add pathway for category here.
     DiscussHelper::getHelper('Pathway')->setCategoryPathway($category);
     // Set breadcrumbs for this discussion.
     $this->setPathway($this->escape($post->title));
     // Mark as viewed for notifications.
     $this->logView();
     // Update hit count for this discussion.
     $post->hit();
     // Set page headers
     $this->setPageHeaders($post);
     // Before sending the title and content to be parsed, we need to store this temporarily in case it needs to be accessed.
     $post->title_clear = $post->title;
     // Filter badwords
     $post->title = DiscussHelper::wordFilter($post->title);
     $post->content = DiscussHelper::wordFilter($post->content);
     // Get the tags for this discussion
     $postsTagsModel = $this->getModel('PostsTags');
     $tags = $postsTagsModel->getPostTags($id);
     // Get adsense codes here.
     $adsense = DiscussHelper::getAdsense();
     $postsModel = DiscussHelper::getModel('Posts');
     // Get the answer for this discussion.
     $answer = $postsModel->getAcceptedReply($post->id);
     // Format the answer object.
     if ($answer) {
         $answer = DiscussHelper::formatReplies($answer, $category);
         $answer = $answer[0];
     }
     // Get a list of replies for this post.
     $data = $this->getReplies($category, $post, $sort, $answer);
     $replies = $data->replies;
     $totalReplies = $data->total;
     $hasMoreReplies = $data->more;
     $readMoreURI = $data->readmore;
     // Get comments for the post
     $commentLimit = $config->get('main_comment_pagination') ? $config->get('main_comment_pagination_count') : null;
     $post->comments = false;
     if ($config->get('main_commentpost')) {
         $comments = $post->getComments($commentLimit);
         $post->comments = DiscussHelper::formatComments($comments);
     }
     // get reply comments count
     $post->commentsCount = $post->getTotalComments();
     // Get the post access object here.
     $access = $post->getAccess($category);
     $post->access = $access;
     // Add custom values.
     $postOwner = $post->getOwner();
     $profileTable = DiscussHelper::getTable('Profile');
     if ($postOwner->id) {
         $profileTable->load($postOwner->id);
     }
     $post->user = $profileTable;
     // update user's post read flag
     if ($my->id != 0) {
         $profile = DiscussHelper::getTable('Profile');
         $profile->load($my->id);
         $profile->read($post->id);
     }
     $badgesTable = DiscussHelper::getTable('Profile');
     $badgesTable->load($post->user->id);
     $postBadges = $badgesTable->getBadges();
     // Get Likes model here.
     $post->likesAuthor = DiscussHelper::getHelper('Likes')->getLikesHTML($post->id, $my->id, 'post');
     $post->isVoted = DiscussHelper::getHelper('Post')->isVoted($post->id);
     // Format the content.
     $post->content = DiscussHelper::formatContent($post);
     // Test if trigger is necessary here.
     if ($config->get('main_content_trigger_posts')) {
         // Move aside the original content_raw
         $content_raw_temp = $post->content_raw;
         // Add the br tags in the content, we do it here so that the content triggers's javascript will not get added with br tags
         $post->content_raw = DiscussHelper::formatContent($post);
         $post->event = new stdClass();
         // Triger onContentPrepare here. Since it doesn't have any return value, just ignore this.
         DiscussHelper::triggerPlugins('content', 'onContentPrepare', $post);
         $post->event->afterDisplayTtle = DiscussHelper::triggerPlugins('content', 'onContentAfterTitle', $post, true);
         $post->event->beforeDisplayContent = DiscussHelper::triggerPlugins('content', 'onContentBeforeDisplay', $post, true);
         $post->event->afterDisplayContent = DiscussHelper::triggerPlugins('content', 'onContentAfterDisplay', $post, true);
         // Assign the processed content back
         $post->content = $post->content_raw;
         // Move back the original content_raw
         $post->content_raw = $content_raw_temp;
     }
     $theme = new DiscussThemes();
     // Get list of moderators from the site.
     $moderators = array();
     $composer = new DiscussComposer("replying", $post);
     // Set the discussion object.
     $theme->set('post', $post);
     $theme->set('composer', $composer);
     $theme->set('replies', $replies);
     $theme->set('answer', $answer);
     $theme->set('sort', $sort);
     $theme->set('adsense', $adsense);
     $theme->set('tags', $tags);
     $theme->set('totalReplies', $totalReplies);
     $theme->set('hasMoreReplies', $hasMoreReplies);
     $theme->set('access', $access);
     $theme->set('category', $category);
     $theme->set('moderators', $moderators);
     $theme->set('readMoreURI', $readMoreURI);
     $theme->set('postBadges', $postBadges);
     echo $theme->fetch('post.php');
 }
Esempio n. 7
0
	<?php 
    } else {
        ?>
		<?php 
        echo JText::_('COM_EASYDISCUSS_POST_IS_CURRENTLY_LOCKED');
        ?>
	<?php 
    }
    ?>
</div>
<?php 
}
?>

<?php 
if (!$post->islock || DiscussHelper::isModerator($post->category_id) || $access->canReply()) {
    ?>
<div class="discuss-user-reply" >
		<a name="respond" id="respond"></a>

		

		<!-- Note: please update form user_type = twitter | facebook | linkedin -->
		<!-- div class="control-group">
			<a href="javascript:void(0);" class="btn btn-mini btn-facebook"><i class="icon-facebook"></i> Reply with Facebook</a>
			<a href="javascript:void(0);" class="btn btn-mini btn-twitter"><i class="icon-twitter"></i> Reply with Twitter</a>
		</div -->

		<?php 
    if ($access->canReply()) {
        ?>
Esempio n. 8
0
 /**
  * Process new reply submission called via an iframe.
  *
  * @since   2.0
  * @access  public
  */
 public function ajaxSubmitReply()
 {
     // Process when a new reply is made from bbcode / wysiwyg editor
     $my = JFactory::getUser();
     $config = DiscussHelper::getConfig();
     $ajax = new Disjax();
     $acl = DiscussHelper::getHelper('ACL');
     $post = JRequest::get('POST');
     // @task: User needs to be logged in, in order to submit a new reply.
     if (!$acl->allowed('add_reply', '0') && $my->id == 0) {
         // Append result
         $output = array();
         $output['message'] = JText::_('COM_EASYDISCUSS_PLEASE_KINDLY_LOGIN_INORDER_TO_REPLY');
         $output['type'] = 'error';
         echo $this->_outputJson($output);
         return false;
     }
     if (!$acl->allowed('add_reply', '0')) {
         // Append result
         $output = array();
         $output['message'] = JText::_('COM_EASYDISCUSS_ENTRY_NO_PERMISSION_TO_REPLY');
         $output['type'] = 'error';
         echo $this->_outputJson($output);
         return false;
     }
     if (!isset($post['parent_id'])) {
         // Append result
         $output = array();
         $output['message'] = JText::_('COM_EASYDISCUSS_SYSTEM_INVALID_ID');
         $output['type'] = 'error';
         echo $this->_outputJson($output);
         return false;
     }
     $question = DiscussHelper::getTable('Post');
     $state = $question->load($post['parent_id']);
     if (!$state) {
         // Append result
         $output = array();
         $output['message'] = JText::_('COM_EASYDISCUSS_SYSTEM_INVALID_ID');
         $output['type'] = 'error';
         echo $this->_outputJson($output);
         return false;
     }
     // Ensure that the user really has access to the discussion
     if ($question->private && $my->id != $question->user_id && !DiscussHelper::isSiteAdmin() && !DiscussHelper::isModerator($post->category_id, $my->id)) {
         // Append result
         $output = array();
         $output['message'] = JText::_('COM_EASYDISCUSS_SYSTEM_INSUFFICIENT_PERMISSIONS');
         $output['type'] = 'error';
         echo $this->_outputJson($output);
         return false;
     }
     $questionCategory = DiscussHelper::getTable('Category');
     $questionCategory->load($question->category_id);
     $questionAccess = $question->getAccess($questionCategory);
     if (!$questionAccess->canReply()) {
         // Append result
         $output = array();
         $output['message'] = JText::_('COM_EASYDISCUSS_ENTRY_NO_PERMISSION_TO_REPLY');
         $output['type'] = 'error';
         echo $this->_outputJson($output);
         return false;
     }
     if (empty($post['dc_reply_content'])) {
         // Append result
         $output = array();
         $output['message'] = JText::_('COM_EASYDISCUSS_ERROR_REPLY_EMPTY');
         $output['type'] = 'error';
         echo $this->_outputJson($output);
         return false;
     }
     if (empty($my->id)) {
         if (empty($post['user_type'])) {
             // Append result
             $output = array();
             $output['message'] = JText::_('COM_EASYDISCUSS_INVALID_USER_TYPE');
             $output['type'] = 'error';
             echo $this->_outputJson($output);
             return false;
         }
         if (!DiscussUserHelper::validateUserType($post['user_type'])) {
             $output = array();
             $output['message'] = JText::sprintf('COM_EASYDISCUSS_THIS_USERTYPE_HAD_BEEN_DISABLED', $post['user_type']);
             $output['type'] = 'error';
             echo $this->_outputJson($output);
             return false;
         }
         if (empty($post['poster_name']) || empty($post['poster_email'])) {
             $output = array();
             $output['message'] = JText::sprintf('COM_EASYDISCUSS_GUEST_SIGN_IN_DESC');
             $output['type'] = 'error';
             echo $this->_outputJson($output);
             return false;
         }
     } else {
         $post['user_type'] = 'member';
         $post['poster_name'] = '';
         $post['poster_email'] = '';
     }
     // get id if available
     $id = 0;
     // set alias
     $post['alias'] = DiscussHelper::getAlias($post['title'], 'post');
     // set post owner
     $post['user_id'] = $my->id;
     $content = JRequest::getVar('dc_reply_content', '', 'post', 'none', JREQUEST_ALLOWRAW);
     $content = DiscussHelper::getHelper('String ')->unhtmlentities($content);
     // Rebind the post data
     $post['dc_reply_content'] = $content;
     $post['content_type'] = DiscussHelper::getEditorType('reply');
     // Set the ip address
     $post['ip'] = JRequest::getVar('REMOTE_ADDR', '', 'SERVER');
     // bind the table
     $table = DiscussHelper::getTable('Post');
     $table->bind($post, true);
     // Set the category id for the reply since we might need to use this for acl checks.
     $table->category_id = $question->category_id;
     if ($config->get('main_moderatepost', 0) && !DiscussHelper::isModerateThreshold($my->id) && !DiscussHelper::isSiteAdmin($post->user_id)) {
         $table->published = DISCUSS_ID_PENDING;
     } else {
         $table->published = DISCUSS_ID_PUBLISHED;
     }
     require_once DISCUSS_CLASSES . '/recaptcha.php';
     if (DiscussRecaptcha::isRequired()) {
         $obj = DiscussRecaptcha::recaptcha_check_answer($config->get('antispam_recaptcha_private'), $_SERVER['REMOTE_ADDR'], $post['recaptcha_challenge_field'], $post['recaptcha_response_field']);
         if (!$obj->is_valid) {
             $output = array();
             $output['message'] = JText::_('COM_EASYDISCUSS_POST_INVALID_RECAPTCHA_RESPONSE');
             $output['type'] = 'error.captcha';
             echo $this->_outputJson($output);
             return false;
         }
     } 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) {
                     $output = array();
                     $output['message'] = JText::sprintf('COM_EASYDISCUSS_INVALID_CAPTCHA');
                     $output['type'] = 'error';
                     echo $this->_outputJson($output);
                     return false;
                 }
             }
         }
     }
     if ($config->get('antispam_akismet') && $config->get('antispam_akismet_key')) {
         require_once DISCUSS_CLASSES . '/akismet.php';
         $data = array('author' => $my->name, 'email' => $my->email, 'website' => DISCUSS_JURIROOT, 'body' => $post['dc_reply_content'], 'alias' => '');
         $akismet = new Akismet(DISCUSS_JURIROOT, $config->get('antispam_akismet_key'), $data);
         if (!$akismet->errorsExist()) {
             if ($akismet->isSpam()) {
                 $output = array();
                 $output['message'] = JText::_('COM_EASYDISCUSS_AKISMET_SPAM_DETECTED');
                 $output['type'] = 'error';
                 echo $this->_outputJson($output);
                 return false;
             }
         }
     }
     // hold last inserted ID in DB
     $lastId = null;
     // @rule: Bind parameters
     $table->bindParams($post);
     $isNew = true;
     // @trigger: onBeforeSave
     DiscussEventsHelper::importPlugin('content');
     DiscussEventsHelper::onContentBeforeSave('reply', $table, $isNew);
     if (!$table->store()) {
         $output = array();
         $output['message'] = JText::_('COM_EASYDISCUSS_ERROR_SUBMIT_REPLY');
         $output['type'] = 'error';
         echo $this->_outputJson($output);
         return false;
     }
     // Process poll items.
     if ($config->get('main_polls_replies')) {
         $polls = JRequest::getVar('pollitems');
         if (!is_array($polls)) {
             $polls = array($polls);
         }
         // If the post is being edited and
         // there is only 1 poll item which is also empty,
         // we need to delete existing polls tied to this post.
         //if( count( $polls ) == 1 && empty( $polls[0] ) && !$isNew )
         if (!$isNew) {
             $post->removePoll();
         }
         if (count($polls) > 0) {
             $hasPolls = false;
             foreach ($polls as $poll) {
                 // As long as there is 1 valid poll, we need to store them.
                 if (!empty($poll)) {
                     $hasPolls = true;
                     break;
                 }
             }
             if ($hasPolls) {
                 $pollItems = JRequest::getVar('pollitems');
                 // 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($table->id);
                     $pollQuestion->post_id = $table->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();
                             }
                         }
                     }
                     foreach ($pollItems as $item) {
                         $value = (string) $item;
                         if (trim($value) == '') {
                             continue;
                         }
                         $poll = DiscussHelper::getTable('Poll');
                         if (!$poll->loadByValue($value, $table->id, $multiplePolls)) {
                             $poll->set('value', $value);
                             $poll->set('post_id', $table->get('id'));
                             $poll->store();
                         }
                     }
                 }
             }
         }
     }
     // Process custom fields
     $this->saveCustomFieldsValue($table->id);
     // @trigger: onAfterSave
     DiscussEventsHelper::onContentAfterSave('reply', $table, $isNew);
     // @rule: Add notifications for the thread starter
     if ($table->published && $config->get('main_notifications_reply')) {
         // Get all users that are subscribed to this post
         $model = $this->getModel('Posts');
         $participants = $model->getParticipants($table->parent_id);
         // Add the thread starter into the list of participants.
         $participants[] = $question->get('user_id');
         // Notify all subscribers
         foreach ($participants as $participant) {
             if ($participant != $my->id) {
                 $notification = DiscussHelper::getTable('Notifications');
                 $notification->bind(array('title' => JText::sprintf('COM_EASYDISCUSS_REPLY_DISCUSSION_NOTIFICATION_TITLE', $question->get('title')), 'cid' => $question->get('id'), 'type' => DISCUSS_NOTIFICATIONS_REPLY, 'target' => $participant, 'author' => $table->get('user_id'), 'permalink' => 'index.php?option=com_easydiscuss&view=post&id=' . $question->get('id')));
                 $notification->store();
             }
         }
         // @rule: Detect if any names are being mentioned in the post
         $names = DiscussHelper::getHelper('String')->detectNames($table->content);
         if ($names) {
             foreach ($names as $name) {
                 $name = JString::str_ireplace('@', '', $name);
                 $id = DiscussHelper::getUserId($name);
                 if (!$id || $id == $table->get('user_id')) {
                     continue;
                 }
                 $notification = DiscussHelper::getTable('Notifications');
                 $notification->bind(array('title' => JText::sprintf('COM_EASYDISCUSS_MENTIONED_REPLY_NOTIFICATION_TITLE', $question->get('title')), 'cid' => $question->get('id'), 'type' => DISCUSS_NOTIFICATIONS_MENTIONED, 'target' => $id, 'author' => $table->get('user_id'), 'permalink' => 'index.php?option=com_easydiscuss&view=post&id=' . $question->get('id')));
                 $notification->store();
             }
         }
     }
     if ($table->published && !$question->private) {
         // Create notification item in EasySocial
         DiscussHelper::getHelper('EasySocial')->notify('new.reply', $table, $question);
         // @rule: Badges
         DiscussHelper::getHelper('History')->log('easydiscuss.new.reply', $table->user_id, JText::sprintf('COM_EASYDISCUSS_BADGES_HISTORY_NEW_REPLY', $question->title), $table->id);
         DiscussHelper::getHelper('Badges')->assign('easydiscuss.new.reply', $table->user_id);
         DiscussHelper::getHelper('Points')->assign('easydiscuss.new.reply', $table->user_id, $table);
         // Assign badge for EasySocial
         DiscussHelper::getHelper('EasySocial')->assignBadge('reply.question', $table->user_id, JText::sprintf('COM_EASYDISCUSS_BADGES_HISTORY_NEW_REPLY', $question->title));
         // @rule: AUP integrations
         DiscussHelper::getHelper('Aup')->assign(DISCUSS_POINTS_NEW_REPLY, $table->user_id, $question->title);
         // @rule: ranking
         DiscussHelper::getHelper('ranks')->assignRank($table->user_id, $config->get('main_ranking_calc_type'));
     }
     // Bind file attachments
     if ($acl->allowed('add_attachment', '0')) {
         if (!$table->bindAttachments() && $table->getError()) {
             $output = array();
             $output['message'] = $table->getError();
             $output['type'] = 'error';
             echo $this->_outputJson($output);
             return false;
         }
     }
     $replier = new stdClass();
     if ($my->id > 0) {
         $replier->id = $my->id;
         $replier->name = $my->name;
     } else {
         $replier->id = 0;
         $replier->name = JText::_('COM_EASYDISCUSS_GUEST');
         // TODO: user the poster_name
     }
     //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($replier->id);
     $table->user = $creator;
     $voteModel = $this->getModel('votes');
     // clean up bad code
     $table->content_raw = $table->content;
     //$table->content       = DiscussHelper::parseContent( $table->content );
     // @rule: URL References
     $table->references = $table->getReferences();
     // Since this is a new reply, it's impossible that it has been voted before.
     $table->voted = false;
     // get total vote for this reply
     $table->totalVote = $table->sum_totalvote;
     $result['status'] = 'success';
     $result['title'] = JText::_('COM_EASYDISCUSS_SUCCESS_SUBMIT_REPLY');
     $result['id'] = $table->id;
     $result['message'] = JText::_('COM_EASYDISCUSS_REPLY_SAVED');
     $table->title = DiscussHelper::wordFilter($table->title);
     $table->content = DiscussHelper::wordFilter($table->content);
     // Legacy fix when switching from WYSIWYG editor to bbcode.
     $table->content = EasyDiscussParser::html2bbcode($table->content);
     $table->content = DiscussHelper::formatContent($table, true);
     //all access control goes here.
     $canDelete = false;
     $isMainLocked = false;
     if (DiscussHelper::isSiteAdmin() || $acl->allowed('delete_reply', '0') || $table->user_id == $my->id) {
         $canDelete = true;
     }
     $parent = DiscussHelper::getTable('Post');
     $parent->load($table->parent_id);
     $isMainLocked = $parent->islock;
     //default value
     $table->isVoted = 0;
     $table->total_vote_cnt = 0;
     $table->likesAuthor = '';
     $table->minimize = 0;
     if ($config->get('main_content_trigger_replies')) {
         $tempContent = $table->content;
         $table->content = str_replace('@', '&#64;', $tempContent);
         // process content plugins
         DiscussEventsHelper::importPlugin('content');
         DiscussEventsHelper::onContentPrepare('reply', $table);
         $table->event = new stdClass();
         $results = DiscussEventsHelper::onContentBeforeDisplay('reply', $table);
         $table->event->beforeDisplayContent = trim(implode("\n", $results));
         $results = DiscussEventsHelper::onContentAfterDisplay('reply', $table);
         $table->event->afterDisplayContent = trim(implode("\n", $results));
     }
     $tpl = new DiscussThemes();
     $category = DiscussHelper::getTable('Category');
     $category->load($question->category_id);
     $table->access = $table->getAccess($category);
     // Since the reply dont have any comments yet.
     $table->comments = array();
     $tpl->set('category', $category);
     $tpl->set('post', $table);
     $tpl->set('question', $parent);
     $tpl->set('isMine', DiscussHelper::isMine($parent->user_id));
     $tpl->set('isAdmin', DiscussHelper::isSiteAdmin());
     $tpl->set('isMainLocked', $isMainLocked);
     $recaptcha = '';
     $enableRecaptcha = $config->get('antispam_recaptcha', 0);
     $publicKey = $config->get('antispam_recaptcha_public');
     $html = $table->published == DISCUSS_ID_PENDING ? $tpl->fetch('post.reply.item.moderation.php') : $tpl->fetch('post.reply.item.php');
     //send notification to all comment's subscribers that want to receive notification immediately
     $notify = DiscussHelper::getNotification();
     $excludeEmails = array();
     $attachments = $table->getAttachments();
     $emailData['attachments'] = $attachments;
     $emailData['postTitle'] = $parent->title;
     $emailData['comment'] = DiscussHelper::parseContent($table->content);
     $emailData['commentAuthor'] = $my->id ? $creator->getName() : $table->poster_name;
     $emailData['postLink'] = DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=post&id=' . $parent->id, false, true);
     $emailContent = $table->content;
     $isEditing = $isNew == true ? false : true;
     $emailContent = DiscussHelper::bbcodeHtmlSwitcher($table, 'reply', $isEditing);
     $emailContent = $question->trimEmail($emailContent);
     $emailData['replyContent'] = $emailContent;
     $emailData['replyAuthor'] = $my->id ? $creator->getName() : $table->poster_name;
     $emailData['replyAuthorAvatar'] = $creator->getAvatar();
     $emailData['post_id'] = $parent->id;
     $emailData['cat_id'] = $parent->category_id;
     $subscriberEmails = array();
     if (($config->get('main_sitesubscription') || $config->get('main_postsubscription')) && $config->get('notify_subscriber') && $table->published == DISCUSS_ID_PUBLISHED) {
         $emailData['emailTemplate'] = 'email.subscription.reply.new.php';
         $emailData['emailSubject'] = JText::sprintf('COM_EASYDISCUSS_NEW_REPLY_ADDED', $parent->id, $parent->title);
         $posterEmail = $post['poster_email'] ? $post['poster_email'] : $my->email;
         // Get the emails of user who subscribe to this post only
         // This does not send to subscribers whom subscribe to site and category
         $subcribersEmails = DiscussHelper::getHelper('Mailer')->notifyThreadSubscribers($emailData, array($posterEmail, $my->email));
         $excludeEmails[] = $posterEmail;
         $excludeEmails = array_merge($excludeEmails, $subcribersEmails);
         $excludeEmails = array_unique($excludeEmails);
     }
     //notify post owner.
     $postOwnerId = $parent->user_id;
     $postOwner = JFactory::getUser($postOwnerId);
     $ownerEmail = $postOwner->email;
     if ($parent->user_type != 'member') {
         $ownerEmail = $parent->poster_email;
     }
     // Notify Owner
     // if reply under moderation, send owner a notification.
     if ($config->get('notify_owner') && $table->published == DISCUSS_ID_PUBLISHED && $postOwnerId != $replier->id && !in_array($ownerEmail, $excludeEmails) && !empty($ownerEmail)) {
         $emailData['owner_email'] = $ownerEmail;
         $emailData['emailSubject'] = JText::sprintf('COM_EASYDISCUSS_NEW_REPLY_ADDED', $parent->id, $parent->title);
         $emailData['emailTemplate'] = 'email.post.reply.new.php';
         DiscussHelper::getHelper('Mailer')->notifyThreadOwner($emailData);
         // Notify Participants
         $excludeEmails[] = $ownerEmail;
         $excludeEmails = array_unique($excludeEmails);
     }
     if ($config->get('notify_participants') && $table->published == DISCUSS_ID_PUBLISHED) {
         $emailData['emailSubject'] = JText::sprintf('COM_EASYDISCUSS_NEW_REPLY_ADDED', $parent->id, $parent->title);
         $emailData['emailTemplate'] = 'email.post.reply.new.php';
         DiscussHelper::getHelper('Mailer')->notifyThreadParticipants($emailData, $excludeEmails);
     }
     if ($table->published == DISCUSS_ID_PENDING) {
         // Notify admins.
         // Generate hashkeys to map this current request
         $hashkey = DiscussHelper::getTable('Hashkeys');
         $hashkey->uid = $table->id;
         $hashkey->type = DISCUSS_REPLY_TYPE;
         $hashkey->store();
         require_once DISCUSS_HELPERS . '/router.php';
         $approveURL = DiscussHelper::getExternalLink('index.php?option=com_easydiscuss&controller=posts&task=approvePost&key=' . $hashkey->key);
         $rejectURL = DiscussHelper::getExternalLink('index.php?option=com_easydiscuss&controller=posts&task=rejectPost&key=' . $hashkey->key);
         $emailData['moderation'] = '<div style="display:inline-block;width:100%;padding:20px;border-top:1px solid #ccc;padding:20px 0 10px;margin-top:20px;line-height:19px;color:#555;font-family:\'Lucida Grande\',Tahoma,Arial;font-size:12px;text-align:left">';
         $emailData['moderation'] .= '<a href="' . $approveURL . '" style="display:inline-block;padding:5px 15px;background:#fc0;border:1px solid #caa200;border-bottom-color:#977900;color:#534200;text-shadow:0 1px 0 #ffe684;font-weight:bold;box-shadow:inset 0 1px 0 #ffe064;-moz-box-shadow:inset 0 1px 0 #ffe064;-webkit-box-shadow:inset 0 1px 0 #ffe064;border-radius:2px;moz-border-radius:2px;-webkit-border-radius:2px;text-decoration:none!important">' . JText::_('COM_EASYDISCUSS_EMAIL_APPROVE_REPLY') . '</a>';
         $emailData['moderation'] .= ' ' . JText::_('COM_EASYDISCUSS_OR') . ' <a href="' . $rejectURL . '" style="color:#477fda">' . JText::_('COM_EASYDISCUSS_REJECT') . '</a>';
         $emailData['moderation'] .= '</div>';
         $emailData['emailSubject'] = JText::sprintf('COM_EASYDISCUSS_NEW_REPLY_MODERATE', $parent->title);
         $emailData['emailTemplate'] = 'email.post.reply.moderation.php';
         DiscussHelper::getHelper('Mailer')->notifyAdministrators($emailData, array(), $config->get('notify_admin'), $config->get('notify_moderator'));
     } elseif ($table->published == DISCUSS_ID_PUBLISHED && !$question->private) {
         $emailData['emailTemplate'] = 'email.post.reply.new.php';
         $emailData['emailSubject'] = JText::sprintf('COM_EASYDISCUSS_NEW_REPLY_ADDED', $parent->id, $parent->title);
         $emailData['post_id'] = $parent->id;
         DiscussHelper::getHelper('Mailer')->notifyAdministrators($emailData, $excludeEmails, $config->get('notify_admin_onreply'), $config->get('notify_moderator_onreply'));
     }
     // @rule: Jomsocial activity integrations
     if ($table->published == DISCUSS_ID_PUBLISHED && !$question->private) {
         DiscussHelper::getHelper('jomsocial')->addActivityReply($table);
         DiscussHelper::getHelper('easysocial')->replyDiscussionStream($table);
     }
     $autoSubscribed = false;
     if ($config->get('main_autopostsubscription') && $config->get('main_postsubscription') && $table->user_type != 'twitter') {
         //automatically subscribe this user into this post.
         $subscription_info = array();
         $subscription_info['type'] = 'post';
         $subscription_info['userid'] = !empty($table->user_id) ? $table->user_id : '0';
         $subscription_info['email'] = !empty($table->user_id) ? $my->email : $table->poster_email;
         $subscription_info['cid'] = $parent->id;
         $subscription_info['member'] = !empty($table->user_id) ? '1' : '0';
         $subscription_info['name'] = !empty($table->user_id) ? $my->name : $table->poster_name;
         $subscription_info['interval'] = 'instant';
         $model = $this->getModel('Subscribe');
         $sid = '';
         if ($subscription_info['userid'] == 0) {
             $sid = $model->isPostSubscribedEmail($subscription_info);
             if (empty($sid)) {
                 if ($model->addSubscription($subscription_info)) {
                     $autoSubscribed = true;
                 }
             }
         } else {
             $sid = $model->isPostSubscribedUser($subscription_info);
             if (empty($sid['id'])) {
                 //add new subscription.
                 if ($model->addSubscription($subscription_info)) {
                     $autoSubscribed = true;
                 }
             }
         }
     }
     // Append result
     $output = array();
     $output['message'] = $autoSubscribed ? JText::_('COM_EASYDISCUSS_SUCCESS_REPLY_POSTED_AND_SUBSCRIBED') : JText::_('COM_EASYDISCUSS_SUCCESS_REPLY_POSTED');
     $output['type'] = 'success';
     $output['html'] = $html;
     // Perhaps the viewer is unable to view the replies.
     if (!$questionCategory->canViewReplies()) {
         $output['message'] = JText::_('COM_EASYDISCUSS_REPLY_SUCCESS_BUT_UNABLE_TO_VIEW_REPLIES');
     }
     if ($enableRecaptcha && !empty($publicKey) && $recaptcha) {
         $output['type'] = 'success.captcha';
     }
     echo $this->_outputJson($output);
 }
Esempio n. 9
0
 public function canViewReplies()
 {
     if (DiscussHelper::isModerator($this->id)) {
         return true;
     }
     $privCats = DiscussHelper::getPrivateCategories(DISCUSS_CATEGORY_ACL_ACTION_VIEWREPLY);
     $canView = in_array($this->id, $privCats) ? false : true;
     return $canView;
 }
Esempio n. 10
0
 /**
  * Responsible to feature a discussion post.
  *
  * @since	3.0
  * @access	public
  */
 public function feature()
 {
     JRequest::checkToken('request') or jexit('Invalid Token');
     $my = JFactory::getUser();
     $id = JRequest::getInt('id', 0);
     $app = JFactory::getApplication();
     // Load the post.
     $post = DiscussHelper::getTable('Post');
     $state = $post->load($id);
     if (!$state || !$id) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_INVALID_POST_ID'), DISCUSS_QUEUE_ERROR);
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss', false));
         $app->close();
     }
     // Load acl.
     $acl = DiscussHelper::getHelper('ACL');
     // Only allow selected users to feature a discussion post.
     if (!DiscussHelper::isSiteAdmin() && !$acl->allowed('feature_post', 0) && !DiscussHelper::isModerator($post->category_id)) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_NO_PERMISSION_TO_PERFORM_THE_REQUESTED_ACTION'), DISCUSS_QUEUE_ERROR);
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss', false));
         $app->close();
     }
     // Set the featured status.
     $task = $this->getTask();
     $post->featured = $task == 'feature' ? 1 : 0;
     $post->store();
     // Send notification to the thread starter that their post is being featured.
     // Only send when the person featuring the post is not himself.
     if ($post->user_id != $my->id && $task == 'feature') {
         $notification = DiscussHelper::getTable('Notifications');
         $notification->bind(array('title' => JText::sprintf('COM_EASYDISCUSS_FEATURED_DISCUSSION_NOTIFICATION_TITLE', $post->title), 'cid' => $post->id, 'type' => DISCUSS_NOTIFICATIONS_FEATURED, 'target' => $post->user_id, 'author' => $my->id, 'permalink' => 'index.php?option=com_easydiscuss&view=post&id=' . $post->get('id')));
         $notification->store();
         // @TODO: Send email to author?
     }
     // Redirect user back to the post.
     $message = $task == 'feature' ? JText::_('COM_EASYDISCUSS_FEATURE_POST_IS_FEATURED') : JText::_('COM_EASYDISCUSS_FEATURE_POST_IS_UNFEATURED');
     DiscussHelper::setMessageQueue($message, DISCUSS_QUEUE_SUCCESS);
     $app->redirect(DiscussRouter::getPostRoute($post->id, false));
     $app->close();
 }
Esempio n. 11
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