Path: blob/master/src/applications/conpherence/controller/ConpherenceRoomPreferencesController.php
12256 views
<?php12final class ConpherenceRoomPreferencesController3extends ConpherenceController {45public function shouldAllowPublic() {6return true;7}89public function handleRequest(AphrontRequest $request) {10$viewer = $request->getViewer();11$conpherence_id = $request->getURIData('id');1213$conpherence = id(new ConpherenceThreadQuery())14->setViewer($viewer)15->withIDs(array($conpherence_id))16->executeOne();17if (!$conpherence) {18return new Aphront404Response();19}2021$view_uri = $conpherence->getURI();2223$participant = $conpherence->getParticipantIfExists($viewer->getPHID());24if (!$participant) {25if ($viewer->isLoggedIn()) {26$text = pht(27'Notification settings are available after joining the room.');28} else {29$text = pht(30'Notification settings are available after logging in and joining '.31'the room.');32}33return $this->newDialog()34->setTitle(pht('Room Preferences'))35->addCancelButton($view_uri)36->appendParagraph($text);37}3839// Save the data and redirect40if ($request->isFormPost()) {41$notifications = $request->getStr('notifications');42$sounds = $request->getArr('sounds');43$theme = $request->getStr('theme');4445$participant->setSettings(array(46'notifications' => $notifications,47'sounds' => $sounds,48'theme' => $theme,49));50$participant->save();5152return id(new AphrontRedirectResponse())53->setURI($view_uri);54}5556$notification_key = PhabricatorConpherenceNotificationsSetting::SETTINGKEY;57$notification_default = $viewer->getUserSetting($notification_key);5859$sound_key = PhabricatorConpherenceSoundSetting::SETTINGKEY;60$sound_default = $viewer->getUserSetting($sound_key);6162$settings = $participant->getSettings();63$notifications = idx($settings, 'notifications', $notification_default);64$theme = idx($settings, 'theme', ConpherenceRoomSettings::COLOR_LIGHT);6566$sounds = idx($settings, 'sounds', array());67$map = PhabricatorConpherenceSoundSetting::getDefaultSound($sound_default);68$receive = idx($sounds,69ConpherenceRoomSettings::SOUND_RECEIVE,70$map[ConpherenceRoomSettings::SOUND_RECEIVE]);71$mention = idx($sounds,72ConpherenceRoomSettings::SOUND_MENTION,73$map[ConpherenceRoomSettings::SOUND_MENTION]);7475$form = id(new AphrontFormView())76->setUser($viewer)77->appendControl(78id(new AphrontFormRadioButtonControl())79->setLabel(pht('Notify'))80->addButton(81PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL,82PhabricatorConpherenceNotificationsSetting::getSettingLabel(83PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL),84'')85->addButton(86PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_NOTIFY,87PhabricatorConpherenceNotificationsSetting::getSettingLabel(88PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_NOTIFY),89'')90->setName('notifications')91->setValue($notifications))92->appendChild(93id(new AphrontFormSelectControl())94->setLabel(pht('New Message'))95->setName('sounds['.ConpherenceRoomSettings::SOUND_RECEIVE.']')96->setOptions(ConpherenceRoomSettings::getDropdownSoundMap())97->setValue($receive))98->appendChild(99id(new AphrontFormSelectControl())100->setLabel(pht('Theme'))101->setName('theme')102->setOptions(ConpherenceRoomSettings::getThemeMap())103->setValue($theme));104105return $this->newDialog()106->setTitle(pht('Room Preferences'))107->appendForm($form)108->addCancelButton($view_uri)109->addSubmitButton(pht('Save'));110}111112}113114115