File manager - Edit - /home/verseaumee/ptitsanes/plugins/solidres/feedback/components/com_solidres/models/feedbacklist.php
Back
<?php /* ------------------------------------------------------------------------ Solidres - Hotel booking extension for Joomla ------------------------------------------------------------------------ @Author Solidres Team @Website http://www.solidres.com @Copyright Copyright (C) 2013 - 2017 Solidres. All Rights Reserved. @License GNU General Public License version 3, or later ------------------------------------------------------------------------ */ defined('_JEXEC') or die; use Joomla\CMS\Factory as CMSFactory; JLoader::register('SolidresFeedbackModelList', JPATH_PLUGINS . '/solidres/feedback/administrator/components/com_solidres/models/feedbackmodellist.php'); JLoader::register('SolidresHelperRoute', JPATH_SITE . '/components/com_solidres/helpers/route.php'); class SolidresModelFeedbackList extends SolidresFeedbackModelList { public $awaitingFeedbacks = array(); protected function populateState($ordering = null, $direction = null) { $input = JFactory::getApplication()->input; $view = $input->getCmd('view'); $layout = $input->get('layout', 'default'); $this->context = 'com_solidres.' . $view; if ($layout != 'default') { $this->context .= '.' . $layout; } parent::populateState($ordering, $direction); } public function resetListStart() { JFactory::getApplication()->setUserState($this->context . '.limitstart', 0); } public function setListStart($itemId = 0, $scope = 0) { $context = $this->context . ($scope ? '.experience_' . $itemId : 'asset_' . $itemId); $start = $this->getUserStateFromRequest($context . '.limitstart', 'limitstart', 0, 'int'); $this->setState('list.start', $start); $limit = $this->getUserStateFromRequest($context . '.limit', 'limit', JComponentHelper::getParams('com_solidres')->get('feedback_limit', 3), 'int'); $this->setState('list.limit', $limit); } protected function getStoreId($id = '') { $id .= ':' . $this->getState('filter.partner_id', 0); $id .= ':' . $this->getState('filter.customer_id', 0); $id .= ':' . $this->getState('filter.token', ''); return parent::getStoreId($id); } protected function getListQuery() { $db = $this->getDbo(); $query = parent::getListQuery(); $customerId = (int) $this->getState('filter.customer_id', 0); $partnerId = (int) $this->getState('filter.partner_id', 0); $scope = (int) $this->getState('filter.scope', 0); if ($customerId) { $query->where('a2.customer_id = ' . $customerId); } if ($partnerId) { if ($scope) { $query->join('LEFT',$db->qn('#__sr_experiences', 'a4') . ' ON a4.id = a.item_id') ->where('(a3.partner_id = ' . $partnerId . ' OR a4.partner_id = ' . $partnerId . ')'); } else { $query->join('LEFT', $db->qn('#__sr_reservation_assets', 'a4') . ' ON a4.id = a.item_id') ->join('LEFT', $db->quoteName('#__sr_property_staff_xref', 'tbl_staff_xref') . ' ON tbl_staff_xref.property_id = a4.id') ->where('(a3.partner_id = ' . $partnerId . ' OR a4.partner_id = ' . $partnerId . ' OR tbl_staff_xref.staff_id = ' . (int) CMSFactory::getUser()->id . ')'); } } return $query; } public function getItems() { $awaitingFeedbacks = array(); $pks = array(); if ($items = parent::getItems()) { foreach ($items as $item) { $pks[] = $item->reservation_id; } } $params = JComponentHelper::getParams('com_solidres'); $scope = (int) $this->getState('filter.scope', '0'); $customerId = (int) $this->getState('filter.customer_id', '0'); $token = $this->getState('filter.token'); $db = $this->getDbo(); $query = $db->getQuery(true) ->select('a.*'); if ($scope) { JLoader::register('SRExperienceHelper', SRPlugin::getAdminPath('experience') . '/helpers/experience.php'); $query->from($db->qn('#__sr_experience_reservations', 'a')); } else { $query->from($db->qn('#__sr_reservations', 'a')); } if ($token) { $query->where('a.token = ' . $db->q($token)); } elseif ($customerId > 0) { $query->where('a.customer_id = ' . $customerId); } if (!$token) { if ($scope) { $query->where('a.state = ' . (int) $params->get('exp_status_trigger_feedback_email', 0)); } else { $query->where('a.state = ' . (int) $params->get('asset_status_trigger_feedback_email', 2)); } } $db->setQuery($query); if ($reservations = $db->loadObjectList()) { foreach ($reservations as $reservation) { if (!in_array($reservation->id, $pks)) { $reservation->scope = $scope; $targetItem = new stdClass; if ($scope) { $targetItem->id = $reservation->experience_id; $targetItem->name = $reservation->experience_name; $targetItem->link = JRoute::_(SRExperienceHelper::getItemRoute($targetItem->id), false); } else { $targetItem->id = $reservation->reservation_asset_id; $targetItem->name = $reservation->reservation_asset_name; $targetItem->link = JRoute::_(SolidresHelperRoute::getReservationAssetRoute($targetItem->id), false); } $reservation->targetItem = $targetItem; $awaitingFeedbacks[] = $reservation; } } } $this->awaitingFeedbacks = $awaitingFeedbacks; return $items; } public function getScores($itemId = 0, $scope = 0) { static $cacheScores = array(); $scope = (int) $scope; $itemId = (int) $itemId; $db = $this->getDbo(); if (!isset($cacheScores['scope' . $scope])) { $query = $db->getQuery(true) ->select('a.id, a.field') ->from($db->qn('#__sr_feedback_conditions', 'a')) ->where('a.scope = ' . $scope); $db->setQuery($query); if ($fields = $db->loadObjectList()) { $cacheScores['scope' . $scope] = $fields; } else { $cacheScores['scope' . $scope] = array(); } } if (!isset($cacheScores['itemId' . $itemId])) { $rows = array(); foreach ($cacheScores['scope' . $scope] as $field) { $query = $db->getQuery(true) ->select('a.score, ' . $db->q($field->field) . ' AS field') ->from($db->qn('#__sr_feedback_scores', 'a')) ->innerJoin($db->qn('#__sr_feedbacks', 'a2') . ' ON a2.id = a.feedback_id') ->where('a2.state = 1 AND a2.scope = ' . (int) $scope) ->where('a.field_id = ' . (int) $field->id); if ($scope) { $query->leftJoin($db->qn('#__sr_experience_reservations', 'a3') . ' ON a3.id = a2.reservation_id') ->where('(a3.experience_id = ' . $itemId . ' OR a2.item_id = ' . $itemId . ')'); } else { $query->leftJoin($db->qn('#__sr_reservations', 'a3') . ' ON a3.id = a2.reservation_id') ->where('(a3.reservation_asset_id = ' . $itemId . ' OR a2.item_id = ' . $itemId . ')'); } $db->setQuery($query); if ($row = $db->loadObjectList()) { $rows = array_merge($rows, $row); } } $cacheScores['itemId' . $itemId] = $rows; } return $cacheScores['itemId' . $itemId]; } public function getCountCondition($itemId = 0, $scope = 0) { static $cacheCond = array(); $itemId = (int) $itemId; $scope = (int) $scope; $k = $scope . ':' . $itemId; if (!isset($cacheCond[$k])) { $db = $this->getDbo(); $query = $db->getQuery(true) ->select('count(a.field_id)') ->from($db->qn('#__sr_feedback_scores', 'a')) ->innerJoin($db->qn('#__sr_feedbacks', 'a2') . ' ON a2.id = a.feedback_id') ->where('a2.scope = ' . $scope) ->group('a.field_id'); if ($scope) { $query->leftJoin($db->qn('#__sr_experience_reservations', 'a3') . ' ON a3.id = a2.reservation_id') ->where('a2.state = 1 AND (a3.experience_id = ' . $itemId . ' OR a2.item_id = ' . $itemId . ')'); } else { $query->leftJoin($db->qn('#__sr_reservations', 'a3') . ' ON a3.id = a2.reservation_id') ->where('a2.state = 1 AND (a3.reservation_asset_id = ' . $itemId . ' OR a2.item_id = ' . $itemId . ')'); } $db->setQuery($query); if ($result = $db->loadResult()) { $cacheCond[$k] = (int) $result; } else { $cacheCond[$k] = 0; } } return $cacheCond[$k]; } }
| ver. 1.4 |
Github
|
.
| PHP 8.5.7 | Generation time: 0 |
proxy
|
phpinfo
|
Settings