Differential D16048 Diff 38616 src/applications/settings/panel/PhabricatorEmailPreferencesSettingsPanel.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/settings/panel/PhabricatorEmailPreferencesSettingsPanel.php
| Show All 9 Lines | final class PhabricatorEmailPreferencesSettingsPanel | ||||
| public function getPanelName() { | public function getPanelName() { | ||||
| return pht('Email Preferences'); | return pht('Email Preferences'); | ||||
| } | } | ||||
| public function getPanelGroupKey() { | public function getPanelGroupKey() { | ||||
| return PhabricatorSettingsEmailPanelGroup::PANELGROUPKEY; | return PhabricatorSettingsEmailPanelGroup::PANELGROUPKEY; | ||||
| } | } | ||||
| public function isEditableByAdministrators() { | public function isManagementPanel() { | ||||
| if ($this->getUser()->getIsMailingList()) { | if ($this->getUser()->getIsMailingList()) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| public function isTemplatePanel() { | |||||
| return true; | |||||
| } | |||||
| public function processRequest(AphrontRequest $request) { | public function processRequest(AphrontRequest $request) { | ||||
| $viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
| $user = $this->getUser(); | $user = $this->getUser(); | ||||
| $preferences = $this->loadTargetPreferences(); | $preferences = $this->getPreferences(); | ||||
| $value_email = PhabricatorEmailTagsSetting::VALUE_EMAIL; | $value_email = PhabricatorEmailTagsSetting::VALUE_EMAIL; | ||||
| $errors = array(); | $errors = array(); | ||||
| if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
| $new_tags = $request->getArr('mailtags'); | $new_tags = $request->getArr('mailtags'); | ||||
| $mailtags = $preferences->getPreference('mailtags', array()); | $mailtags = $preferences->getPreference('mailtags', array()); | ||||
| $all_tags = $this->getAllTags($user); | $all_tags = $this->getAllTags($user); | ||||
| ▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | $form_box = id(new PHUIObjectBoxView()) | ||||
| ->setHeaderText(pht('Email Preferences')) | ->setHeaderText(pht('Email Preferences')) | ||||
| ->setFormSaved($request->getStr('saved')) | ->setFormSaved($request->getStr('saved')) | ||||
| ->setFormErrors($errors) | ->setFormErrors($errors) | ||||
| ->setForm($form); | ->setForm($form); | ||||
| return $form_box; | return $form_box; | ||||
| } | } | ||||
| private function getAllEditorsWithTags(PhabricatorUser $user) { | private function getAllEditorsWithTags(PhabricatorUser $user = null) { | ||||
| $editors = id(new PhutilClassMapQuery()) | $editors = id(new PhutilClassMapQuery()) | ||||
| ->setAncestorClass('PhabricatorApplicationTransactionEditor') | ->setAncestorClass('PhabricatorApplicationTransactionEditor') | ||||
| ->setFilterMethod('getMailTagsMap') | ->setFilterMethod('getMailTagsMap') | ||||
| ->execute(); | ->execute(); | ||||
| foreach ($editors as $key => $editor) { | foreach ($editors as $key => $editor) { | ||||
| // Remove editors for applications which are not installed. | // Remove editors for applications which are not installed. | ||||
| $app = $editor->getEditorApplicationClass(); | $app = $editor->getEditorApplicationClass(); | ||||
| if ($app !== null) { | if ($app !== null && $user !== null) { | ||||
| if (!PhabricatorApplication::isClassInstalledForViewer($app, $user)) { | if (!PhabricatorApplication::isClassInstalledForViewer($app, $user)) { | ||||
| unset($editors[$key]); | unset($editors[$key]); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return $editors; | return $editors; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines | |||||