<?php
/**
 * @package DJ-Catalog2
 * @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
 * @license http://www.gnu.org/licenses GNU/GPL
 * @author url: http://dj-extensions.com
 * @author email contact@dj-extensions.com
 */
 

defined('_JEXEC') or die;

/**
 * Message Table class
 *
 */
class DJCatalog2TableMessage extends JTable
{
	/**
	 * Constructor
	 *
	 * @param   JDatabaseDriver  &$db  Database connector object
	 *
	 * @since   1.5
	 */
	public function __construct(&$db)
	{
		parent::__construct('#__djc2_messages', 'id', $db);
	}

	/**
	 * Validation and filtering.
	 *
	 * @return  boolean
	 *
	 * @since   1.5
	 */
	public function check()
	{
		// Check the to and from users.
		/*$user = new JUser($this->user_from);

		if (empty($user->id))
		{
			$this->setError(JText::_('COM_DJCATALOG2_ERROR_INVALID_FROM_USER'));

			return false;
		}*/

		/*$user = new JUser($this->user_to);

		if (empty($user->id))
		{
			$this->setError(JText::_('COM_DJCATALOG2_ERROR_INVALID_TO_USER'));

			return false;
		}*/

		if (empty($this->subject))
		{
			$this->setError(JText::_('COM_DJCATALOG2_ERROR_INVALID_SUBJECT'));

			return false;
		}

		if (empty($this->message))
		{
			$this->setError(JText::_('COM_DJCATALOG2_ERROR_INVALID_MESSAGE'));

			return false;
		}

		return true;
	}
}
