diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -311,6 +311,7 @@ 'ConpherenceReplyHandler' => 'applications/conpherence/mail/ConpherenceReplyHandler.php', 'ConpherenceRoomListController' => 'applications/conpherence/controller/ConpherenceRoomListController.php', 'ConpherenceRoomPictureController' => 'applications/conpherence/controller/ConpherenceRoomPictureController.php', + 'ConpherenceRoomSettings' => 'applications/conpherence/constants/ConpherenceRoomSettings.php', 'ConpherenceRoomTestCase' => 'applications/conpherence/__tests__/ConpherenceRoomTestCase.php', 'ConpherenceSchemaSpec' => 'applications/conpherence/storage/ConpherenceSchemaSpec.php', 'ConpherenceTestCase' => 'applications/conpherence/__tests__/ConpherenceTestCase.php', @@ -2398,6 +2399,7 @@ 'PhabricatorConpherenceNotificationsSetting' => 'applications/settings/setting/PhabricatorConpherenceNotificationsSetting.php', 'PhabricatorConpherencePreferencesSettingsPanel' => 'applications/settings/panel/PhabricatorConpherencePreferencesSettingsPanel.php', 'PhabricatorConpherenceProfileMenuItem' => 'applications/search/menuitem/PhabricatorConpherenceProfileMenuItem.php', + 'PhabricatorConpherenceSoundSetting' => 'applications/settings/setting/PhabricatorConpherenceSoundSetting.php', 'PhabricatorConpherenceThreadPHIDType' => 'applications/conpherence/phid/PhabricatorConpherenceThreadPHIDType.php', 'PhabricatorConpherenceWidgetVisibleSetting' => 'applications/settings/setting/PhabricatorConpherenceWidgetVisibleSetting.php', 'PhabricatorConsoleApplication' => 'applications/console/application/PhabricatorConsoleApplication.php', @@ -5103,6 +5105,7 @@ 'ConpherenceReplyHandler' => 'PhabricatorMailReplyHandler', 'ConpherenceRoomListController' => 'ConpherenceController', 'ConpherenceRoomPictureController' => 'ConpherenceController', + 'ConpherenceRoomSettings' => 'ConpherenceConstants', 'ConpherenceRoomTestCase' => 'ConpherenceTestCase', 'ConpherenceSchemaSpec' => 'PhabricatorConfigSchemaSpec', 'ConpherenceTestCase' => 'PhabricatorTestCase', @@ -7505,6 +7508,7 @@ 'PhabricatorConpherenceNotificationsSetting' => 'PhabricatorSelectSetting', 'PhabricatorConpherencePreferencesSettingsPanel' => 'PhabricatorEditEngineSettingsPanel', 'PhabricatorConpherenceProfileMenuItem' => 'PhabricatorProfileMenuItem', + 'PhabricatorConpherenceSoundSetting' => 'PhabricatorSelectSetting', 'PhabricatorConpherenceThreadPHIDType' => 'PhabricatorPHIDType', 'PhabricatorConpherenceWidgetVisibleSetting' => 'PhabricatorInternalSetting', 'PhabricatorConsoleApplication' => 'PhabricatorApplication', diff --git a/src/applications/conpherence/constants/ConpherenceRoomSettings.php b/src/applications/conpherence/constants/ConpherenceRoomSettings.php new file mode 100644 --- /dev/null +++ b/src/applications/conpherence/constants/ConpherenceRoomSettings.php @@ -0,0 +1,31 @@ + array( + 'name' => pht('No Sound'), + 'rsrc' => '', + ), + 'tap' => array( + 'name' => pht('Tap'), + 'rsrc' => celerity_get_resource_uri('/rsrc/audio/basic/tap.mp3'), + ), + ); + } + + public static function getDropdownSoundMap() { + $map = self::getSoundMap(); + return ipull($map, 'name'); + } + + +} diff --git a/src/applications/conpherence/controller/ConpherenceUpdateController.php b/src/applications/conpherence/controller/ConpherenceUpdateController.php --- a/src/applications/conpherence/controller/ConpherenceUpdateController.php +++ b/src/applications/conpherence/controller/ConpherenceUpdateController.php @@ -12,7 +12,7 @@ $need_participants = false; $needed_capabilities = array(PhabricatorPolicyCapability::CAN_VIEW); - $action = $request->getStr('action', ConpherenceUpdateActions::METADATA); + $action = $request->getStr('action'); switch ($action) { case ConpherenceUpdateActions::REMOVE_PERSON: $person_phid = $request->getStr('remove_person'); @@ -21,7 +21,6 @@ } break; case ConpherenceUpdateActions::ADD_PERSON: - case ConpherenceUpdateActions::METADATA: $needed_capabilities[] = PhabricatorPolicyCapability::CAN_EDIT; break; case ConpherenceUpdateActions::NOTIFICATIONS: @@ -96,7 +95,7 @@ $xactions[] = id(new ConpherenceTransaction()) ->setTransactionType( ConpherenceTransaction::TYPE_PARTICIPANTS) - ->setNewValue(array('+' => $person_phids)); + ->setNewValue(array('+' => array_fuse($person_phids))); } break; case ConpherenceUpdateActions::REMOVE_PERSON: @@ -115,45 +114,18 @@ break; case ConpherenceUpdateActions::NOTIFICATIONS: $notifications = $request->getStr('notifications'); + $sounds = $request->getArr('sounds'); $participant = $conpherence->getParticipantIfExists($user->getPHID()); if (!$participant) { return id(new Aphront404Response()); } $participant->setSettings(array('notifications' => $notifications)); + $participant->setSettings(array('sounds' => $sounds)); $participant->save(); return id(new AphrontRedirectResponse()) ->setURI('/'.$conpherence->getMonogram()); break; - case ConpherenceUpdateActions::METADATA: - $title = $request->getStr('title'); - $topic = $request->getStr('topic'); - - // all other metadata updates are continue requests - if (!$request->isContinueRequest()) { - break; - } - - $title = $request->getStr('title'); - $topic = $request->getStr('topic'); - $xactions[] = id(new ConpherenceTransaction()) - ->setTransactionType( - ConpherenceThreadTitleTransaction::TRANSACTIONTYPE) - ->setNewValue($title); - $xactions[] = id(new ConpherenceTransaction()) - ->setTransactionType( - ConpherenceThreadTopicTransaction::TRANSACTIONTYPE) - ->setNewValue($topic); - $xactions[] = id(new ConpherenceTransaction()) - ->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) - ->setNewValue($request->getStr('viewPolicy')); - $xactions[] = id(new ConpherenceTransaction()) - ->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY) - ->setNewValue($request->getStr('editPolicy')); - if (!$request->getExists('force_ajax')) { - $response_mode = 'redirect'; - } - break; case ConpherenceUpdateActions::LOAD: $updated = false; $response_mode = 'ajax'; @@ -226,10 +198,6 @@ case ConpherenceUpdateActions::REMOVE_PERSON: $dialog = $this->renderRemovePersonDialog($conpherence); break; - case ConpherenceUpdateActions::METADATA: - default: - $dialog = $this->renderMetadataDialog($conpherence, $error_view); - break; } return @@ -266,29 +234,60 @@ $notification_key = PhabricatorConpherenceNotificationsSetting::SETTINGKEY; $notification_default = $user->getUserSetting($notification_key); + $sound_key = PhabricatorConpherenceSoundSetting::SETTINGKEY; + $sound_default = $user->getUserSetting($sound_key); + if ($sound_default) { + $sound = ConpherenceRoomSettings::DEFAULT_SOUND; + } else { + $sound = ConpherenceRoomSettings::DEFAULT_NO_SOUND; + } + $settings = $participant->getSettings(); - $notifications = idx( - $settings, - 'notifications', - $notification_default); + $notifications = idx($settings, 'notifications', $notification_default); + + $sounds = idx($settings, 'sounds', array()); + $send = idx($sounds, ConpherenceRoomSettings::SOUND_SEND, $sound); + $receive = idx($sounds, ConpherenceRoomSettings::SOUND_RECEIVE, $sound); + $mention = idx($sounds, ConpherenceRoomSettings::SOUND_MENTION, $sound); $form = id(new AphrontFormView()) ->setUser($user) - ->setFullWidth(true) ->appendControl( - id(new AphrontFormRadioButtonControl()) - ->addButton( + id(new AphrontFormRadioButtonControl()) + ->setLabel(pht('Notify')) + ->addButton( PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL, PhabricatorConpherenceNotificationsSetting::getSettingLabel( PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL), - '') - ->addButton( + '') + ->addButton( PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_NOTIFY, PhabricatorConpherenceNotificationsSetting::getSettingLabel( PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_NOTIFY), - '') - ->setName('notifications') - ->setValue($notifications)); + '') + ->setName('notifications') + ->setValue($notifications)) + ->appendChild( + id(new AphrontFormSelectControl()) + ->setLabel(pht('Message Sent')) + ->setName('sounds['.ConpherenceRoomSettings::SOUND_SEND.']') + ->setOptions(ConpherenceRoomSettings::getDropdownSoundMap()) + ->setValue($send)) + ->appendChild( + id(new AphrontFormSelectControl()) + ->setLabel(pht('Message Received')) + ->setName('sounds['.ConpherenceRoomSettings::SOUND_RECEIVE.']') + ->setOptions(ConpherenceRoomSettings::getDropdownSoundMap()) + ->setValue($receive)); + + // TODO: Future Adventure! Expansion Pack + // + // ->appendChild( + // id(new AphrontFormSelectControl()) + // ->setLabel(pht('Username Mentioned')) + // ->setName(ConpherenceRoomSettings::SOUND_RECEIVE) + // ->setOptions(ConpherenceRoomSettings::getDropdownSoundMap()) + // ->setValue($mention)); return id(new AphrontDialogView()) ->setTitle(pht('Room Preferences')) @@ -408,62 +407,6 @@ return $dialog; } - private function renderMetadataDialog( - ConpherenceThread $conpherence, - $error_view) { - - $request = $this->getRequest(); - $user = $request->getUser(); - - $title = pht('Update Room'); - $form = id(new PHUIFormLayoutView()) - ->appendChild($error_view) - ->appendChild( - id(new AphrontFormTextControl()) - ->setLabel(pht('Title')) - ->setName('title') - ->setValue($conpherence->getTitle())) - ->appendChild( - id(new AphrontFormTextControl()) - ->setLabel(pht('Topic')) - ->setName('topic') - ->setValue($conpherence->getTopic())); - - $policies = id(new PhabricatorPolicyQuery()) - ->setViewer($user) - ->setObject($conpherence) - ->execute(); - - $form - ->appendChild( - id(new AphrontFormPolicyControl()) - ->setName('viewPolicy') - ->setPolicyObject($conpherence) - ->setCapability(PhabricatorPolicyCapability::CAN_VIEW) - ->setPolicies($policies)) - ->appendChild( - id(new AphrontFormPolicyControl()) - ->setName('editPolicy') - ->setPolicyObject($conpherence) - ->setCapability(PhabricatorPolicyCapability::CAN_EDIT) - ->setPolicies($policies)); - - $view = id(new AphrontDialogView()) - ->setTitle($title) - ->addHiddenInput('action', 'metadata') - ->addHiddenInput( - 'latest_transaction_id', - $request->getInt('latest_transaction_id')) - ->addHiddenInput('__continue__', true) - ->appendChild($form); - - if ($request->getExists('force_ajax')) { - $view->addHiddenInput('force_ajax', true); - } - - return $view; - } - private function loadAndRenderUpdates( $action, $conpherence_id, @@ -471,7 +414,6 @@ $need_transactions = false; switch ($action) { - case ConpherenceUpdateActions::METADATA: case ConpherenceUpdateActions::LOAD: $need_transactions = true; break; @@ -496,6 +438,8 @@ ->executeOne(); $non_update = false; + $participant = $conpherence->getParticipant($user->getPHID()); + if ($need_transactions && $conpherence->getTransactions()) { $data = ConpherenceTransactionRenderer::renderTransactions( $user, @@ -503,9 +447,7 @@ $key = PhabricatorConpherenceColumnMinimizeSetting::SETTINGKEY; $minimized = $user->getUserSetting($key); if (!$minimized) { - $participant_obj = $conpherence->getParticipant($user->getPHID()); - $participant_obj - ->markUpToDate($conpherence, $data['latest_transaction']); + $participant->markUpToDate($conpherence, $data['latest_transaction']); } } else if ($need_transactions) { $non_update = true; @@ -547,7 +489,8 @@ ->setViewer($user); $dropdown_query->execute(); - $receive_sound = celerity_get_resource_uri('/rsrc/audio/basic/tap.mp3'); + $sounds = $this->getSoundForParticipant($user, $participant); + $receive_sound = $sounds[ConpherenceRoomSettings::SOUND_RECEIVE]; $content = array( 'non_update' => $non_update, @@ -570,4 +513,30 @@ return $content; } + protected function getSoundForParticipant( + PhabricatorUser $user, + ConpherenceParticipant $participant) { + + $sound_key = PhabricatorConpherenceSoundSetting::SETTINGKEY; + $sound_default = $user->getUserSetting($sound_key); + if ($sound_default) { + $sound = ConpherenceRoomSettings::DEFAULT_SOUND; + } else { + $sound = ConpherenceRoomSettings::DEFAULT_NO_SOUND; + } + + $settings = $participant->getSettings(); + $sounds = idx($settings, 'sounds', array()); + $send = idx($sounds, ConpherenceRoomSettings::SOUND_SEND, $sound); + $receive = idx($sounds, ConpherenceRoomSettings::SOUND_RECEIVE, $sound); + $mention = idx($sounds, ConpherenceRoomSettings::SOUND_MENTION, $sound); + + return array( + ConpherenceRoomSettings::SOUND_SEND => $send, + ConpherenceRoomSettings::SOUND_RECEIVE => $receive, + ConpherenceRoomSettings::SOUND_MENTION => $mention, + ); + + } + } diff --git a/src/applications/settings/setting/PhabricatorConpherenceSoundSetting.php b/src/applications/settings/setting/PhabricatorConpherenceSoundSetting.php new file mode 100644 --- /dev/null +++ b/src/applications/settings/setting/PhabricatorConpherenceSoundSetting.php @@ -0,0 +1,50 @@ + pht('No Sounds'), + self::VALUE_CONPHERENCE_HARMONIC => pht('A Harmonic Experience'), + ); + } + +}