Пример #1
0
 /**
  * Cancel a tool contribution
  *
  * @return     void
  */
 public function cancelTask()
 {
     // get vars
     if (!$this->_toolid) {
         $this->_toolid = Request::getInt('toolid', 0);
     }
     // Create a Tool object
     $obj = new \Components\Tools\Tables\Tool($this->database);
     // do we have an alias?
     if ($this->_toolid == 0) {
         if ($alias = Request::getVar('app', '')) {
             $this->_toolid = $obj->getToolId($alias);
         }
     }
     // check access rights
     if (!$this->_checkAccess($this->_toolid)) {
         App::abort(403, Lang::txt('COM_TOOLS_ALERTNOTAUTH'));
         return;
     }
     // get tool status
     $obj->getToolStatus($this->_toolid, $this->_option, $status, 'dev');
     if (!$status) {
         App::abort(404, Lang::txt('COM_TOOLS_ERR_EDIT_CANNOT_FIND'));
         return;
     }
     if ($status['state'] == \Components\Tools\Helpers\Html::getStatusNum('Abandoned')) {
         App::abort(404, Lang::txt('COM_TOOLS_ERR_ALREADY_CANCELLED'));
         return;
     }
     if ($status['published'] == 1) {
         App::abort(404, Lang::txt('COM_TOOLS_ERR_CANNOT_CANCEL_PUBLISHED_TOOL'));
         return;
     }
     // unpublish resource page
     include_once __DIR__ . DS . 'resource.php';
     $resource = new Resource();
     $resource->updatePage($status['resourceid'], $status, '4');
     // change tool status to 'abandoned' and priority to 'lowest'
     $obj->updateTool($this->_toolid, \Components\Tools\Helpers\Html::getStatusNum('Abandoned'), 5);
     // add comment to ticket
     $this->_updateTicket($this->_toolid, '', '', Lang::txt('COM_TOOLS_NOTICE_TOOL_CANCELLED'), 0, 1, 5);
     // continue output
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=pipeline'), Lang::txt('COM_TOOLS_NOTICE_TOOL_CANCELLED'));
 }