Spade
Mini Shell
| Directory:~$ /home/lmsyaran/public_html/joomla5/administrator/components/com_fabrik/tables/ |
| [Home] [System Details] [Kill Me] |
<?php
/**
* Group Fabrik Table
*
* @package Joomla
* @subpackage Fabrik
* @copyright Copyright (C) 2005-2020 Media A-Team, Inc. - All rights
reserved.
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
*/
// No direct access
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Language\Text;
use Joomla\CMS\Table\Table;
require_once JPATH_ADMINISTRATOR .
'/components/com_fabrik/tables/fabtable.php';
/**
* Group Fabrik Table
*
* @package Joomla
* @subpackage Fabrik
* @since 3.0
*/
class FabrikTableGroup extends FabTable
{
/**
* Join ID - not sure its used?
* @var int
*/
public $join_id = null;
public $is_join = false;
public $params = '';
public $id = null;
public $name = '';
public $label = '';
public $css = '';
/**
* Constructor
*
* @param JDatabaseDriver &$db database object
*/
public function __construct(&$db)
{
parent::__construct('#__fabrik_groups', 'id', $db);
}
/**
* Overloaded check function
*
* @return bool
*/
public function check()
{
if (trim($this->name) == '')
{
$this->_error = Text::_("YOUR GROUP MUST CONTAIN A NAME");
return false;
}
return true;
}
/**
* Method to load a row from the database by primary key and bind the
fields
* to the Table instance properties.
*
* @param mixed $keys An optional primary key value to load the row
by, or an array of fields to match. If not
* set the instance property value is used.
* @param boolean $reset True to reset the default values before
loading the new row.
*
* @return boolean True if successful. False if row not found or on
error (internal error state set in that case).
*/
public function load($keys = null, $reset = true)
{
if (empty($keys))
{
// If empty, use the value of the current key
$keyName = $this->_tbl_key;
$keyValue = $this->$keyName;
// If empty primary key there's is no need to load anything
if (empty($keyValue))
{
return true;
}
$keys = array($keyName => $keyValue);
}
elseif (!is_array($keys))
{
// Load by primary key.
$keys = array($this->_tbl_key => $keys);
}
if ($reset)
{
$this->reset();
}
$db = $this->getDBO();
$query = $db->getQuery(true);
$query->select('#__fabrik_groups.*, #__fabrik_joins.id AS
join_id')->from($this->_tbl)
->join('LEFT', '#__fabrik_joins ON #__fabrik_groups.id
= #__fabrik_joins.group_id');
foreach ($keys as $field => $value)
{
$query->where($db->qn('#__fabrik_groups') .
'.' . $db->qn($field) . ' = ' . $db->q($value));
}
$query->where(" (( element_id = 0 OR is_join = 0) OR element_id
IS NULL)");
$db->setQuery($query);
$row = $db->loadAssoc();
// Check that we have a result.
if (empty($row))
{
return false;
}
// Bind the object with the row and return.
return $this->bind($row);
}
/**
* Method to store a row in the database from the Table instance
properties.
* If a primary key value is set the row with that primary key value will
be
* updated with the instance property values. If no primary key value is
set
* a new row will be inserted into the database with the properties from
the
* Table instance.
*
* @param boolean $updateNulls True to update fields even if they are
null.
*
* @return boolean True on success.
*/
public function store($updateNulls = true)
{
unset($this->join_id);
//return parent::store($updateNulls);
if (!parent::store($updateNulls))
{
throw new RuntimeException('Fabrik error storing group data: '
. $this->getError());
}
return true;
}
}