| Current Path : /home/smartconb/www/armencom33/administrator/components/com_jmailalerts/models/ |
| Current File : /home/smartconb/www/armencom33/administrator/components/com_jmailalerts/models/frequency.php |
<?php
/**
* @package JMailAlerts
* @subpackage com_jmailalerts
*
* @author Techjoomla <extensions@techjoomla.com>
* @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access.
defined('_JEXEC') or die;
jimport('joomla.application.component.modeladmin');
/**
* Jmailalerts model.
*
* @since 1.6
*/
class JmailalertsModelfrequency extends JModelAdmin
{
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_JMAILALERTS';
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
*
* @since 1.7
* @see JController
*/
public function __construct($config = array())
{
$config['event_after_save'] = 'jmaOnAfterFrequencySave';
$config['event_after_delete'] = 'jmaOnAfterFrequencyDelete';
parent::__construct($config);
}
/**
* Returns a Table object, always creating it.
*
* @param string $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
*/
public function getTable($type = 'Frequency', $prefix = 'JmailalertsTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* 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|boolean A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Initialise variables.
$app = JFactory::getApplication();
// Get the form.
$form = $this->loadForm('com_jmailalerts.frequency', 'frequency', 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_jmailalerts.edit.frequency.data', array());
if (empty($data))
{
$data = $this->getItem();
}
return $data;
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
// Do any procesing on fields here if needed
}
return $item;
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
jimport('joomla.filter.output');
if (empty($table->id))
{
// Set ordering to the last item if not set
if (@$table->ordering === '')
{
$db = JFactory::getDbo();
$db->setQuery('SELECT MAX(ordering) FROM #__jma_frequencies');
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
}
}