Path: blob/master/src/applications/meta/xactions/PhabricatorApplicationUninstallTransaction.php
12256 views
<?php12final class PhabricatorApplicationUninstallTransaction3extends PhabricatorApplicationTransactionType {45const TRANSACTIONTYPE = 'application.uninstall';67public function generateOldValue($object) {8$key = 'phabricator.uninstalled-applications';9$config_entry = PhabricatorConfigEntry::loadConfigEntry($key);10$list = $config_entry->getValue();11$uninstalled = PhabricatorEnv::getEnvConfig($key);1213if (isset($uninstalled[get_class($object)])) {14return 'uninstalled';15} else {16return 'installed';17}18}1920public function generateNewValue($object, $value) {21if ($value === 'uninstall') {22return 'uninstalled';23} else {24return 'installed';25}26}2728public function applyExternalEffects($object, $value) {29$application = $object;30$user = $this->getActor();3132$key = 'phabricator.uninstalled-applications';33$config_entry = PhabricatorConfigEntry::loadConfigEntry($key);34$list = $config_entry->getValue();35$uninstalled = PhabricatorEnv::getEnvConfig($key);3637if (isset($uninstalled[get_class($application)])) {38unset($list[get_class($application)]);39} else {40$list[get_class($application)] = true;41}4243$editor = $this->getEditor();44$content_source = $editor->getContentSource();4546// Today, changing config requires "Administrator", but "Can Edit" on47// applications to let you uninstall them may be granted to any user.48PhabricatorConfigEditor::storeNewValue(49PhabricatorUser::getOmnipotentUser(),50$config_entry,51$list,52$content_source,53$user->getPHID());54}5556public function getTitle() {57if ($this->getNewValue() === 'uninstalled') {58return pht(59'%s uninstalled this application.',60$this->renderAuthor());61} else {62return pht(63'%s installed this application.',64$this->renderAuthor());65}66}6768public function getTitleForFeed() {69if ($this->getNewValue() === 'uninstalled') {70return pht(71'%s uninstalled %s.',72$this->renderAuthor(),73$this->renderObject());74} else {75return pht(76'%s installed %s.',77$this->renderAuthor(),78$this->renderObject());79}80}8182}838485