public function upload( $fileItem, $fileName = '', $storagePath = '', $published = 1 ) { // $fileItem['name'] = filename // $fileItem['type'] = mime // $fileItem['tmp_name'] = temporary source // $fileItem['size'] = size if( empty( $fileItem ) ) { return false; } // store record first $uploadtable = Komento::getTable( 'uploads' ); $now = Komento::getDate()->toMySQL(); $uploadtable->created = $now; $profile = Komento::getProfile(); $uploadtable->created_by = $profile->id; $uploadtable->published = $published; $uploadtable->mime = $fileItem['type']; $uploadtable->size = $fileItem['size']; if( $fileName == '' ) { $fileName = $fileItem['name']; } $uploadtable->filename = $fileName; if( $storagePath == '' ) { $config = Komento::getConfig(); $storagePath = $config->get( 'upload_path' ); } $uploadtable->path = $storagePath; if( !$uploadtable->upload() ) { return false; } $source = $fileItem['tmp_name']; $destination = $uploadtable->getFilePath(); jimport( 'joomla.filesystem.file' ); if( !JFile::copy( $source , $destination ) ) { $uploadtable->rollback(); return false; } return $uploadtable->id; }
public function init() { $obj = new stdClass(); $obj->config = Komento::getConfig(); $obj->konfig = Komento::getKonfig(); $obj->my = Komento::getProfile(); $obj->acl = Komento::getHelper('acl'); $obj->session = JFactory::getSession(); $this->_system = $obj; }
public function display($tpl = null) { $konfig = Komento::getKonfig(); $id = JRequest::getInt('id', 0); // @task: If profiles are disabled, do not show the profile here. if (!$konfig->get('profile_enable')) { $app = JFactory::getApplication(); $app->redirect('index.php', JText::_('COM_KOMENTO_PROFILE_SYSTEM_DISABLED')); $app->close(); } $profileModel = Komento::getModel('Profile'); $activityModel = Komento::getModel('Activity'); $commentsModel = Komento::getModel('Comments'); $actionsModel = Komento::getModel('Actions'); $count = new stdClass(); $user = JFactory::getUser(); if ($id === 0 && $user->id > 0) { $id = $user->id; } // Block non-exists profile if (!$profileModel->exists($id)) { echo JText::_('COM_KOMENTO_PROFILE_NOT_FOUND'); return; } // TODO: Block custom profile id // .. $profile = Komento::getProfile($id); // $activities = $activityModel->getUserActivities( $profile->id ); $count->totalComments = $commentsModel->getTotalComment($profile->id); $count->likesReceived = $actionsModel->getLikesReceived($profile->id); $count->likesGiven = $actionsModel->getLikesGiven($profile->id); // Set Pathway // Check if Komento profile menu item exist before setting profile pathway $app = JFactory::getApplication(); $menu = $app->getMenu(); $item = $menu->getActive(); if (empty($item) || $item->query['view'] != 'profile') { $this->setPathway(JText::_('COM_KOMENTO_PROFILE'), ''); } $this->setPathway($profile->getName(), ''); // Set browser title $document = JFactory::getDocument(); $document->setTitle(JText::_('COM_KOMENTO_USER_PROFILE') . ' - ' . $profile->getName()); // set component to com_komento Komento::setCurrentComponent('com_komento'); $theme = Komento::getTheme(); $theme->set('profile', $profile); $theme->set('count', $count); // $theme->set( 'activities', $activities ); echo $theme->fetch('profile/profile.php'); }
public function __construct() { $konfig = Komento::getKonfig(); $config = Komento::getConfig(); // @legacy: If environment is set to production, change to static. $environment = $konfig->get('komento_environment'); if ($environment=='production') { $environment='static'; } $this->fullName = 'Komento'; $this->shortName = 'kmt'; $this->environment = $environment; $this->mode = $konfig->get('komento_mode'); $this->version = (string) Komento::getHelper( 'Version' )->getLocalVersion(); $this->baseUrl = Komento::getHelper( 'Document' )->getBaseUrl(); $this->token = Komento::_( 'getToken' ); $newConfig = clone $config->toObject(); $newKonfig = clone $konfig->toObject(); unset( $newConfig->antispam_recaptcha_private_key ); unset( $newConfig->antispam_recaptcha_public_key ); unset( $newConfig->antispam_akismet_key ); unset( $newConfig->layout_phpbb_path ); unset( $newConfig->layout_phpbb_url ); unset( $newKonfig->layout_phpbb_path ); unset( $newKonfig->layout_phpbb_url ); $this->options = array( "responsive" => (bool) $config->get('enable_responsive'), "jversion" => Komento::joomlaVersion(), "spinner" => JURI::root() . 'media/com_komento/images/loader.gif', "view" => JRequest::getString( 'view', '' ), "guest" => Komento::getProfile()->guest ? 1 : 0, "config" => $newConfig, "konfig" => $newKonfig, "acl" => Komento::getACL(), "element" => new stdClass() ); parent::__construct(); }
public static function loadHeaders() { if (!self::$loaded) { $url = KomentoDocumentHelper::getBaseUrl(); $resourcePath = $url . '&tmpl=component&no_html=1&controller=foundry&task=getResource&kmtcomponent=' . JRequest::getCmd('option', ''); $document = JFactory::getDocument(); $config = Komento::getConfig(); $konfig = Komento::getKonfig(); $acl = Komento::getAcl(); $guest = Komento::getProfile()->guest ? 1 : 0; if ($document->getType() != 'html') { return true; } // only temporary to load development css // waiting chang to finalise reset.css and comments.css self::addTemplateCss('common.css'); // self::addTemplateCss( 'comments.css' ); // Load KomentoConfiguration class require_once KOMENTO_CLASSES . DIRECTORY_SEPARATOR . 'configuration.php'; // Get configuration instance $configuration = KomentoConfiguration::getInstance(); // Attach configuration to headers $configuration->attach(); if ($config->get('layout_inherit_kuro_css', 1) && $config->get('layout_theme') != 'wireframe') { $document->addStylesheet(JURI::root() . 'components/com_komento/themes/kuro/css/style.css'); } // support for RTL sites // forcertl = 1 for dev purposes if (($document->direction == 'rtl' || JRequest::getInt('forcertl') == 1) && $config->get('layout_theme') != 'wireframe') { $document->addStylesheet(JURI::root() . 'components/com_komento/themes/kuro/css/style-rtl.css'); } $document->addStylesheet(JURI::root() . 'media/foundry/3.1/styles/dialog/default.css'); $document->addStylesheet(JURI::root() . 'media/foundry/3.1/styles/fancybox/default.css'); self::load('style', 'css', 'themes'); // load SH css if config is on if ($config->get('enable_syntax_highlighting')) { $shtheme = $config->get('syntaxhighlighter_theme', 'default'); self::load('syntaxhighlighter/' . $shtheme, 'css', 'assets'); } self::$loaded = true; } return self::$loaded; }
public function download() { $id = JRequest::getInt( 'id' ); // need to get component to check acl because controller link component is com_komento $filetable = Komento::getTable( 'uploads' ); if( !$filetable->load( $id ) ) { echo JText::_( 'COM_KOMENTO_ATTACHMENT_INVALID_ID' ); exit; } $comment = Komento::getComment( $filetable->uid ); $profile = Komento::getProfile(); if( !$profile->allow( 'download_attachment', $comment->component ) ) { echo JText::_( 'COM_KOMENTO_ATTACHMENT_NO_PERMISSION' ); exit; } return $filetable->download(); }
function display($tmpl = null) { $config = Komento::getConfig(); if (!$config->get('enable_rss')) { return; } require_once KOMENTO_HELPERS . DIRECTORY_SEPARATOR . 'helper.php'; $component = JRequest::getString('component', 'all'); $cid = JRequest::getInt('cid'); $cid = !$cid ? 'all' : $cid; $userid = JRequest::getInt('userid', null); if ($component != 'all' && $cid != 'all') { $application = Komento::loadApplication($component)->load($cid); if ($application === false) { $application = Komento::getErrorApplication($component, $cid); } $contentTitle = $component != 'all' && $cid != 'all' ? $application->getContentTitle() : ''; } $username = $userid !== null ? Komento::getProfile($userid)->getName() : ''; $document = JFactory::getDocument(); // to do: get permalink or view name from api/componentlist if ($component != 'all' && $cid != 'all') { $document->link = $application->getContentPermalink(); } else { $document->link = JURI::root(); } // to do : get article name from api/componentlist // document title based on request parameter // integrate settings for rss // allow all component rss // allow all article rss // allow all user rss // allow all guest rss $document->setTitle(JText::_('COM_KOMENTO_FEEDS_LATEST_TITLE')); $document->setDescription(JText::_('COM_KOMENTO_FEEDS_LATEST_TITLE_DESCRIPTION')); if ($component == 'all') { if ($cid != 'all') { // impossible all component and specific article echo 'Error! Component = all, cid != all.'; exit; } // all component all article if (is_null($userid)) { // all users/guests $document->setTitle(JText::_('COM_KOMENTO_FEEDS_ALL_COMMENTS_TITLE')); $document->setDescription(JText::_('COM_KOMENTO_FEEDS_ALL_COMMENTS_TITLE_DESCRIPTION')); } else { if ($userid === 0) { // for all guest $userid = 0 $document->setTitle(JText::_('COM_KOMENTO_FEEDS_GUEST_COMMENTS_TITLE')); $document->setDescription(JText::_('COM_KOMENTO_FEEDS_GUEST_COMMENTS_TITLE_DESCRIPTION')); } else { // specific user $document->setTitle(JText::_('COM_KOMENTO_FEEDS_COMMENTS_FROM_USER_TITLE') . ' : ' . $username); $document->setDescription(JText::_('COM_KOMENTO_FEEDS_COMMENTS_FROM_USER_TITLE_DESCRIPTION') . ' : ' . $username); } } } else { // specific component if ($cid == 'all') { // all article if (is_null($userid)) { // all users/guests $document->setTitle(JText::_('COM_KOMENTO_FEEDS_COMMENTS_FOR_COMPONENT_TITLE') . ' : ' . Komento::loadApplication($component)->getComponentName()); $document->setDescription(JText::_('COM_KOMENTO_FEEDS_COMMENTS_FOR_COMPONENT_TITLE_DESCRIPTION')); } else { if ($userid === 0) { // for all guest $userid = 0 $document->setTitle(JText::_('COM_KOMENTO_FEEDS_GUEST_COMMENTS_FOR_COMPONENT_TITLE') . ' : ' . Komento::loadApplication($component)->getComponentName()); $document->setDescription(JText::_('COM_KOMENTO_FEEDS_GUEST_COMMENTS_FOR_COMPONENT_TITLE_DESCRIPTION')); } else { // specific user $document->setTitle(JText::_('COM_KOMENTO_FEEDS_COMMENTS_FROM_USER_FOR_COMPONENT_TITLE') . ' : ' . $username . ' : ' . Komento::loadApplication($component)->getComponentName()); $document->setDescription(JText::_('COM_KOMENTO_FEEDS_COMMENTS_FROM_USER_FOR_COMPONENT_TITLE_DESCRIPTION') . ' : ' . $username); } } } else { // specific article if (is_null($userid)) { // all users/guests $document->setTitle(JText::_('COM_KOMENTO_FEEDS_COMMENTS_FOR_COMPONENT_OF_ARTICLE_TITLE') . ' : ' . Komento::loadApplication($component)->getComponentName() . ' : ' . $contentTitle); $document->setDescription(JText::_('COM_KOMENTO_FEEDS_COMMENTS_FOR_COMPONENT_OF_ARTICLE_TITLE_DESCRIPTION')); } else { if ($userid === 0) { // for all guest $userid = 0 $document->setTitle(JText::_('COM_KOMENTO_FEEDS_GUEST_COMMENTS_FOR_COMPONENT_OF_ARTICLE_TITLE') . ' : ' . Komento::loadApplication($component)->getComponentName() . ' : ' . $contentTitle); $document->setDescription(JText::_('COM_KOMENTO_FEEDS_GUEST_COMMENTS_FOR_COMPONENT_OF_ARTICLE_TITLE_DESCRIPTION')); } else { // specific user $document->setTitle(JText::_('COM_KOMENTO_FEEDS_COMMENTS_FROM_USER_FOR_COMPONENT_TITLE_OF_ARTICLE') . ' : ' . $username . ' : ' . Komento::loadApplication($component)->getComponentName() . ' : ' . $contentTitle); $document->setDescription(JText::_('COM_KOMENTO_FEEDS_COMMENTS_FROM_USER_FOR_COMPONENT_TITLE_OF_ARTICLE_DESCRIPTION') . ' : ' . $username); } } } } $options = array('sort' => 'latest', 'limit' => $config->get('rss_max_items'), 'userid' => $userid === null ? 'all' : $userid, 'threaded' => 0); $commentsModel = Komento::getModel('comments'); $comments = $commentsModel->getComments($component, $cid, $options); if (!empty($comments)) { foreach ($comments as $row) { $row = Komento::getHelper('comment')->process($row); // Todo : configurable $title = 'Comment - ' . $row->created; // Assign to feed item $item = new JFeedItem(); $item->title = $title; $item->link = $row->permalink; $item->description = $row->comment; $item->date = $row->unformattedDate; $item->author = $row->name; $item->authorEmail = $row->email; $document->addItem($item); } } }
public static function getRules( $userId, $component = 'com_content' ) { $signature = serialize( array( $userId, $component ) ); if( empty( self::$rules[$signature] ) ) { $profile = Komento::getProfile( $userId ); $model = Komento::getModel( 'acl' ); $data = array(); // check user group specific rules $gids = $profile->getUsergroups(); foreach( $gids as $gid ) { $data[] = $model->getAclObject( $gid, 'usergroup', $component ); } // check user specific rules $data[] = $model->getAclObject( $userId, 'user', $component ); // remove empty set foreach( $data as $key => $value ) { if( empty( $value ) ) { unset( $data[$key] ); } } if( count( $data ) < 1 ) { $data[] = KomentoACLHelper::getEmptySet( true ); } self::$rules[$signature] = self::merge( $data ); } return self::$rules[$signature]; }
if (!Komento::getProfile($row->created_by)->guest) { ?> <a href="<?php echo Komento::getProfile($row->created_by)->getProfileLink(); ?> "> <img src="<?php echo Komento::getProfile($row->created_by)->getAvatar($row->email); ?> " class="avatar" width="30" /> </a> <?php } else { ?> <img src="<?php echo Komento::getProfile($row->created_by)->getAvatar($row->email); ?> " class="avatar" width="30" /> <?php } ?> </div> <?php } ?> <!-- Author --> <?php if ($params->get('showauthor')) { ?> <?php
<ul class="kmt-form-author reset-ul float-li clearfix"> <?php // Name field li.kmt-form-name echo $this->fetch('comment/form/namefield.php'); // Email field li.kmt-form-email echo $this->fetch('comment/form/emailfield.php'); // Website field li.kmt-form-website echo $this->fetch('comment/form/websitefield.php'); ?> </ul> <?php } ?> <?php if (!Komento::getProfile()->guest) { ?> <div class="kmt-form-author clearfix"> <?php // Avatar div.kmt-avatar echo $this->fetch('comment/form/avatar.php'); // Author div.kmt-comment-detail echo $this->fetch('comment/form/author.php'); ?> </div> <?php } ?> <div class="kmt-form-content"> <?php
function getLikedUsers( $id ) { $query = 'SELECT * FROM ' . $this->db->nameQuote( '#__komento_actions' ); $query .= ' WHERE ' . $this->db->nameQuote( 'comment_id' ) . ' = ' . $this->db->quote( $id ); $query .= ' AND ' . $this->db->nameQuote( 'type' ) . ' = ' . $this->db->quote( 'likes' ); $this->db->setQuery( $query ); $result = $this->db->loadObjectList(); foreach( $result as &$row ) { $row->author = Komento::getProfile( $row->action_by ); } return $result; }
private function prepareData( $type = 'new', $options ) { Komento::import( 'helper', 'date' ); $data = array(); if( $type === 'confirm' ) { $subscribeTable = Komento::getTable( 'subscription' ); $subscribeTable->load( $options['subscribeId'] ); $profile = Komento::getProfile( $subscribeTable->userid ); } else { $profile = Komento::getProfile( $options['comment']->created_by ); $data['contentTitle'] = $options['comment']->contenttitle; $data['contentPermalink'] = $options['comment']->pagelink; $data['commentAuthorName'] = $options['comment']->name; $data['commentAuthorAvatar'] = $profile->getAvatar(); } $config = Komento::getConfig(); switch( $type ) { case 'confirm': $data['confirmLink'] = rtrim( JURI::root() , '/' ) . '/index.php?option=com_komento&task=confirmSubscription&id=' . $options['subscribeId']; break; case 'pending': case 'moderate': $hashkeys = Komento::getTable( 'hashkeys' ); $hashkeys->uid = $options['comment']->id; $hashkeys->type = 'comment'; $hashkeys->store(); $key = $hashkeys->key; $data['approveLink'] = rtrim( JURI::root() , '/' ) . '/index.php?option=com_komento&task=approveComment&token=' . $key; $data['commentContent'] = JFilterOutput::cleanText($options['comment']->comment); $date = KomentoDateHelper::dateWithOffSet( $options['comment']->unformattedDate ); $date = KomentoDateHelper::toFormat( $date , $config->get( 'date_format' , '%A, %B %e, %Y' ) ); $data['commentDate'] = $date; break; case 'report': $action = Komento::getTable( 'actions' ); $action->load( $options['actionId'] ); $actionUser = $action->action_by; $data['actionUser'] = Komento::getProfile( $actionUser ); $data['commentPermalink'] = $data['contentPermalink'] . '#kmt-' . $options['comment']->id; $data['commentContent'] = JFilterOutput::cleanText($options['comment']->comment); $date = KomentoDateHelper::dateWithOffSet( $options['comment']->unformattedDate ); $date = KomentoDateHelper::toFormat( $date , $config->get( 'date_format' , '%A, %B %e, %Y' ) ); $data['commentDate'] = $date; break; case 'reply': case 'comment': case 'new': default: $data['commentPermalink'] = $data['contentPermalink'] . '#kmt-' . $options['comment']->id; $data['commentContent'] = JFilterOutput::cleanText($options['comment']->comment); $date = KomentoDateHelper::dateWithOffSet( $options['comment']->unformattedDate ); $date = KomentoDateHelper::toFormat( $date , $config->get( 'date_format' , '%A, %B %e, %Y' ) ); $data['commentDate'] = $date; $data['unsubscribe'] = rtrim( JURI::root(), '/' ) . '/index.php?option=com_komento&task=unsubscribe&id='; break; } return $data; }
/** * @package Komento * @copyright Copyright (C) 2012 Stack Ideas Private Limited. All rights reserved. * @license GNU/GPL, see LICENSE.php * Komento 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( 'enable_info' ) && $row->modified_by ) { ?> <span class="commentInfo kmt-info"> <?php $modified = $row->modified; if( $system->config->get( 'enable_lapsed_time' ) ) { $modified = Komento::getHelper( 'date' )->getLapsedTime( $row->modified ); } ?> <?php echo JText::sprintf( 'COM_KOMENTO_COMMENT_EDITTED_BY', $modified, Komento::getProfile( $row->modified_by )->getName() ); ?> <!-- Extended data for schema purposes --> <?php if( $system->konfig->get( 'enable_schema' ) ) { ?> <span class="hidden" itemprop="editor" itemscope itemtype="http://schema.org/Person"> <span itemprop="name"><?php echo Komento::getProfile( $row->modified_by )->getName(); ?></span> </span> <time class="hidden" itemprop="dateModified" datetime="<?php echo $this->formatDate( 'c', $row->modified ); ?>"></time> <?php } ?> </span> <?php } else { ?> <span class="commentInfo kmt-info hidden"></span> <?php }
<!-- Permalink --> <li class="kmt-permalink"><a href="<?php echo Komento::loadApplication( $row->component )->load( $row->cid )->getContentPermalink() . '#kmt-' . $row->id; ?>"><?php echo JText::_( 'COM_KOMENTO_COMMENT_PERMALINK' ) ; ?></a></li> </ul> <div class="kmt-body"> <?php // parseBBcode to HTML $row->comment = KomentoCommentHelper::parseBBCode($row->comment); $row->comment = nl2br($row->comment); ?> <span class="kmt-text"><?php echo $row->comment; ?></span> </div> <ul class="kmt-info"> <?php if($row->modified_by != 0) { ?> <li> Comment last edited on <?php echo $row->modified; ?> by <?php echo Komento::getProfile($row->modified_by)->getName(); ?> </li> <?php } ?> </ul> <div class="kmt-control"> <ul class="kmt-control-admin"> <li> <?php if( $system->my->allow( 'publish_all_comment', $row->component ) || ( $row->created_by == $system->my->id && $system->my->allow( 'publish_own_comment', $row->component ) ) ) { ?> <a href="javascript:void(0);" class="kmt-status"> <?php } ?> <?php switch ($row->published) { case 0: echo JText::_( 'COM_KOMENTO_UNPUBLISHED' );
/** * This is the heart of Komento that does magic * * @param $component string * @param $article object * @param $options array * @return null */ public static function commentify($component, &$article, $options = array()) { $eventTrigger = null; $context = null; $params = array(); $page = 0; if (array_key_exists('trigger', $options)) { $eventTrigger = $options['trigger']; } if (array_key_exists('context', $options)) { $context = $options['context']; } if (array_key_exists('params', $options)) { $params = $options['params']; } if (array_key_exists('page', $options)) { $page = $options['page']; } // TODO: Allow string/int: see line 662 // Sometimes people pass in $article as an array, we convert it to object if (is_array($article)) { $article = (object) $article; } // Check if there is a valid component if (empty($component)) { return false; } // @task: prepare data and checking on plugin level $application = Komento::loadApplication($component); // We verify context and trigger first before going into onBeforeLoad because onBeforeLoad already expects the article to be what Komento want to integrate // @task: verify if context is correct if (!Komento::verifyContext($context, $application->getContext())) { return false; } // @task: verify if event trigger is correct if (!Komento::verifyEventTrigger($eventTrigger, $application->getEventTrigger())) { return false; } // @trigger: onBeforeLoad // we do this checking before load because in some cases, // article is not an object and the article id might be missing. if (!$application->onBeforeLoad($eventTrigger, $context, $article, $params, $page, $options)) { return false; } // @task: set the component self::setCurrentComponent($component); // @task: get all the configuration $config = self::getConfig($component); $konfig = Komento::getKonfig(); // @task: check if enabled if (!$config->get('enable_komento')) { return false; } // @task: disable Komento in tmpl=component mode such as print mode if ($config->get('disable_komento_on_tmpl_component') && JRequest::getString('tmpl', '') === 'component') { return false; } // We accept $article as an int // For $article as a string, onBeforeLoad should already prepare the $article object properly if (is_string($article) || is_int($article)) { $cid = $article; } else { // @task: set cid based on application mapping keys because some component might have custom keys (not necessarily always $article-id) $cid = $article->{$application->_map['id']}; } // Don't proceed if $cid is empty if (empty($cid)) { return false; } // @task: process in-content parameters self::processParameter($article, $options); // terminate if it's disabled if ($options['disable']) { if (!$application->onParameterDisabled($eventTrigger, $context, $article, $params, $page, $options)) { return false; } } // @task: loading article infomation with defined get methods if (!$application->load($cid)) { return false; } // If enabled flag exists, bypass category check if (array_key_exists('enable', $options) && !$options['enable']) { // @task: category access check $categories = $config->get('allowed_categories'); // no categories mode switch ($config->get('allowed_categories_mode')) { // selected categories case 1: if (empty($categories)) { return false; } else { // @task: For some reason $article->catid might not be set. If it it's not set, just return false. $catid = $application->getCategoryId(); if (!$catid) { if (!$application->onRollBack($eventTrigger, $context, $article, $params, $page, $options)) { // raise error } return false; } if (!is_array($categories)) { $categories = explode(',', $categories); } if (!in_array($catid, $categories)) { if (!$application->onRollBack($eventTrigger, $context, $article, $params, $page, $options)) { // raise error } return false; } } break; // except selected categories // except selected categories case 2: if (!empty($categories)) { // @task: For some reason $article->catid might not be set. If it it's not set, just return false. $catid = $application->getCategoryId(); if (!$catid) { if (!$application->onRollBack($eventTrigger, $context, $article, $params, $page, $options)) { // raise error } return false; } if (!is_array($categories)) { $categories = explode(',', $categories); } if (in_array($catid, $categories)) { if (!$application->onRollBack($eventTrigger, $context, $article, $params, $page, $options)) { // raise error } return false; } } break; // no categories // no categories case 3: return false; break; // all categories // all categories case 0: default: break; } } // @trigger: onAfterLoad // Now the article with id has been loaded. if (!$application->onAfterLoad($eventTrigger, $context, $article, $params, $page, $options)) { return false; } // @task: send mail on page load if ($config->get('notification_sendmailonpageload')) { self::getMailQueue()->sendOnPageLoad(); } // @task: clear captcha database if ($konfig->get('database_clearcaptchaonpageload')) { self::clearCaptcha(); } // @task: load necessary css and javascript files. self::getHelper('Document')->loadHeaders(); /**********************************************/ // Run Komento! $commentsModel = Komento::getModel('comments'); $comments = ''; $return = false; $commentCount = $commentsModel->getCount($component, $cid); // Get total ratings $ratings = $commentsModel->getOverallRatings($component, $cid); $totalRating = 0; $totalRatingCount = 0; if ($ratings) { $totalRating = $ratings->value; $totalRatingCount = $ratings->total; } if ($application->isListingView()) { $html = ''; if (!array_key_exists('skipBar', $options)) { $commentOptions = array(); $commentOptions['threaded'] = 0; $commentOptions['limit'] = $config->get('preview_count', '3'); $commentOptions['sort'] = $config->get('preview_sort', 'latest'); $commentOptions['parentid'] = $config->get('preview_parent_only', false) ? 0 : 'all'; $commentOptions['sticked'] = $config->get('preview_sticked_only', false) ? true : 'all'; if ($commentOptions['sort'] == 'popular') { $comments = $commentsModel->getPopularComments($component, $cid, $commentOptions); } else { $comments = $commentsModel->getComments($component, $cid, $commentOptions); } $theme = Komento::getTheme(); $theme->set('commentCount', $commentCount); $theme->set('componentHelper', $application); $theme->set('component', $component); $theme->set('cid', $cid); $theme->set('comments', $comments); $theme->set('article', $article); $html = $theme->fetch('comment/bar.php'); } $return = $application->onExecute($article, $html, 'listing', $options); } if ($application->isEntryView()) { // check for escaped_fragment (google ajax crawler) $fragment = JRequest::getVar('_escaped_fragment_', ''); if ($fragment != '') { $tmp = explode('=', $fragment); $fragment = array($tmp[0] => $tmp[1]); if (isset($fragment['kmt-start'])) { $options['limitstart'] = $fragment['kmt-start']; } } else { // Sort comments oldest first by default. if (!isset($options['sort'])) { $options['sort'] = JRequest::getVar('kmt-sort', $config->get('default_sort')); } if ($config->get('load_previous')) { $options['limitstart'] = $commentCount - $config->get('max_comments_per_page'); if ($options['limitstart'] < 0) { $options['limitstart'] = 0; } } } $options['threaded'] = $config->get('enable_threaded'); $profile = Komento::getProfile(); $my = JFactory::getUser(); if (!$profile->allow('read_others_comment')) { $options['userid'] = $my->id; } if ($profile->allow('read_comment')) { $comments = $commentsModel->getComments($component, $cid, $options); } $contentLink = $application->getContentPermalink(); $theme = Komento::getTheme(); $theme->set('totalRating', $totalRating); $theme->set('totalRatingCount', $totalRatingCount); $theme->set('component', $component); $theme->set('cid', $cid); $theme->set('comments', $comments); $theme->set('options', $options); $theme->set('componentHelper', $application); $theme->set('application', $application); $theme->set('commentCount', $commentCount); $theme->set('contentLink', $contentLink); $html = $theme->fetch('comment/box.php'); /* [KOMENTO_POWERED_BY_LINK] */ // free version powered by link append (for reference only) // $html .= '<div style="text-align: center; padding: 20px 0;"><a href="http://stackideas.com">' . JText::_( 'COM_KOMENTO_POWERED_BY_KOMENTO' ) . '</a></div>'; $return = $application->onExecute($article, $html, 'entry', $options); // @task: Append hidden token into the page. $return .= '<span id="komento-token" style="display:none;"><input type="hidden" name="' . Komento::_('getToken') . '" value="1" /></span>'; } return $return; }
echo $params->get('moduleclass_sfx'); ?> "> <?php foreach ($activities as $activity) { $activity->comment = Komento::getComment($activity->comment_id, $process = true); $activity->comment->comment = strip_tags($activity->comment->comment); // trim comment length if (JString::strlen($activity->comment->comment) > $params->get('maxcommentlength')) { $activity->comment->comment = JString::substr($activity->comment->comment, 0, $params->get('maxcommentlength')) . '...'; } // trim title length if (JString::strlen($activity->comment->contenttitle) > $params->get('maxtitlelength')) { $activity->comment->contenttitle = JString::substr($activity->comment->contenttitle, 0, $params->get('maxtitlelength')) . '...'; } $profile = Komento::getProfile($activity->uid); $config = Komento::getConfig($activity->comment->component); if ($activity->uid != 0 && $profile->id != $activity->uid && $config->get('enable_orphanitem_convert')) { $table = Komento::getTable('activities'); $table->load($activity->id); $table->uid = $config->get('orphanitem_ownership'); $table->store(); $activity->uid = $config->get('orphanitem_ownership'); } ?> <div class="mod-item stream kmt-activity-<?php echo $activity->id; ?> "> <div class="stream-head stream-<?php echo $activity->type;
<?php /** * @package Komento * @copyright Copyright (C) 2012 Stack Ideas Private Limited. All rights reserved. * @license GNU/GPL, see LICENSE.php * * Komento 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('layout_avatar_enable')) { ?> <div class="kmt-avatar"> <a href="<?php echo Komento::getProfile()->getProfileLink(); ?> "> <img src="<?php echo Komento::getProfile()->getAvatar(); ?> " class="avatar" alt="" /> </a> </div> <?php }
public function save() { $config = Komento::getConfig(); // Create the comment table object $commentsModel = Komento::getModel( 'comments' ); $commentTable = Komento::getTable( 'Comments' ); $commentTable->bind($this->getProperties()); // empty name, email defaults to user // or if guest, then default empty name to 'Guest' $profile = Komento::getProfile(); $now = Komento::getDate()->toMySQL(); // @rule: Determine if this record is new or not. $isNew = ( empty( $this->id ) ) ? true : false; // Trigger onBeforeSaveComment( $this->component, $this->cid, &$this ) $triggerResult = Komento::trigger( 'onBeforeSaveComment', array( 'component' => $this->component, 'cid' => $this->cid, 'comment' => &$this ) ); if( $triggerResult === false ) { $this->setError( 'Trigger onBeforeSaveComment false' ); return false; } if( !$commentTable->store() ) { $this->setError( 'Comment save failed' ); return false; } $this->id = $commentTable->id; // Trigger onAfterSaveComment( $this->component, $this->cid, &$this ) Komento::trigger( 'onAfterSaveComment', array( 'component' => $this->component, 'cid' => $this->cid, 'comment' => &$this ) ); // Add activity $action = $commentTable->parent_id ? 'reply' : 'comment'; $activity = Komento::getHelper( 'activity' )->process( $action, $commentTable->id ); // Send notifications if( $config->get( 'notification_enable' ) ) { if( $commentTable->published == 1 && $isNew && ( ( $action == 'comment' && $config->get( 'notification_event_new_comment' ) ) || ( $action == 'reply' && $config->get( 'notification_event_new_reply' ) ) ) ) { Komento::getHelper( 'Notification' )->push( $action, 'subscribers,author,usergroups', array( 'commentId' => $this->id ) ); } if( $commentTable->published == 2 && $config->get( 'notification_event_new_pending' ) ) { Komento::getHelper( 'Notification' )->push( 'pending', 'author,usergroups', array( 'commentId' => $this->id ) ); } } return true; }
<?php /** * @package Komento * @copyright Copyright (C) 2012 Stack Ideas Private Limited. All rights reserved. * @license GNU/GPL, see LICENSE.php * * Komento 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' ); ?> <div class="kmt-author-detail"> <h3 class="kmt-author"> <a href="<?php echo Komento::getProfile()->getProfileLink(); ?>"> <?php echo $system->my->getName(); ?> </a> </h3> <br /> <span class="kmt-author-time"><?php echo Komento::getDate()->toFormat('%A, %B %d, %Y') ?></span> </div>
?> </b> </a> </li> <?php } ?> <!-- No avatar mode --> <?php } else { ?> <!-- Render registered user --> <?php foreach ($authors->registered as $item) { $authorProfile = Komento::getProfile($item->created_by); ?> <li> <a href="<?php echo $authorProfile->getProfileLink(); ?> "><?php echo $authorProfile->getName(); ?> </a> </li> <?php } ?> <!-- Render guests (if settings set to not include guest, then guest will be empty) -->
<?php if (!Komento::getProfile($row->created_by)->guest) { ?> <a href="<?php echo Komento::getProfile($row->created_by)->getProfileLink(); ?> "> <?php } ?> <img src="<?php echo Komento::getProfile($row->created_by)->getAvatar($row->email); ?> " class="avatar" width="30" /> <?php if (!Komento::getProfile($row->created_by)->guest) { ?> </a> <?php } ?> </div> <?php } ?> <!-- Author --> <?php if ($params->get('showauthor')) { ?> <?php
/** * Process comments data **/ public static function process($row, $admin = 0) { if (isset($row->processed) && $row->processed) { return $row; } Komento::setCurrentComponent($row->component); $config = Komento::getConfig(); $konfig = Komento::getKonfig(); $user = JFactory::getUser()->id; $commentsModel = Komento::getModel('comments'); Komento::import('helper', 'date'); // Duplicate created date first before lapsed time messing up the original date $row->unformattedDate = $row->created; // get number of child for each comment $row->childs = $commentsModel->getTotalChilds($row->id); // set url to proper url if (!empty($row->url)) { // Add 'http://' if not present $row->url = 0 === strpos($row->url, 'http') ? $row->url : 'http://' . $row->url; } // 1. Load article and article details $application = Komento::loadApplication($row->component)->load($row->cid); if ($application === false) { $application = Komento::getErrorApplication($row->component, $row->cid); } // set component title $row->componenttitle = $application->getComponentName(); // set content title $row->contenttitle = $application->getContentTitle(); // get permalink $row->pagelink = $application->getContentPermalink(); $row->permalink = $row->pagelink . '#kmt-' . $row->id; // set parentlink if ($row->parent_id != 0) { $row->parentlink = $row->pagelink . '#kmt-' . $row->parent_id; } // to be reassign $row->shortlink = $row->permalink; // set extension object // use this to check if application is able to load article details // if row->extension is false, means error loading article details $row->extension = $application; if ($admin == 0) { // frontend $actionsModel = Komento::getModel('actions'); $socialHelper = Komento::getHelper('social'); // parse comments HTML $row->comment = self::parseComment($row->comment); // author's object $row->author = Komento::getProfile($row->created_by); // don't convert for guest if ($row->created_by != 0 && $row->created_by != $row->author->id) { if ($config->get('enable_orphanitem_convert')) { KomentoCommentHelper::convertOrphanitem($row->id); } } if ($row->created_by != 0) { switch ($config->get('name_type')) { case 'username': // force username $row->name = $row->author->getUsername(); break; case 'name': $row->name = $row->author->getName(); break; case 'default': default: // default name to profile if name is null if (empty($row->name)) { $row->name = $row->author->getName(); } break; } } else { if (empty($row->name)) { $row->name = JText::_('COM_KOMENTO_GUEST'); } else { if ($config->get('guest_label')) { $row->name = JText::_('COM_KOMENTO_GUEST') . ' - ' . $row->name; } } } // set datetime if ($config->get('enable_lapsed_time')) { $row->created = KomentoDateHelper::getLapsedTime($row->unformattedDate); } else { $dateformat = $config->get('date_format'); $row->created = KomentoDateHelper::toFormat(KomentoDateHelper::dateWithOffSet($row->created), $dateformat); // $row->created = Komento::getDate( $row->created )->toFormat( $dateformat ); } // get actions likes $row->likes = $actionsModel->countAction('likes', $row->id); // get user liked $row->liked = $actionsModel->liked($row->id, $user); // get user reported $row->reported = $actionsModel->reported($row->id, $user); } else { // backend // format comments $row->comment = nl2br(Komento::getHelper('comment')->parseBBCode($row->comment)); $row->created = KomentoDateHelper::dateWithOffSet($row->created); } $row->processed = true; return $row; }
$helper = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_komento' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'helper.php'; if( !JFile::exists( $helper ) ) { return; } // load all dependencies require_once( $helper ); // KomentoDocumentHelper::loadHeaders(); KomentoDocumentHelper::load( 'module', 'css', 'assets' ); JFactory::getLanguage()->load( 'com_komento' , JPATH_ROOT ); // initialise all data $profile = Komento::getProfile(); $config = Komento::getConfig(); $konfig = Komento::getKonfig(); /* $params limit component sort = latest/likes filtersticked showtitle showcomponent showavatar showauthor lapsedtime maxcommenttext maxtitletext */
public function process( $action, $comment ) { // process all activities and 3rd party integration here // Due to the possible conflict data of $comment->created containing lapsed time instead of raw date, we use the table object directly instead if( !( $comment instanceof KomentoTableComments ) ) { $id = 0; if( is_int( $comment ) || is_string( $comment ) ) { $id = $comment; } if( $comment instanceof KomentoComment ) { $id = $comment->id; } $comment = Komento::getTable( 'comments' ); $comment->load( $id ); } if( $action != 'remove' && $comment->published != 1 ) { return false; } $config = Komento::getConfig(); $profile = Komento::getProfile(); $application = Komento::loadApplication( $comment->component )->load( $comment->cid ); if( $application === false) { $application = Komento::getErrorApplication( $comment->component, $comment->cid ); } $pagelink = $application->getContentPermalink(); $permalink = $pagelink . '#' . $comment->id; $author = $application->getAuthorId(); $title = $application->getContentTitle(); if( $profile->id == 0 ) { return false; } // native activity if( ( $action == 'comment' && $config->get( 'activities_comment' ) ) || ( $action == 'reply' && $config->get( 'activities_reply' ) ) || ( $action == 'like' && $config->get( 'activities_like' ) ) ) { $this->addActivity( $action, $comment->id, $comment->created_by ); } // Add jomsocial activity if( $action == 'comment' && $config->get( 'jomsocial_enable_comment' ) ) { $this->addJomSocialActivityComment( $comment ); } if( $action == 'reply' && $config->get( 'jomsocial_enable_reply' ) ) { $this->addJomSocialActivityReply( $comment ); } if( $action == 'like' && $config->get( 'jomsocial_enable_like' ) ) { $this->addJomSocialActivityLike( $comment, $profile->id ); } // Add jomsocial userpoints if( $config->get( 'jomsocial_enable_userpoints' ) ) { switch( $action ) { case 'comment': Komento::addJomSocialPoint( 'com_komento.comment.add' ); Komento::addJomSocialPoint( 'com_komento.comment.add.author', $author ); break; case 'reply': Komento::addJomSocialPoint( 'com_komento.comment.reply' ); break; case 'like': Komento::addJomSocialPoint( 'com_komento.comment.like' ); Komento::addJomSocialPoint( 'com_komento.comment.liked', $comment->created_by ); break; case 'unlike': Komento::addJomSocialPoint( 'com_komento.comment.unlike' ); Komento::addJomSocialPoint( 'com_komento.comment.unliked', $comment->created_by ); break; case 'report': Komento::addJomSocialPoint( 'com_komento.comment.report' ); Komento::addJomSocialPoint( 'com_komento.comment.reported', $comment->created_by ); break; case 'unreported': Komento::addJomSocialPoint( 'com_komento.comment.unreport' ); Komento::addJomSocialPoint( 'com_komento.comment.unreported', $comment->created_by ); break; case 'stick': Komento::addJomSocialPoint( 'com_komento.comment.sticked' ); break; case 'unstick': Komento::addJomSocialPoint( 'com_komento.comment.unsticked' ); break; case 'remove': Komento::addJomSocialPoint( 'com_komento.comment.removed' ); Komento::addJomSocialPoint( 'com_komento.comment.removed.author', $author ); break; } } // Add aup if( $config->get( 'enable_aup' ) ) { switch( $action ) { case 'comment': Komento::addAUP( 'plgaup_komento_post_comment', $comment->created_by, 'komento_post_comment_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_POST_COMMENT', $permalink, $title ) ); Komento::addAUP( 'plgaup_komento_add_comment_author', $author, 'komento_post_comment_on_' . $comment->component . '_' . $comment->cid, JText::sprintf( 'COM_KOMENTO_AUP_POST_COMMENT', $permalink, $title ) ); break; case 'reply': Komento::addAUP( 'plgaup_komento_reply_comment', $comment->created_by, 'komento_reply_comment_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_REPLY_COMMENT', $permalink, $title ) ); break; case 'like': Komento::addAUP( 'plgaup_komento_like_comment', $profile->id, 'komento_like_comment_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_LIKE_COMMENT', $permalink, $title ) ); Komento::addAUP( 'plgaup_komento_comment_liked', $comment->created_by, 'komento_comment_liked_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_COMMENT_LIKED', $permalink, $title ) ); break; case 'unlike': Komento::addAUP( 'plgaup_komento_unlike_comment', $profile->id, 'komento_unlike_comment_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_UNLIKE_COMMENT', $permalink, $title ) ); Komento::addAUP( 'plgaup_komento_comment_unliked', $comment->created_by, 'komento_comment_unliked_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_COMMENT_UNLIKED', $permalink, $title ) ); break; case 'report': Komento::addAUP( 'plgaup_komento_report_comment', $profile->id, 'komento_report_comment_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_REPORT_COMMENT', $permalink, $title ) ); Komento::addAUP( 'plgaup_komento_comment_reported', $comment->created_by, 'komento_comment_reported_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_COMMENT_REPORTED', $permalink, $title ) ); break; case 'unreport': Komento::addAUP( 'plgaup_komento_unreport_comment', $profile->id, 'komento_unreport_comment_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_UNREPORT_COMMENT', $permalink, $title ) ); Komento::addAUP( 'plgaup_komento_comment_unreported', $comment->created_by, 'komento_comment_unreported_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_COMMENT_UNREPORTED', $permalink, $title ) ); break; case 'stick': Komento::addAUP( 'plgaup_komento_comment_sticked', $comment->created_by, 'komento_comment_sticked_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_COMMENT_STICKED', $permalink, $title ) ); break; case 'unstick': Komento::addAUP( 'plgaup_komento_comment_unsticked', $comment->created_by, 'komento_comment_unsticked_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_COMMENT_UNSTICKED', $permalink, $title ) ); break; case 'remove': Komento::addAUP( 'plgaup_komento_comment_removed', $comment->created_by, 'komento_comment_removed_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_COMMENT_REMOVED', $pagelink, $title ) ); Komento::addAUP( 'plgaup_komento_remove_comment_author', $author, 'komento_remove_comment_on_' . $comment->component . '_' . $comment->cid, JText::sprintf( 'COM_KOMENTO_AUP_REMOVED_COMMENT_AUTHOR', $pagelink, $title ) ); break; } } // Add Discuss points if( $config->get( 'enable_discuss_points' ) ) { switch( $action ) { case 'comment': Komento::addDiscussPoint( 'komento.add.comment', $comment->created_by, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_ADD_COMMENT', $title ) ); Komento::addDiscussPoint( 'komento.add.comment.article.author', $author, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_ADD_COMMENT_ARTICLE_AUTHOR', $title ) ); break; case 'reply': Komento::addDiscussPoint( 'komento.reply.comment', $comment->created_by, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_REPLY_COMMENT', $title ) ); break; case 'like': Komento::addDiscussPoint( 'komento.like.comment', $profile->id, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_LIKE_COMMENT', $title ) ); Komento::addDiscussPoint( 'komento.comment.liked', $comment->created_by, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_COMMENT_LIKED', $title ) ); break; case 'unlike': Komento::addDiscussPoint( 'komento.unlike.comment', $profile->id, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_UNLIKE_COMMENT', $title ) ); Komento::addDiscussPoint( 'komento.comment.unliked', $comment->created_by, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_COMMENT_UNLIKED', $title ) ); break; case 'report': Komento::addDiscussPoint( 'komento.report.comment', $profile->id, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_REPORT_COMMENT', $title ) ); Komento::addDiscussPoint( 'komento.comment.reported', $comment->created_by, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_COMMENT_REPORTED', $title ) ); break; case 'unreport': Komento::addDiscussPoint( 'komento.unreport.comment', $profile->id, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_UNREPORT_COMMENT', $title ) ); Komento::addDiscussPoint( 'komento.comment.unreported', $comment->created_by, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_COMMENT_UNREPORTED', $title ) ); break; case 'stick': Komento::addDiscussPoint( 'komento.comment.sticked', $comment->created_by, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_COMMENT_STICKED', $title ) ); break; case 'unstick': Komento::addDiscussPoint( 'komento.comment.unsticked', $comment->created_by, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_COMMENT_UNSTICKED', $title ) ); break; case 'remove': Komento::addDiscussPoint( 'komento.comment.removed', $comment->created_by, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_COMMENT_REMOVED', $title ) ); Komento::addDiscussPoint( 'komento.remove.comment.article.author', $author, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_REMOVE_COMMENT_ARTICLE_AUTHOR', $title ) ); break; } } if( $config->get( 'enable_easysocial_points' ) ) { $es = Komento::getHelper( 'EasySocial' ); switch( $action ) { case 'comment': $es->assignPoints( 'komento.add.comment' , $comment->created_by, $comment); //Add points to user when a user post a comment. $es->assignPoints( 'komento.add.comment.article.author' , $author, $comment); //Add points for article author when a user posts a new comment on that article. break; case 'reply': $es->assignPoints( 'komento.reply.comment', $comment->created_by, $comment); //Add points to user when a user reply to a comment. break; case 'like': $es->assignPoints( 'komento.like.comment' , $profile->id ); //Add points to user when a user likes a comment. $es->assignPoints( 'komento.comment.liked' , $comment->created_by ); //Add points to comment author when a user likes the comment. *? break; case 'unlike': $es->assignPoints( 'komento.unlike.comment' , $profile->id ); //Add points to user when a user unlikes a comment. $es->assignPoints( 'komento.comment.unliked' , $comment->created_by ); //Deduct points to comment author when a user unlike the comment. break; case 'report': $es->assignPoints( 'komento.report.comment' , $profile->id ); // Add points to user when a user reports a comment. $es->assignPoints( 'komento.comment.reported' , $comment->created_by ); //Deduct points to comment author when a comment is reported. break; case 'unreport': $es->assignPoints( 'komento.unreport.comment' , $profile->id ); // Deduct points to user when a user unreports a comment. $es->assignPoints( 'komento.comment.unreported' , $comment->created_by ); //Add points to comment author when a comment is unreported. break; case 'stick': $es->assignPoints( 'komento.comment.sticked' , $comment->created_by ); //Add points to comment author when a comment is sticked. break; case 'unstick': $es->assignPoints( 'komento.comment.unsticked' , $comment->created_by ); //Deduct points to comment author when a comment is unsticked. break; case 'remove': $es->assignPoints( 'komento.comment.removed' , $comment->created_by ); //Deduct points to comment author when a comment is removed. $es->assignPoints( 'komento.remove.comment.article.author' , $author ); //Deduct points for article author when a comment is removed from that article. break; case 'upload': $es->assignPoints( 'komento.upload.attachments' , $comment->created_by ); //Deduct points to comment author when a comment is removed. break; } } if( $config->get( 'enable_easysocial_badges' ) ) { $es = Komento::getHelper( 'EasySocial' ); switch( $action ) { case 'comment': $es->assignBadge( 'komento.add.comment', JText::_( 'COM_KOMENTO_EASYSOCIAL_BADGES_ADD_COMMENTS_MESSAGE' ) ); break; case 'reply': $es->assignBadge( 'komento.reply.comment', JText::_( 'COM_KOMENTO_EASYSOCIAL_BADGES_REPLY_COMMENTS_MESSAGE' ) ); break; case 'like': $es->assignBadge( 'komento.like.comment', JText::_( 'COM_KOMENTO_EASYSOCIAL_BADGES_LIKE_COMMENTS_MESSAGE' ) ); break; case 'report': $es->assignBadge( 'komento.report.comment', JText::_( 'COM_KOMENTO_EASYSOCIAL_BADGES_REPORT_COMMENTS_MESSAGE' ) ); break; case 'upload': $es->assignBadge( 'komento.upload.attachments', JText::_( 'COM_KOMENTO_EASYSOCIAL_BADGES_UPLOAD_COMMENTS_MESSAGE' ) ); break; } } if( $config->get( 'notification_es_enable' ) && ( $config->get( 'notification_es_event_new_' . $action ) ) ) { $es = Komento::getHelper( 'EasySocial' ); $es->notify( $action, $comment ); } // If action is reply and sync comment is on, then we don't create a stream // If comment params->source is from com_easysocial, then we don't create a stream if( ( ( in_array( $action, array( 'comment', 'like' ) ) && $config->get( 'enable_easysocial_stream_' . $action ) ) || $action === 'reply' && !$config->get( 'enable_easysocial_sync_comment' ) ) && ( empty( $comment->params->source ) || $comment->params->source !== 'com_easysocial' ) ) { $es = Komento::getHelper( 'EasySocial' ); $es->createStream( $action, $comment ); } if( $action === 'reply' && $config->get( 'enable_easysocial_sync_comment' ) && empty( $comment->params->social->source ) ) { $es = Komento::getHelper( 'EasySocial' ); $es->injectComment( $comment ); } if( $action === 'remove' && $config->get( 'enable_easysocial_sync_comment' ) ) { $es = Komento::getHelper( 'EasySocial' ); $es->removeComment( $comment ); } if( $action === 'like' && $config->get( 'enable_easysocial_sync_like' ) ) { $es = Komento::getHelper( 'EasySocial' ); $es->injectLike( $comment ); } if( $action === 'unlike' && $config->get( 'enable_easysocial_sync_like' ) ) { $es = Komento::getHelper( 'EasySocial' ); $es->removeLike( $comment ); } }
public function subscribeUser() { $id = JRequest::getInt( 'user', null ); $component = JRequest::getCmd( 'component' ); $cid = JRequest::getCmd( 'cid' ); $user = Komento::getProfile( $id ); $state = $this->subscribe( 'comment', $component, $cid, 0, $id, $user->getName(), $user->email ); $ajax = Komento::getAjax(); if( $state ) { $ajax->success(); } else { $ajax->fail(); } $ajax->send(); }