public function getRule() { $component = Komento::getCurrentComponent(); $ip = KomentoIpHelper::getIP(); $rules = Komento::getModel( 'ipfilter' )->getRule( $component, $ip ); }
function display($tmpl = null) { $mainframe = JFactory::getApplication(); $commentsModel = Komento::getModel( 'comments' ); $cid = JRequest::getVar( 'cid', 'all' ); $filter['component'] = $mainframe->getUserStateFromRequest( 'com_komento.pending.filter_component', 'filter-component', 'all', 'string' ); $filter['sort'] = $mainframe->getUserStateFromRequest( 'com_komento.pending.filter_sort', 'filter-sort', 'latest', 'string' ); $filter['search'] = trim( JString::strtolower( $mainframe->getUserStateFromRequest( 'com_komento.pending.filter_search', 'filter-search', '', 'string' ) ) ); $options = array( 'limit' => 0, 'sort' => $filter['sort'], 'search' => $filter['search'], 'published' => 2, 'threaded' => 0 ); $comments = $commentsModel->getComments( $filter['component'], $cid, $options ); $pagination = $commentsModel->getPagination(); $components = $commentsModel->getUniqueComponents(); $theme = Komento::getTheme(); $theme->set( 'components', $components ); $theme->set( 'pagination', $pagination ); $theme->set( 'comments', $comments ); $theme->set( 'filter', $filter ); echo $theme->fetch('dashboard/pending.php'); }
public function form($tpl = null) { $user = JFactory::getUser(); $mainframe = JFactory::getApplication(); if (Komento::joomlaVersion() >= '1.6') { if (!$user->authorise('komento.manage.acl', 'com_komento')) { $mainframe->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error'); $mainframe->close(); } } $component = JRequest::getString('component', ''); if ($component == '') { $mainframe->redirect('index.php?option=com_komento&view=acl'); } $components = $this->getComponentState($component); $id = $mainframe->getUserStateFromRequest('com_komento.acl.id', 'id', '0'); $type = JRequest::getCmd('type', 'usergroup'); $usergroups = ''; if ($type == 'usergroup') { $usergroups = $this->getUsergroupState($id); } $type = JRequest::getCmd('type'); $id = JRequest::getInt('id'); $model = Komento::getModel('acl', true); $model->updateUserGroups($component); $rulesets = $model->getData($component, $type, $id); $this->assignRef('rulesets', $rulesets); $this->assignRef('component', $component); $this->assignRef('components', $components); $this->assignRef('type', $type); $this->assignRef('id', $id); $this->assignRef('usergroups', $usergroups); parent::display($tpl); }
function publish($publish = '1') { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); $task = $this->getTask(); if ($task === 'unpublish') { $publish = 0; } $comments = JRequest::getVar('cid', array(0), 'POST'); $message = ''; $type = 'message'; if (count($comments) <= 0) { $message = JText::_('COM_KOMENTO_COMMENTS_COMMENT_INVALID_ID'); $type = 'error'; } else { if ($publish) { $message = 'COM_KOMENTO_COMMENTS_COMMENT_PUBLISHED'; } else { $message = 'COM_KOMENTO_COMMENTS_COMMENT_UNPUBLISHED'; } $model = Komento::getModel('comments'); if (!$model->publish($comments, $publish)) { $message .= '_ERROR'; $type = 'error'; } $message = JText::_($message); } $this->setRedirect('index.php?option=com_komento&view=pending', $message, $type); }
private function doSave() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); $mainframe = JFactory::getApplication(); if (!JRequest::getMethod() == 'POST') { $mainframe->enqueueMessage(JText::_('COM_KOMENTO_ACL_STORE_INVALID_REQUEST', 'error')); return false; } // Unset unecessary post data. $post = JRequest::get('POST'); unset($post['task']); unset($post['option']); unset($post['c']); $token = Komento::_('getToken'); unset($post[$token]); // check the target component if (!$post['target_component']) { $mainframe->enqueueMessage(JText::_('COM_KOMENTO_ACL_MISSING_TARGET_COMPONENT')); return false; } // rememeber user's choice // $mainframe->setUserState('com_komento.acl.component', $post['target_component']); // Save post data $model = Komento::getModel('Acl', true); if (!$model->save($post)) { $mainframe->enqueueMessage(JText::_('COM_KOMENTO_ACL_STORE_ERROR', 'error')); return false; } $mainframe->enqueueMessage(JText::_('COM_KOMENTO_ACL_STORE_SUCCESS', 'message')); // Clear the component's cache $cache = JFactory::getCache('com_komento'); $cache->clean(); return true; }
public function purge() { JRequest::checkToken() or jexit('Invalid Token'); $app = JFactory::getApplication(); $model = Komento::getModel('Mailq', $backend = true); $model->purge(); $app->redirect('index.php?option=com_komento&view=mailq', JText::_('COM_KOMENTO_EMAILS_PURGED'), 'success'); }
/** * Renders the comment count for Komento * * @since 5.0 * @access public * @param string * @return */ public function getCount(EasyBlogPost $post) { if (!$this->exists()) { return; } $model = Komento::getModel('Comments'); $count = $model->getCount('com_easyblog', $post->id); return $count; }
function getComponentState($filter_component = '*') { $model = Komento::getModel('comments'); $components = $model->getUniqueComponents(); $component_state[] = JHTML::_('select.option', '*', '- ' . JText::_('COM_KOMENTO_ALL_COMPONENTS') . ' -'); foreach ($components as $component) { $component_state[] = JHTML::_('select.option', $component, $component); } return JHTML::_('select.genericlist', $component_state, 'filter_component', 'class="inputbox" size="1" onchange="submitform();"', 'value', 'text', $filter_component); }
function getComponentState($filter_component = '*') { $model = Komento::getModel('subscription'); $components = $model->getUniqueComponents(); $component_state[] = JHTML::_('select.option', '*', JText::_('COM_KOMENTO_ALL_COMPONENTS')); foreach ($components as $component) { $component_state[] = JHTML::_('select.option', $component, Komento::loadApplication($component)->getComponentName()); } return JHTML::_('select.genericlist', $component_state, 'filter_component', 'class="inputbox" .fa- onchange="submitform();"', 'value', 'text', $filter_component); }
public function getModel($name = null) { static $model = array(); $name = preg_replace('/[^A-Z0-9_]/i', '', trim($name)); if (!isset($model[$name])) { if (!$name) { $name = JRequest::getString('view', null); } $model[$name] = Komento::getModel($name, true); } return $model[$name]; }
function loadReplies() { $ajax = Komento::getAjax(); $model = Komento::getModel('comments'); $options['parent_id'] = JRequest::getInt('parentId'); $startCount = JRequest::getInt('startCount'); $commentsModel = Komento::getModel('comments'); $comments = $commentsModel->getData($options); $count = count($comments); $this->assign('comments', $comments); $this->assign('search', ''); $this->assign('startCount', $startCount); $this->assign('columns', Komento::getConfig('com_komento_comments_columns', false)); $html = $this->loadTemplate('list_' . $this->getTheme()); $ajax->success($html); $ajax->send(); }
public static function loadComments( $id, $component, $options = array() ) { $commentsModel = Komento::getModel( 'comments' ); $comments = $commentsModel->getComments( $component, $id, $options ); $commentsModel = Komento::getModel( 'comments' ); $commentCount = $commentsModel->getCount( $component, $id ); if( array_key_exists('raw', $options) ) { return $comments; } // @task: load necessary css and javascript files. Komento::getHelper( 'Document' )->loadHeaders(); $application = Komento::loadApplication( $component ); if( $application->load( $id ) === false ) { $application = Komento::getErrorApplication( $component, $id ); } $theme = Komento::getTheme(); $theme->set( 'component', $component ); $theme->set( 'cid', $id ); $theme->set( 'comments', $comments ); $theme->set( 'options', $options ); $theme->set( 'componentHelper', $application ); $theme->set( 'application', $application ); $theme->set( 'commentCount', $commentCount ); $contentLink = $application->getContentPermalink(); $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 $html; }
function display($tpl = null) { $document = JFactory::getDocument(); $user = JFactory::getUser(); $mainframe = JFactory::getApplication(); if (Komento::joomlaVersion() >= '1.6') { if (!$user->authorise('komento.manage.mailq', 'com_komento')) { $mainframe->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error'); $mainframe->close(); } } // Get data from the model $model = Komento::getModel('Mailq', true); $pagination = $model->getPagination(); $items = $model->getItems(); $this->assignRef('items', $items); $this->assignRef('pagination', $pagination); parent::display($tpl); }
function populateChildBoundaries($child, $parent_id) { $commentsModel = Komento::getModel('comments'); $latest = $commentsModel->getLatestComment($this->component, $this->cid, $parent_id); $parent = Komento::getTable('comments'); $parent->load($parent_id); //adding new child comment $lft = $parent->lft + 1; $rgt = $parent->lft + 2; $node = $parent->lft; if (!empty($latest)) { $lft = $latest->rgt + 1; $rgt = $latest->rgt + 2; $node = $latest->rgt; } $commentsModel->updateCommentSibling($this->component, $this->cid, $node); $child->lft = $lft; $child->rgt = $rgt; return $child; }
function remove() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); $subscribers = JRequest::getVar('cid', array(0), 'POST'); $message = ''; $type = 'message'; if (empty($subscribers)) { $message = JText::_('COM_KOMENTO_SUBSCRIBERS_SUBSCRIBER_INVALID_ID'); $type = 'error'; } else { $model = Komento::getModel('subscription'); if ($model->remove($subscribers)) { $message = JText::_('COM_KOMENTO_SUBSCRIBERS_SUBSCRIBER_REMOVED'); } else { $message = JText::_('COM_KOMENTO_SUBSCRIBERS_SUBSCRIBER_REMOVE_ERROR'); $type = 'error'; } } $this->setRedirect('index.php?option=com_komento&view=subscribers', $message, $type); }
function display($tmpl = null) { $mainframe = JFactory::getApplication(); $commentsModel = Komento::getModel( 'comments' ); $cid = JRequest::getVar( 'cid', 'all' ); $filter['component'] = $mainframe->getUserStateFromRequest( 'com_komento.reports.filter_component', 'filter-component', 'all', 'string' ); $filter['sort'] = $mainframe->getUserStateFromRequest( 'com_komento.reports.filter_sort', 'filter-sort', 'latest', 'string' ); $filter['search'] = trim( JString::strtolower( $mainframe->getUserStateFromRequest( 'com_komento.reports.filter_search', 'filter-search', '', 'string' ) ) ); $options = array( 'limit' => 0, 'sort' => $filter['sort'], 'search' => $filter['search'], 'published' => 'all', 'threaded' => 0 ); $comments = $commentsModel->getComments( $filter['component'], $cid, $options ); $pagination = $commentsModel->getPagination(); $result = $commentsModel->getUniqueComponents(); $components = array(); // @task: Let's replace it with a proper text. foreach( $result as $item ) { $components[ $item ] = Komento::loadApplication( $item )->getComponentName(); } $theme = Komento::getTheme(); $theme->set( 'components', $components ); $theme->set( 'pagination', $pagination ); $theme->set( 'comments', $comments ); $theme->set( 'filter', $filter ); echo $theme->fetch( 'dashboard/flags.php' ); }
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]; }
public function addActivity( $type, $comment_id, $uid ) { $model = Komento::getModel( 'Activity' ); return $model->add( $type, $comment_id, $uid ); }
function getModel($name = null) { return Komento::getModel('Profile'); }
* @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_subscription' ) && ( !$system->my->guest || $system->config->get( 'show_email' ) > 0 ) && !$system->config->get( 'subscription_auto' ) ) { $subscribed = null; if( $system->my->id ) { $subscribed = Komento::getModel( 'subscription' )->checkSubscriptionExist( $component, $cid, $system->my->id ); } ?> <span class="<?php if( $subscribed !== null ) echo 'subscribed '; ?>subscribeForm kmt-form-subscription"> <?php if( !is_null( $subscribed ) ) { if( $subscribed ) { echo JText::_( 'COM_KOMENTO_FORM_ALREADY_SUBSCRIBE' ); } else { echo JText::_( 'COM_KOMENTO_FORM_SUBSCRIBE_PENDING' ); } ?>. <a href="javascript:void(0);" class="unsubscribeButton kmt-form-unsubscribe"><?php echo JText::_( 'COM_KOMENTO_FORM_UNSUBSCRIBE' ); ?></a>. <?php } else { ?> <input type="checkbox" name="subscribe-checkbox" id="subscribe-checkbox" value="y" class="subscribeCheckbox input checkbox" /> <label for="subscribe-checkbox"><?php echo JText::_( 'COM_KOMENTO_FORM_SUBSCRIBE' ); ?></label> <?php } ?> </span>
/** * Retrieves the comment count for the specific blog * * @param int $blogId The blog id. **/ public static function getCommentCount($blog) { $blogId = $blog->id; $config = EasyBlogHelper::getConfig(); // If multiple comments, we output a common link if ($config->get('main_comment_multiple')) { return false; } if ($config->get('comment_komento')) { $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_komento' . DIRECTORY_SEPARATOR . 'bootstrap.php'; if (JFile::exists($file)) { require_once $file; $commentsModel = Komento::getModel('comments'); $commentCount = $commentsModel->getCount('com_easyblog', $blog->id); return $commentCount; } } $easysocial = EasyBlogHelper::getHelper('EasySocial'); if ($config->get('comment_easysocial') && $easysocial->exists()) { return $easysocial->getCommentCount($blog); } 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; return CommentEasyBlog::output($blog, array(), true); } $file = JPATH_ROOT . '/components/com_comment/helpers/utils.php'; if (JFile::exists($file)) { JLoader::discover('ccommentHelper', JPATH_ROOT . '/components/com_comment/helpers'); return ccommentHelperUtils::commentInit('com_easyblog', $blog); } } if ($config->get('intensedebate')) { return false; } if ($config->get('comment_disqus')) { static $disqus = false; if (!$disqus) { ob_start(); ?> var disqus_shortname = '<?php echo $config->get('comment_disqus_code'); ?> '; (function () { var s = document.createElement('script'); s.async = true; s.type = 'text/javascript'; s.src = 'http://' + disqus_shortname + '.disqus.com/count.js'; (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s); }()); <?php $contents = ob_get_contents(); ob_end_clean(); JFactory::getDocument()->addScriptDeclaration($contents); $disqus = true; } $string = '<!-- Disqus -->'; $string .= '<span class="discus-comment">'; $string .= '<a href="' . EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $blogId) . '#disqus_thread"><span>' . JText::_('COM_EASYBLOG_COMMENTS') . '</span></a>'; $string .= '</span>'; return $string; // return false; } if ($config->get('comment_livefyre')) { return false; } if ($config->get('comment_jomcomment')) { $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_jomcomment' . DIRECTORY_SEPARATOR . 'helper' . DIRECTORY_SEPARATOR . 'minimal.helper.php'; jimport('joomla.filesystem.file'); if (!JFile::exists($file)) { return false; } require_once $file; return jcCountComment($blogId, 'com_easyblog'); } $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_jcomments' . DIRECTORY_SEPARATOR . 'jcomments.php'; if ($config->get('comment_jcomments') && JFile::exists($file)) { $db = EasyBlogHelper::db(); $query = 'SELECT COUNT(1) FROM ' . $db->nameQuote('#__jcomments') . ' ' . 'WHERE ' . $db->nameQuote('object_id') . '=' . $db->Quote($blogId) . ' ' . 'AND ' . $db->nameQuote('object_group') . '=' . $db->Quote('com_easyblog') . ' ' . 'AND ' . $db->nameQuote('published') . '=' . $db->Quote(1); $db->setQuery($query); $total = $db->loadResult(); return $total; } if ($config->get('comment_rscomments')) { return false; } if ($config->get('comment_facebook')) { return false; } // @task: Let's allow the plugin to also trigger the comment count. $params = EasyBlogHelper::getRegistry(); $result = EasyBlogHelper::triggerEvent('easyblog.commentCount', $blog, $params, 0); $count = trim(implode(" ", $result)); if (!empty($count)) { return $count; } $db = EasyBlogHelper::db(); $query = 'SELECT COUNT(1) FROM ' . $db->nameQuote('#__easyblog_comment') . ' WHERE ' . $db->nameQuote('post_id') . '=' . $db->Quote($blogId) . ' AND `published` = ' . $db->Quote('1'); $db->setQuery($query); $count = $db->loadResult(); return $count; }
defined( '_JEXEC' ) or die( 'Restricted access' ); ?> <script type="text/javascript"> function resetform() { Foundry('#filter-component option[value=all]').attr('selected', 'selected'); Foundry('#filter-sort option[value=latest]').attr('selected', 'selected'); Foundry('#filter-search').val(''); } </script> <form id="dashboard-comment-filter" action="index.php?option=com_komento&view=reports" method="post"> <?php $model = Komento::getModel( 'comments' ); $allComponents = $model->getUniqueComponents(); $component[] = JHTML::_( 'select.option', 'all', JText::_( 'COM_KOMENTO_ALL_COMPONENTS' ) ); foreach( $allComponents as $row ) { $component[] = JHTML::_( 'select.option', $row, $row ); } $view[] = JHTML::_( 'select.option', 'latest', JText::_( 'COM_KOMENTO_SORT_LATEST' ) ); $view[] = JHTML::_( 'select.option', 'oldest', JText::_( 'COM_KOMENTO_SORT_OLDEST' ) ); echo JHTML::_( 'select.genericlist', $component, 'filter-component', 'class="inputbox" size="1"', 'value', 'text', $filter['component'] ); echo JHTML::_( 'select.genericlist', $view, 'filter-sort', 'class="inputbox" size="1"', 'value', 'text', $filter['sort'] );
<?php /** * @package Komento * @copyright Copyright (C) 2010 - 2015 Stack Ideas Sdn Bhd. 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'); $componentHelper = Komento::getHelper('components'); if ($componentHelper->isInstalled('com_rscomments')) { $components = Komento::getModel('migrators', true)->getMigrator('rscomments')->getUniqueComponents(); $selection = array(); foreach ($components as $component) { $selection[] = JHtml::_('select.option', $component, Komento::loadApplication($component)->getComponentName()); } $componentSelect = JHTML::_('select.genericlist', $selection, 'components', 'multiple="multiple" size="10" style="height: auto !important;"', 'value', 'text'); ?> <div id="migrator-rscomments" migrator-type="rscomments" migration-type="component" class="noshow migratorTable"> <div class="row"> <div class="col-md-6"> <fieldset class="panel"> <div class="panel-head"><?php echo JText::_('COM_KOMENTO_MIGRATORS_LAYOUT_MAIN'); ?> </div>
/** * 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; }
/** * 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; }
<?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->my->allow('read_comment')) { if ($system->config->get('enable_conversation_bar') && count($comments) > 0) { $authors = Komento::getModel('comments')->getConversationBarAuthors($component, $cid); ?> <div class="conversationBar kmt-conversation-bar"> <h3 class="kmt-title"><?php echo JText::_('COM_KOMENTO_COMMENT_CONVERSATION_BAR_TITLE'); ?> </h3> <ul class="kmt-people-list reset-ul float-li clearfix"> <!-- Avatar mode --> <?php if ($system->config->get('layout_avatar_enable')) { ?> <!-- Render registered user --> <?php
$submenus = array('komento' => JText::_('COM_KOMENTO_TAB_HOME'), 'system' => JText::_('COM_KOMENTO_TAB_SYSTEM'), 'integrations' => JText::_('COM_KOMENTO_TAB_INTEGRATIONS'), 'comments' => JText::_('COM_KOMENTO_TAB_COMMENTS'), 'pending' => JText::_('COM_KOMENTO_TAB_PENDINGS'), 'reports' => JText::_('COM_KOMENTO_TAB_REPORTS'), 'subscribers' => JText::_('COM_KOMENTO_TAB_SUBSCRIBERS'), 'acl' => JText::_('COM_KOMENTO_TAB_ACL'), 'migrators' => JText::_('COM_KOMENTO_TAB_MIGRATORS'), 'mailq' => JText::_('COM_KOMENTO_TAB_MAILQ')); $current = JRequest::getVar('view', 'komento'); $user = JFactory::getUser(); // @task: For the frontpage, we just show the the icons. if ($current == 'komento') { $submenus = array('komento' => JText::_('COM_KOMENTO_TAB_HOME')); } foreach ($submenus as $view => $title) { // Check submenus to add based on JACL if (!Komento::isJoomla15()) { $jacl = $current === 'komento' ? 'core.manage' : 'komento.manage.' . $view; if (!$user->authorise($jacl, 'com_komento')) { continue; } } $isActive = $current == $view; $notification = ''; $count = 0; switch ($view) { case 'pendings': $count = Komento::getModel('comments')->getCount('all', 'all', array('published' => 2)); break; case 'reports': $count = Komento::getModel('reports', true)->getTotal(); break; } if ($count > 0) { $notification = '<b>' . $count . '</b>'; } JSubMenuHelper::addEntry($title . $notification, 'index.php?option=com_komento&view=' . $view, $isActive); }
<?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( 'enable_rank_bar' ) ) { $userRank = ( $row->author->getCommentCount() / Komento::getModel( 'comments' )->getTotalComment() ) * 100; if( !$row->author->guest ) { ?> <div class="kmt-rank kmt-rank--author"> <div class="kmt-rank-bar"> <div class="kmt-rank-progress" style="width: <?php echo $userRank; ?>%;"></div> </div> </div> <?php } }
public function onExecute(&$article, $html, $view, $options = array()) { if ($options['trigger'] == 'onK2CommentsCounter' || $this->_currentTrigger == 'onK2BeforeDisplayContent') { // Try to integrate with K2's comment counter $model = Komento::getModel('comments'); $count = $model->getCount($this->component, $this->getContentId()); $article->numOfComments = $count; } if ($options['trigger'] == 'onK2CommentsBlock') { // Try to integrate with K2's comment counter $model = Komento::getModel('comments'); $count = $model->getCount($this->component, $this->getContentId()); $article->numOfComments = $count; return $html; } }
/** * When article of the component is deleted * * @access public * * @param int/object $article The article id or object * * @return boolean True if success */ public function onArticleDeleted( $article ) { $cid = $article; if( is_object( $article ) ) { $cid = $article->{$this->_map['id']}; } require_once( JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_komento' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'helper.php' ); $model = Komento::getModel( 'comments' ); $result = $model->deleteArticleComments( $this->component, $cid ); return $result; }