Если делать через сторонний плагин у меня это плагин Like, то получается необходимо:
1. создать правило в AUP - это я сделал.
2. и в каком-то месте файла Like вставить код:
$api_AUP = JPATH_SITE.'/components/com_altauserpoints/helper.php';
if ( file_exists($api_AUP))
{
require_once $api_AUP;
$aupid = AltaUserPointsHelper::getAnyUserReferreID( $userID );
if ( $aupid )
AltaUserPointsHelper::newpoints( 'plgaup_content_like', $aupid );
}
Я пробовал устанавливать в разных местах, но начисление баллов происходит сразу как открывается статья(радует, что начисление уже происходит...).
Вот как выглядит файл плагина Like:
<?php
/**
* @package Joomla.Plugin
* @subpackage Content.vote
*
* [member=126442]copyright[/member] Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Vote plugin.
*
* @since 1.5
*/
$doc = JFactory::getDocument();
$doc->addStyleDeclaration(".form-like {margin:15px 0!important;}.btn-like {background-color: transparent!important;background-image: none;border-radius: 4px;border: 1px solid #ccc;color: #999;line-height: 18px!important;height: 30px!important;padding: 6px 10px 5px 10px!important;text-shadow:none;box-sizing:border-box;}.btn-like:hover {border-color: #4098d1;}.btn-like img {margin-right: 5px;float: left;}.element-invisible {position: absolute;padding: 0;margin: 0;border: 0;height: 1px;width: 1px;overflow: hidden;}
");
class PlgContentLike extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Displays the voting area if in an article
*
* @param string $context The context of the content being passed to the plugin
* @param object &$row The article object
* @param object &$params The article params
* @param integer $page The 'page' number
*
* @return mixed HTML string containing code for the votes if in com_content else boolean false
*
* @since 1.6
*/
public function onContentBeforeDisplay($context, &$row, &$params, $page=0)
{
$parts = explode(".", $context);
if ($parts[0] != 'com_content')
{
return false;
}
$html = '';
if (!empty($params) && $params->get('show_vote', null))
{
$rating = (int) @$row->rating;
$view = JFactory::getApplication()->input->getString('view', '');
$img = '';
$starImageOn = JHtml::_('image', JURI::root().'plugins/content/like/assets/like_on.png', JText::_('PLG_LIKE_STAR_ACTIVE'), 'width="16"', true);
$starImageOff = JHtml::_('image', JURI::root().'plugins/content/like/assets/like_off.png', JText::_('PLG_LIKE_STAR_INACTIVE'), 'width="16"', true);
if($rating > 1) {
$img .= $starImageOn;
} else {
$img .= $starImageOff;
}
$html .= '<div class="content_rating" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">';
$html .= '<p class="unseen element-invisible">'
. JText::sprintf('PLG_LIKE_USER_RATING', '<span itemprop="ratingValue">' . $rating . '</span>', '<span itemprop="bestRating">5</span>')
. '<meta itemprop="ratingCount" content="' . (int) $row->rating_count . '" />'
. '<meta itemprop="worstRating" content="0" />'
. '</p>';
$html .= '<>';
if ($view == 'article' && $row->state == 1)
{
$uri = JUri::getInstance();
$uri->setQuery($uri->getQuery(). '&hitcount=0');
// Generate voting form
$html .= '<form method="post" action="' . htmlspecialchars($uri->toString()). '" class="form-inline form-like">';
$html .= '<span class="content_like">';
$html .= '<input type="hidden" name="user_rating" value="5" />';
$html .= '<button type="submit" name="submit_vote" class="btn btn-like">'.$row->rating_count ." ".$img.'</button>';
$html .= '<input type="hidden" name="task" value="article.vote" />';
$html .= '<input type="hidden" name="hitcount" value="0" />';
$html .= '<input type="hidden" name="url" value="' . htmlspecialchars($uri->toString()). '" />';
$html .= JHtml::_('form.token');
$html .= '</span>';
$html .= '</form>';
}
}
return $html;
}
}
Но в какое место вставить этот код, чтобы начисление баллов происходило только после оценки статьи?