/**
* Overridden Table::store to set created/modified and user id.
*
* @param boolean $updateNulls True to update fields even if they are null.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function store($updateNulls = true)
{
$date = Factory::getDate()->toSql();
$user = Factory::getUser();
// Set created date if not set.
if (!(int) $this->created_time) {
$this->created_time = $date;
}
if ($this->id) {
// Existing category
$this->modified_user_id = $user->get('id');
$this->modified_time = $date;
} else {
if (!(int) $this->modified_time) {
$this->modified_time = $this->created_time;
}
// Field created_user_id can be set by the user, so we don't touch it if it's set.
if (empty($this->created_user_id)) {
$this->created_user_id = $user->get('id');
}
if (empty($this->modified_user_id)) {
$this->modified_user_id = $this->created_user_id;
}
}
// Verify that the alias is unique
$table = Table::getInstance('Category', 'JTable', array('dbo' => $this->getDbo()));
if ($table->load(array('alias' => $this->alias, 'parent_id' => (int) $this->parent_id, 'extension' => $this->extension)) && ($table->id != $this->id || $this->id == 0)) {
$this->setError(Text::_('JLIB_DATABASE_ERROR_CATEGORY_UNIQUE_ALIAS'));
return false;
}
return parent::store($updateNulls);
}