Your IP : 10.10.0.253


Current Path : /var/www/components/com_contactpush/views/pushuid/
Upload File :
Current File : /var/www/components/com_contactpush/views/pushuid/view.html.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');



/**
* HTML View class for the Contactpush component
*
* @package	Contactpush
* @subpackage	Pushuid
*/
class ContactpushCkViewPushuid extends ContactpushClassView
{
	/**
	* List of the reachables layouts. Fill this array in every view file.
	*
	* @var array
	*/
	protected $layouts = array('pushreg');

	/**
	* Execute and display a template : Push registration
	*
	* @access	protected
	* @param	string	$tpl	The name of the template file to parse; automatically searches through the template paths.
	*
	*
	* @since	11.1
	*
	* @return	mixed	A string if successful, otherwise a JError object.
	*/
	protected function displayPushreg($tpl = null)
	{
		// Initialiase variables.
		$this->model	= $model	= $this->getModel();
        $jinput = JFactory::getApplication()->input;
        $iid = $jinput->get('id');
        if(!$iid)
        {
            $jinput->set('id',$this->setCid());
        }

		$this->state	= $state	= $this->get('State');
		$this->params 	= $state->get('params');
		$state->set('context', 'layout.pushreg');
		$this->item		= $item		= $this->get('Item');

		$this->form		= $form		= $this->get('Form');
		$this->canDo	= $canDo	= ContactpushHelper::getActions($model->getId());
		$lists = array();
		$this->lists = &$lists;

		// Define the title
		$this->_prepareDocument(JText::_('CONTACTPUSH_LAYOUT_PUSH_REGISTRATION'), $this->item, 'push_user_id');

		$user		= JFactory::getUser();

		$isNew		= ($model->getId() == 0);

		//Check ACL before opening the form (prevent from direct access)
//		if (!$model->canEdit($item, true))
//			$model->setError(JText::_('JERROR_ALERTNOAUTHOR'));

		// Check for errors.
		if (count($errors = $model->getErrors()))
		{
			JError::raiseError(500, implode(BR, array_unique($errors)));
			return false;
		}
		//Toolbar

		// Save & Close
//		if (($isNew && $model->canCreate()) || (!$isNew && $item->params->get('access-edit')))
//			JToolBarHelper::save('pushuid.save', "CONTACTPUSH_JTOOLBAR_SAVE_CLOSE");
		// Save
		if (($isNew && $model->canCreate()) || (!$isNew && $item->params->get('access-edit')))
			JToolBarHelper::apply('pushuid.apply', "CONTACTPUSH_JTOOLBAR_SAVE");
		// Cancel
		JToolBarHelper::back('Back');

		// Publish
//		if (!$isNew && $model->canEditState($item) && ($item->published != 1))
//			JToolBarHelper::publish('pushuids.publish', "Activate");
//		// Unpublish
//		if (!$isNew && $model->canEditState($item) && ($item->published != 0))
//			JToolBarHelper::unpublish('pushuids.unpublish', "Deactivate");

		$this->toolbar = JToolbar::getInstance();
		$model_user = CkJModel::getInstance('ThirdUsers', 'ContactpushModel');
		$model_user->addGroupOrder("a.name");
		$lists['fk']['user'] = $model_user->getItems();
	}

	public function setCid()
    {
        $db = JFactory::getDbo();
        $query ="SELECT id FROM #__contactpush_pushuids WHERE user =" . JFactory::getUser()->id;
        $db->setQuery($query);
        return $db->loadResult();
    }


}

// Load the fork
ContactpushHelper::loadFork(__FILE__);

// Fallback if no fork has been found
if (!class_exists('ContactpushViewPushuid')){ class ContactpushViewPushuid extends ContactpushCkViewPushuid{} }