| Current Path : /var/www/components/com_contactpush/controllers/ |
| Current File : /var/www/components/com_contactpush/controllers/pushuid.php |
<?php
/** ______________________________________________
* o O | |
* ((((( o < Generated with Cook Self Service V3.1 |
* ( o o ) |______________________________________________|
* --------oOOO-----(_)-----OOOo---------------------------------- www.j-cook.pro --- +
* @version 1.0.0
* @package Contact Push
* @subpackage Push UIDs
* @copyright Netamity 2017
* @author Andy Hickey - www.netamity.com - andy@netamity.com
* @license GPL V2+
*
* .oooO Oooo.
* ( ) ( )
* -------------\ (----) /----------------------------------------------------------- +
* \_) (_/
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
/**
* Contactpush Pushuid Controller
*
* @package Contactpush
* @subpackage Pushuid
*/
class ContactpushCkControllerPushuid extends ContactpushClassControllerItem
{
/**
* The context for storing internal data, e.g. record.
*
* @var string
*/
protected $context = 'pushuid';
/**
* The URL view item variable.
*
* @var string
*/
protected $view_item = 'pushuid';
/**
* The URL view list variable.
*
* @var string
*/
protected $view_list = 'pushuids';
/**
* Constructor
*
* @access public
* @param array $config An optional associative array of configuration settings.
*
* @return void
*/
public function __construct($config = array())
{
parent::__construct($config);
$app = JFactory::getApplication();
}
/**
* Method to cancel an element.
*
* @access public
* @param string $key The name of the primary key of the URL variable.
*
* @return void
*/
public function cancel($key = null)
{
$this->_result = $result = parent::cancel();
$model = $this->getModel();
//Define the redirections
switch($this->getLayout() .'.'. $this->getTask())
{
case 'pushreg.cancel':
$this->applyRedirection($result, array(
'stay',
'com_contactpush.cpanel.default'
), array(
'cid[]' => null
));
break;
default:
$this->applyRedirection($result, array(
'stay',
'stay'
));
break;
}
}
/**
* Return the current layout.
*
* @access protected
* @param bool $default If true, return the default layout.
*
* @return string Requested layout or default layout
*/
protected function getLayout($default = null)
{
if ($default === 'edit')
return 'pushreg';
if ($default)
return 'pushreg';
$jinput = JFactory::getApplication()->input;
return $jinput->get('layout', 'pushreg', 'CMD');
}
/**
* Method to save an element.
*
* @access public
* @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 void
*/
public function save($key = null, $urlVar = null)
{
JSession::checkToken() or JSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
//Check the ACLs
$model = $this->getModel();
$item = $model->getItem();
$result = false;
if ($model->canEdit($item, true))
{
$result = parent::save();
//Get the model through postSaveHook()
if ($this->model)
{
$model = $this->model;
$item = $model->getItem();
}
}
else
JError::raiseWarning( 403, JText::sprintf('ACL_UNAUTORIZED_TASK', JText::_('CONTACTPUSH_JTOOLBAR_SAVE')) );
$this->_result = $result;
//Define the redirections
switch($this->getLayout() .'.'. $this->getTask())
{
case 'pushreg.save':
$this->applyRedirection($result, array(
'stay',
'com_contactpush.cpanel.default'
), array(
'cid[]' => null
));
break;
case 'pushreg.apply':
$this->applyRedirection($result, array(
'stay',
'com_contactpush.pushuid.pushreg'
), array(
'cid[]' => $model->getState('pushuid.id')
));
break;
default:
$this->applyRedirection($result, array(
'stay',
'stay'
));
break;
}
}
}
// Load the fork
ContactpushHelper::loadFork(__FILE__);
// Fallback if no fork has been found
if (!class_exists('ContactpushControllerPushuid')){ class ContactpushControllerPushuid extends ContactpushCkControllerPushuid{} }