Differential D16025 Diff 38577 src/applications/conpherence/controller/ConpherenceWidgetController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/conpherence/controller/ConpherenceWidgetController.php
| <?php | <?php | ||||
| final class ConpherenceWidgetController extends ConpherenceController { | final class ConpherenceWidgetController extends ConpherenceController { | ||||
| private $userPreferences; | |||||
| public function setUserPreferences(PhabricatorUserPreferences $pref) { | |||||
| $this->userPreferences = $pref; | |||||
| return $this; | |||||
| } | |||||
| public function getUserPreferences() { | |||||
| return $this->userPreferences; | |||||
| } | |||||
| public function shouldAllowPublic() { | public function shouldAllowPublic() { | ||||
| return true; | return true; | ||||
| } | } | ||||
| public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
| $request = $this->getRequest(); | $request = $this->getRequest(); | ||||
| $user = $request->getUser(); | $user = $request->getUser(); | ||||
| $conpherence_id = $request->getURIData('id'); | $conpherence_id = $request->getURIData('id'); | ||||
| if (!$conpherence_id) { | if (!$conpherence_id) { | ||||
| return new Aphront404Response(); | return new Aphront404Response(); | ||||
| } | } | ||||
| $conpherence = id(new ConpherenceThreadQuery()) | $conpherence = id(new ConpherenceThreadQuery()) | ||||
| ->setViewer($user) | ->setViewer($user) | ||||
| ->withIDs(array($conpherence_id)) | ->withIDs(array($conpherence_id)) | ||||
| ->needWidgetData(true) | ->needWidgetData(true) | ||||
| ->executeOne(); | ->executeOne(); | ||||
| if (!$conpherence) { | if (!$conpherence) { | ||||
| return new Aphront404Response(); | return new Aphront404Response(); | ||||
| } | } | ||||
| $this->setConpherence($conpherence); | $this->setConpherence($conpherence); | ||||
| $this->setUserPreferences($user->loadPreferences()); | |||||
| switch ($request->getStr('widget')) { | switch ($request->getStr('widget')) { | ||||
| case 'widgets-people': | case 'widgets-people': | ||||
| $content = $this->renderPeopleWidgetPaneContent(); | $content = $this->renderPeopleWidgetPaneContent(); | ||||
| break; | break; | ||||
| case 'widgets-settings': | case 'widgets-settings': | ||||
| $content = $this->renderSettingsWidgetPaneContent(); | $content = $this->renderSettingsWidgetPaneContent(); | ||||
| break; | break; | ||||
| default: | default: | ||||
| ▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | if (!$participant) { | ||||
| } | } | ||||
| return phutil_tag( | return phutil_tag( | ||||
| 'div', | 'div', | ||||
| array( | array( | ||||
| 'class' => 'no-settings', | 'class' => 'no-settings', | ||||
| ), | ), | ||||
| $text); | $text); | ||||
| } | } | ||||
| $default = ConpherenceSettings::EMAIL_ALWAYS; | $notification_key = PhabricatorConpherenceNotificationsSetting::SETTINGKEY; | ||||
| $preference = $this->getUserPreferences(); | $notification_default = $viewer->getUserSetting($notification_key); | ||||
| if ($preference) { | |||||
| $default = $preference->getPreference( | |||||
| PhabricatorUserPreferences::PREFERENCE_CONPH_NOTIFICATIONS, | |||||
| ConpherenceSettings::EMAIL_ALWAYS); | |||||
| } | |||||
| $settings = $participant->getSettings(); | $settings = $participant->getSettings(); | ||||
| $notifications = idx( | $notifications = idx( | ||||
| $settings, | $settings, | ||||
| 'notifications', | 'notifications', | ||||
| $default); | $notification_default); | ||||
| $options = id(new AphrontFormRadioButtonControl()) | $options = id(new AphrontFormRadioButtonControl()) | ||||
| ->addButton( | ->addButton( | ||||
| ConpherenceSettings::EMAIL_ALWAYS, | PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL, | ||||
| ConpherenceSettings::getHumanString( | PhabricatorConpherenceNotificationsSetting::getSettingLabel( | ||||
| ConpherenceSettings::EMAIL_ALWAYS), | PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL), | ||||
| '') | '') | ||||
| ->addButton( | ->addButton( | ||||
| ConpherenceSettings::NOTIFICATIONS_ONLY, | PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_NOTIFY, | ||||
| ConpherenceSettings::getHumanString( | PhabricatorConpherenceNotificationsSetting::getSettingLabel( | ||||
| ConpherenceSettings::NOTIFICATIONS_ONLY), | PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_NOTIFY), | ||||
| '') | '') | ||||
| ->setName('notifications') | ->setName('notifications') | ||||
| ->setValue($notifications); | ->setValue($notifications); | ||||
| $layout = array( | $layout = array( | ||||
| $options, | $options, | ||||
| phutil_tag( | phutil_tag( | ||||
| 'input', | 'input', | ||||
| Show All 30 Lines | |||||