- md5
- 17da8bb07ba54c6d9de03a0bc90cafd9
- sha1
- 80bd46a1ff877e33f9f9c5c8d18261cbb8719366
- sha256
- dba7f884b4616fc8d4b18f3fc66240de5c5c724666674f0ad897be42c32009aa
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
<?php
/**
* @package Joomla.Administrator
* @subpackage com_messages
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Messages\Administrator\Table;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Table\Table;
use Joomla\CMS\User\User;
use Joomla\Database\DatabaseDriver;
use Joomla\Event\DispatcherInterface;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Message Table class
*
* @since 1.5
*/
class MessageTable extends Table
{
/**
* Constructor
*
* @param DatabaseDriver $db Database connector object
* @param ?DispatcherInterface $dispatcher Event dispatcher for this table
*
* @since 1.5
*/
public function __construct(DatabaseDriver $db, DispatcherInterface $dispatcher = null)
{
parent::__construct('#__messages', 'message_id', $db, $dispatcher);
$this->setColumnAlias('published', 'state');
}
/**
* Validation and filtering.
*
* @return boolean
*
* @since 1.5
*/
public function check()
{
try {
parent::check();
} catch (\Exception $e) {
$this->setError($e->getMessage());
return false;
}
// Check the to and from users.
$user = new User($this->user_id_from);
if (empty($user->id)) {
$this->setError(Text::_('COM_MESSAGES_ERROR_INVALID_FROM_USER'));
return false;
}
$user = new User($this->user_id_to);
if (empty($user->id)) {
$this->setError(Text::_('COM_MESSAGES_ERROR_INVALID_TO_USER'));
return false;
}
if (empty($this->subject)) {
$this->setError(Text::_('COM_MESSAGES_ERROR_INVALID_SUBJECT'));
return false;
}
if (empty($this->message)) {
$this->setError(Text::_('COM_MESSAGES_ERROR_INVALID_MESSAGE'));
return false;
}
return true;
}
}
The same content is in 37 releases, Joomla 5.0.0-beta1 to 5.2.0-alpha3. See them all, or every version of this file.