| Current Path : /var/www/components/com_contactpush/views/message/ |
| Current File : /var/www/components/com_contactpush/views/message/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 Message
*/
class ContactpushCkViewMessage extends ContactpushClassView
{
/**
* List of the reachables layouts. Fill this array in every view file.
*
* @var array
*/
protected $layouts = array('messagedetails', 'newmessage');
/**
* Execute and display a template : Message details
*
* @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 displayMessagedetails($tpl = null)
{
// Initialiase variables.
$this->model = $model = $this->getModel();
$this->state = $state = $this->get('State');
$this->params = $state->get('params');
$state->set('context', 'layout.messagedetails');
$this->item = $item = $this->get('Item');
$this->canDo = $canDo = ContactpushHelper::getActions($model->getId());
$lists = array();
$this->lists = &$lists;
// Define the title
$this->_prepareDocument(JText::_('CONTACTPUSH_LAYOUT_MESSAGE_DETAILS'), $this->item, 'created_by');
$user = JFactory::getUser();
$isNew = ($model->getId() == 0);
//Check ACL before opening the view (prevent from direct access)
if (!$model->canAccess($item))
$model->setError(JText::_('JERROR_ALERTNOAUTHOR'));
// Check for errors.
if (count($errors = $model->getErrors()))
{
JError::raiseError(500, implode(BR, array_unique($errors)));
return false;
}
//Toolbar
$this->toolbar = JToolbar::getInstance();
}
/**
* Execute and display a template : New message
*
* @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 displayNewmessage($tpl = null)
{
// Initialiase variables.
$this->model = $model = $this->getModel();
$this->state = $state = $this->get('State');
$this->params = $state->get('params');
$state->set('context', 'layout.newmessage');
$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_NEW_MESSAGE'), $this->item, 'created_by');
$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
// Cancel
JToolBarHelper::cancel('message.cancel', "CONTACTPUSH_JTOOLBAR_CANCEL");
// Save & Close
$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 (($isNew && $model->canCreate()) || (!$isNew && $item->params->get('access-edit')))
JToolBarHelper::save('message.save', "Send message");
}
$this->toolbar = JToolbar::getInstance();
$model_created_by = CkJModel::getInstance('ThirdUsers', 'ContactpushModel');
$model_created_by->addGroupOrder("a.name");
$lists['fk']['created_by'] = $model_created_by->getItems();
}
public function getRecipientList()
{
$db = JFactory::getDbo();
$query ="SELECT pu.id , u.name FROM #__contactpush_pushuids pu INNER JOIN #__users u ON pu.user = u.id WHERE u.block = 0 AND pu.published = 1";
$db->setQuery($query);
$results = $db->loadObjectList();
$rtn = '<select id="jform_pushuids" name="jform[pushuids][]" multiple>';
foreach($results as $r)
{
$rtn .= '<option value="'.$r->id.'">'.$r->name.'</option>';
}
$rtn .= '</select>';
return $rtn;
}
public function getRecipients($id)
{
$db = JFactory::getDbo();
$query ="SELECT name FROM #__users WHERE id IN (SELECT user FROM #__contactpush_pushuids WHERE id IN ( SELECT user FROM #__contactpush_messagerecipients WHERE message = ".$id."))";
$db->setQuery($query);
//return $query;
return $db->loadColumn();
}
}
// Load the fork
ContactpushHelper::loadFork(__FILE__);
// Fallback if no fork has been found
if (!class_exists('ContactpushViewMessage')){ class ContactpushViewMessage extends ContactpushCkViewMessage{} }