[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/meta/controller/ -> PhabricatorApplicationUninstallController.php (source)

   1  <?php
   2  
   3  final class PhabricatorApplicationUninstallController
   4    extends PhabricatorApplicationsController {
   5  
   6    private $application;
   7    private $action;
   8  
   9    public function shouldRequireAdmin() {
  10      return true;
  11    }
  12  
  13    public function willProcessRequest(array $data) {
  14      $this->application = $data['application'];
  15      $this->action = $data['action'];
  16    }
  17  
  18    public function processRequest() {
  19      $request = $this->getRequest();
  20      $user = $request->getUser();
  21  
  22      $selected = PhabricatorApplication::getByClass($this->application);
  23  
  24      if (!$selected) {
  25        return new Aphront404Response();
  26      }
  27  
  28      $view_uri = $this->getApplicationURI('view/'.$this->application);
  29  
  30      $prototypes_enabled = PhabricatorEnv::getEnvConfig(
  31        'phabricator.show-prototypes');
  32  
  33      $dialog = id(new AphrontDialogView())
  34                 ->setUser($user)
  35                 ->addCancelButton($view_uri);
  36  
  37      if ($selected->isPrototype() && !$prototypes_enabled) {
  38        $dialog
  39          ->setTitle(pht('Prototypes Not Enabled'))
  40          ->appendChild(
  41            pht(
  42              'To manage prototypes, enable them by setting %s in your '.
  43              'Phabricator configuration.',
  44              phutil_tag('tt', array(), 'phabricator.show-prototypes')));
  45        return id(new AphrontDialogResponse())->setDialog($dialog);
  46      }
  47  
  48      if ($request->isDialogFormPost()) {
  49        $this->manageApplication();
  50        return id(new AphrontRedirectResponse())->setURI($view_uri);
  51      }
  52  
  53      if ($this->action == 'install') {
  54        if ($selected->canUninstall()) {
  55          $dialog->setTitle('Confirmation')
  56                 ->appendChild(
  57                   'Install '.$selected->getName().' application?')
  58                 ->addSubmitButton('Install');
  59  
  60        } else {
  61          $dialog->setTitle('Information')
  62                 ->appendChild('You cannot install an installed application.');
  63        }
  64      } else {
  65        if ($selected->canUninstall()) {
  66          $dialog->setTitle('Confirmation')
  67                 ->appendChild(
  68                   'Really Uninstall '.$selected->getName().' application?')
  69                 ->addSubmitButton('Uninstall');
  70        } else {
  71          $dialog->setTitle('Information')
  72                 ->appendChild(
  73                   'This application cannot be uninstalled,
  74                   because it is required for Phabricator to work.');
  75        }
  76      }
  77      return id(new AphrontDialogResponse())->setDialog($dialog);
  78    }
  79  
  80    public function manageApplication() {
  81      $key = 'phabricator.uninstalled-applications';
  82      $config_entry = PhabricatorConfigEntry::loadConfigEntry($key);
  83      $list = $config_entry->getValue();
  84      $uninstalled = PhabricatorEnv::getEnvConfig($key);
  85  
  86      if (isset($uninstalled[$this->application])) {
  87        unset($list[$this->application]);
  88      } else {
  89        $list[$this->application] = true;
  90      }
  91  
  92      PhabricatorConfigEditor::storeNewValue(
  93        $this->getRequest()->getUser(),
  94        $config_entry,
  95        $list,
  96        PhabricatorContentSource::newFromRequest($this->getRequest()));
  97    }
  98  
  99  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1