コード例 #1
0
 /**
  * Delete a page
  *
  * @apiParameter {
  * 		"name":          "id",
  * 		"description":   "Page identifier",
  * 		"type":          "integer",
  * 		"required":      true,
  * 		"default":       0
  * }
  * @return  void
  */
 public function deleteTask()
 {
     $this->requiresAuthentication();
     $id = Request::getInt('id', 0);
     $record = new Page($id);
     if (!$record->exists()) {
         throw new Exception(Lang::txt('Specified page does not exist.'), 404);
     }
     if (!$record->delete()) {
         throw new Exception(Lang::txt('Failed to delete page.'), 500);
     }
     $this->send(null, 202);
 }
コード例 #2
0
ファイル: pages.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Remove one or more pages
  *
  * @return  void
  */
 public function removeTask()
 {
     // Incoming
     $ids = Request::getVar('id', array(0));
     $ids = !is_array($ids) ? array($ids) : $ids;
     if (count($ids) <= 0) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_WIKI_ERROR_MISSING_ID'), 'warning');
         return;
     }
     $step = Request::getInt('step', 1);
     $step = !$step ? 1 : $step;
     // What step are we on?
     switch ($step) {
         case 1:
             Request::setVar('hidemainmenu', 1);
             // Instantiate a new view
             $this->view->ids = $ids;
             // Set any errors
             foreach ($this->getErrors() as $error) {
                 $this->view->setError($error);
             }
             // Output the HTML
             $this->view->display();
             break;
         case 2:
             // Check for request forgeries
             Request::checkToken();
             // Check if they confirmed
             $confirmed = Request::getInt('confirm', 0);
             if (!$confirmed) {
                 // Instantiate a new view
                 $this->view->ids = $ids;
                 $this->setMessage(Lang::txt('COM_WIKI_CONFIRM_DELETE'), 'error');
                 // Output the HTML
                 $this->view->display();
                 return;
             }
             if (!empty($ids)) {
                 foreach ($ids as $id) {
                     // Finally, delete the page itself
                     $page = new Page(intval($id));
                     if (!$page->delete()) {
                         $this->setError($page->getError());
                     }
                 }
             }
             App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_WIKI_PAGES_DELETED', count($ids)));
             break;
     }
 }