Exemplo n.º 1
0
 public function display($cachable = false, $urlparams = false)
 {
     require_once JPATH_COMPONENT . '/helpers/djreviews.php';
     DJReviewsHelper::addSubmenu(JFactory::getApplication()->input->getCmd('view', 'cpanel'));
     JHtml::_('behavior.framework');
     JFactory::getDocument()->addScript(JUri::base() . 'components/com_djreviews/assets/js/script.js');
     parent::display($cachable, $urlparams);
 }
Exemplo n.º 2
0
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * DJ-Reviews is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with DJ-Reviews. If not, see <http://www.gnu.org/licenses/>.
 *
 */
defined('_JEXEC') or die('Restricted access');
$user = JFactory::getUser();
$params = DJReviewsHelper::getParams($this->review_object->rating_group_id);
?>
<div id="djrv-reviews-list-<?php 
echo $this->review_object->id;
?>
" class="djrv_reviews_list djreviews clearfix">
<?php 
if ($params->get('reviews', '1') == '1') {
    ?>

<h3><?php 
    echo JText::_('COM_DJREVIEWS_USERS_REVIEWS_HEADING');
    ?>
</h3>

<?php 
Exemplo n.º 3
0
 /**
  * 
  * @param int $rating_group Rating Group ID
  * @param string $object_type Type of an object, eg. com_content, com_content.article
  * @param string $object_name Friendly name, title
  * @param string $object_link Object's URL, eg. link to an article
  * @param int $entry_id rated object's ID
  * @throws RuntimeException
  */
 public function __construct($rating_group, $object_type, $object_name, $object_link, $entry_id, $params = false)
 {
     if (!(int) $rating_group) {
         throw new RuntimeException('Missing rating group');
     }
     $object_type = strtolower(preg_replace('#[^a-z0-9\\.\\_\\-]#i', '.', $object_type));
     if (!$object_type) {
         throw new RuntimeException('Missing object type');
     }
     if (!$object_name) {
         throw new RuntimeException('Missing object name');
     }
     if (!$object_link) {
         throw new RuntimeException('Missing object link');
     }
     if (!(int) $entry_id) {
         throw new RuntimeException('Missing or invalid object ID');
     }
     $this->rating_group_id = $rating_group;
     $this->object_type = $object_type;
     $this->entry_id = $entry_id;
     $this->name = $object_name;
     $this->link = $object_link;
     require_once JPath::clean(JPATH_ROOT . '/components/com_djreviews/helpers/djreviews.php');
     if (!$params) {
         $params = DJReviewsHelper::getParams($this->rating_group_id);
     }
     $this->params = $params;
     if (!self::$assets) {
         self::recalculate();
         $lang = JFactory::getLanguage();
         $lang->load('com_djreviews', JPATH_ROOT, 'en-GB', false, false);
         $lang->load('com_djreviews', JPATH_ROOT . JPath::clean('/components/com_djreviews'), 'en-GB', false, false);
         $lang->load('com_djreviews', JPATH_ROOT, null, true, false);
         $lang->load('com_djreviews', JPATH_ROOT . JPath::clean('/components/com_djreviews'), null, true, false);
         JHtml::_('behavior.tooltip', '.djrv_tooltip');
         $theme = $this->params->get('theme', 'bootstrap');
         JFactory::getDocument()->addStyleSheet(JUri::base() . 'components/com_djreviews/themes/' . $theme . '/css/theme.css');
         self::$assets = true;
     }
 }
Exemplo n.º 4
0
 public function validate($form, $data, $group = null)
 {
     $user = JFactory::getUser();
     $params = DJReviewsHelper::getParams((int) $data['rating_group_id']);
     $db = JFactory::getDbo();
     if (isset($data['id']) && $data['id'] > 0) {
         // if the review has been edited we don't change it's state
         unset($data['published']);
         if ($item = $this->getItem($data['id'])) {
             $data['created_by'] = $item->created_by;
             $data['user_name'] = $item->user_name;
             $data['user_login'] = $item->user_login;
             $data['email'] = $item->email;
         }
     } else {
         if ($user->authorise('review.autopublish', 'com_djreviews') || $user->authorise('core.edit.state', 'com_djreviews')) {
             $data['published'] = 1;
         } else {
             $data['published'] = 0;
         }
         if ($user->id > 0) {
             $data['created_by'] = $user->id;
             $data['user_name'] = $user->name;
             $data['user_login'] = $user->username;
             $data['email'] = $user->email;
         }
     }
     $canRate = true;
     $userRating = $this->getUserRating((int) $data['object_id']);
     foreach ($userRating as $userRate) {
         if ($userRate->avg_rate > 0 && (int) $data['id'] != $userRate->id) {
             $canRate = false;
         }
     }
     $canSubmit = true;
     if (!$canRate && ((int) $params->get('message', 2) == 0 || (int) $params->get('followup', 1) == 0)) {
         $canSubmit = false;
     }
     if (!$canSubmit) {
         $this->setError(JText::_('COM_DJREVIEWS_CANNOT_ADD_MORE_REVIEWS'));
         return false;
     }
     if ($canRate) {
         if (isset($data['rating_group_id'])) {
             $group_id = (int) $data['rating_group_id'];
             if ($group_id == 0) {
                 $this->setError(JText::_('COM_DJREVIEWS_ERROR_FORM_MALFORMED'));
                 return false;
             }
             $db->setQuery('SELECT * FROM #__djrevs_rating_fields WHERE group_id = ' . (int) $data['rating_group_id'] . ' AND required=1');
             $fields = $db->loadObjectList('id');
             if (count($fields) && empty($data['rating'])) {
                 $this->setError(JText::_('COM_DJREVIEWS_ERROR_FORM_MALFORMED'));
                 return false;
             }
             $allFieldsValid = true;
             foreach ($fields as $field) {
                 if (!array_key_exists($field->id, $data['rating']) || empty($data['rating'][$field->id])) {
                     $allFieldsValid = false;
                     break;
                 }
             }
             if (!$allFieldsValid) {
                 $this->setError(JText::_('COM_DJREVIEWS_ERROR_RATING_IS_MISSING'));
                 return false;
             }
         }
     } else {
         if (!empty($data['rating'])) {
             $this->setError(JText::_('COM_DJREVIEWS_ERROR_YOU_HAVE_ALREADY_RATED'));
             return false;
         }
     }
     $title_splited = explode(' ', $data['title']);
     $msg_splited = explode(' ', $data['message']);
     if ($params->get('word_blacklist', "")) {
         $word_blacklist = explode(',', $params->get('word_blacklist', ""));
         $word_whitelist = explode(',', $params->get('word_whitelist', ""));
         foreach ($msg_splited as &$word) {
             foreach ($word_blacklist as $bl) {
                 $bl = trim(JString::strtolower($bl));
                 $tmpWord = JString::strtolower($word);
                 if (strstr($tmpWord, $bl)) {
                     $bl_found = 1;
                     foreach ($word_whitelist as $wl) {
                         $wl = trim(JString::strtolower($wl));
                         if ($wl && strstr($tmpWord, $wl)) {
                             $bl_found = 0;
                             break;
                         }
                     }
                     if ($bl_found) {
                         $stars_l = JString::strlen($word);
                         $stars = '';
                         for ($i = 0; $i < JString::strlen($bl); $i++) {
                             $stars .= '*';
                         }
                         $word = JString::str_ireplace($bl, $stars, $word);
                     }
                 }
             }
         }
         unset($word);
         foreach ($title_splited as &$word) {
             foreach ($word_blacklist as $bl) {
                 $bl = trim(JString::strtolower($bl));
                 $tmpWord = JString::strtolower($word);
                 if (strstr($tmpWord, $bl)) {
                     $bl_found = 1;
                     foreach ($word_whitelist as $wl) {
                         $wl = trim(JString::strtolower($wl));
                         if ($wl && strstr($tmpWord, $wl)) {
                             $bl_found = 0;
                             break;
                         }
                     }
                     if ($bl_found) {
                         $stars_l = JString::strlen($word);
                         $stars = '';
                         for ($i = 0; $i < JString::strlen($bl); $i++) {
                             $stars .= '*';
                         }
                         $word = JString::str_ireplace($bl, $stars, $word);
                     }
                 }
             }
         }
         unset($word);
         $data['message'] = implode(' ', $msg_splited);
         $data['title'] = implode(' ', $title_splited);
     }
     return parent::validate($form, $data, $group);
 }
Exemplo n.º 5
0
 *
 * DJ-Reviews is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with DJ-Reviews. If not, see <http://www.gnu.org/licenses/>.
 *
 */
defined('_JEXEC') or die('Restricted access');
//JHtml::_('behavior.tooltip', '.djrv_tooltip');
JHtml::_('behavior.formvalidation');
$user = JFactory::getUser();
$app = JFactory::getApplication();
$params = DJReviewsHelper::getParams((int) $this->form->getValue('rating_group_id'));
$canRate = true;
$canSubmit = true;
foreach ($this->userRating as $userRate) {
    if ($userRate->avg_rate > 0 && (int) $this->item->id != $userRate->id) {
        $canRate = false;
    }
}
if (!$canRate && ((int) $params->get('message', 2) == 0 || (int) $params->get('followup', 1) == 0)) {
    $canSubmit = false;
}
$style = 'style="display: none;"';
if ($app->input->get('djreviews_action') == 'add' || $app->input->get('djreviews_action') == 'edit') {
    $style = '';
}
?>