Spade
Mini Shell
access.xml000064400000001162151166621630006536 0ustar00<?xml
version="1.0" encoding="utf-8" ?>
<access component="com_messages">
<section name="component">
<action name="core.admin" title="JACTION_ADMIN"
description="JACTION_ADMIN_COMPONENT_DESC" />
<action name="core.manage" title="JACTION_MANAGE"
description="JACTION_MANAGE_COMPONENT_DESC" />
<action name="core.create" title="JACTION_CREATE"
description="JACTION_CREATE_COMPONENT_DESC" />
<action name="core.delete" title="JACTION_DELETE"
description="JACTION_DELETE_COMPONENT_DESC" />
<action name="core.edit.state"
title="JACTION_EDITSTATE"
description="JACTION_EDITSTATE_COMPONENT_DESC" />
</section>
</access>
config.xml000064400000000546151166621630006547 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<config>
<fieldset
name="permissions"
label="JCONFIG_PERMISSIONS_LABEL"
description="JCONFIG_PERMISSIONS_DESC"
>
<field
name="rules"
type="rules"
label="JCONFIG_PERMISSIONS_LABEL"
filter="rules"
validate="rules"
component="com_messages"
section="component"
/>
</fieldset>
</config>
controller.php000064400000003132151166621630007446 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_messages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Messages master display controller.
*
* @since 1.6
*/
class MessagesController extends JControllerLegacy
{
/**
* Method to display a view.
*
* @param boolean $cachable If true, the view output will be cached.
* @param array $urlparams An array of safe URL parameters and their
variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
*
* @since 1.5
*/
public function display($cachable = false, $urlparams = false)
{
JLoader::register('MessagesHelper', JPATH_ADMINISTRATOR .
'/components/com_messages/helpers/messages.php');
$view = $this->input->get('view',
'messages');
$layout = $this->input->get('layout',
'default');
$id = $this->input->getInt('id');
// Check for edit form.
if ($view == 'message' && $layout == 'edit'
&& !$this->checkEditId('com_messages.edit.message',
$id))
{
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID',
$id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_messages&view=messages',
false));
return false;
}
// Load the submenu.
MessagesHelper::addSubmenu($this->input->get('view',
'messages'));
parent::display();
}
}
controllers/config.php000064400000003756151166621630011112 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_messages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Messages Component Message Model
*
* @since 1.6
*/
class MessagesControllerConfig extends JControllerLegacy
{
/**
* Method to save a record.
*
* @return boolean
*
* @since 1.6
*/
public function save()
{
// Check for request forgeries.
$this->checkToken();
$app = JFactory::getApplication();
$model = $this->getModel('Config',
'MessagesModel');
$data = $this->input->post->get('jform', array(),
'array');
// Validate the posted data.
$form = $model->getForm();
if (!$form)
{
JError::raiseError(500, $model->getError());
return false;
}
$data = $model->validate($form, $data);
// Check for validation errors.
if ($data === false)
{
// Get the validation messages.
$errors = $model->getErrors();
// Push up to three validation messages out to the user.
for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++)
{
if ($errors[$i] instanceof Exception)
{
$app->enqueueMessage($errors[$i]->getMessage(),
'warning');
}
else
{
$app->enqueueMessage($errors[$i], 'warning');
}
}
// Redirect back to the main list.
$this->setRedirect(JRoute::_('index.php?option=com_messages&view=messages',
false));
return false;
}
// Attempt to save the data.
if (!$model->save($data))
{
// Redirect back to the main list.
$this->setMessage(JText::sprintf('JERROR_SAVE_FAILED',
$model->getError()), 'warning');
$this->setRedirect(JRoute::_('index.php?option=com_messages&view=messages',
false));
return false;
}
// Redirect to the list screen.
$this->setMessage(JText::_('COM_MESSAGES_CONFIG_SAVED'));
$this->setRedirect(JRoute::_('index.php?option=com_messages&view=messages',
false));
return true;
}
}
controllers/message.php000064400000002451151166621630011260
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_messages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Messages Component Message Model
*
* @since 1.6
*/
class MessagesControllerMessage extends JControllerForm
{
/**
* Method (override) to check if you can save a new or existing record.
*
* Adjusts for the primary key name and hands off to the parent class.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
*
* @since 1.6
*/
protected function allowSave($data, $key = 'message_id')
{
return parent::allowSave($data, $key);
}
/**
* Reply to an existing message.
*
* This is a simple redirect to the compose form.
*
* @return void
*
* @since 1.6
*/
public function reply()
{
if ($replyId = $this->input->getInt('reply_id'))
{
$this->setRedirect('index.php?option=com_messages&view=message&layout=edit&reply_id='
. $replyId);
}
else
{
$this->setMessage(JText::_('COM_MESSAGES_INVALID_REPLY_ID'));
$this->setRedirect('index.php?option=com_messages&view=messages');
}
}
}
controllers/messages.php000064400000001571151166621630011445
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_messages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Messages list controller class.
*
* @since 1.6
*/
class MessagesControllerMessages extends JControllerAdmin
{
/**
* Method to get a model object, loading it if required.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return object The model.
*
* @since 1.6
*/
public function getModel($name = 'Message', $prefix =
'MessagesModel', $config = array('ignore_request' =>
true))
{
return parent::getModel($name, $prefix, $config);
}
}
helpers/html/messages.php000064400000005237151166621630011510
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_messages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* JHtml administrator messages class.
*
* @since 1.6
*/
class JHtmlMessages
{
/**
* Get the HTML code of the state switcher
*
* @param int $value The state value
* @param int $i Row number
* @param boolean $canChange Can the user change the state?
*
* @return string
*
* @since 1.6
*
* @deprecated 4.0 Use JHtmlMessages::status() instead
*/
public static function state($value = 0, $i = 0, $canChange = false)
{
// Log deprecated message
try
{
JLog::add(
sprintf('%s() is deprecated. Use JHtmlMessages::status()
instead.', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
// Note: $i is required but has to be an optional argument in the
function call due to argument order
if (null === $i)
{
throw new InvalidArgumentException('$i is a required argument in
JHtmlMessages::state');
}
// Note: $canChange is required but has to be an optional argument in the
function call due to argument order
if (null === $canChange)
{
throw new InvalidArgumentException('$canChange is a required
argument in JHtmlMessages::state');
}
return static::status($i, $value, $canChange);
}
/**
* Get the HTML code of the state switcher
*
* @param int $i Row number
* @param int $value The state value
* @param boolean $canChange Can the user change the state?
*
* @return string
*
* @since 3.4
*/
public static function status($i, $value = 0, $canChange = false)
{
// Array of image, task, title, action.
$states = array(
-2 => array('trash', 'messages.unpublish',
'JTRASHED', 'COM_MESSAGES_MARK_AS_UNREAD'),
1 => array('publish', 'messages.unpublish',
'COM_MESSAGES_OPTION_READ',
'COM_MESSAGES_MARK_AS_UNREAD'),
0 => array('unpublish', 'messages.publish',
'COM_MESSAGES_OPTION_UNREAD',
'COM_MESSAGES_MARK_AS_READ'),
);
$state = ArrayHelper::getValue($states, (int) $value, $states[0]);
$icon = $state[0];
if ($canChange)
{
$html = '<a href="#" onclick="return
listItemTask(\'cb' . $i . '\',\'' . $state[1]
. '\')" class="btn btn-micro hasTooltip'
. ($value == 1 ? ' active' : '') . '"
title="' . JHtml::_('tooltipText', $state[3])
. '"><span class="icon-' . $icon .
'" aria-hidden="true"></span></a>';
}
return $html;
}
}
helpers/messages.php000064400000003571151166621630010543 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_messages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Messages helper class.
*
* @since 1.6
*/
class MessagesHelper
{
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*
* @since 1.6
*/
public static function addSubmenu($vName)
{
JHtmlSidebar::addEntry(
JText::_('COM_MESSAGES_ADD'),
'index.php?option=com_messages&view=message&layout=edit',
$vName == 'message'
);
JHtmlSidebar::addEntry(
JText::_('COM_MESSAGES_READ'),
'index.php?option=com_messages',
$vName == 'messages'
);
}
/**
* Gets a list of the actions that can be performed.
*
* @return JObject
*
* @deprecated 3.2 Use JHelperContent::getActions() instead
*/
public static function getActions()
{
// Log usage of deprecated function
try
{
JLog::add(
sprintf('%s() is deprecated. Use JHelperContent::getActions() with
new arguments order instead.', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
// Get list of actions
return JHelperContent::getActions('com_messages');
}
/**
* Get a list of filter options for the state of a module.
*
* @return array An array of JHtmlOption elements.
*
* @since 1.6
*/
public static function getStateOptions()
{
// Build the filter options.
$options = array();
$options[] = JHtml::_('select.option', '1',
JText::_('COM_MESSAGES_OPTION_READ'));
$options[] = JHtml::_('select.option', '0',
JText::_('COM_MESSAGES_OPTION_UNREAD'));
$options[] = JHtml::_('select.option', '-2',
JText::_('JTRASHED'));
return $options;
}
}
messages.php000064400000001205151166621630007071 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_messages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
if (!JFactory::getUser()->authorise('core.manage',
'com_messages'))
{
throw new
JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'),
403);
}
$task =
JFactory::getApplication()->input->get('task');
$controller = JControllerLegacy::getInstance('Messages');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();
messages.xml000064400000002212151166621630007101 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<extension type="component" version="3.1"
method="upgrade">
<name>com_messages</name>
<author>Joomla! Project</author>
<creationDate>April 2006</creationDate>
<copyright>(C) 2005 - 2020 Open Source Matters. All rights
reserved.</copyright>
<license>GNU General Public License version 2 or later; see
LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>COM_MESSAGES_XML_DESCRIPTION</description>
<languages folder="site">
<language
tag="en-GB">language/en-GB.com_messages.ini</language>
</languages>
<administration>
<files folder="admin">
<filename>config.xml</filename>
<filename>controller.php</filename>
<filename>messages.php</filename>
<folder>controllers</folder>
<folder>helpers</folder>
<folder>models</folder>
<folder>tables</folder>
<folder>views</folder>
</files>
<languages folder="admin">
<language
tag="en-GB">language/en-GB.com_messages.ini</language>
<language
tag="en-GB">language/en-GB.com_messages.sys.ini</language>
</languages>
</administration>
</extension>
models/config.php000064400000006572151166621630010026 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_messages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Message configuration model.
*
* @since 1.6
*/
class MessagesModelConfig extends JModelForm
{
/**
* Method to auto-populate the model state.
*
* This method should only be called once per instantiation and is
designed
* to be called on the first call to the getState() method unless the
model
* configuration flag to ignore the request is set.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
* @since 1.6
*/
protected function populateState()
{
$user = JFactory::getUser();
$this->setState('user.id', $user->get('id'));
// Load the parameters.
$params = JComponentHelper::getParams('com_messages');
$this->setState('params', $params);
}
/**
* Method to get a single record.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function &getItem()
{
$item = new JObject;
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('cfg_name, cfg_value')
->from('#__messages_cfg')
->where($db->quoteName('user_id') . ' = ' .
(int) $this->getState('user.id'));
$db->setQuery($query);
try
{
$rows = $db->loadObjectList();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
foreach ($rows as $row)
{
$item->set($row->cfg_name, $row->cfg_value);
}
$this->preprocessData('com_messages.config', $item);
return $item;
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return JForm A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_messages.config',
'config', array('control' => 'jform',
'load_data' => $loadData));
if (empty($form))
{
return false;
}
return $form;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$db = $this->getDbo();
if ($userId = (int) $this->getState('user.id'))
{
$query = $db->getQuery(true)
->delete($db->quoteName('#__messages_cfg'))
->where($db->quoteName('user_id') . '=' .
(int) $userId);
$db->setQuery($query);
try
{
$db->execute();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
if (count($data))
{
$query = $db->getQuery(true)
->insert($db->quoteName('#__messages_cfg'))
->columns($db->quoteName(array('user_id',
'cfg_name', 'cfg_value')));
foreach ($data as $k => $v)
{
$query->values($userId . ', ' . $db->quote($k) .
', ' . $db->quote($v));
}
$db->setQuery($query);
try
{
$db->execute();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
}
return true;
}
else
{
$this->setError('COM_MESSAGES_ERR_INVALID_USER');
return false;
}
}
}
models/fields/messagestates.php000064400000001705151166621630012670
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_messages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('MessagesHelper', JPATH_ADMINISTRATOR .
'/components/com_messages/helpers/messages.php');
JFormHelper::loadFieldClass('list');
/**
* Message States field.
*
* @since 3.6.0
*/
class JFormFieldMessageStates extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.6.0
*/
protected $type = 'MessageStates';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.6.0
*/
protected function getOptions()
{
// Merge state options with any additional options in the XML definition.
return array_merge(parent::getOptions(),
MessagesHelper::getStateOptions());
}
}
models/fields/usermessages.php000064400000003255151166621630012530
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_messages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JFormHelper::loadFieldClass('user');
/**
* Supports a modal select of users that have access to com_messages
*
* @since 1.6
*/
class JFormFieldUserMessages extends JFormFieldUser
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
public $type = 'UserMessages';
/**
* Method to get the filtering groups (null means no filtering)
*
* @return array|null array of filtering groups or null.
*
* @since 1.6
*/
protected function getGroups()
{
// Compute usergroups
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('id')
->from('#__usergroups');
$db->setQuery($query);
try
{
$groups = $db->loadColumn();
}
catch (RuntimeException $e)
{
JError::raiseNotice(500, $e->getMessage());
return null;
}
foreach ($groups as $i => $group)
{
if (JAccess::checkGroup($group, 'core.admin'))
{
continue;
}
if (!JAccess::checkGroup($group, 'core.manage',
'com_messages'))
{
unset($groups[$i]);
continue;
}
if (!JAccess::checkGroup($group, 'core.login.admin'))
{
unset($groups[$i]);
continue;
}
}
return array_values($groups);
}
/**
* Method to get the users to exclude from the list of users
*
* @return array|null array of users to exclude or null to to not exclude
them
*
* @since 1.6
*/
protected function getExcluded()
{
return array(JFactory::getUser()->id);
}
}
models/forms/config.xml000064400000001451151166621630011154
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="lock"
type="radio"
label="COM_MESSAGES_FIELD_LOCK_LABEL"
description="COM_MESSAGES_FIELD_LOCK_DESC"
class="btn-group btn-group-yesno"
default="0"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="mail_on_new"
type="radio"
label="COM_MESSAGES_FIELD_MAIL_ON_NEW_LABEL"
description="COM_MESSAGES_FIELD_MAIL_ON_NEW_DESC"
class="btn-group btn-group-yesno"
default="1"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="auto_purge"
type="number"
label="COM_MESSAGES_FIELD_AUTO_PURGE_LABEL"
description="COM_MESSAGES_FIELD_AUTO_PURGE_DESC"
size="6"
default="7"
/>
</fieldset>
</form>
models/forms/filter_messages.xml000064400000003052151166621630013062
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_MESSAGES_FILTER_SEARCH_LABEL"
description="COM_MESSAGES_SEARCH_IN_SUBJECT"
hint="JSEARCH_FILTER"
/>
<field
name="state"
type="messagestates"
label="COM_MESSAGES_FILTER_STATES_LABEL"
description="COM_MESSAGES_FILTER_STATES_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
<option value="*">JALL</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
default="a.date_time DESC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.subject
ASC">COM_MESSAGES_HEADING_SUBJECT_ASC</option>
<option value="a.subject
DESC">COM_MESSAGES_HEADING_SUBJECT_DESC</option>
<option value="a.state
ASC">COM_MESSAGES_HEADING_READ_ASC</option>
<option value="a.state
DESC">COM_MESSAGES_HEADING_READ_DESC</option>
<option value="a.user_id_from
ASC">COM_MESSAGES_HEADING_FROM_ASC</option>
<option value="a.user_id_from
DESC">COM_MESSAGES_HEADING_FROM_DESC</option>
<option value="a.date_time ASC">JDATE_ASC</option>
<option value="a.date_time
DESC">JDATE_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="JGLOBAL_LIMIT"
description="JGLOBAL_LIMIT"
class="input-mini"
default="5"
onchange="this.form.submit();"
/>
</fields>
</form>
models/forms/message.xml000064400000001217151166621630011333
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="user_id_to"
type="usermessages"
label="COM_MESSAGES_FIELD_USER_ID_TO_LABEL"
description="COM_MESSAGES_FIELD_USER_ID_TO_DESC"
default="0"
required="true"
/>
<field
name="subject"
type="text"
label="COM_MESSAGES_FIELD_SUBJECT_LABEL"
description="COM_MESSAGES_FIELD_SUBJECT_DESC"
required="true"
/>
<field
name="message"
type="editor"
label="COM_MESSAGES_FIELD_MESSAGE_LABEL"
description="COM_MESSAGES_FIELD_MESSAGE_DESC"
required="true"
filter="JComponentHelper::filterText"
buttons="false"
/>
</fieldset>
</form>
models/message.php000064400000032120151166621630010171 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_messages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Router\Route;
/**
* Private Message model.
*
* @since 1.6
*/
class MessagesModelMessage extends JModelAdmin
{
/**
* Message
*/
protected $item;
/**
* Method to auto-populate the model state.
*
* This method should only be called once per instantiation and is
designed
* to be called on the first call to the getState() method unless the
model
* configuration flag to ignore the request is set.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
* @since 1.6
*/
protected function populateState()
{
parent::populateState();
$input = JFactory::getApplication()->input;
$user = JFactory::getUser();
$this->setState('user.id', $user->get('id'));
$messageId = (int) $input->getInt('message_id');
$this->setState('message.id', $messageId);
$replyId = (int) $input->getInt('reply_id');
$this->setState('reply.id', $replyId);
}
/**
* Check that recipient user is the one trying to delete and then call
parent delete method
*
* @param array &$pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @since 3.1
*/
public function delete(&$pks)
{
$pks = (array) $pks;
$table = $this->getTable();
$user = JFactory::getUser();
// Iterate the items to delete each one.
foreach ($pks as $i => $pk)
{
if ($table->load($pk))
{
if ($table->user_id_to != $user->id)
{
// Prune items that you can't change.
unset($pks[$i]);
try
{
JLog::add(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'),
JLog::WARNING, 'jerror');
}
catch (RuntimeException $exception)
{
JFactory::getApplication()->enqueueMessage(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'),
'warning');
}
return false;
}
}
else
{
$this->setError($table->getError());
return false;
}
}
return parent::delete($pks);
}
/**
* Returns a Table object, always creating it.
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'Message', $prefix =
'MessagesTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if (!isset($this->item))
{
if ($this->item = parent::getItem($pk))
{
// Invalid message_id returns 0
if ($this->item->user_id_to === '0')
{
$this->setError(JText::_('JERROR_ALERTNOAUTHOR'));
return false;
}
// Prime required properties.
if (empty($this->item->message_id))
{
// Prepare data for a new record.
if ($replyId = $this->getState('reply.id'))
{
// If replying to a message, preload some data.
$db = $this->getDbo();
$query = $db->getQuery(true)
->select($db->quoteName(array('subject',
'user_id_from', 'user_id_to')))
->from($db->quoteName('#__messages'))
->where($db->quoteName('message_id') . ' =
' . (int) $replyId);
try
{
$message = $db->setQuery($query)->loadObject();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
if (!$message || $message->user_id_to !=
JFactory::getUser()->id)
{
$this->setError(JText::_('JERROR_ALERTNOAUTHOR'));
return false;
}
$this->item->set('user_id_to',
$message->user_id_from);
$re = JText::_('COM_MESSAGES_RE');
if (stripos($message->subject, $re) !== 0)
{
$this->item->set('subject', $re . ' ' .
$message->subject);
}
}
}
elseif ($this->item->user_id_to != JFactory::getUser()->id)
{
$this->setError(JText::_('JERROR_ALERTNOAUTHOR'));
return false;
}
else
{
// Mark message read
$db = $this->getDbo();
$query = $db->getQuery(true)
->update($db->quoteName('#__messages'))
->set($db->quoteName('state') . ' = 1')
->where($db->quoteName('message_id') . ' =
' . $this->item->message_id);
$db->setQuery($query)->execute();
}
}
// Get the user name for an existing message.
if ($this->item->user_id_from && $fromUser = new
JUser($this->item->user_id_from))
{
$this->item->set('from_user_name', $fromUser->name);
}
}
return $this->item;
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return JForm A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_messages.message',
'message', array('control' => 'jform',
'load_data' => $loadData));
if (empty($form))
{
return false;
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_messages.edit.message.data',
array());
if (empty($data))
{
$data = $this->getItem();
}
$this->preprocessData('com_messages.message', $data);
return $data;
}
/**
* Checks that the current user matches the message recipient and calls
the parent publish method
*
* @param array &$pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
*
* @since 3.1
*/
public function publish(&$pks, $value = 1)
{
$user = JFactory::getUser();
$table = $this->getTable();
$pks = (array) $pks;
// Check that the recipient matches the current user
foreach ($pks as $i => $pk)
{
$table->reset();
if ($table->load($pk))
{
if ($table->user_id_to != $user->id)
{
// Prune items that you can't change.
unset($pks[$i]);
try
{
JLog::add(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'),
JLog::WARNING, 'jerror');
}
catch (RuntimeException $exception)
{
JFactory::getApplication()->enqueueMessage(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'),
'warning');
}
return false;
}
}
}
return parent::publish($pks, $value);
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$table = $this->getTable();
// Bind the data.
if (!$table->bind($data))
{
$this->setError($table->getError());
return false;
}
// Assign empty values.
if (empty($table->user_id_from))
{
$table->user_id_from = JFactory::getUser()->get('id');
}
if ((int) $table->date_time == 0)
{
$table->date_time = JFactory::getDate()->toSql();
}
// Check the data.
if (!$table->check())
{
$this->setError($table->getError());
return false;
}
// Load the user details (already valid from table check).
$toUser = \JUser::getInstance($table->user_id_to);
// Check if recipient can access com_messages.
if (!$toUser->authorise('core.login.admin') ||
!$toUser->authorise('core.manage', 'com_messages'))
{
$this->setError(\JText::_('COM_MESSAGES_ERROR_RECIPIENT_NOT_AUTHORISED'));
return false;
}
// Load the recipient user configuration.
$model = JModelLegacy::getInstance('Config',
'MessagesModel', array('ignore_request' => true));
$model->setState('user.id', $table->user_id_to);
$config = $model->getItem();
if (empty($config))
{
$this->setError($model->getError());
return false;
}
if ($config->get('lock', false))
{
$this->setError(JText::_('COM_MESSAGES_ERR_SEND_FAILED'));
return false;
}
// Store the data.
if (!$table->store())
{
$this->setError($table->getError());
return false;
}
if ($config->get('mail_on_new', true))
{
$fromUser = JUser::getInstance($table->user_id_from);
$debug =
JFactory::getConfig()->get('debug_lang');
$default_language =
JComponentHelper::getParams('com_languages')->get('administrator');
$lang =
JLanguage::getInstance($toUser->getParam('admin_language',
$default_language), $debug);
$lang->load('com_messages', JPATH_ADMINISTRATOR);
// Build the email subject and message
$app = JFactory::getApplication();
$linkMode = $app->get('force_ssl', 0) >= 1 ?
Route::TLS_FORCE : Route::TLS_IGNORE;
$sitename = $app->get('sitename');
$fromName = $fromUser->get('name');
$siteURL = JRoute::link('administrator',
'index.php?option=com_messages&view=message&message_id='
. $table->message_id, false, $linkMode, true);
$subject = html_entity_decode($table->subject, ENT_COMPAT,
'UTF-8');
$message = strip_tags(html_entity_decode($table->message,
ENT_COMPAT, 'UTF-8'));
$subj = sprintf($lang->_('COM_MESSAGES_NEW_MESSAGE'),
$fromName, $sitename);
$msg = $subject . "\n\n" . $message . "\n\n" .
sprintf($lang->_('COM_MESSAGES_PLEASE_LOGIN'), $siteURL);
// Send the email
$mailer = JFactory::getMailer();
if (!$mailer->addReplyTo($fromUser->email, $fromUser->name))
{
try
{
JLog::add(JText::_('COM_MESSAGES_ERROR_COULD_NOT_SEND_INVALID_REPLYTO'),
JLog::WARNING, 'jerror');
}
catch (RuntimeException $exception)
{
JFactory::getApplication()->enqueueMessage(JText::_('COM_MESSAGES_ERROR_COULD_NOT_SEND_INVALID_REPLYTO'),
'warning');
}
// The message is still saved in the database, we do not allow this
failure to cause the entire save routine to fail
return true;
}
if (!$mailer->addRecipient($toUser->email, $toUser->name))
{
try
{
JLog::add(JText::_('COM_MESSAGES_ERROR_COULD_NOT_SEND_INVALID_RECIPIENT'),
JLog::WARNING, 'jerror');
}
catch (RuntimeException $exception)
{
JFactory::getApplication()->enqueueMessage(JText::_('COM_MESSAGES_ERROR_COULD_NOT_SEND_INVALID_RECIPIENT'),
'warning');
}
// The message is still saved in the database, we do not allow this
failure to cause the entire save routine to fail
return true;
}
$mailer->setSubject($subj);
$mailer->setBody($msg);
// The Send method will raise an error via JError on a failure, we do
not need to check it ourselves here
$mailer->Send();
}
return true;
}
/**
* Sends a message to the site's super users
*
* @param string $subject The message subject
* @param string $message The message
*
* @return boolean
*
* @since 3.9.0
*/
public function notifySuperUsers($subject, $message, $fromUser = null)
{
$db = $this->getDbo();
try
{
/** @var JTableAsset $table */
$table = $this->getTable('Asset', 'JTable');
$rootId = $table->getRootId();
/** @var JAccessRule[] $rules */
$rules = JAccess::getAssetRules($rootId)->getData();
$rawGroups = $rules['core.admin']->getData();
if (empty($rawGroups))
{
$this->setError(JText::_('COM_MESSAGES_ERROR_MISSING_ROOT_ASSET_GROUPS'));
return false;
}
$groups = array();
foreach ($rawGroups as $g => $enabled)
{
if ($enabled)
{
$groups[] = $db->quote($g);
}
}
if (empty($groups))
{
$this->setError(JText::_('COM_MESSAGES_ERROR_NO_GROUPS_SET_AS_SUPER_USER'));
return false;
}
$query = $db->getQuery(true)
->select($db->quoteName('map.user_id'))
->from($db->quoteName('#__user_usergroup_map',
'map'))
->join('LEFT', $db->quoteName('#__users',
'u') . ' ON ' . $db->quoteName('u.id') .
' = ' . $db->quoteName('map.user_id'))
->where($db->quoteName('map.group_id') . '
IN(' . implode(',', $groups) . ')')
->where($db->quoteName('u.block') . ' = 0')
->where($db->quoteName('u.sendEmail') . ' =
1');
$userIDs = $db->setQuery($query)->loadColumn(0);
if (empty($userIDs))
{
$this->setError(JText::_('COM_MESSAGES_ERROR_NO_USERS_SET_AS_SUPER_USER'));
return false;
}
foreach ($userIDs as $id)
{
/*
* All messages must have a valid from user, we have use cases where an
unauthenticated user may trigger this
* so we will set the from user as the to user
*/
$data = array(
'user_id_from' => $id,
'user_id_to' => $id,
'subject' => $subject,
'message' => $message,
);
if (!$this->save($data))
{
return false;
}
}
return true;
}
catch (Exception $exception)
{
$this->setError($exception->getMessage());
return false;
}
}
}
models/messages.php000064400000007420151166621630010361 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_messages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Messages Component Messages Model
*
* @since 1.6
*/
class MessagesModelMessages extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'message_id', 'a.id',
'subject', 'a.subject',
'state', 'a.state',
'user_id_from', 'a.user_id_from',
'user_id_to', 'a.user_id_to',
'date_time', 'a.date_time',
'priority', 'a.priority',
);
}
parent::__construct($config);
}
/**
* Method to auto-populate the model state.
*
* This method should only be called once per instantiation and is
designed
* to be called on the first call to the getState() method unless the
model
* configuration flag to ignore the request is set.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @since 1.6
*/
protected function populateState($ordering = 'a.date_time',
$direction = 'desc')
{
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
$this->setState('filter.state',
$this->getUserStateFromRequest($this->context .
'.filter.state', 'filter_state', '',
'cmd'));
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 1.6
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.state');
return parent::getStoreId($id);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
$user = JFactory::getUser();
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.*, ' .
'u.name AS user_from'
)
);
$query->from('#__messages AS a');
// Join over the users for message owner.
$query->join('INNER', '#__users AS u ON u.id =
a.user_id_from')
->where('a.user_id_to = ' . (int)
$user->get('id'));
// Filter by published state.
$state = $this->getState('filter.state');
if (is_numeric($state))
{
$query->where('a.state = ' . (int) $state);
}
elseif ($state !== '*')
{
$query->where('(a.state IN (0, 1))');
}
// Filter by search in subject or message.
$search = $this->getState('filter.search');
if (!empty($search))
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$query->where('(a.subject LIKE ' . $search . ' OR
a.message LIKE ' . $search . ')');
}
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering',
'a.date_time')) . ' ' .
$db->escape($this->getState('list.direction',
'DESC')));
return $query;
}
}
tables/message.php000064400000006254151166621630010171 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_messages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Message Table class
*
* @since 1.5
*/
class MessagesTableMessage extends JTable
{
/**
* Constructor
*
* @param JDatabaseDriver &$db Database connector object
*
* @since 1.5
*/
public function __construct(&$db)
{
parent::__construct('#__messages', 'message_id',
$db);
$this->setColumnAlias('published', 'state');
}
/**
* Validation and filtering.
*
* @return boolean
*
* @since 1.5
*/
public function check()
{
// Check the to and from users.
$user = new JUser($this->user_id_from);
if (empty($user->id))
{
$this->setError(JText::_('COM_MESSAGES_ERROR_INVALID_FROM_USER'));
return false;
}
$user = new JUser($this->user_id_to);
if (empty($user->id))
{
$this->setError(JText::_('COM_MESSAGES_ERROR_INVALID_TO_USER'));
return false;
}
if (empty($this->subject))
{
$this->setError(JText::_('COM_MESSAGES_ERROR_INVALID_SUBJECT'));
return false;
}
if (empty($this->message))
{
$this->setError(JText::_('COM_MESSAGES_ERROR_INVALID_MESSAGE'));
return false;
}
return true;
}
/**
* Method to set the publishing state for a row or list of rows in the
database
* table. The method respects checked out rows by other users and will
attempt
* to checkin rows that it can after adjustments are made.
*
* @param mixed $pks An optional array of primary key values to
update. If not
* set the instance property value is used.
* @param integer $state The publishing state. eg. [0 = unpublished,
1 = published]
* @param integer $userId The user id of the user performing the
operation.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function publish($pks = null, $state = 1, $userId = 0)
{
$k = $this->_tbl_key;
// Sanitize input.
$pks = ArrayHelper::toInteger($pks);
$state = (int) $state;
// If there are no primary keys set check to see if the instance key is
set.
if (empty($pks))
{
if ($this->$k)
{
$pks = array($this->$k);
}
// Nothing to set publishing state on, return false.
else
{
$this->setError(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
return false;
}
}
// Build the WHERE clause for the primary keys.
$where = $k . ' IN (' . implode(',', $pks) .
')';
// Update the publishing state for rows with the given primary keys.
$this->_db->setQuery(
'UPDATE ' . $this->_db->quoteName($this->_tbl)
. ' SET ' . $this->_db->quoteName('state') .
' = ' . (int) $state
. ' WHERE (' . $where . ')'
);
try
{
$this->_db->execute();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
// If the JTable instance value is in the list of primary keys that were
set, set the instance.
if (in_array($this->$k, $pks))
{
$this->state = $state;
}
$this->setError('');
return true;
}
}
views/config/tmpl/default.php000064400000002620151166621670012272
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_messages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
// Include the HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.formvalidator');
JHtml::_('behavior.keepalive');
JHtml::_('bootstrap.tooltip', '.hasTooltip',
array('placement' => 'bottom'));
JFactory::getDocument()->addScriptDeclaration(
"
Joomla.submitbutton = function(task)
{
if (task == 'config.cancel' ||
document.formvalidator.isValid(document.getElementById('config-form')))
{
Joomla.submitform(task,
document.getElementById('config-form'));
}
};
"
);
?>
<div class="container-popup">
<form action="<?php echo
JRoute::_('index.php?option=com_messages&view=config');
?>" method="post" name="adminForm"
id="message-form" class="form-validate
form-horizontal">
<fieldset>
<?php echo $this->form->renderField('lock'); ?>
<?php echo $this->form->renderField('mail_on_new');
?>
<?php echo $this->form->renderField('auto_purge');
?>
</fieldset>
<button id="saveBtn" type="button"
class="hidden"
onclick="Joomla.submitform('config.save',
this.form);"></button>
<input type="hidden" name="task"
value="" />
<?php echo JHtml::_('form.token'); ?>
</form>
</div>
views/config/view.html.php000064400000002125151166621670011607
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_messages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* View to edit messages user configuration.
*
* @since 1.6
*/
class MessagesViewConfig extends JViewLegacy
{
protected $form;
protected $item;
protected $state;
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse;
automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*
* @since 1.6
*/
public function display($tpl = null)
{
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
}
// Bind the record to the form.
$this->form->bind($this->item);
parent::display($tpl);
}
}
views/message/tmpl/default.php000064400000003167151166621670012460
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_messages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('behavior.core');
JHtml::_('formbehavior.chosen', 'select');
?>
<form action="<?php echo
JRoute::_('index.php?option=com_messages'); ?>"
method="post" name="adminForm" id="adminForm"
class="form-horizontal">
<fieldset>
<div class="control-group">
<div class="control-label">
<?php echo
JText::_('COM_MESSAGES_FIELD_USER_ID_FROM_LABEL'); ?>
</div>
<div class="controls">
<?php echo $this->item->get('from_user_name'); ?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo JText::_('COM_MESSAGES_FIELD_DATE_TIME_LABEL');
?>
</div>
<div class="controls">
<?php echo JHtml::_('date', $this->item->date_time,
JText::_('DATE_FORMAT_LC2')); ?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo JText::_('COM_MESSAGES_FIELD_SUBJECT_LABEL');
?>
</div>
<div class="controls">
<?php echo $this->item->subject; ?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo JText::_('COM_MESSAGES_FIELD_MESSAGE_LABEL');
?>
</div>
<div class="controls">
<?php echo $this->item->message; ?>
</div>
</div>
<input type="hidden" name="task"
value="" />
<input type="hidden" name="reply_id"
value="<?php echo $this->item->message_id; ?>" />
<?php echo JHtml::_('form.token'); ?>
</fieldset>
</form>
views/message/tmpl/edit.php000064400000003232151166621670011752
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_messages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
// Include the HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.formvalidator');
JHtml::_('behavior.keepalive');
JFactory::getDocument()->addScriptDeclaration("
Joomla.submitbutton = function(task)
{
if (task == 'message.cancel' ||
document.formvalidator.isValid(document.getElementById('message-form')))
{
Joomla.submitform(task,
document.getElementById('message-form'));
}
};
");
?>
<form action="<?php echo
JRoute::_('index.php?option=com_messages'); ?>"
method="post" name="adminForm"
id="message-form" class="form-validate
form-horizontal">
<fieldset class="adminform">
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('user_id_to');
?>
</div>
<div class="controls">
<?php echo $this->form->getInput('user_id_to');
?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('subject'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('subject'); ?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('message'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('message'); ?>
</div>
</div>
</fieldset>
<input type="hidden" name="task" value=""
/>
<?php echo JHtml::_('form.token'); ?>
</form>
views/message/view.html.php000064400000004072151166621670011771
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_messages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* HTML View class for the Messages component
*
* @since 1.6
*/
class MessagesViewMessage extends JViewLegacy
{
protected $form;
protected $item;
protected $state;
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse;
automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*
* @since 1.6
*/
public function display($tpl = null)
{
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
}
parent::display($tpl);
$this->addToolbar();
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
if ($this->getLayout() == 'edit')
{
JFactory::getApplication()->input->set('hidemainmenu',
true);
JToolbarHelper::title(JText::_('COM_MESSAGES_WRITE_PRIVATE_MESSAGE'),
'envelope-opened new-privatemessage');
JToolbarHelper::save('message.save',
'COM_MESSAGES_TOOLBAR_SEND');
JToolbarHelper::cancel('message.cancel');
JToolbarHelper::help('JHELP_COMPONENTS_MESSAGING_WRITE');
}
else
{
JToolbarHelper::title(JText::_('COM_MESSAGES_VIEW_PRIVATE_MESSAGE'),
'envelope inbox');
$sender = JUser::getInstance($this->item->user_id_from);
if ($sender->authorise('core.admin') ||
$sender->authorise('core.manage', 'com_messages')
&& $sender->authorise('core.login.admin'))
{
JToolbarHelper::custom('message.reply', 'redo',
null, 'COM_MESSAGES_TOOLBAR_REPLY', false);
}
JToolbarHelper::cancel('message.cancel');
JToolbarHelper::help('JHELP_COMPONENTS_MESSAGING_READ');
}
}
}
views/messages/tmpl/default.php000064400000006740151166621670012643
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_messages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('formbehavior.chosen', 'select');
$user = JFactory::getUser();
$listOrder =
$this->escape($this->state->get('list.ordering'));
$listDirn =
$this->escape($this->state->get('list.direction'));
JFactory::getDocument()->addStyleDeclaration(
'
@media (min-width: 768px) {
div.modal {
left: none;
width: 500px;
margin-left: -250px;
}
}
'
);
?>
<form action="<?php echo
JRoute::_('index.php?option=com_messages&view=messages');
?>" method="post" name="adminForm"
id="adminForm">
<?php if (!empty( $this->sidebar)) : ?>
<div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?>
</div>
<div id="j-main-container" class="span10">
<?php else : ?>
<div id="j-main-container">
<?php endif; ?>
<?php echo
JLayoutHelper::render('joomla.searchtools.default',
array('view' => $this)); ?>
<div class="clearfix"></div>
<?php if (empty($this->items)) : ?>
<div class="alert alert-no-items">
<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php else : ?>
<table class="table table-striped">
<thead>
<tr>
<th width="1%" class="nowrap center">
<?php echo JHtml::_('grid.checkall'); ?>
</th>
<th class="title nowrap">
<?php echo JHtml::_('searchtools.sort',
'COM_MESSAGES_HEADING_SUBJECT', 'a.subject', $listDirn,
$listOrder); ?>
</th>
<th width="1%" class="nowrap center">
<?php echo JHtml::_('searchtools.sort',
'COM_MESSAGES_HEADING_READ', 'a.state', $listDirn,
$listOrder); ?>
</th>
<th width="15%" class="nowrap">
<?php echo JHtml::_('searchtools.sort',
'COM_MESSAGES_HEADING_FROM', 'a.user_id_from',
$listDirn, $listOrder); ?>
</th>
<th width="20%" class="nowrap hidden-tablet
hidden-phone">
<?php echo JHtml::_('searchtools.sort',
'JDATE', 'a.date_time', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="5">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php foreach ($this->items as $i => $item) :
$canChange = $user->authorise('core.edit.state',
'com_messages');
?>
<tr class="row<?php echo $i % 2; ?>">
<td class="center">
<?php echo JHtml::_('grid.id', $i,
$item->message_id); ?>
</td>
<td>
<a href="<?php echo
JRoute::_('index.php?option=com_messages&view=message&message_id='
. (int) $item->message_id); ?>">
<?php echo $this->escape($item->subject); ?></a>
</td>
<td class="center">
<?php echo JHtml::_('messages.status', $i,
$item->state, $canChange); ?>
</td>
<td>
<?php echo $item->user_from; ?>
</td>
<td class="hidden-phone hidden-tablet">
<?php echo JHtml::_('date', $item->date_time,
JText::_('DATE_FORMAT_LC2')); ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<div>
<input type="hidden" name="task"
value="" />
<input type="hidden" name="boxchecked"
value="0" />
<?php echo JHtml::_('form.token'); ?>
</div>
</div>
</form>
views/messages/view.html.php000064400000005624151166621670012160
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_messages
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* View class for a list of messages.
*
* @since 1.6
*/
class MessagesViewMessages extends JViewLegacy
{
protected $items;
protected $pagination;
protected $state;
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse;
automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*
* @since 1.6
*/
public function display($tpl = null)
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
$state = $this->get('State');
$canDo = JHelperContent::getActions('com_messages');
JToolbarHelper::title(JText::_('COM_MESSAGES_MANAGER_MESSAGES'),
'envelope inbox');
if ($canDo->get('core.create'))
{
JToolbarHelper::addNew('message.add');
}
if ($canDo->get('core.edit.state'))
{
JToolbarHelper::divider();
JToolbarHelper::publish('messages.publish',
'COM_MESSAGES_TOOLBAR_MARK_AS_READ', true);
JToolbarHelper::unpublish('messages.unpublish',
'COM_MESSAGES_TOOLBAR_MARK_AS_UNREAD', true);
}
JToolbarHelper::divider();
$bar = JToolBar::getInstance('toolbar');
$bar->appendButton(
'Popup',
'cog',
'COM_MESSAGES_TOOLBAR_MY_SETTINGS',
'index.php?option=com_messages&view=config&tmpl=component',
500,
250,
0,
0,
'',
'',
'<button type="button" class="btn"
data-dismiss="modal">'
. JText::_('JCANCEL')
. '</button>'
. '<button type="button" class="btn
btn-success" data-dismiss="modal"'
. ' onclick="jQuery(\'#modal-cog
iframe\').contents().find(\'#saveBtn\').click();">'
. JText::_('JSAVE')
. '</button>'
);
if ($state->get('filter.state') == -2 &&
$canDo->get('core.delete'))
{
JToolbarHelper::divider();
JToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE',
'messages.delete', 'JTOOLBAR_EMPTY_TRASH');
}
elseif ($canDo->get('core.edit.state'))
{
JToolbarHelper::divider();
JToolbarHelper::trash('messages.trash');
}
if ($canDo->get('core.admin'))
{
JToolbarHelper::preferences('com_messages');
}
JToolbarHelper::divider();
JToolbarHelper::help('JHELP_COMPONENTS_MESSAGING_INBOX');
}
}