@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Move room preferences into own controller

Summary: Ref T12591. These preferences are per user and we need to reload the whole UI on a change anyways. Simplifies future expansion.

Test Plan: Option click into new window, set preferences. View in Conpherence, see saved settings, change sound. Hear new sound.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T12591

Differential Revision: https://secure.phabricator.com/D17740

+118 -115
+2
src/__phutil_library_map__.php
··· 310 310 'ConpherenceReplyHandler' => 'applications/conpherence/mail/ConpherenceReplyHandler.php', 311 311 'ConpherenceRoomListController' => 'applications/conpherence/controller/ConpherenceRoomListController.php', 312 312 'ConpherenceRoomPictureController' => 'applications/conpherence/controller/ConpherenceRoomPictureController.php', 313 + 'ConpherenceRoomPreferencesController' => 'applications/conpherence/controller/ConpherenceRoomPreferencesController.php', 313 314 'ConpherenceRoomSettings' => 'applications/conpherence/constants/ConpherenceRoomSettings.php', 314 315 'ConpherenceRoomTestCase' => 'applications/conpherence/__tests__/ConpherenceRoomTestCase.php', 315 316 'ConpherenceSchemaSpec' => 'applications/conpherence/storage/ConpherenceSchemaSpec.php', ··· 5108 5109 'ConpherenceReplyHandler' => 'PhabricatorMailReplyHandler', 5109 5110 'ConpherenceRoomListController' => 'ConpherenceController', 5110 5111 'ConpherenceRoomPictureController' => 'ConpherenceController', 5112 + 'ConpherenceRoomPreferencesController' => 'ConpherenceController', 5111 5113 'ConpherenceRoomSettings' => 'ConpherenceConstants', 5112 5114 'ConpherenceRoomTestCase' => 'ConpherenceTestCase', 5113 5115 'ConpherenceSchemaSpec' => 'PhabricatorConfigSchemaSpec',
+2
src/applications/conpherence/application/PhabricatorConpherenceApplication.php
··· 55 55 => 'ConpherenceNotificationPanelController', 56 56 'participant/(?P<id>[1-9]\d*)/' 57 57 => 'ConpherenceParticipantController', 58 + 'preferences/(?P<id>[1-9]\d*)/' 59 + => 'ConpherenceRoomPreferencesController', 58 60 'update/(?P<id>[1-9]\d*)/' 59 61 => 'ConpherenceUpdateController', 60 62 ),
-1
src/applications/conpherence/constants/ConpherenceUpdateActions.php
··· 8 8 const JOIN_ROOM = 'join_room'; 9 9 const ADD_PERSON = 'add_person'; 10 10 const REMOVE_PERSON = 'remove_person'; 11 - const NOTIFICATIONS = 'notifications'; 12 11 const ADD_STATUS = 'add_status'; 13 12 const LOAD = 'load'; 14 13 }
+6 -8
src/applications/conpherence/controller/ConpherenceController.php
··· 57 57 ConpherenceThread $conpherence) { 58 58 $viewer = $this->getViewer(); 59 59 $header = null; 60 + $id = $conpherence->getID(); 60 61 61 - if ($conpherence->getID()) { 62 + if ($id) { 62 63 $data = $conpherence->getDisplayData($this->getViewer()); 63 64 64 65 $header = id(new PHUIHeaderView()) ··· 83 84 84 85 if ($can_edit) { 85 86 $header->setImageURL( 86 - $this->getApplicationURI('picture/'.$conpherence->getID().'/')); 87 + $this->getApplicationURI("picture/{$id}/")); 87 88 } 88 89 89 90 $participating = $conpherence->getParticipantIfExists($viewer->getPHID()); 90 91 91 92 $header->addActionItem( 92 93 id(new PHUIIconCircleView()) 93 - ->setHref( 94 - $this->getApplicationURI('update/'.$conpherence->getID()).'/') 94 + ->setHref($this->getApplicationURI("update/{$id}/")) 95 95 ->setIcon('fa-pencil') 96 96 ->addClass('hide-on-device') 97 97 ->setColor('violet') ··· 99 99 100 100 $header->addActionItem( 101 101 id(new PHUIIconCircleView()) 102 - ->setHref( 103 - $this->getApplicationURI('update/'.$conpherence->getID()).'/'. 104 - '?action='.ConpherenceUpdateActions::NOTIFICATIONS) 102 + ->setHref($this->getApplicationURI("preferences/{$id}/")) 105 103 ->setIcon('fa-gear') 106 104 ->addClass('hide-on-device') 107 105 ->setColor('pink') ··· 136 134 137 135 if (!$participating) { 138 136 $action = ConpherenceUpdateActions::JOIN_ROOM; 139 - $uri = $this->getApplicationURI('update/'.$conpherence->getID().'/'); 137 + $uri = $this->getApplicationURI("update/{$id}/"); 140 138 $button = phutil_tag( 141 139 'button', 142 140 array(
+104
src/applications/conpherence/controller/ConpherenceRoomPreferencesController.php
··· 1 + <?php 2 + 3 + final class ConpherenceRoomPreferencesController 4 + extends ConpherenceController { 5 + 6 + public function shouldAllowPublic() { 7 + return true; 8 + } 9 + 10 + public function handleRequest(AphrontRequest $request) { 11 + $viewer = $request->getViewer(); 12 + $conpherence_id = $request->getURIData('id'); 13 + 14 + $conpherence = id(new ConpherenceThreadQuery()) 15 + ->setViewer($viewer) 16 + ->withIDs(array($conpherence_id)) 17 + ->executeOne(); 18 + if (!$conpherence) { 19 + return new Aphront404Response(); 20 + } 21 + 22 + $view_uri = $conpherence->getURI(); 23 + 24 + $participant = $conpherence->getParticipantIfExists($viewer->getPHID()); 25 + if (!$participant) { 26 + if ($viewer->isLoggedIn()) { 27 + $text = pht( 28 + 'Notification settings are available after joining the room.'); 29 + } else { 30 + $text = pht( 31 + 'Notification settings are available after logging in and joining '. 32 + 'the room.'); 33 + } 34 + return $this->newDialog() 35 + ->setTitle(pht('Room Preferences')) 36 + ->addCancelButton($view_uri) 37 + ->appendParagraph($text); 38 + } 39 + 40 + // Save the data and redirect 41 + if ($request->isFormPost()) { 42 + $notifications = $request->getStr('notifications'); 43 + $sounds = $request->getArr('sounds'); 44 + 45 + $participant->setSettings(array( 46 + 'notifications' => $notifications, 47 + 'sounds' => $sounds, 48 + )); 49 + $participant->save(); 50 + 51 + return id(new AphrontRedirectResponse()) 52 + ->setURI($view_uri); 53 + } 54 + 55 + $notification_key = PhabricatorConpherenceNotificationsSetting::SETTINGKEY; 56 + $notification_default = $viewer->getUserSetting($notification_key); 57 + 58 + $sound_key = PhabricatorConpherenceSoundSetting::SETTINGKEY; 59 + $sound_default = $viewer->getUserSetting($sound_key); 60 + 61 + $settings = $participant->getSettings(); 62 + $notifications = idx($settings, 'notifications', $notification_default); 63 + 64 + $sounds = idx($settings, 'sounds', array()); 65 + $map = PhabricatorConpherenceSoundSetting::getDefaultSound($sound_default); 66 + $receive = idx($sounds, 67 + ConpherenceRoomSettings::SOUND_RECEIVE, 68 + $map[ConpherenceRoomSettings::SOUND_RECEIVE]); 69 + $mention = idx($sounds, 70 + ConpherenceRoomSettings::SOUND_MENTION, 71 + $map[ConpherenceRoomSettings::SOUND_MENTION]); 72 + 73 + $form = id(new AphrontFormView()) 74 + ->setUser($viewer) 75 + ->appendControl( 76 + id(new AphrontFormRadioButtonControl()) 77 + ->setLabel(pht('Notify')) 78 + ->addButton( 79 + PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL, 80 + PhabricatorConpherenceNotificationsSetting::getSettingLabel( 81 + PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL), 82 + '') 83 + ->addButton( 84 + PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_NOTIFY, 85 + PhabricatorConpherenceNotificationsSetting::getSettingLabel( 86 + PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_NOTIFY), 87 + '') 88 + ->setName('notifications') 89 + ->setValue($notifications)) 90 + ->appendChild( 91 + id(new AphrontFormSelectControl()) 92 + ->setLabel(pht('New Message')) 93 + ->setName('sounds['.ConpherenceRoomSettings::SOUND_RECEIVE.']') 94 + ->setOptions(ConpherenceRoomSettings::getDropdownSoundMap()) 95 + ->setValue($receive)); 96 + 97 + return $this->newDialog() 98 + ->setTitle(pht('Room Preferences')) 99 + ->appendForm($form) 100 + ->addCancelButton($view_uri) 101 + ->addSubmitButton(pht('Save')); 102 + } 103 + 104 + }
-106
src/applications/conpherence/controller/ConpherenceUpdateController.php
··· 24 24 case ConpherenceUpdateActions::METADATA: 25 25 $needed_capabilities[] = PhabricatorPolicyCapability::CAN_EDIT; 26 26 break; 27 - case ConpherenceUpdateActions::NOTIFICATIONS: 28 - $need_participants = true; 29 - break; 30 27 case ConpherenceUpdateActions::LOAD: 31 28 break; 32 29 } ··· 113 110 $response_mode = 'go-home'; 114 111 } 115 112 break; 116 - case ConpherenceUpdateActions::NOTIFICATIONS: 117 - $notifications = $request->getStr('notifications'); 118 - $sounds = $request->getArr('sounds'); 119 - $participant = $conpherence->getParticipantIfExists($user->getPHID()); 120 - if (!$participant) { 121 - return id(new Aphront404Response()); 122 - } 123 - $participant->setSettings(array( 124 - 'notifications' => $notifications, 125 - 'sounds' => $sounds, 126 - )); 127 - $participant->save(); 128 - return id(new AphrontRedirectResponse()) 129 - ->setURI('/'.$conpherence->getMonogram()); 130 - 131 - break; 132 113 case ConpherenceUpdateActions::METADATA: 133 114 $title = $request->getStr('title'); 134 115 $topic = $request->getStr('topic'); ··· 221 202 } 222 203 223 204 switch ($action) { 224 - case ConpherenceUpdateActions::NOTIFICATIONS: 225 - $dialog = $this->renderPreferencesDialog($conpherence); 226 - break; 227 205 case ConpherenceUpdateActions::ADD_PERSON: 228 206 $dialog = $this->renderAddPersonDialog($conpherence); 229 207 break; ··· 246 224 247 225 } 248 226 249 - private function renderPreferencesDialog( 250 - ConpherenceThread $conpherence) { 251 - 252 - $request = $this->getRequest(); 253 - $user = $request->getUser(); 254 - 255 - $participant = $conpherence->getParticipantIfExists($user->getPHID()); 256 - if (!$participant) { 257 - if ($user->isLoggedIn()) { 258 - $text = pht( 259 - 'Notification settings are available after joining the room.'); 260 - } else { 261 - $text = pht( 262 - 'Notification settings are available after logging in and joining '. 263 - 'the room.'); 264 - } 265 - return id(new AphrontDialogView()) 266 - ->setTitle(pht('Room Preferences')) 267 - ->appendParagraph($text); 268 - } 269 - 270 - $notification_key = PhabricatorConpherenceNotificationsSetting::SETTINGKEY; 271 - $notification_default = $user->getUserSetting($notification_key); 272 - 273 - $sound_key = PhabricatorConpherenceSoundSetting::SETTINGKEY; 274 - $sound_default = $user->getUserSetting($sound_key); 275 - 276 - $settings = $participant->getSettings(); 277 - $notifications = idx($settings, 'notifications', $notification_default); 278 - 279 - $sounds = idx($settings, 'sounds', array()); 280 - $map = PhabricatorConpherenceSoundSetting::getDefaultSound($sound_default); 281 - $receive = idx($sounds, 282 - ConpherenceRoomSettings::SOUND_RECEIVE, 283 - $map[ConpherenceRoomSettings::SOUND_RECEIVE]); 284 - $mention = idx($sounds, 285 - ConpherenceRoomSettings::SOUND_MENTION, 286 - $map[ConpherenceRoomSettings::SOUND_MENTION]); 287 - 288 - $form = id(new AphrontFormView()) 289 - ->setUser($user) 290 - ->appendControl( 291 - id(new AphrontFormRadioButtonControl()) 292 - ->setLabel(pht('Notify')) 293 - ->addButton( 294 - PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL, 295 - PhabricatorConpherenceNotificationsSetting::getSettingLabel( 296 - PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL), 297 - '') 298 - ->addButton( 299 - PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_NOTIFY, 300 - PhabricatorConpherenceNotificationsSetting::getSettingLabel( 301 - PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_NOTIFY), 302 - '') 303 - ->setName('notifications') 304 - ->setValue($notifications)) 305 - ->appendChild( 306 - id(new AphrontFormSelectControl()) 307 - ->setLabel(pht('Message Received')) 308 - ->setName('sounds['.ConpherenceRoomSettings::SOUND_RECEIVE.']') 309 - ->setOptions(ConpherenceRoomSettings::getDropdownSoundMap()) 310 - ->setValue($receive)); 311 - 312 - // TODO: Future Adventure! Expansion Pack 313 - // 314 - // ->appendChild( 315 - // id(new AphrontFormSelectControl()) 316 - // ->setLabel(pht('Username Mentioned')) 317 - // ->setName('sounds['.ConpherenceRoomSettings::SOUND_MENTION.']') 318 - // ->setOptions(ConpherenceRoomSettings::getDropdownSoundMap()) 319 - // ->setValue($mention)); 320 - 321 - return id(new AphrontDialogView()) 322 - ->setTitle(pht('Room Preferences')) 323 - ->addHiddenInput('action', 'notifications') 324 - ->addHiddenInput( 325 - 'latest_transaction_id', 326 - $request->getInt('latest_transaction_id')) 327 - ->appendForm($form); 328 - 329 - } 330 - 331 227 private function renderAddPersonDialog( 332 228 ConpherenceThread $conpherence) { 333 229 ··· 508 404 $need_transactions = true; 509 405 break; 510 406 case ConpherenceUpdateActions::REMOVE_PERSON: 511 - case ConpherenceUpdateActions::NOTIFICATIONS: 512 407 default: 513 408 break; 514 409 ··· 566 461 $people_widget = hsprintf('%s', $people_widget->render()); 567 462 break; 568 463 case ConpherenceUpdateActions::REMOVE_PERSON: 569 - case ConpherenceUpdateActions::NOTIFICATIONS: 570 464 default: 571 465 break; 572 466 }
+4
src/applications/conpherence/storage/ConpherenceThread.php
··· 72 72 return 'Z'.$this->getID(); 73 73 } 74 74 75 + public function getURI() { 76 + return '/'.$this->getMonogram(); 77 + } 78 + 75 79 public function attachParticipants(array $participants) { 76 80 assert_instances_of($participants, 'ConpherenceParticipant'); 77 81 $this->participants = $participants;