Current File : /home/pacjaorg/public_html/kmm/administrator/components/com_djclassifieds/models/fieldsgroup.php
<?php
/**
 * @package DJ-Classifieds
 * @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;

class DJClassifiedsModelFieldsgroup extends DJClassifiedsAdminModel
{
	public function __construct($config = array())
	{
		$config['event_after_save'] = 'onDJClassifiedsModelAdminAfterSave';
		$config['event_after_delete'] = 'onDJClassifiedsModelAdminAfterDelete';
		parent::__construct($config);
	}

	public function getTable($type = 'Fieldsgroups', $prefix = 'DJClassifiedsTable', $config = array())
	{
		return JTable::getInstance($type, $prefix, $config);
	}

	public function getForm($data = array(), $loadData = true)
	{
		// Initialise variables.
		$app	= JFactory::getApplication();

		// Get the form.
		$form = $this->loadForm('com_djclassifieds.fieldsgroup', 'fieldsgroup', array('control' => 'jform', 'load_data' => $loadData));
		if (empty($form)) {
			return false;
		}
		return $form;
	}

	protected function loadFormData()
	{
		$data = JFactory::getApplication()->getUserState('com_djclassifieds.edit.fieldsgroup.data', array());

		if (empty($data)) {
			$data = $this->getItem();
		}

		if(!empty($data->id)){
			$db = JFactory::getDBO();
			$query = "SELECT usergroup_id FROM #__djcf_fields_groups_usergroups WHERE group_id=".$data->id;
			$db->setQuery($query);
			$ug = $db->loadColumn();

			$data->usergroup_access = $ug;
			$data->groups_assignment = explode(',', $data->groups_assignment);
		}

		return $data;
	}

	protected function prepareTable($table)
	{
		$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);

		if (empty($table->id)) {
			if (empty($table->ordering)) {
				$db = JFactory::getDbo();
				$db->setQuery('SELECT MAX(ordering) FROM #__djcf_fields_groups');
				$max = $db->loadResult();

				$table->ordering = $max+1;
			}
		}

		$table->groups_assignment = is_array($table->groups_assignment) ? implode(',', $table->groups_assignment) : '';
	}

	protected function getReorderConditions($table = null)
	{
		$condition = array();
		$condition[] = 'source = '.(int) $table->source;
		return $condition;
	}
}
Site is undergoing maintenance

PACJA Events

Maintenance mode is on

Site will be available soon. Thank you for your patience!