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 __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(); }
/** * 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; }
public function display($cacheable = false, $urlparams = false) { JFactory::getApplication()->enqueueMessage('You are using Komento free version. <a href="http://stackideas.com/komento/plans.html" target="_blank">Upgrade to Komento Pro</a> to enjoy our priority support and more. <a href="http://stackideas.com/komento/plans.html" target="_blank" style="padding: 5px 10px; background-color: #C02828; color: #FFFFFF;">Upgrade now!</a>', 'notice'); // free version text (for reference only) // JFactory::getApplication()->enqueueMessage( 'You are using Komento free version. <a href="http://stackideas.com/komento/plans.html" target="_blank">Upgrade to Komento Pro</a> to enjoy our priority support and more. <a href="http://stackideas.com/komento/plans.html" target="_blank" style="padding: 5px 10px; background-color: #C02828; color: #FFFFFF;">Upgrade now!</a>', 'notice' ); $document = JFactory::getDocument(); // Set the layout $viewType = $document->getType(); $viewName = JRequest::getCmd('view', $this->getName()); $viewLayout = JRequest::getCmd('layout', 'default'); $view = $this->getView($viewName, $viewType, ''); $view->setLayout($viewLayout); $format = JRequest::getCmd('format', 'html'); // Test if the call is for Ajax if (!empty($format) && $format == 'ajax') { // Ajax calls. if (!JRequest::checkToken('GET')) { $ejax = new Ejax(); $ejax->script('alert("' . JText::_('Not allowed here') . '");'); $ejax->send(); } // Process Ajax call $data = JRequest::get('POST'); $arguments = array(); foreach ($data as $key => $value) { if (JString::substr($key, 0, 5) == 'value') { if (is_array($value)) { $arrVal = array(); foreach ($value as $val) { $item =& $val; $item = stripslashes($item); $item = rawurldecode($item); $arrVal[] = $item; } $arguments[] = $arrVal; } else { $val = stripslashes($value); $val = rawurldecode($val); $arguments[] = $val; } } } // if(!method_exists( $view , $viewLayout ) ) // { // $ejax = new Ejax(); // $ejax->script( 'alert("' . JText::sprintf( 'Method %1$s does not exists in this context' , $viewLayout ) . '");'); // $ejax->send(); // return; // } // Execute method call_user_func_array(array($view, $viewLayout), $arguments); } else { // Non ajax calls. if ($viewLayout != 'default') { if ($cacheable) { $cache = JFactory::getCache('com_komento', 'view'); $cache->get($view, $viewLayout); } else { if (!method_exists($view, $viewLayout)) { $view->display(); } else { // @todo: Display error about unknown layout. $view->{$viewLayout}(); } } } else { $view->display(); } // Add necessary buttons to the site. if (method_exists($view, 'registerToolbar')) { $view->registerToolbar(); } // Override submenu if needed if (method_exists($view, 'registerSubmenu') && $view->registerSubmenu() != '') { $this->loadSubmenu($view->getName(), $view->registerSubmenu()); } // @task: Append hidden token into the page. echo '<span id="komento-token" style="display:none;"><input type="hidden" name="' . Komento::_('getToken') . '" value="1" /></span>'; } }
/** * Push the email notification to MailQ * @param string $type type of notification * @param string $recipient recipient (subscribers,admins,author,me) * @param array $options various options * * @return nothing */ public function push( $type, $recipients, $options = array() ) { if( !empty( $options['commentId'] ) ) { $comment = Komento::getComment( $options['commentId'] ); $options['comment'] = $comment; $options['component'] = $comment->component; $options['cid'] = $comment->cid; $options['comment'] = Komento::getHelper( 'comment' )->process( $options['comment'] ); unset( $options['commentId'] ); } if( !isset( $options['component'] ) || !isset( $options['cid'] ) ) { return; } if( $type == 'new' && $options['comment']->parent_id ) { $type = 'reply'; } $recipients = explode(',', $recipients); $rows = array(); $skipMe = true; // process requested recipients first foreach ($recipients as $recipient) { $recipient = 'get' . ucfirst( strtolower( trim($recipient) ) ); if( !method_exists($this, $recipient) ) { continue; } if( $recipient == 'getMe' ) { $skipMe = false; } $result = $this->$recipient( $type, $options ); // stacking up all the emails and details $rows = $rows + $result; } // process usergroups notification based on notification type $rows = $rows + $this->getUsergroups( $type ); if( $type == 'report' ) { $admins = $this->getAdmins(); foreach( $admins as $admin ) { if( isset($rows[$options['comment']->email]) && $options['comment']->email === $admin->email ) { $skipMe = false; } } } if( empty($rows) ) { return; } // Do not send to the commentor/actor if( $skipMe && isset($rows[$options['comment']->email]) ) { unset( $rows[$options['comment']->email] ); } $lang = JFactory::getLanguage(); // Load English first as fallback $konfig = Komento::getKonfig(); if( $konfig->get( 'enable_language_fallback' ) ) { $lang->load( 'com_komento', JPATH_ROOT, 'en-GB', true ); } // Load site's selected language $lang->load( 'com_komento', JPATH_ROOT, $lang->getDefault(), true ); // Load user's preferred language file $lang->load( 'com_komento', JPATH_ROOT, null, true ); $jconfig = JFactory::getConfig(); $data = $this->prepareData( $type, $options ); $template = $this->prepareTemplate( $type, $options ); $subject = $this->prepareTitle( $type, $options ); $mailfrom = Komento::_( 'JFactory::getConfig', 'mailfrom' ); $fromname = Komento::_( 'JFactory::getConfig', 'fromname' ); $config = Komento::getConfig(); $sendHTML = $config->get( 'notification_sendmailinhtml' ) ? 'html' : 'text'; // Storing notifications into mailq foreach ($rows as $row) { if( Komento::trigger( 'onBeforeSendNotification', array( 'component' => $options['component'], 'cid' => $options['cid'], 'recipient' => &$row ) ) === false ) { continue; } if( empty( $row->email ) ) { continue; } $body = $this->getTemplateBuffer( $template, $data, array( 'recipient' => $row ) ); $mailQ = Komento::getTable( 'mailq' ); $mailQ->mailfrom = $mailfrom; $mailQ->fromname = $fromname; $mailQ->recipient = $row->email; $mailQ->subject = $subject; $mailQ->body = $body; $mailQ->created = Komento::getDate()->toMySQL(); $mailQ->type = $sendHTML; $mailQ->status = 0; $result = $mailQ->store(); } }
* @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'); ?> <?php Komento::trigger( 'onBeforeKomentoBar', array( 'component' => $component, 'cid' => $cid, 'commentCount', &$commentCount ) ); ?> <?php $readmore = false; if( $component == 'com_content' ) { if( $system->config->get( 'layout_frontpage_readmore_use_joomla' ) == 0 && ( ( $system->config->get( 'layout_frontpage_readmore' ) == 2 ) || ( $system->config->get( 'layout_frontpage_readmore' ) == 1 && Komento::_('JParameter::get', $article->params, 'show_readmore') && $article->readmore ) ) ) { $readmore = true; } } else { if( $system->config->get( 'layout_frontpage_readmore' ) != 0 ) { $readmore = true; } } if( $readmore || $system->config->get( 'layout_frontpage_comment') || $system->config->get( 'layout_frontpage_hits') ) { ?> <div class="kmt-readon"> <?php if( $readmore ) { ?> <span class="kmt-readmore aligned-<?php echo $system->config->get( 'layout_frontpage_alignment' ); ?>">
private function doSave() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); $result = array(); $mainframe = JFactory::getApplication(); if (!JRequest::getMethod() == 'POST') { // $mainframe->enqueueMessage( JText::_('COM_KOMENTO_SETTINGS_STORE_INVALID_REQUEST' ), 'error' ); $result['message'] = JText::_('COM_KOMENTO_SETTINGS_STORE_INVALID_REQUEST'); $result['type'] = 'error'; return $result; } // Unset unecessary post data. $post = JRequest::get('POST'); unset($post['active']); unset($post['activechild']); unset($post['task']); unset($post['option']); unset($post['c']); $token = Komento::_('getToken'); unset($post[$token]); // check the target component if (!$post['component']) { // $mainframe->enqueueMessage( JText::_('COM_KOMENTO_SETTINGS_MISSING_TARGET_COMPONENT'), 'error' ); $result['message'] = JText::_('COM_KOMENTO_SETTINGS_MISSING_TARGET_COMPONENT'); $result['type'] = 'error'; return $result; } // custom field that requires processing before save should all goes here if (array_key_exists('email_regex', $post)) { $post['email_regex'] = array(urlencode($post['email_regex'])); } if (array_key_exists('website_regex', $post)) { $post['website_regex'] = array(urlencode($post['website_regex'])); } if (array_key_exists('smileycode', $post)) { foreach ($post['smileycode'] as $index => $smileycode) { if (empty($smileycode)) { unset($post['smileycode'][$index]); } } } if (array_key_exists('smileypath', $post)) { foreach ($post['smileypath'] as $index => $smileypath) { if (empty($smileypath)) { unset($post['smileypath'][$index]); } } } // Overwrite the value by using getVar to preserve the html tag $post['tnc'] = JRequest::getVar('tnc', '', 'post', 'string', JREQUEST_ALLOWRAW); // Fix multiple select $multiples = array('allowed_categories', 'requires_moderation', 'show_tnc', 'notification_to_usergroup_comment', 'notification_to_usergroup_reply', 'notification_to_usergroup_pending', 'notification_to_usergroup_reported', 'notification_es_to_usergroup_comment', 'notification_es_to_usergroup_reply', 'notification_es_to_usergroup_like', 'smileypath', 'smileycode'); foreach ($multiples as $multiple) { if (!array_key_exists($multiple, $post)) { $post[$multiple] = array(); } } // Save post data $model = Komento::getModel('system', true); if (!$model->save($post)) { $result['message'] = JText::_('COM_KOMENTO_SETTINGS_STORE_ERROR'); $result['type'] = 'error'; return $result; } // Post save actions $result['message'] = JText::_('COM_KOMENTO_SETTINGS_STORE_SUCCESS'); $result['type'] = 'message'; // Clear the component's cache $cache = JFactory::getCache(); $cache->clean(); return $result; }
/** * START OF STRING RETURN FUNCTIONS */ public function debug() { $prefix = Komento::_("JFactory::getConfig", "dbprefix"); $query = $this->buildSql(); return str_ireplace( '#__' , $prefix , $query ); }