Differential D16036 Diff 38602 src/applications/settings/panel/PhabricatorDesktopNotificationsSettingsPanel.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/settings/panel/PhabricatorDesktopNotificationsSettingsPanel.php
| Show All 20 Lines | public function getPanelName() { | ||||
| return pht('Desktop Notifications'); | return pht('Desktop Notifications'); | ||||
| } | } | ||||
| public function getPanelGroupKey() { | public function getPanelGroupKey() { | ||||
| return PhabricatorSettingsApplicationsPanelGroup::PANELGROUPKEY; | return PhabricatorSettingsApplicationsPanelGroup::PANELGROUPKEY; | ||||
| } | } | ||||
| public function processRequest(AphrontRequest $request) { | public function processRequest(AphrontRequest $request) { | ||||
| $user = $request->getUser(); | $viewer = $this->getViewer(); | ||||
| $preferences = $user->loadPreferences(); | $preferences = $this->loadTargetPreferences(); | ||||
| $pref = PhabricatorUserPreferences::PREFERENCE_DESKTOP_NOTIFICATIONS; | $notifications_key = PhabricatorDesktopNotificationsSetting::SETTINGKEY; | ||||
| $notifications_value = $preferences->getSettingValue($notifications_key); | |||||
| if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
| $notifications = $request->getInt($pref); | |||||
| $preferences->setPreference($pref, $notifications); | $this->writeSetting( | ||||
| $preferences->save(); | $preferences, | ||||
| $notifications_key, | |||||
| $request->getInt($notifications_key)); | |||||
| return id(new AphrontRedirectResponse()) | return id(new AphrontRedirectResponse()) | ||||
| ->setURI($this->getPanelURI('?saved=true')); | ->setURI($this->getPanelURI('?saved=true')); | ||||
| } | } | ||||
| $title = pht('Desktop Notifications'); | $title = pht('Desktop Notifications'); | ||||
| $control_id = celerity_generate_unique_node_id(); | $control_id = celerity_generate_unique_node_id(); | ||||
| $status_id = celerity_generate_unique_node_id(); | $status_id = celerity_generate_unique_node_id(); | ||||
| $browser_status_id = celerity_generate_unique_node_id(); | $browser_status_id = celerity_generate_unique_node_id(); | ||||
| ▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | $control_config = array( | ||||
| 'deniedAsk' => $reject_ask, | 'deniedAsk' => $reject_ask, | ||||
| 'defaultStatus' => $default_status, | 'defaultStatus' => $default_status, | ||||
| 'deniedStatus' => $denied_status, | 'deniedStatus' => $denied_status, | ||||
| 'grantedStatus' => $granted_status, | 'grantedStatus' => $granted_status, | ||||
| 'noSupport' => $no_support, | 'noSupport' => $no_support, | ||||
| ); | ); | ||||
| $form = id(new AphrontFormView()) | $form = id(new AphrontFormView()) | ||||
| ->setUser($user) | ->setUser($viewer) | ||||
| ->appendChild( | ->appendChild( | ||||
| id(new AphrontFormSelectControl()) | id(new AphrontFormSelectControl()) | ||||
| ->setLabel($title) | ->setLabel($title) | ||||
| ->setControlID($control_id) | ->setControlID($control_id) | ||||
| ->setName($pref) | ->setName($notifications_key) | ||||
| ->setValue($preferences->getPreference($pref)) | ->setValue($notifications_value) | ||||
| ->setOptions( | ->setOptions( | ||||
| array( | array( | ||||
| 1 => pht('Send Desktop Notifications Too'), | 1 => pht('Send Desktop Notifications Too'), | ||||
| 0 => pht('Send Application Notifications Only'), | 0 => pht('Send Application Notifications Only'), | ||||
| )) | )) | ||||
| ->setCaption( | ->setCaption( | ||||
| pht( | pht( | ||||
| 'Should Phabricator send desktop notifications? These are sent '. | 'Should Phabricator send desktop notifications? These are sent '. | ||||
| Show All 38 Lines | |||||