3 final class ConpherenceRoomPreferencesController
4 extends ConpherenceController
{
6 public function shouldAllowPublic() {
10 public function handleRequest(AphrontRequest
$request) {
11 $viewer = $request->getViewer();
12 $conpherence_id = $request->getURIData('id');
14 $conpherence = id(new ConpherenceThreadQuery())
16 ->withIDs(array($conpherence_id))
19 return new Aphront404Response();
22 $view_uri = $conpherence->getURI();
24 $participant = $conpherence->getParticipantIfExists($viewer->getPHID());
26 if ($viewer->isLoggedIn()) {
28 'Notification settings are available after joining the room.');
31 'Notification settings are available after logging in and joining '.
34 return $this->newDialog()
35 ->setTitle(pht('Room Preferences'))
36 ->addCancelButton($view_uri)
37 ->appendParagraph($text);
40 // Save the data and redirect
41 if ($request->isFormPost()) {
42 $notifications = $request->getStr('notifications');
43 $sounds = $request->getArr('sounds');
44 $theme = $request->getStr('theme');
46 $participant->setSettings(array(
47 'notifications' => $notifications,
53 return id(new AphrontRedirectResponse())
57 $notification_key = PhabricatorConpherenceNotificationsSetting
::SETTINGKEY
;
58 $notification_default = $viewer->getUserSetting($notification_key);
60 $sound_key = PhabricatorConpherenceSoundSetting
::SETTINGKEY
;
61 $sound_default = $viewer->getUserSetting($sound_key);
63 $settings = $participant->getSettings();
64 $notifications = idx($settings, 'notifications', $notification_default);
65 $theme = idx($settings, 'theme', ConpherenceRoomSettings
::COLOR_LIGHT
);
67 $sounds = idx($settings, 'sounds', array());
68 $map = PhabricatorConpherenceSoundSetting
::getDefaultSound($sound_default);
69 $receive = idx($sounds,
70 ConpherenceRoomSettings
::SOUND_RECEIVE
,
71 $map[ConpherenceRoomSettings
::SOUND_RECEIVE
]);
72 $mention = idx($sounds,
73 ConpherenceRoomSettings
::SOUND_MENTION
,
74 $map[ConpherenceRoomSettings
::SOUND_MENTION
]);
76 $form = id(new AphrontFormView())
79 id(new AphrontFormRadioButtonControl())
80 ->setLabel(pht('Notify'))
82 PhabricatorConpherenceNotificationsSetting
::VALUE_CONPHERENCE_EMAIL
,
83 PhabricatorConpherenceNotificationsSetting
::getSettingLabel(
84 PhabricatorConpherenceNotificationsSetting
::VALUE_CONPHERENCE_EMAIL
),
87 PhabricatorConpherenceNotificationsSetting
::VALUE_CONPHERENCE_NOTIFY
,
88 PhabricatorConpherenceNotificationsSetting
::getSettingLabel(
89 PhabricatorConpherenceNotificationsSetting
::VALUE_CONPHERENCE_NOTIFY
),
91 ->setName('notifications')
92 ->setValue($notifications))
94 id(new AphrontFormSelectControl())
95 ->setLabel(pht('New Message'))
96 ->setName('sounds['.ConpherenceRoomSettings
::SOUND_RECEIVE
.']')
97 ->setOptions(ConpherenceRoomSettings
::getDropdownSoundMap())
100 id(new AphrontFormSelectControl())
101 ->setLabel(pht('Theme'))
103 ->setOptions(ConpherenceRoomSettings
::getThemeMap())
106 return $this->newDialog()
107 ->setTitle(pht('Room Preferences'))
109 ->addCancelButton($view_uri)
110 ->addSubmitButton(pht('Save'));