Exemplo n.º 1
0
 /**
  * Create an instance of the object.
  *
  * <code>
  * $options = array(
  *    "limit"          => 10,
  *    "sort_direction" => "DESC"
  * );
  *
  * $statuses     = UserIdeasStatuses::getInstance(JFactory::getDbo(), $options);
  * </code>
  *
  * @param JDatabaseDriver $db
  * @param array $options
  *
  * @return null|UserIdeasStatuses
  */
 public static function getInstance(JDatabaseDriver $db, $options = array())
 {
     if (is_null(self::$instance)) {
         $item = new UserIdeasStatuses($db);
         $item->load($options);
         self::$instance = $item;
     }
     return self::$instance;
 }
Exemplo n.º 2
0
 /**
  * Add a menu on the sidebar of page
  */
 protected function addSidebar()
 {
     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
     jimport("userideas.statuses");
     $statuses = UserIdeasStatuses::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();
 }
Exemplo n.º 3
0
 /**
  * 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 = JArrayHelper::getValue($data, "id", 0, "int");
     $title = JArrayHelper::getValue($data, "title");
     $description = JArrayHelper::getValue($data, "description");
     $categoryId = JArrayHelper::getValue($data, "catid", 0, "int");
     $userId = JArrayHelper::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 (!empty($row->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
         jimport("userideas.statuses");
         $statuses = UserIdeasStatuses::getInstance(JFactory::getDbo());
         $defaultStatus = $statuses->getDefault();
         if (!empty($defaultStatus->id)) {
             $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);
     return $row->get("id");
 }