File manager - Edit - /home/verseaumee/ptitsanes/plugins/solidres/limitbooking/components/com_solidres/controllers/limitbookingform.php
Back
<?php /*------------------------------------------------------------------------ Solidres - Hotel booking extension for Joomla ------------------------------------------------------------------------ @Author Solidres Team @Website http://www.solidres.com @Copyright Copyright (C) 2013 - 2015 Solidres. All Rights Reserved. @License GNU General Public License version 3, or later ------------------------------------------------------------------------*/ defined('_JEXEC') or die; require_once SR_PLUGIN_LIMITBOOKING_ADMINISTRATOR.'/controllers/limitbooking.php'; /** * Limit Booking Form controller class. * * @package Solidres * @subpackage LimitBooking * @since 0.6.0 */ class SolidresControllerLimitBookingForm extends SolidresControllerLimitBooking { /** * The URL view item variable. * * @var string * @since 1.6 */ protected $view_item = 'limitbookingform'; /** * The URL view list variable. * * @var string * @since 1.6 */ protected $view_list = 'limitbookings'; /** * The URL edit variable. * * @var string * @since 3.2 */ protected $urlVar = 'id'; public function __construct($config = array()) { parent::__construct($config); } /** * Method to add a new record. * * @return mixed True if the record can be added, a error object if not. * * @since 1.6 */ public function add() { if (!parent::add()) { // Redirect to the return page. $this->setRedirect($this->getReturnPage()); } } /** * Method to cancel an edit. * * @param string $key The name of the primary key of the URL variable. * * @return boolean True if access level checks pass, false otherwise. * * @since 1.6 */ public function cancel($key = 'id') { parent::cancel($key); // Redirect to the return page. $this->setRedirect($this->getReturnPage()); } /** * Get the return URL. * * If a "return" variable has been passed in the request * * @return string The return URL. * * @since 1.6 */ public function getReturnPage() { $return = $this->input->get('return', null, 'base64'); if (empty($return) || !JUri::isInternal(base64_decode($return))) { return JUri::base(); } else { return base64_decode($return); } } /** * Method to edit an existing record. * * @param string $key The name of the primary key of the URL variable. * @param string $urlVar The name of the URL variable if different from the primary key * (sometimes required to avoid router collisions). * * @return boolean True if access level check and checkout passes, false otherwise. * * @since 1.6 */ public function edit($key = null, $urlVar = 'id') { $result = parent::edit($key, $urlVar); return $result; } public function getModel($name = 'LimitBookingForm', $prefix = 'SolidresModel', $config = array('ignore_request' => true)) { $model = parent::getModel($name, $prefix, array('ignore_request' => true)); return $model; } /** * Gets the URL arguments to append to an item redirect. * * @param integer $recordId The primary key id for the item. * @param string $urlVar The name of the URL variable for the id. * * @return string The arguments to append to the redirect URL. * * @since 1.6 */ protected function getRedirectToItemAppend($recordId = null, $urlVar = 'a_id') { // Need to override the parent method completely. $tmpl = $this->input->get('tmpl'); // $layout = $this->input->get('layout', 'edit'); $append = ''; // Setup redirect info. if ($tmpl) { $append .= '&tmpl='.$tmpl; } // TODO This is a bandaid, not a long term solution. // if ($layout) // { // $append .= '&layout=' . $layout; // } $append .= '&layout=edit'; if ($recordId) { $append .= '&'.$urlVar.'='.$recordId; } $itemId = $this->input->getInt('Itemid'); $return = $this->getReturnPage(); $catId = $this->input->getInt('catid', null, 'get'); if ($itemId) { $append .= '&Itemid='.$itemId; } if ($catId) { $append .= '&catid='.$catId; } if ($return) { $append .= '&return='.base64_encode($return); } return $append; } /** * Method override to check if you can add a new record. * * @param array $data An array of input data. * @return boolean * @since 1.6 */ protected function allowAdd($data = array()) { // Initialise variables. $user = JFactory::getUser(); $categoryId = JArrayHelper::getValue($data, 'category_id', JRequest::getInt('filter_category_id'), 'int'); $allow = null; if ($categoryId) { // If the category has been passed in the data or URL check it. $allow = $user->authorise('core.create', 'com_solidres.category.'.$categoryId); } if ($allow === null) { // In the absense of better information, revert to the component permissions. return parent::allowAdd($data); } else { return $allow; } } /** * Method to check if you can add a new record. * * @param array $data An array of input data. * @param string $key The name of the key for the primary key. * @return boolean * @since 1.6 */ protected function allowEdit($data = array(), $key = 'id') { $recordId = (int) isset($data[$key]) ? $data[$key] : 0; $user = JFactory::getUser(); $userId = $user->get('id'); $tableCustomer = JTable::getInstance('Customer', 'SolidresTable'); $tableCustomer->load(array('user_id' => $userId)); // Check general edit permission first. if ($user->authorise('core.edit', 'com_solidres.reservationasset.' . $recordId)) { return true; } // Fallback on edit.own. // First test if the permission is available.r if ($user->authorise('core.edit.own', 'com_solidres.reservationasset.' . $recordId)) { // Now test the owner is the user. $ownerId = (int) isset($data['partner_id']) ? $data['partner_id'] : 0; if (empty($ownerId) && $recordId) { // Need to do a lookup from the model. $record = $this->getModel()->getItem($recordId); if (empty($record)) { return false; } $ownerId = $record->partner_id; } // If the owner matches 'me' then do the test. if ($ownerId == $tableCustomer->id) { return true; } } // Since there is no asset tracking, revert to the component permissions. return parent::allowEdit($data, $key); } }
| ver. 1.4 |
Github
|
.
| PHP 8.5.7 | Generation time: 0 |
proxy
|
phpinfo
|
Settings