public function display($tpl = null) { if (!JUDirectoryHelper::hasMultiRating()) { JError::raiseError(500, JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN')); return false; } if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode('<br />', $errors)); return false; } $this->form = $this->get('Form'); $this->item = $this->get('Item'); $this->script = $this->get('Script'); $this->canDo = JUDirectoryHelper::getActions('com_judirectory'); $this->addToolBar(); parent::display($tpl); $this->setDocument(); }
protected function getOptions() { $options = array(); foreach ($this->element->children() as $option) { if ($option->getName() != 'option') { continue; } $disabled = $option['disabled'] == 'true'; if (!$disabled && $option['value'] == 'bycriteria' && !JUDirectoryHelper::hasMultiRating()) { $disabled = true; } $tmp = JHtml::_('select.option', (string) $option['value'], JText::alt(trim((string) $option), preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)), 'value', 'text', (string) $disabled); $tmp->class = (string) $option['class']; $tmp->onclick = (string) $option['onclick']; $options[] = $tmp; } reset($options); return $options; }
public function display($tpl = null) { if (!JUDirectoryHelper::hasMultiRating()) { JError::raiseError(500, JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN')); return false; } if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode('<br />', $errors)); return false; } $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->canDo = JUDirectoryHelper::getActions('com_judirectory'); $this->groupCanDoManage = JUDirectoryHelper::checkGroupPermission("criteria.edit"); $this->groupCanDoDelete = JUDirectoryHelper::checkGroupPermission("criterias.delete"); $this->addToolBar(); if (JUDirectoryHelper::isJoomla3x()) { $this->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters'); } parent::display($tpl); $this->setDocument(); }
public function multiRating() { JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); $data = $app->input->getArray($_POST); $listingId = $data['listing_id']; $params = JUDirectoryHelper::getParams(null, $listingId); $canRateListing = JUDirectoryFrontHelperPermission::canRateListing($listingId); JUDirectoryHelper::obCleanData(); if (!$canRateListing) { echo JText::_('COM_JUDIRECTORY_YOU_CAN_NOT_VOTE_ON_THIS_LISTING'); exit; } if (!JUDirectoryHelper::hasMultiRating()) { echo JText::_('COM_JUDIRECTORY_MULTI_RATING_HAS_BEEN_DISABLED_PLEASE_CONTACT_ADMINISTRATOR'); exit; } $inputCookie = $app->input->cookie; $ratingInterval = $params->get('rating_interval', 86400); $user = JFactory::getUser(); $timeNow = JFactory::getDate()->toSql(); $timeNowStamp = strtotime($timeNow); if ($user->get('guest')) { $lastTimeRated = $inputCookie->get('judir-listing-rated-' . $listingId, null); if ($lastTimeRated != null) { if ($timeNowStamp > $lastTimeRated) { if ($timeNowStamp - $lastTimeRated < $ratingInterval) { echo JText::_('COM_JUDIRECTORY_YOU_ARE_ALREADY_VOTED_ON_THIS_LISTING'); exit; } } } } else { $lastTimeRated = JUDirectoryFrontHelperRating::getLastTimeVoteListingOfUser($user->id, $listingId); if (!$lastTimeRated) { $lastTimeRated = 0; } $lastTimeRated = strtotime($lastTimeRated); if ($lastTimeRated > 0) { if ($timeNowStamp > $lastTimeRated) { if ($timeNowStamp - $lastTimeRated < $ratingInterval) { echo JText::_('COM_JUDIRECTORY_YOU_ARE_ALREADY_VOTED_ON_THIS_LISTING'); exit; } } } } $dataValid = array(); $mainCatId = JUDirectoryFrontHelperCategory::getMainCategoryId($listingId); $criteriaArray = JUDirectoryFrontHelperCriteria::getCriteriasByCatId($mainCatId); $postCriteria = $data['criteria']; if (count($criteriaArray) > 0) { foreach ($criteriaArray as $key => $criteria) { if ($criteria->required) { if (isset($postCriteria[$criteria->id]) && $postCriteria[$criteria->id] > 0 && $postCriteria[$criteria->id] <= 10) { $criteria->value = $postCriteria[$criteria->id]; } else { echo JText::_('Invalid Field ' . $criteria->title); exit; } } else { if (isset($postCriteria[$criteria->id]) && $postCriteria[$criteria->id] > 0 && $postCriteria[$criteria->id] <= 10) { $criteria->value = $postCriteria[$criteria->id]; } else { unset($criteriaArray[$key]); } } } } else { echo JText::_('COM_JUDIRECTORY_VOTING_FAILED_PLEASE_CONTACT_ADMINISTRATOR'); exit; } $model = $this->getModel(); JUDirectoryHelper::obCleanData(); if ($model->saveRating($dataValid, $listingId, $criteriaArray)) { echo JText::_('COM_JUDIRECTORY_THANK_YOU_FOR_VOTING'); } else { echo JText::_('COM_JUDIRECTORY_VOTING_FAILED_PLEASE_CONTACT_ADMINISTRATOR'); } exit; }
?> /administrator/components/com_judirectory/assets/img/icon/criteria.png" /> <span><?php echo JText::_('COM_JUDIRECTORY_DASHBOARD_CRITERIAS'); ?> </span> </a> </div> </div> </div> <?php } ?> <?php if (JUDirectoryHelper::checkGroupPermission(null, "criteriagroups") && JUDirectoryHelper::hasMultiRating()) { ?> <div class="cpanel"> <div class="icon-wrapper"> <div class="icon"> <a href="<?php echo JRoute::_('index.php?option=com_judirectory&view=criteriagroups'); ?> "> <img alt="<?php echo JText::_('COM_JUDIRECTORY_DASHBOARD_CRITERIA_GROUPS'); ?> " src="<?php echo JUri::root(true); ?> /administrator/components/com_judirectory/assets/img/icon/criteria-group.png" />
<a href="<?php echo JRoute::_('index.php?option=com_judirectory&task=fieldgroup.edit&id=' . $item->fieldgroup_id); ?> "> <?php echo $item->field_group_title; ?> </a> <?php } else { echo $item->field_group_title; } ?> </td> <?php if (JUDirectoryHelper::hasMultiRating()) { ?> <td> <?php if ($item->selected_criteriagroup > 0) { ?> <a href="<?php echo JRoute::_('index.php?option=com_judirectory&task=criteriagroup.edit&id=' . $item->selected_criteriagroup); ?> "> <?php echo $item->selected_criteriagroup_title; ?> </a> <?php } else {
public function getOutput($options = array()) { if (!$this->isPublished()) { return ""; } $options = new JRegistry($options); $this->initMultipleRatingField(); $this->loadDefaultAssets(); if ($this->listing->cat_id) { $this->criteriaGroupId = JUDirectoryFrontHelperCriteria::getCriteriaGroupIdByCategoryId($this->listing->cat_id); } if (JUDirectoryHelper::hasMultiRating()) { if ($this->criteriaGroupId) { $this->criteriaObjectList = JUDirectoryFrontHelperCriteria::getCriteriasByCatId($this->listing->cat_id); } } $this->selectedStar = round($this->listing->rating * $this->totalStars / 10, 2); if ($this->isDetailsView($options)) { $this->canRateListing = JUDirectoryFrontHelperPermission::canRateListing($this->listing_id); $document = JFactory::getDocument(); $document->addStyleSheet(JUri::root(true) . "/components/com_judirectory/assets/css/jquery.rating.css"); $document->addScript(JUri::root(true) . "/components/com_judirectory/assets/js/jquery.MetaData.js"); $document->addScript(JUri::root(true) . "/components/com_judirectory/assets/js/jquery.rating.js"); $singleRatingScript = ' jQuery(document).ready(function ($) { $(".judir-single-rating").rating({ callback: function (value) { var str = $(this).attr("name"); var patt = /^judir-listing-rating-result-(.*)$/i; var result = str.match(patt); var listingId = result[1]; var ratingValue = $(this).val(); var objectListing = {}; var token = $("#judir-single-rating-token").attr("name"); objectListing.listing_id = listingId; objectListing.ratingValue = ratingValue; if ($.isNumeric(listingId) && (ratingValue > 0 && ratingValue <= 10)) { $.ajax({ type: "POST", url : "index.php?option=com_judirectory&task=listing.singleRating&" + token + "=1", data: objectListing }).done(function (msg) { alert(msg); }); } } }); });'; if ($this->canRateListing) { $document->addScriptDeclaration($singleRatingScript); } } if (is_object($this->multiRating)) { return $this->multiRating->getOutput($options); } else { $this->setVariable('options', $options); $this->setVariable('className', __CLASS__); return $this->fetch('output.php', __CLASS__); } }
<?php /** * ------------------------------------------------------------------------ * JUDirectory for Joomla 2.5, 3.x * ------------------------------------------------------------------------ * * @copyright Copyright (C) 2010-2015 JoomUltra Co., Ltd. All Rights Reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @author JoomUltra Co., Ltd * @website http://www.joomultra.com * @----------------------------------------------------------------------@ */ // No direct access to this file defined('_JEXEC') or die('Restricted access'); if (JUDirectoryHelper::hasMultiRating() && isset($this->item->fields['rating']) && $this->item->fields['rating']->canView()) { echo $this->item->fields['rating']->getDisplayPrefixText() . ' ' . $this->item->fields['rating']->getOutput(array("view" => "details", "template" => $this->template, "type" => "multi_rating")) . ' ' . $this->item->fields['rating']->getDisplaySuffixText(); }
public static function canRateListing($listingId) { $listingObject = JUDirectoryHelper::getListingById($listingId); if (!is_object($listingObject)) { return false; } $params = JUDirectoryHelper::getParams(null, $listingId); if (!$params->get('enable_listing_rate', 1)) { return false; } $userCanViewListing = JUDirectoryFrontHelperPermission::userCanDoListing($listingId, true); if (!$userCanViewListing) { return false; } $ratingField = new JUDirectoryFieldCore_rating(); if (!$ratingField->canView()) { return false; } $user = JFactory::getUser(); $criteriaGroupId = JUDirectoryFrontHelperCriteria::getCriteriaGroupIdByCategoryId($listingObject->cat_id); if ($criteriaGroupId == 0 || !JUDirectoryHelper::hasMultiRating()) { $assetName = 'com_judirectory.category.' . $listingObject->cat_id; if ($user->authorise('judir.single.rate', $assetName)) { if ($user->authorise('judir.single.rate.many_times', $assetName)) { return true; } else { if ($user->get('guest')) { $session = JFactory::getSession(); if (!$session->has('judir-listing-rated-' . $listingId)) { return true; } } else { $totalVoteTimes = JUDirectoryFrontHelperRating::getTotalListingVotesOfUser($user->id, $listingId); if ($totalVoteTimes == 0) { return true; } } } } } else { $assetName = 'com_judirectory.criteriagroup.' . $criteriaGroupId; if ($user->authorise('judir.criteria.rate', $assetName)) { if ($user->authorise('judir.criteria.rate.many_times', $assetName)) { return true; } else { if ($user->get('guest')) { $session = JFactory::getSession(); if (!$session->has('judir-listing-rated-' . $listingId)) { return true; } } else { $totalVoteTimes = JUDirectoryFrontHelperRating::getTotalListingVotesOfUser($user->id, $listingId); if ($totalVoteTimes == 0) { return true; } } } } } return false; }
public function copyListings($listing_id_arr, $tocat_id_arr, $copy_option_arr, $tmp_listing = false, &$fieldsData = array()) { $dispatcher = JDispatcher::getInstance(); JTable::addIncludePath(JPATH_ADMINISTRATOR . "/components/com_judirectory/tables"); $db = JFactory::getDbo(); $user = JFactory::getUser(); $catTable = JTable::getInstance("Category", "JUDirectoryTable"); $table = $this->getTable(); if (empty($listing_id_arr)) { return false; } if (empty($tocat_id_arr)) { return false; } set_time_limit(0); $assetTable = JTable::getInstance('Asset', 'JTable'); $commentTable = JTable::getInstance("Comment", "JUDirectoryTable"); $reportTable = JTable::getInstance("Report", "JUDirectoryTable"); $subscriptionTable = JTable::getInstance("Subscription", "JUDirectoryTable"); $logTable = JTable::getInstance("Log", "JUDirectoryTable"); $total_copied_listings = 0; foreach ($tocat_id_arr as $tocat_id) { $catTable->reset(); if (!$catTable->load($tocat_id)) { continue; } $assetName = 'com_judirectory.category.' . (int) $tocat_id; $canDoCreate = $user->authorise('judir.listing.create', $assetName); if (!$canDoCreate) { JError::raiseWarning(401, JText::sprintf('COM_JUDIRECTORY_CAN_NOT_CREATE_LISTING_IN_THIS_CATEGORY', $catTable->title)); continue; } foreach ($listing_id_arr as $listing_id) { $table->reset(); if (!$table->load($listing_id)) { continue; } $oldTable = $table; $table->id = 0; $table->cat_id = $tocat_id; do { $query = $db->getQuery(true); $query->SELECT('COUNT(*)'); $query->FROM('#__judirectory_listings AS listing'); $query->JOIN('', '#__judirectory_listings_xref AS listingxref ON listingxref.listing_id = listing.id'); $query->JOIN('', '#__judirectory_categories AS c ON listingxref.cat_id = c.id'); $query->WHERE('c.id = ' . $tocat_id); $query->WHERE('listing.alias = "' . $table->alias . '"'); $db->setQuery($query); $sameAliasListing = $db->loadResult(); if ($sameAliasListing) { $table->title = JString::increment($table->title); $table->alias = JApplication::stringURLSafe(JString::increment($table->alias, 'dash')); } } while ($sameAliasListing); if ($table->style_id == -1) { $old_cat_id = JUDirectoryFrontHelperCategory::getMainCategoryId($listing_id); if ($old_cat_id != $tocat_id) { $oldTemplateStyleObject = JUDirectoryFrontHelperTemplate::getTemplateStyleOfCategory($old_cat_id); $newTemplateStyleObject = JUDirectoryFrontHelperTemplate::getTemplateStyleOfCategory($tocat_id); if ($oldTemplateStyleObject->template_id != $newTemplateStyleObject->template_id) { if (in_array('keep_template_params', $copy_option_arr) && $tmp_listing == false) { $table->style_id = $oldTemplateStyleObject->style_id; } else { if ($tmp_listing == false) { $table->template_params = ''; } } } } } if (!in_array('copy_rates', $copy_option_arr) && $tmp_listing == false) { $table->rating = 0; $table->total_votes = 0; } if (!in_array('copy_hits', $copy_option_arr) && $tmp_listing == false) { $table->hits = 0; } if (in_array('copy_permission', $copy_option_arr)) { $assetTable->reset(); if ($assetTable->loadByName('com_judirectory.listing.' . $listing_id)) { $table->setRules($assetTable->rules); } else { $table->setRules('{}'); } } else { $table->setRules('{}'); } if (!$table->check()) { continue; } $result = $dispatcher->trigger('onContentBeforeCopy', array($this->option . '.' . $this->name, $table, $oldTable, $copy_option_arr)); if (in_array(false, $result, true)) { $this->setError($table->getError()); return false; } if ($table->store()) { $table->checkIn(); $total_copied_listings++; } else { continue; } $newListingId = $table->id; $query = "INSERT INTO #__judirectory_listings_xref (listing_id, cat_id, main) VALUES({$newListingId}, {$tocat_id}, 1)"; $db->setQuery($query); $db->execute(); $ori_fieldgroup_id = JUDirectoryHelper::getFieldGroupIdByListingId($listing_id); $copy_extra_fields = in_array("copy_extra_fields", $copy_option_arr); if ($copy_extra_fields) { $copy_extra_fields = $ori_fieldgroup_id == $catTable->fieldgroup_id ? true : false; } $query = $db->getQuery(true); $query->select("field.*"); $query->from("#__judirectory_fields AS field"); $query->select("plg.folder"); $query->join("", "#__judirectory_plugins AS plg ON field.plugin_id = plg.id"); if ($copy_extra_fields && $ori_fieldgroup_id) { $query->where("field.group_id IN (1, {$ori_fieldgroup_id})"); } else { $query->where("field.group_id = 1"); } $query->order('field.group_id, field.ordering'); $db->setQuery($query); $fields = $db->loadObjectList(); foreach ($fields as $field) { $fieldObj = JUDirectoryFrontHelperField::getField($field, $listing_id); $fieldObj->onCopy($newListingId, $fieldsData); } if (in_array('copy_related_listings', $copy_option_arr)) { $query = "INSERT INTO `#__judirectory_listings_relations` (listing_id, listing_id_related, ordering) SELECT {$newListingId}, listing_id_related, ordering FROM `#__judirectory_listings_relations` WHERE listing_id = {$listing_id}"; $db->setQuery($query); $db->execute(); } if (in_array('copy_rates', $copy_option_arr)) { $ratingMapping = array(); $query = "SELECT * FROM #__judirectory_rating WHERE listing_id = {$listing_id}"; $db->setQuery($query); $ratings = $db->loadObjectList(); if (count($ratings)) { $criteriagroup_id = JUDirectoryHelper::getCriteriaGroupIdByListingId($listing_id); foreach ($ratings as $rating) { $oldRatingId = $rating->id; $rating->id = 0; $rating->listing_id = $newListingId; if ($db->insertObject('#__judirectory_rating', $rating, 'id')) { if (JUDirectoryHelper::hasMultiRating() && $criteriagroup_id && $criteriagroup_id == $catTable->criteriagroup_id) { JUDirectoryMultiRating::copyCriteriaValue($rating->id, $oldRatingId); } $ratingMapping[$oldRatingId] = $rating->id; } } } } if (in_array('copy_comments', $copy_option_arr)) { $query = "SELECT id FROM #__judirectory_comments WHERE listing_id=" . $listing_id . " AND parent_id = 1"; $db->setQuery($query); $commentIds = $db->loadColumn(); $commentMapping = array(); while (!empty($commentIds)) { $commentId = array_shift($commentIds); $query = "SELECT id FROM #__judirectory_comments WHERE listing_id=" . $listing_id . " AND parent_id = {$commentId}"; $db->setQuery($query); $_commentIds = $db->loadColumn(); foreach ($_commentIds as $_commentId) { if (!in_array($_commentId, $commentIds)) { array_push($commentIds, $_commentId); } } $commentTable->load($commentId, true); $commentTable->id = 0; $commentTable->listing_id = $newListingId; $commentTable->parent_id = isset($commentMapping[$commentTable->parent_id]) ? $commentMapping[$commentTable->parent_id] : 0; if (in_array('copy_rates', $copy_option_arr)) { $commentTable->rating_id = isset($ratingMapping[$commentTable->rating_id]) ? $ratingMapping[$commentTable->rating_id] : 0; } $commentTable->store(); $new_comment_id = $commentTable->id; $commentMapping[$commentId] = $new_comment_id; $query = "SELECT * FROM #__judirectory_reports WHERE `item_id` = {$commentId} AND `type` = 'comment'"; $db->setQuery($query); $reports = $db->loadObjectList(); if ($reports) { foreach ($reports as $report) { $reportTable->reset(); if ($reportTable->bind($report) && $reportTable->check()) { $reportTable->id = 0; $reportTable->item_id = $new_comment_id; $reportTable->store(); } else { continue; } } } $query = "SELECT * FROM #__judirectory_subscriptions WHERE `item_id` = {$commentId} AND `type` = 'comment'"; $db->setQuery($query); $subscriptions = $db->loadObjectList(); if ($subscriptions) { foreach ($subscriptions as $subscription) { $subscriptionTable->reset(); if ($subscriptionTable->bind($subscription) && $subscriptionTable->check()) { $subscriptionTable->id = 0; $subscriptionTable->item_id = $new_comment_id; $subscriptionTable->store(); } else { continue; } } } } } if (in_array('copy_reports', $copy_option_arr)) { $query = "SELECT * FROM #__judirectory_reports WHERE `item_id` = {$listing_id} AND `type` = 'listing'"; $db->setQuery($query); $reports = $db->loadObjectList(); if ($reports) { foreach ($reports as $report) { $reportTable->reset(); if ($reportTable->bind($report) && $reportTable->check()) { $reportTable->id = 0; $reportTable->item_id = $newListingId; $reportTable->store(); } else { continue; } } } } if (in_array('copy_subscriptions', $copy_option_arr)) { $query = "SELECT * FROM #__judirectory_subscriptions WHERE `item_id` = {$listing_id} AND `type` = 'listing'"; $db->setQuery($query); $subscriptions = $db->loadObjectList(); if ($subscriptions) { foreach ($subscriptions as $subscription) { $subscriptionTable->reset(); if ($subscriptionTable->bind($subscription) && $subscriptionTable->check()) { $subscriptionTable->id = 0; $subscriptionTable->item_id = $newListingId; $subscriptionTable->store(); } else { continue; } } } } if (in_array('copy_logs', $copy_option_arr)) { $query = "SELECT * FROM #__judirectory_logs WHERE (`listing_id` = {$listing_id})"; $db->setQuery($query); $logs = $db->loadObjectList(); if ($logs) { foreach ($logs as $log) { $logTable->reset(); if ($logTable->bind($log) && $logTable->check()) { $logTable->id = 0; $logTable->item_id = $newListingId; $logTable->listing_id = $newListingId; $logTable->store(); } else { continue; } } } } if ($tmp_listing) { return $newListingId; } $this->cleanCache(); $dispatcher->trigger('onContentAfterCopy', array($this->option . '.' . $this->name, $table, $oldTable, $copy_option_arr)); } } return $total_copied_listings; }
public function saveComment($postData = array()) { $user = JFactory::getUser(); $nowDate = JFactory::getDate()->toSql(); $title = htmlspecialchars($postData['title']); $comment = htmlspecialchars($postData['comment'], ENT_NOQUOTES); if ($user->get('guest')) { $guestName = strip_tags($postData['guest_name']); $guestEmail = strip_tags($postData['guest_email']); } else { $guestName = ''; $guestEmail = ''; } $website = isset($postData['website']) ? strip_tags($postData['website']) : ''; $listingId = (int) $postData['listing_id']; $params = JUDirectoryHelper::getParams(null, $listingId); $totalVotes = 0; $helpfulVotes = 0; $ipAddress = JUDirectoryFrontHelper::getIpAddress(); $parentId = (int) $postData['parent_id']; $rootComment = JUDirectoryFrontHelperComment::getRootComment(); if ($parentId == $rootComment->id) { $approved = JUDirectoryFrontHelperPermission::canAutoApprovalComment($listingId); $level = 1; if ($params->get('filter_comment_language', 0)) { $language = $postData['comment_language']; } else { $language = '*'; } } else { $approved = JUDirectoryFrontHelperPermission::canAutoApprovalReplyComment($listingId); $parentComment = $this->getCommentObject($parentId); $level = $parentComment->level + 1; $language = '*'; } if ($approved) { $approved = 1; $published = 1; } else { $approved = 0; $published = 0; } $dataComment = array('title' => $title, 'comment' => $comment, 'user_id' => $user->id, 'guest_name' => $guestName, 'guest_email' => $guestEmail, 'website' => $website, 'listing_id' => $listingId, 'created' => $nowDate, 'total_votes' => $totalVotes, 'helpful_votes' => $helpfulVotes, 'ip_address' => $ipAddress, 'approved' => $approved, 'published' => $published, 'parent_id' => $parentId, 'level' => $level, 'language' => $language); JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_judirectory/tables'); $commentTable = JTable::getInstance('Comment', 'JUDirectoryTable'); $commentTable->setLocation($postData['parent_id'], 'last-child'); $commentTable->bind($dataComment); if (!$commentTable->check() || !$commentTable->store()) { $this->setError($commentTable->getError()); return false; } $canRateListing = JUDirectoryFrontHelperPermission::canRateListing($listingId); if ($canRateListing && $params->get('enable_listing_rate_in_comment_form', 1) && $commentTable->parent_id == $rootComment->id) { $postData['approved'] = $approved; $criteriaArray = array(); if (isset($postData['criteria_array'])) { if (JUDirectoryHelper::hasMultiRating()) { $criteriaArray = $postData['criteria_array']; $saveRating = $this->saveRating($postData, $listingId, $criteriaArray, $commentTable->id); } } else { if (isset($postData['ratingValue'])) { $saveRating = $this->saveRating($postData, $listingId, $criteriaArray, $commentTable->id); } } if (!$saveRating) { $this->setError(JText::_('COM_JUDIRECTORY_SAVE_RATING_FAILED')); return false; } } if (JUDIRPROVERSION && isset($postData['subscribe']) && $postData['subscribe']) { $subscriptionData = array(); $subscriptionData['user_id'] = $user->id; $subscriptionData['type'] = 'comment'; $subscriptionData['comment_id'] = $commentTable->id; $subscriptionData['name'] = $user->id == 0 ? $guestName : $user->username; $subscriptionData['email'] = $user->id == 0 ? $guestEmail : $user->email; $subscriptionData['item_id'] = $commentTable->id; $subscriptionData['ip_address'] = $ipAddress; $subscriptionData['created'] = $nowDate; $subscriptionData['published'] = $user->id == 0 && $params->get('activate_subscription_by_email', 1) ? 0 : 1; require_once JPATH_SITE . '/components/com_judirectory/models/subscribe.php'; JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_judirectory/models'); $subscribeModel = JModelLegacy::getInstance('Subscribe', 'JUDirectoryModel'); if (!$subscribeModel->add($subscriptionData)) { $this->setError(JText::_('COM_JUDIRECTORY_SUBSCRIBE_FAILED')); return false; } } if ($commentTable->parent_id == $rootComment->id) { JUDirectoryFrontHelperMail::sendEmailByEvent('comment.create', $commentTable->id); $logData = array('item_id' => $commentTable->id, 'listing_id' => $listingId, 'user_id' => $user->id, 'event' => 'comment.create'); $commentSubmitType = 'create'; } else { JUDirectoryFrontHelperMail::sendEmailByEvent('comment.reply', $commentTable->id); $logData = array('user_id' => $user->id, 'event' => 'comment.reply', 'item_id' => $commentTable->id, 'listing_id' => $listingId, 'value' => 0, 'reference' => $commentTable->parent_id); $commentSubmitType = 'reply'; } JUDirectoryFrontHelperLog::addLog($logData); $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('judirectory'); $dispatcher->trigger('onCommentSubmit', array($commentTable, $commentSubmitType)); return $commentTable->id; }