Example #1
0
 /**
  * Save a tag
  *
  * @return  void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Check that the user is authorized
     if (!$this->config->get('access-edit-tag')) {
         throw new Exception(Lang::txt('ALERTNOTAUTH'), 403);
     }
     $tag = Request::getVar('fields', array(), 'post');
     // Bind incoming data
     $row = new Tag(intval($tag['id']));
     if (!$row->bind($tag)) {
         $this->setError($row->getError());
         $this->editTask($row);
         return;
     }
     // Store new content
     if (!$row->store(true)) {
         $this->setError($row->getError());
         $this->editTask($row);
         return;
     }
     $limit = Request::getInt('limit', 0);
     $start = Request::getInt('limitstart', 0);
     $sortby = Request::getInt('sortby', '');
     $search = urldecode(Request::getString('search', ''));
     // Redirect to main listing
     App::redirect(Route::url('index.php?option=' . $this->_option . '&task=browse&search=' . urlencode($search) . '&sortby=' . $sortby . '&limit=' . $limit . '&limitstart=' . $start));
 }
Example #2
0
 /**
  * Save an entry
  *
  * @return  void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     $fields = Request::getVar('fields', array(), 'post');
     $row = new Tag(intval($fields['id']));
     if (!$row->bind($fields)) {
         Notify::error($row->getError());
         return $this->editTask($row);
     }
     $row->set('admin', 0);
     if (isset($fields['admin']) && $fields['admin']) {
         $row->set('admin', 1);
     }
     // Store new content
     if (!$row->store(true)) {
         Notify::error($row->getError());
         return $this->editTask($row);
     }
     Notify::success(Lang::txt('COM_TAGS_TAG_SAVED'));
     // Redirect to main listing
     if ($this->getTask() == 'apply') {
         return $this->editTask($row);
     }
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false));
 }