Example #1
0
 /**
  * Retire a tool
  *
  * @return     void
  */
 public function retireTask()
 {
     // Set the layout (note: all the views for this controller use the same layout)
     $this->view->setLayout('display');
     // Create a Tool object
     $obj = new \Components\Tools\Tables\Tool($this->database);
     // Do we have an alias?
     if ($alias = Request::getVar('app', '')) {
         $this->_toolid = $obj->getToolId($alias);
     }
     // Do we have a tool ID
     if (!$this->_toolid) {
         App::abort(403, Lang::txt('COM_TOOLS_ERROR_TOOL_NOT_FOUND'));
         return;
     }
     // Get the tool status
     $obj->getToolStatus($this->_toolid, $this->_option, $status, 'dev');
     // Check for a status
     if (count($status) <= 0) {
         App::abort(500, Lang::txt('COM_TOOLS_ERR_CANNOT_RETRIEVE'));
         return;
     }
     // Create a Tool Version object
     $objV = new \Components\Tools\Tables\Version($this->database);
     // Unpublish all previous versions
     if (!$objV->unpublish($this->_toolid)) {
         $this->setError(Lang::txt('COM_TOOLS_ERR_FAILED_TO_UNPUBLISH_PREV_VERSIONS'));
     } else {
         $this->setMessage(Lang::txt('COM_TOOLS_NOTICE_UNPUBLISHED_PREV_VERSIONS'));
     }
     // Set errors to view
     if ($this->getError()) {
         foreach ($this->getErrors() as $error) {
             $this->view->setError($error);
         }
     }
     // Set messages to view
     $this->view->messages = $this->getMessages();
     // Output HTML
     if (!($no_html = Request::getInt('no_html', 0))) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=pipeline&task=status&app=' . $alias));
         return;
     }
     $this->view->display();
 }