| Server IP : 54.36.91.62 / Your IP : 216.73.217.112 Web Server : Apache System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : coopiak ( 151928) PHP Version : 8.3.23 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/coopiak/amisdesseniors-fr/components/com_djcatalog2/controllers/ |
Upload File : |
<?php
/**
* @package DJ-Catalog2
* @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
* @license http://www.gnu.org/licenses GNU/GPL
* @author url: http://dj-extensions.com
* @author email contact@dj-extensions.com
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Language\Text;
require_once(JPATH_ROOT.'/administrator/components/com_djcatalog2/lib/controllerform.php');
class Djcatalog2ControllerAddress extends DJCFormController {
function __construct($config = array())
{
$this->view_list = 'addresses';
$this->view_item = 'address';
parent::__construct($config);
//$this->unregisterTask('save2copy');
}
protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id')
{
$app = Factory::getApplication();
$tmpl = $app->input->get('tmpl');
// got rid of edit layout
$layout = $app->input->get('layout');
$append = '';
// Setup redirect info.
if ($tmpl)
{
$append .= '&tmpl=' . $tmpl;
}
if ($layout)
{
$append .= '&layout=' . $layout;
}
if ($recordId)
{
$append .= '&' . $urlVar . '=' . $recordId;
}
$needles = array(
'addresses' => array(0)
);
if ($item = DJCatalogHelperRoute::_findItem($needles)) {
$append .= '&Itemid='.$item;
}
return $append;
}
protected function getRedirectToListAppend()
{
$app = Factory::getApplication();
$tmpl = Factory::getApplication()->input->get('tmpl');
$append = '';
// Setup redirect info.
if ($tmpl)
{
$append .= '&tmpl=' . $tmpl;
}
$needles = array(
'addresses' => array(0)
);
if ($item = DJCatalogHelperRoute::_findItem($needles)) {
$append .= '&Itemid='.$item;
}
return $append;
}
protected function allowEdit($data = array(), $key = 'id') {
// Initialise variables.
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
$user = Factory::getUser();
$userId = $user->get('id');
//$asset = 'com_djcatalog2.item.'.$recordId;
// Check general edit permission first.
if ($user->authorise('core.edit', $this->option)) {
return true;
}
$ownerId = (int) isset($data['user_id']) ? $data['user_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->user_id;
}
if ($ownerId == $userId) {
return true;
}
// Since there is no asset tracking, revert to the component permissions.
return parent::allowEdit($data, $key);
}
protected function allowAdd($data = array())
{
$user = Factory::getUser();
return $user->id ? true : false;
}
public function add() {
$user = Factory::getUser();
if ((bool)$user->guest && !$this->allowAdd()) {
$return_url = base64_encode(DJCatalogHelperRoute::getAddressesRoute().'&task=address.add');
$this->setRedirect(Route::_('index.php?option=com_users&view=login&return='.$return_url, false), Text::_('COM_DJCATALOG2_PLEASE_LOGIN'));
return true;
}
$this->setRedirect(Route::_('index.php?option=com_djcatalog2&view=address&id=0', false));
return 1;
}
}
?>