Please help where to add
// Filter by user logged
$where[] = "a.created_by = ". (int)JFactory::getUser()->get('id');
on my code
/**
* Preparation of the list query.
*
* @access protected
* @param object &$query returns a filled query object.
* @return void
*/
protected function prepareQuery(&$query)
{
$user = JFactory::getUser();
$acl = EjuiceHelper::getActions();
//FROM : Main table
$query->from('#__ejuice_userprodreg AS a');
//IMPORTANT REQUIRED FIELDS
$this->addSelect( 'a.id,'
. 'a.access,'
. 'a.created_by');
switch($this->getState('context'))
{
case 'userprodreg.default':
//BASE FIELDS
$this->addSelect( 'a.active,'
. 'a.date_created,'
. 'a.flavor_name,'
. 'a.product_code');
//SELECT
$this->addSelect('_created_by_.name AS `_created_by_name`');
$this->addSelect('_flavor_name_.flavor_name AS `_flavor_name_flavor_name`');
//JOIN
$this->addJoin('`#__users` AS _created_by_ ON _created_by_.id = a.created_by', 'LEFT');
$this->addJoin('`#__ejuice_flavorlist` AS _flavor_name_ ON _flavor_name_.id = a.flavor_name', 'LEFT');
break;
default:
//SELECT : raw complete query without joins
$this->addSelect('a.*');
// Disable the pagination
$this->setState('list.limit', null);
$this->setState('list.start', null);
break;
}
//WHERE - FILTER : Flavor Name
if($this->getState('filter.flavor_name') != null)
$this->addWhere('a.flavor_name = '. (int)$this->getState('filter.flavor_name'));
// WHERE : Implement View Level Access
if (!$acl->get('core.admin'))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN ('.$groups.')');
}
//Populate only uniques strings to the query
//SELECT
foreach($this->getState('query.select', array()) as $select)
$query->select($select);
//JOIN
foreach($this->getState('query.join.left', array()) as $join)
$query->join('LEFT', $join);
//WHERE
foreach($this->getState('query.where', array()) as $where)
$query->where($where);
//ORDER
foreach($this->getState('query.groupby', array()) as $groupby)
$query->order($groupby);
//ORDER
foreach($this->getState('query.order', array()) as $order)
$query->order($order);
//ORDER
$orderCol = $this->getState('list.ordering');
$orderDir = $this->getState('list.direction', 'asc');
if ($orderCol)
$query->order($orderCol . ' ' . $orderDir);
}
}
I was able to make this work on Cook 1.5.. but I cant figure it out on cook 2.0
Thanks