Your IP : 10.10.0.253


Current Path : /var/www/components/com_contactpush/views/messages/
Upload File :
Current File : /var/www/components/com_contactpush/views/messages/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	Messages
* @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	Messages
*/
class ContactpushCkViewMessages extends ContactpushClassView
{
	/**
	* List of the reachables layouts. Fill this array in every view file.
	*
	* @var array
	*/
	protected $layouts = array('default');

	/**
	* Execute and display a template : Messages
	*
	* @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 displayDefault($tpl = null)
	{
		$this->model		= $model	= $this->getModel();
		$this->state		= $state	= $this->get('State');
		$this->params 		= JComponentHelper::getParams('com_contactpush', true);
		$state->set('context', 'layout.default');
		$this->items		= $items	= $this->get('Items');
		$this->canDo		= $canDo	= ContactpushHelper::getActions();
		$this->pagination	= $this->get('Pagination');
		$this->filters = $filters = $model->getForm('default.filters');
		$this->menu = ContactpushHelper::addSubmenu('messages', 'default');
		$lists = array();
		$this->lists = &$lists;

		// Define the title
		$this->_prepareDocument(JText::_('CONTACTPUSH_LAYOUT_MESSAGES'));

		

		//Filters
		// Created By > Name
		$modelCreated_by = CkJModel::getInstance('thirdusers', 'ContactpushModel');
		$modelCreated_by->set('context', $model->get('context'));
		$filters['filter_created_by']->jdomOptions = array(
			'list' => $modelCreated_by->getItems()
		);

		// Sort by
		$filters['sortTable']->jdomOptions = array(
			'list' => $this->getSortFields('default')
		);

		// Limit
		$filters['limit']->jdomOptions = array(
			'pagination' => $this->pagination
		);

		// Toolbar

		// New
        $params = JComponentHelper::getParams('com_contactpush');
        $send_usergroups = $params->get('send_usergroups');
        $prior_usergroups = $params->get('prior_usergroups');
        $user = JFactory::getUser();
        jimport( 'joomla.access.access' );
        $g = JAccess::getAuthorisedViewLevels($user->id);
        if(array_intersect($g,$send_usergroups)) {
            if ($model->canCreate())
                JToolBarHelper::addNew('message.add', "CONTACTPUSH_JTOOLBAR_NEW");
        }
		$this->toolbar = JToolbar::getInstance();
	}

	/**
	* Execute and display a template : Messages
	*
	* @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 displayModal($tpl = null)
	{
		$this->model		= $model	= $this->getModel();
		$this->state		= $state	= $this->get('State');
		$this->params 		= JComponentHelper::getParams('com_contactpush', true);
		$state->set('context', 'layout.modal');
		$this->items		= $items	= $this->get('Items');
		$this->canDo		= $canDo	= ContactpushHelper::getActions();
		$this->pagination	= $this->get('Pagination');
		$this->filters = $filters = $model->getForm('modal.filters');
		$this->menu = ContactpushHelper::addSubmenu('messages', 'modal');
		$lists = array();
		$this->lists = &$lists;

		// Define the title
		$this->_prepareDocument(JText::_('CONTACTPUSH_LAYOUT_MESSAGES'));

		

		//Filters
		// Limit
		$filters['limit']->jdomOptions = array(
			'pagination' => $this->pagination
		);

		// Toolbar

		// New
		if ($model->canCreate())
			JToolBarHelper::addNew('message.add', "CONTACTPUSH_JTOOLBAR_NEW");

		// Delete
		if ($model->canDelete())
			JToolBarHelper::deleteList(JText::_('CONTACTPUSH_JTOOLBAR_ARE_YOU_SURE_TO_DELETE'), 'message.delete', "CONTACTPUSH_JTOOLBAR_DELETE");



		// Archive
		if ($model->canEditState())
			JToolBarHelper::archiveList('messages.archive', "CONTACTPUSH_JTOOLBAR_ARCHIVE");

		// Trash
		if ($model->canEditState())
			JToolBarHelper::trash('messages.trash', "CONTACTPUSH_JTOOLBAR_TRASH");

		$this->toolbar = JToolbar::getInstance();
	}

	/**
	* Returns an array of fields the table can be sorted by.
	*
	* @access	protected
	* @param	string	$layout	The name of the called layout. Not used yet
	*
	*
	* @since	3.0
	*
	* @return	array	Array containing the field name to sort by as the key and display text as value.
	*/
	protected function getSortFields($layout = null)
	{
		return array(
			'creation_date' => JText::_('CONTACTPUSH_FIELD_DATE'),
			'created_by.name' => JText::_('CONTACTPUSH_FIELD_SENDER'),
			'title' => JText::_('CONTACTPUSH_FIELD_TITLE'),
			'priority' => JText::_('CONTACTPUSH_FIELD_PRIORITY'),
			'status' => JText::_('CONTACTPUSH_FIELD_STATUS')
		);
	}


}

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

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