function display($tmpl = null) { $document = JFactory::getDocument(); $config = EasyBlogHelper::getConfig(); // set meta tags for teamblog view EasyBlogHelper::setMeta(META_ID_TAGS, META_TYPE_VIEW); if (!EasyBlogRouter::isCurrentActiveMenu('tags')) { $this->setPathway(JText::_('COM_EASYBLOG_TAGS_BREADCRUMB')); } // $document->setTitle( JText::_( 'COM_EASYBLOG_TAGS_PAGE_TITLE' ) ); parent::setPageTitle(JText::_('COM_EASYBLOG_TAGS_PAGE_TITLE'), '', true); // Add canonical URL to satify Googlebot. Incase they think it's duplicated content. EasyblogHelper::addCanonicalURL(array('ordering', 'sorting')); $model = $this->getModel('Tags'); $ordering = JString::strtolower(JRequest::getString('ordering', '')); $sorting = JString::strtolower(JRequest::getString('sorting', $config->get('main_tags_sorting'))); $tags = $model->getTagCloud('', $ordering, $sorting, true); $titleURL = 'index.php?option=com_easyblog&view=tags&ordering=title'; $titleURL .= $sorting ? '&sorting=' . $sorting : ''; $postURL = 'index.php?option=com_easyblog&view=tags&ordering=postcount'; $postURL .= $sorting ? '&sorting=' . $sorting : ''; $ascURL = 'index.php?option=com_easyblog&view=tags&sorting=asc'; $ascURL .= $ordering ? '&ordering=' . $ordering : ''; $descURL = 'index.php?option=com_easyblog&view=tags&sorting=desc'; $descURL .= $ordering ? '&ordering=' . $ordering : ''; $tpl = new CodeThemes(); $tpl->set('ascURL', $ascURL); $tpl->set('descURL', $descURL); $tpl->set('titleURL', $titleURL); $tpl->set('postURL', $postURL); $tpl->set('tags', $tags); $tpl->set('sorting', $sorting); $tpl->set('ordering', $ordering); echo $tpl->fetch('blog.tagcloud.php'); }
public static function getCommentHTML($blog, $comments = array(), $pagination = '') { $config = EasyBlogHelper::getConfig(); $path = EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'comments'; $registration = $config->get('comment_registeroncomment'); $commentSystems = array(); // Double check this with Joomla's registration component if ($registration) { $params = JComponentHelper::getParams('com_users'); $registration = $params->get('allowUserRegistration') == '0' ? false : $registration; } if ($config->get('comment_facebook')) { require_once $path . DIRECTORY_SEPARATOR . 'facebook.php'; $commentSystems['FACEBOOK'] = EasyBlogCommentFacebook::getHTML($blog); if (!$config->get('main_comment_multiple')) { return $commentSystems['FACEBOOK']; } } $easysocial = EasyBlogHelper::getHelper('EasySocial'); if ($config->get('comment_easysocial') && $easysocial->exists()) { $easysocial->init(); $commentSystems['EASYSOCIAL'] = $easysocial->getCommentHTML($blog); if (!$config->get('main_comment_multiple')) { return $commentSystems['EASYSOCIAL']; } } if ($config->get('comment_compojoom')) { $file = JPATH_ROOT . '/administrator/components/com_comment/plugin/com_easyblog/josc_com_easyblog.php'; if (JFile::exists($file)) { require_once $file; $commentSystems['COMPOJOOM'] = CommentEasyBlog::output($blog, array()); } $file = JPATH_ROOT . '/components/com_comment/helpers/utils.php'; if (JFile::exists($file)) { JLoader::discover('ccommentHelper', JPATH_ROOT . '/components/com_comment/helpers'); $commentSystems['COMPOJOOM'] = ccommentHelperUtils::commentInit('com_easyblog', $blog); } if (!$config->get('main_comment_multiple')) { return $commentSystems['COMPOJOOM']; } } if ($config->get('comment_intensedebate')) { require_once $path . DIRECTORY_SEPARATOR . 'intensedebate.php'; $commentSystems['INTENSEDEBATE'] = EasyBlogCommentIntenseDebate::getHTML($blog); if (!$config->get('main_comment_multiple')) { return $commentSystems['INTENSEDEBATE']; } } if ($config->get('comment_disqus')) { require_once $path . DIRECTORY_SEPARATOR . 'disqus.php'; $commentSystems['DISQUS'] = EasyBlogCommentDisqus::getHTML($blog); if (!$config->get('main_comment_multiple')) { return $commentSystems['DISQUS']; } } if ($config->get('comment_jomcomment')) { $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_jomcomment' . DIRECTORY_SEPARATOR . 'jomcomment.php'; // Test if jomcomment exists. if (JFile::exists($file)) { require_once $path . DIRECTORY_SEPARATOR . 'jomcomment.php'; $commentSystems['JOMCOMMENT'] = EasyBlogCommentJomComment::getHTML($blog); if (!$config->get('main_comment_multiple')) { return $commentSystems['JOMCOMMENT']; } } } if ($config->get('comment_livefyre')) { require_once $path . DIRECTORY_SEPARATOR . 'livefyre.php'; $commentSystems['LIVEFYRE'] = EasyBlogCommentLiveFyre::getHTML($blog); if (!$config->get('main_comment_multiple')) { return $commentSystems['LIVEFYRE']; } } if ($config->get('comment_jcomments')) { $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_jcomments' . DIRECTORY_SEPARATOR . 'jcomments.php'; if (JFile::exists($file)) { require_once $path . DIRECTORY_SEPARATOR . 'jcomments.php'; $commentSystems['JCOMMENTS'] = EasyBlogCommentJComments::getHTML($blog); if (!$config->get('main_comment_multiple')) { return $commentSystems['JCOMMENTS']; } } } if ($config->get('comment_rscomments')) { $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_rscomments' . DIRECTORY_SEPARATOR . 'rscomments.php'; if (JFile::exists($file)) { include_once $path . DIRECTORY_SEPARATOR . 'rscomments.php'; $commentSystems['RSCOMMENTS'] = EasyBlogCommentRSComments::getHTML($blog); if (!$config->get('main_comment_multiple')) { return $commentSystems['RSCOMMENTS']; } } } if ($config->get('comment_easydiscuss')) { $enabled = JPluginHelper::isEnabled('content', 'easydiscuss'); if ($enabled) { JPluginHelper::importPlugin('content', 'easydiscuss'); $articleParams = new stdClass(); $result = JFactory::getApplication()->triggerEvent('onDisplayComments', array(&$blog, &$articleParams)); if (isset($result[0]) || isset($result[1])) { // There could be komento running on the site if (isset($result[1]) && $result[1]) { $commentSystems['EASYDISCUSS'] = $result[1]; } else { $commentSystems['EASYDISCUSS'] = $result[0]; } if (!$config->get('main_comment_multiple')) { return $commentSystems['EASYDISCUSS']; } } } } if ($config->get('comment_komento')) { $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_komento' . DIRECTORY_SEPARATOR . 'bootstrap.php'; if (JFile::exists($file)) { include_once $file; $commentSystems['KOMENTO'] = Komento::commentify('com_easyblog', $blog, array('trigger' => 'onDisplayComments')); if (!$config->get('main_comment_multiple')) { return $commentSystems['KOMENTO']; } } } if (!$config->get('main_comment_multiple') || $config->get('comment_easyblog')) { //check if bbcode enabled or not. if ($config->get('comment_bbcode')) { EasyBlogCommentHelper::loadBBCode(); } // If all else fail, try to use the default comment system $theme = new CodeThemes(); // setup my own info to show in comment form area $my = JFactory::getUser(); $profile = EasyBlogHelper::getTable('Profile', 'Table'); $profile->load($my->id); $my->avatar = $profile->getAvatar(); $my->displayName = $profile->getName(); $my->url = $profile->url; $blogURL = base64_encode(EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false)); $loginURL = EasyBlogHelper::getLoginLink($blogURL); $enableRecaptcha = $config->get('comment_recaptcha'); $publicKey = $config->get('comment_recaptcha_public'); // check if the user has subcribed to this thread $subscriptionId = false; if ($my->id > 0) { $blogModel = EasyblogHelper::getModel('Blog'); $subscriptionId = $blogModel->isBlogSubscribedUser($blog->id, $my->id, $my->email); $subscriptionId = is_null($subscriptionId) ? false : $subscriptionId; } $theme->set('loginURL', $loginURL); $theme->set('blog', $blog); $theme->set('my', $my); $theme->set('config', $config); $theme->set('blogComments', $comments); $theme->set('pagination', $pagination); $theme->set('allowComment', true); $theme->set('canRegister', $registration); $theme->set('acl', EasyBlogACLHelper::getRuleSet()); $theme->set('subscriptionId', $subscriptionId); $commentSystems['EASYBLOGCOMMENTS'] = $theme->fetch('blog.comment.box.php'); } if (!$config->get('main_comment_multiple')) { return $commentSystems['EASYBLOGCOMMENTS']; } // If there's 1 system only, there's no point loading the tabs. if (count($commentSystems) == 1) { return $commentSystems[key($commentSystems)]; } unset($theme); // Reverse the comment systems array so that easyblog comments are always the first item. $commentSystems = array_reverse($commentSystems); $theme = new CodeThemes(); $theme->set('commentSystems', $commentSystems); return $theme->fetch('blog.comment.multiple.php'); }
/** * This method is invoked when a user submits a comment via ajax. * * @access public * @params Array $post An array of posted data. * @return null */ public function commentSave($post) { $ajax = new Ejax(); $app = JFactory::getApplication(); $my = JFactory::getUser(); $config = EasyBlogHelper::getConfig(); $acl = EasyBlogACLHelper::getRuleSet(); if (empty($acl->rules->allow_comment) && (empty($my->id) && !$config->get('main_allowguestcomment'))) { $ajax->script('eblog.spinner.hide()'); $ajax->script("eblog.loader.doneLoading();"); $ajax->script('eblog.comment.displayInlineMsg( "error" , "' . JText::_('COM_EASYBLOG_NO_PERMISSION_TO_POST_COMMENT') . '");'); $ajax->send(); } $isModerated = false; $parentId = $post['parent_id']; $commentDepth = $post['comment_depth']; $blogId = $post['id']; $subscribeBlog = isset($post['subscribe-to-blog']) ? true : false; // @task: Cleanup posted values. array_walk($post, array($this, '_trim')); array_walk($post, array($this, '_revertValue')); if (!$config->get('comment_require_email') && !isset($post['esemail'])) { $post['esemail'] = ''; } // @task: Run some validation tests on the posted values. if (!$this->_validateFields($post)) { // @task: Reload captcha if necessary EasyBlogHelper::getHelper('Captcha')->reload($ajax, $post); $ajax->script("eblog.loader.doneLoading();"); $ajax->script('eblog.spinner.hide()'); $ajax->script('$("#' . $this->err[1] . '").addClass("input-error");'); $ajax->script("eblog.element.focus('" . $this->err[1] . "');"); $ajax->script('eblog.comment.displayInlineMsg(\'error\', \'' . $this->err[0] . '\');'); $ajax->send(); return; } // @task: Akismet detection service. if ($config->get('comment_akismet')) { $data = array('author' => $post['esname'], 'email' => $post['esname'], 'website' => JURI::root(), 'body' => $post['comment'], 'permalink' => EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $post['id'])); if (EasyBlogHelper::getHelper('Akismet')->isSpam($data)) { $ajax->script('eblog.comment.displayInlineMsg(\'error\', \'' . JText::_('COM_EASYBLOG_SPAM_DETECTED_IN_COMMENT') . '\');'); $ajax->script("eblog.loader.doneLoading();"); $ajax->script('eblog.spinner.hide();'); $ajax->send(); return false; } } // @task: Retrieve the comments model $model = $this->getModel('Comment'); // @task: Retrieve the comment's table $comment = EasyBlogHelper::getTable('Comment'); // We need to rename the esname and esemail back to name and email. $post['name'] = $post['esname']; $post['email'] = $post['esemail']; unset($post['esname']); unset($post['esemail']); // @task: Bind posted values into the table. $comment->bindPost($post); if (!EasyBlogHelper::getHelper('Captcha')->verify($post)) { return EasyBlogHelper::getHelper('Captcha')->getError($ajax, $post); } // @task: Process registrations $registerUser = isset($post['esregister']) ? true : false; $fullname = isset($post['name']) ? $post['name'] : ''; $username = isset($post['esusername']) ? $post['esusername'] : ''; $email = $post['email']; $message = ''; $newUserId = 0; // @task: Process registrations if necessary if ($registerUser && $my->id <= 0) { $state = $this->processRegistrations($post, $username, $email, $ajax); if (!is_numeric($state)) { $ajax->script("eblog.loader.doneLoading();"); $ajax->script('eblog.comment.displayInlineMsg( "error" , "' . $state . '");'); EasyBlogHelper::getHelper('Captcha')->reload($ajax, $post); return $ajax->send(); } $newUserId = $state; } $totalComments = empty($post['totalComment']) ? 1 : $post['totalComment']; $date = EasyBlogHelper::getDate(); $comment->set('created', $date->toMySQL()); $comment->set('modified', $date->toMySQL()); $comment->set('published', 1); $comment->set('parent_id', $parentId); $comment->set('sent', 0); $comment->set('created_by', $my->id); // @rule: Update the user's id if they have just registered earlier. if ($newUserId != 0) { $comment->set('created_by', $newUserId); } // @rule: Update publish status if the comment requires moderation if ($config->get('comment_moderatecomment') == 1 || $my->id == 0 && $config->get('comment_moderateguestcomment') == 1) { $comment->set('published', EBLOG_COMMENT_STATUS_MODERATED); $isModerated = true; } $blog = EasyBlogHelper::getTable('Blog'); $blog->load($blogId); // If moderation for author is disabled, ensure that the comment is published. // If the author is the owner of the blog, it should never be moderated. if (!$config->get('comment_moderateauthorcomment') && $blog->created_by == $my->id) { $comment->set('published', 1); $isModerated = false; } if (!$comment->store()) { //$ejax->alert( JText::_('COM_EASYBLOG_COMMENT_FAILED_TO_SAVE'), JText::_('COM_EASYBLOG_ERROR') , '450', 'auto'); $ajax->script('eblog.comment.displayInlineMsg(\'error\', \'' . JText::_('COM_EASYBLOG_COMMENT_FAILED_TO_SAVE') . '\');'); return $ajax->send(); } // @task: Clean up the comment form $ajax->script('$(\'#title\').val(\'\');'); $ajax->script('$(\'#url\').val(\'\');'); $ajax->script('$(\'#comment\').val(\'\');'); $ajax->script('$(\'#esusername\').val(\'\');'); $ajax->script('$(\'#esregister\').attr(\'checked\',false);'); $message = JText::_('COM_EASYBLOG_COMMENTS_SUCCESS'); if ($newUserId != 0 && $registerUser) { $message = JText::_('COM_EASYBLOG_COMMENTS_SUCCESS_AND_REGISTERED'); } // @rule: Process subscription for blog automatically when the user submits a new comment and wants to subscribe to the blog. if ($subscribeBlog && $config->get('main_subscription') && $blog->subscription) { $isSubscribed = false; $userId = $my->id; $blogModel = EasyblogHelper::getModel('Blog'); if ($userId == 0) { $sid = $blogModel->isBlogSubscribedEmail($blog->id, $email); if (empty($sid)) { $isSubscribed = $blogModel->addBlogSubscription($blog->id, $email, '', $fullname); } } else { $sid = $blogModel->isBlogSubscribedUser($blog->id, $userId, $email); if (!empty($sid)) { // @task: User found, update the email address $blogModel->updateBlogSubscriptionEmail($sid, $userId, $email); } else { $isSubscribed = $blogModel->addBlogSubscription($blog->id, $email, $userId, $fullname); } } if ($isSubscribed) { $message .= ' ' . JText::_('COM_EASYBLOG_ENTRY_AUTO_SUBSCRIBED_SUCCESS'); $sid = $blogModel->isBlogSubscribedUser($blog->id, $userId, $email); $html = ''; $html .= '<div id="unsubscription-box" class="unsubscription-box">'; $html .= ' ' . JText::_('COM_EASYBLOG_ENTRY_AUTO_SUBSCRIBE_SUBSCRIBED_NOTE'); $html .= ' <a href="javascript:void(0);" title="" onclick="eblog.blog.unsubscribe( \'' . $sid . '\', \'' . $blog->id . '\' );">'; $html .= ' ' . JText::_('COM_EASYBLOG_UNSUBSCRIBE_BLOG'); $html .= ' </a>'; $html .= '</div>'; $ajax->append('subscription-box', $html); $ajax->script('$(\'#subscription-message\').remove();'); } } $row = $comment; $creator = EasyBlogHelper::getTable('Profile'); $creator->load($my->id); $row->poster = $creator; $row->comment = nl2br($row->comment); $row->comment = EasyBlogCommentHelper::parseBBCode($row->comment); $row->depth = is_null($commentDepth) ? '0' : $commentDepth; $row->likesAuthor = ''; // @rule: Process notifications $comment->processEmails($isModerated, $blog); if ($isModerated) { $tpl = new CodeThemes(); $tpl->set('comment', $row); $tpl->set('totalComment', $totalComments); $tpl->set('config', $config); $tpl->set('my', $my); $commentHtml = $tpl->fetch('blog.comment.moderate.php'); if ($parentId != 0) { $ajax->after('comment-' . $parentId, $commentHtml); $ajax->script('eblog.comment.cancel(\'' . $parentId . '\')'); } else { $ajax->append('blog-comment', $commentHtml); } // Reload recaptcha image once the comment is saved. EasyBlogHelper::getHelper('Captcha')->reload($ajax, $post); $ajax->script("eblog.loader.doneLoading();"); $ajax->script('eblog.comment.displayInlineMsg(\'info\', \'' . $message . '\');'); $ajax->send(); return; } $tpl = new CodeThemes(); $tpl->set('comment', $row); $tpl->set('totalComment', $totalComments); $tpl->set('config', $config); $tpl->set('my', $my); $tpl->set('acl', $acl); $commentHtml = $tpl->fetch('blog.comment.ejax.php'); if ($parentId != 0) { $ajax->after('comment-' . $parentId, $commentHtml); $ajax->script('eblog.comment.cancel(\'' . $parentId . '\')'); } else { $ajax->append('blog-comment', $commentHtml); } //update the sent flag to sent $comment->updateSent(); // Reload whichever captcha necessary for the next run EasyBlogHelper::getHelper('Captcha')->reload($ajax, $post); $ajax->script("eblog.loader.doneLoading();"); // update comment total count text on blog post if ($comment->published == 1) { $commentText = $tpl->getNouns('COM_EASYBLOG_COMMENT_COUNT', $totalComments, true); $ajax->script('$(\'.blog-comments a\').text(\'' . $commentText . '\');'); } //update the comment total count $ajax->script('$(\'#comment-total-count\').text(\'' . $totalComments . '\');'); //the next count. $ajax->script('$(\'#totalComment\').val(\'' . ($totalComments + 1) . '\');'); //$ejax->alert( $message, JText::_('COM_EASYBLOG_INFO') , '450', 'auto'); $ajax->script('eblog.comment.displayInlineMsg(\'info\', \'' . $message . '\');'); $ajax->send(); }
public function post() { $app = JFactory::getApplication(); $my = $this->plugin->getUser(); $config = EasyBlogHelper::getConfig(); //$acl = EasyBlogACLHelper::getRuleSet(); $acl = EB::acl(); $post = $app->input->post->getArray(); if (empty($acl->rules->allow_comment) && (empty($my->id) && !$config->get('main_allowguestcomment'))) { $this->plugin->setResponse($this->getErrorResponse(500, JText::_('COM_EASYBLOG_NO_PERMISSION_TO_POST_COMMENT'))); } $isModerated = false; $parentId = isset($post['parent_id']) ? $post['parent_id'] : 0; $commentDepth = isset($post['comment_depth']) ? $post['comment_depth'] : 0; $blogId = isset($post['id']) ? $post['id'] : 0; $subscribeBlog = isset($post['subscribe-to-blog']) ? true : false; if (!$blogId) { $this->plugin->setResponse($this->getErrorResponse(404, 'Invalid Blog')); } // @task: Cleanup posted values. array_walk($post, array($this, '_trim')); array_walk($post, array($this, '_revertValue')); if (!$config->get('comment_require_email') && !isset($post['esemail'])) { $post['esemail'] = ''; } // @task: Run some validation tests on the posted values. if (!$this->_validateFields($post)) { $this->plugin->setResponse($this->getErrorResponse(500, $this->err[0])); } // @task: Akismet detection service. if ($config->get('comment_akismet')) { $data = array('author' => $post['esname'], 'email' => $post['esname'], 'website' => JURI::root(), 'body' => $post['comment'], 'permalink' => EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $post['id'])); if (EasyBlogHelper::getHelper('Akismet')->isSpam($data)) { $this->plugin->setResponse($this->getErrorResponse(500, JText::_('COM_EASYBLOG_SPAM_DETECTED_IN_COMMENT'))); } } // @task: Retrieve the comments model $model = EasyBlogHelper::getModel('Comment'); // @task: Retrieve the comment's table $comment = EasyBlogHelper::table('Comment'); // We need to rename the esname and esemail back to name and email. $post['post_id'] = $post['id']; $post['name'] = $post['esname']; $post['email'] = $post['esemail']; unset($post['id']); unset($post['esname']); unset($post['esemail']); // @task: Bind posted values into the table. $comment->bindPost($post); // @task: Process registrations $registerUser = isset($post['esregister']) ? true : false; $fullname = isset($post['name']) ? $post['name'] : ''; $username = isset($post['esusername']) ? $post['esusername'] : ''; $email = $post['email']; $message = ''; $newUserId = 0; // @task: Process registrations if necessary if ($registerUser && $my->id <= 0) { $state = $this->processRegistrations($post, $username, $email, $ajax); if (!is_numeric($state)) { $this->plugin->setResponse($this->getErrorResponse(500, $state)); } $newUserId = $state; } $totalComments = empty($post['totalComment']) ? 1 : $post['totalComment']; //$date = EasyBlogHelper::getDate(); $date = EasyBlogDate::getDate(); $comment->set('created', $date->toMySQL()); $comment->set('modified', $date->toMySQL()); $comment->set('published', 1); $comment->set('parent_id', $parentId); $comment->set('sent', 0); $comment->set('created_by', $my->id); // @rule: Update the user's id if they have just registered earlier. if ($newUserId != 0) { $comment->set('created_by', $newUserId); } // @rule: Update publish status if the comment requires moderation if ($config->get('comment_moderatecomment') == 1 || $my->id == 0 && $config->get('comment_moderateguestcomment') == 1) { $comment->set('published', EBLOG_COMMENT_STATUS_MODERATED); $isModerated = true; } $blog = EasyBlogHelper::table('Blog'); $blog->load($blogId); // If moderation for author is disabled, ensure that the comment is published. // If the author is the owner of the blog, it should never be moderated. if (!$config->get('comment_moderateauthorcomment') && $blog->created_by == $my->id) { $comment->set('published', 1); $isModerated = false; } if (!$comment->store()) { $this->plugin->setResponse($this->getErrorResponse(500, 'There was a problem saving the comment')); } // @rule: Process subscription for blog automatically when the user submits a new comment and wants to subscribe to the blog. if ($subscribeBlog && $config->get('main_subscription') && $blog->subscription) { $isSubscribed = false; $userId = $my->id; $blogModel = EasyblogHelper::getModel('Blog'); if ($userId == 0) { $sid = $blogModel->isBlogSubscribedEmail($blog->id, $email); if (empty($sid)) { $isSubscribed = $blogModel->addBlogSubscription($blog->id, $email, '', $fullname); } } else { $sid = $blogModel->isBlogSubscribedUser($blog->id, $userId, $email); if (!empty($sid)) { // @task: User found, update the email address $blogModel->updateBlogSubscriptionEmail($sid, $userId, $email); } else { $isSubscribed = $blogModel->addBlogSubscription($blog->id, $email, $userId, $fullname); } } } $row = $comment; $creator = EasyBlogHelper::table('Profile'); $creator->load($my->id); $row->poster = $creator; $row->comment = nl2br($row->comment); $row->comment = EasyBlogComment::parseBBCode($row->comment); $row->depth = is_null($commentDepth) ? '0' : $commentDepth; $row->likesAuthor = ''; // @rule: Process notifications $comment->processEmails($isModerated, $blog); //update the sent flag to sent $comment->updateSent(); // @TODO - Move this to a map comment function $item = new CommentSimpleSchema(); $item->commentid = $comment->id; $item->postid = $comment->post_id; $item->title = $comment->title; $item->text = EasyBlogComment::parseBBCode($comment->comment); $item->textplain = strip_tags(EasyBlogComment::parseBBCode($comment->comment)); $item->created_date = $comment->created; $item->created_date_elapsed = EasyBlogDate::getLapsedTime($comment->created); $item->updated_date = $comment->modified; // Author $item->author->name = isset($comment->poster->nickname) ? $comment->poster->nickname : $comment->name; $item->author->photo = isset($comment->poster->avatar) ? $comment->poster->avatar : 'default_blogger.png'; $item->author->photo = JURI::root() . 'components/com_easyblog/assets/images/' . $item->author->photo; $item->author->email = $comment->email; $item->author->website = isset($comment->poster->url) ? $comment->poster->url : $comment->url; $this->plugin->setResponse($item); }
/** * @since 3.0 * Unsubscribe a user with email to a blog post * * @param int Subscription ID * @param int Blog post ID * * @return bool True on success */ public function unsubscribe() { $subscriptionId = JRequest::getInt('subscription_id'); $blogId = JRequest::getInt('blog_id'); $my = JFactory::getUser(); $mainframe = JFactory::getApplication(); $redirect = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $blogId, false); // Check variables if ($my->id == 0 || !$subscriptionId || !$blogId) { EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_NOT_ALLOWED'), 'error'); $mainframe->redirect($redirect); } // Need to ensure that whatever id passed in is owned by the current browser $blogModel = EasyblogHelper::getModel('Blog'); $sid = $blogModel->isBlogSubscribedUser($blogId, $my->id, $my->email); if ($subscriptionId != $sid) { EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_NOT_ALLOWED'), 'error'); $mainframe->redirect($redirect); } // Proceed to unsubscribe $table = EasyBlogHelper::getTable('Subscription', 'Table'); $table->load($subscriptionId); if (!$table->delete()) { EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_UNSUBSCRIBE_BLOG_FAILED'), 'error'); $mainframe->redirect($redirect); } EasyBlogHelper::setMessageQueue(JText::_('COM_EASYBLOG_UNSUBSCRIBE_BLOG_SUCCESS'), 'success'); $mainframe->redirect($redirect); }