/** * Save a role * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); if (!User::authorise('core.edit', $this->_option) && !User::authorise('core.create', $this->_option)) { App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR')); } $fields = Request::getVar('fields', array(), 'post'); $fields = array_map('trim', $fields); // Initiate extended database class $row = Role::oneOrNew($fields['id'])->set($fields); // Store new content if (!$row->save()) { $this->setError($row->getError()); return $this->editTask($row); } $types = Request::getVar('types', array(), 'post'); $types = array_map('trim', $types); if (!$row->setTypes($types)) { $this->setError($row->getError()); return $this->editTask($row); } Notify::success(Lang::txt('COM_RESOURCES_ITEM_SAVED')); if ($this->getTask() == 'apply') { return $this->editTask($row); } // Redirect $this->cancelTask(); }
/** * Save an entry * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); // Incoming $fields = Request::getVar('fields', array(), 'post'); $authorid = Request::getVar('authorid', 0); $id = Request::getVar('id', 0); if (!$authorid) { return $this->cancelTask(); } $rows = array(); if (is_array($fields)) { foreach ($fields as $fieldset) { $fieldset['authorid'] = $authorid; $row = Role::oneOrNew($fieldset['id'])->set($fieldset); if (!$row->save()) { $this->setError($row->getError()); } $rows[] = $row; } } if ($this->getTask() == 'apply') { return $this->editTask($rows); } $this->cancelTask(); }