Installation & Uninstallion of Applications
Summary: Created Applications application which allows uninstallation & installation of application. Test Plan: In "Applications" application, clicked on uninstalled the application by cliking Uninstall and chekcing whether they are really uninstalled(Disabling URI & in appearance in the side pane). Then Clicked on the install button of the uninstalled application to check whether they are installed. Reviewers: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4715
This commit is contained in:
committed by
epriestley
parent
683df86d54
commit
5017c80b31
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
final class PhabricatorApplicationUninstallController
|
||||
extends PhabricatorApplicationsController {
|
||||
|
||||
private $application;
|
||||
private $action;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->application = $data['application'];
|
||||
$this->action = $data['action'];
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
$app_name = substr($this->application, strlen('PhabricatorApplication'));
|
||||
|
||||
if ($request->isDialogFormPost()) {
|
||||
$this->manageApplication();
|
||||
return id(new AphrontRedirectResponse())->setURI('/applications/');
|
||||
}
|
||||
|
||||
if ($this->action == 'install') {
|
||||
|
||||
$dialog = id(new AphrontDialogView())
|
||||
->setUser($user)
|
||||
->setTitle('Confirmation')
|
||||
->appendChild('Install '. $app_name. ' application ?')
|
||||
->addSubmitButton('Install')
|
||||
->addCancelButton('/applications/view/'.$this->application);
|
||||
} else {
|
||||
$dialog = id(new AphrontDialogView())
|
||||
->setUser($user)
|
||||
->setTitle('Confirmation')
|
||||
->appendChild('Really Uninstall '. $app_name. ' application ?')
|
||||
->addSubmitButton('Uninstall')
|
||||
->addCancelButton('/applications/view/'.$this->application);
|
||||
}
|
||||
|
||||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||
}
|
||||
|
||||
public function manageApplication() {
|
||||
$key = 'phabricator.uninstalled-applications';
|
||||
|
||||
$config_entry = id(new PhabricatorConfigEntry())
|
||||
->loadOneWhere(
|
||||
'configKey = %s AND namespace = %s',
|
||||
$key,
|
||||
'default');
|
||||
|
||||
if (!$config_entry) {
|
||||
$config_entry = id(new PhabricatorConfigEntry())
|
||||
->setConfigKey($key)
|
||||
->setNamespace('default');
|
||||
}
|
||||
|
||||
$list = $config_entry->getValue();
|
||||
|
||||
$uninstalled = PhabricatorEnv::getEnvConfig($key);
|
||||
|
||||
if ($uninstalled[$this->application]) {
|
||||
unset($list[$this->application]);
|
||||
} else {
|
||||
$list[$this->application] = true;
|
||||
}
|
||||
|
||||
$xaction = id(new PhabricatorConfigTransaction())
|
||||
->setTransactionType(PhabricatorConfigTransaction::TYPE_EDIT)
|
||||
->setNewValue(
|
||||
array(
|
||||
'deleted' => false,
|
||||
'value' => $list
|
||||
));
|
||||
|
||||
$editor = id(new PhabricatorConfigEditor())
|
||||
->setActor($this->getRequest()->getUser())
|
||||
->setContinueOnNoEffect(true)
|
||||
->setContentSource(
|
||||
PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_WEB,
|
||||
array(
|
||||
'ip' => $this->getRequest()->getRemoteAddr(),
|
||||
)));
|
||||
|
||||
|
||||
$editor->applyTransactions($config_entry, array($xaction));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user