/** * Add a menu on the sidebar of page */ protected function addSidebar() { UserIdeasHelper::addSubmenu($this->getName()); JHtmlSidebar::setAction('index.php?option=' . $this->option . '&view=' . $this->getName()); JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_state', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array("archived" => false, "trash" => false)), 'value', 'text', $this->state->get('filter.state'), true)); JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_CATEGORY'), 'filter_category', JHtml::_('select.options', JHtml::_('category.options', 'com_userideas'), 'value', 'text', $this->state->get('filter.category'), true)); // Item statuses $statuses = Userideas\Status\Statuses::getInstance(JFactory::getDbo()); JHtmlSidebar::addFilter(JText::_('COM_USERIDEAS_SELECT_ITEM_STATUS'), 'filter_status', JHtml::_('select.options', $statuses->getStatusesOptions(), 'value', 'text', $this->state->get('filter.status'), true)); $this->sidebar = JHtmlSidebar::render(); }
/** * Method to save the form data. * * @param array $data The form data. * * @return mixed The record id on success, null on failure. * @since 1.6 */ public function save($data) { $id = Joomla\Utilities\ArrayHelper::getValue($data, 'id', 0, 'int'); $title = Joomla\Utilities\ArrayHelper::getValue($data, 'title'); $description = Joomla\Utilities\ArrayHelper::getValue($data, 'description'); $categoryId = Joomla\Utilities\ArrayHelper::getValue($data, 'catid', 0, 'int'); $userId = Joomla\Utilities\ArrayHelper::getValue($data, 'user_id', 0, 'int'); $keys = array('id' => $id, 'user_id' => $userId); // Load a record from the database $row = $this->getTable(); /** @var $row UserIdeasTableItem */ $row->load($keys); // If there is an id, the item is not new $isNew = true; if ($row->get('id')) { $isNew = false; } $row->set('title', $title); $row->set('description', $description); $row->set('catid', $categoryId); if ($isNew) { $recordDate = new JDate(); $row->set('record_date', $recordDate->toSql()); $row->set('user_id', $userId); // Set status $statuses = Userideas\Status\Statuses::getInstance(JFactory::getDbo()); $defaultStatus = $statuses->getDefault(); if ($defaultStatus !== null and $defaultStatus->id > 0) { $row->set('status_id', (int) $defaultStatus->id); } // Auto publishing $params = JComponentHelper::getParams($this->option); /** @var $params Joomla\Registry\Registry */ $published = $params->get('security_item_auto_publish', 0); $row->set('published', $published); } $this->prepareTable($row); $row->store(); $this->triggerAfterSaveEvent($row, $isNew); $this->cleanCache(); return $row->get('id'); }