Differential D17726 Diff 42648 src/applications/conpherence/controller/ConpherenceUpdateController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/conpherence/controller/ConpherenceUpdateController.php
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | if ($request->isFormPost() || ($action == ConpherenceUpdateActions::LOAD)) { | ||||
->setTransactionType( | ->setTransactionType( | ||||
ConpherenceTransaction::TYPE_PARTICIPANTS) | ConpherenceTransaction::TYPE_PARTICIPANTS) | ||||
->setNewValue(array('-' => array($person_phid))); | ->setNewValue(array('-' => array($person_phid))); | ||||
$response_mode = 'go-home'; | $response_mode = 'go-home'; | ||||
} | } | ||||
break; | break; | ||||
case ConpherenceUpdateActions::NOTIFICATIONS: | case ConpherenceUpdateActions::NOTIFICATIONS: | ||||
$notifications = $request->getStr('notifications'); | $notifications = $request->getStr('notifications'); | ||||
$sounds = $request->getArr('sounds'); | |||||
$participant = $conpherence->getParticipantIfExists($user->getPHID()); | $participant = $conpherence->getParticipantIfExists($user->getPHID()); | ||||
if (!$participant) { | if (!$participant) { | ||||
return id(new Aphront404Response()); | return id(new Aphront404Response()); | ||||
} | } | ||||
$participant->setSettings(array('notifications' => $notifications)); | $participant->setSettings(array('notifications' => $notifications)); | ||||
$participant->setSettings(array('sounds' => $sounds)); | |||||
$participant->save(); | $participant->save(); | ||||
return id(new AphrontRedirectResponse()) | return id(new AphrontRedirectResponse()) | ||||
->setURI('/'.$conpherence->getMonogram()); | ->setURI('/'.$conpherence->getMonogram()); | ||||
break; | break; | ||||
case ConpherenceUpdateActions::METADATA: | case ConpherenceUpdateActions::METADATA: | ||||
$title = $request->getStr('title'); | $title = $request->getStr('title'); | ||||
$topic = $request->getStr('topic'); | $topic = $request->getStr('topic'); | ||||
▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | if (!$participant) { | ||||
return id(new AphrontDialogView()) | return id(new AphrontDialogView()) | ||||
->setTitle(pht('Room Preferences')) | ->setTitle(pht('Room Preferences')) | ||||
->appendParagraph($text); | ->appendParagraph($text); | ||||
} | } | ||||
$notification_key = PhabricatorConpherenceNotificationsSetting::SETTINGKEY; | $notification_key = PhabricatorConpherenceNotificationsSetting::SETTINGKEY; | ||||
$notification_default = $user->getUserSetting($notification_key); | $notification_default = $user->getUserSetting($notification_key); | ||||
$sound_key = PhabricatorConpherenceSoundSetting::SETTINGKEY; | |||||
$sound_default = $user->getUserSetting($sound_key); | |||||
$settings = $participant->getSettings(); | $settings = $participant->getSettings(); | ||||
$notifications = idx( | $notifications = idx($settings, 'notifications', $notification_default); | ||||
$settings, | |||||
'notifications', | $sounds = idx($settings, 'sounds', array()); | ||||
$notification_default); | $map = PhabricatorConpherenceSoundSetting::getDefaultSound($sound_default); | ||||
$receive = idx($sounds, | |||||
ConpherenceRoomSettings::SOUND_RECEIVE, | |||||
$map[ConpherenceRoomSettings::SOUND_RECEIVE]); | |||||
$mention = idx($sounds, | |||||
ConpherenceRoomSettings::SOUND_MENTION, | |||||
$map[ConpherenceRoomSettings::SOUND_MENTION]); | |||||
$form = id(new AphrontFormView()) | $form = id(new AphrontFormView()) | ||||
->setUser($user) | ->setUser($user) | ||||
->setFullWidth(true) | |||||
->appendControl( | ->appendControl( | ||||
id(new AphrontFormRadioButtonControl()) | id(new AphrontFormRadioButtonControl()) | ||||
->setLabel(pht('Notify')) | |||||
->addButton( | ->addButton( | ||||
PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL, | PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL, | ||||
PhabricatorConpherenceNotificationsSetting::getSettingLabel( | PhabricatorConpherenceNotificationsSetting::getSettingLabel( | ||||
PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL), | PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL), | ||||
'') | '') | ||||
->addButton( | ->addButton( | ||||
PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_NOTIFY, | PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_NOTIFY, | ||||
PhabricatorConpherenceNotificationsSetting::getSettingLabel( | PhabricatorConpherenceNotificationsSetting::getSettingLabel( | ||||
PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_NOTIFY), | PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_NOTIFY), | ||||
'') | '') | ||||
->setName('notifications') | ->setName('notifications') | ||||
->setValue($notifications)); | ->setValue($notifications)) | ||||
->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('sounds['.ConpherenceRoomSettings::SOUND_MENTION.']') | |||||
// ->setOptions(ConpherenceRoomSettings::getDropdownSoundMap()) | |||||
// ->setValue($mention)); | |||||
return id(new AphrontDialogView()) | return id(new AphrontDialogView()) | ||||
->setTitle(pht('Room Preferences')) | ->setTitle(pht('Room Preferences')) | ||||
->addHiddenInput('action', 'notifications') | ->addHiddenInput('action', 'notifications') | ||||
->addHiddenInput( | ->addHiddenInput( | ||||
'latest_transaction_id', | 'latest_transaction_id', | ||||
$request->getInt('latest_transaction_id')) | $request->getInt('latest_transaction_id')) | ||||
->appendForm($form); | ->appendForm($form); | ||||
▲ Show 20 Lines • Show All 191 Lines • ▼ Show 20 Lines | $conpherence = id(new ConpherenceThreadQuery()) | ||||
->setAfterTransactionID($latest_transaction_id) | ->setAfterTransactionID($latest_transaction_id) | ||||
->needProfileImage(true) | ->needProfileImage(true) | ||||
->needParticipants(true) | ->needParticipants(true) | ||||
->needTransactions($need_transactions) | ->needTransactions($need_transactions) | ||||
->withIDs(array($conpherence_id)) | ->withIDs(array($conpherence_id)) | ||||
->executeOne(); | ->executeOne(); | ||||
$non_update = false; | $non_update = false; | ||||
$participant = $conpherence->getParticipant($user->getPHID()); | |||||
if ($need_transactions && $conpherence->getTransactions()) { | if ($need_transactions && $conpherence->getTransactions()) { | ||||
$data = ConpherenceTransactionRenderer::renderTransactions( | $data = ConpherenceTransactionRenderer::renderTransactions( | ||||
$user, | $user, | ||||
$conpherence); | $conpherence); | ||||
$key = PhabricatorConpherenceColumnMinimizeSetting::SETTINGKEY; | $key = PhabricatorConpherenceColumnMinimizeSetting::SETTINGKEY; | ||||
$minimized = $user->getUserSetting($key); | $minimized = $user->getUserSetting($key); | ||||
if (!$minimized) { | if (!$minimized) { | ||||
$participant_obj = $conpherence->getParticipant($user->getPHID()); | $participant->markUpToDate($conpherence, $data['latest_transaction']); | ||||
$participant_obj | |||||
->markUpToDate($conpherence, $data['latest_transaction']); | |||||
} | } | ||||
} else if ($need_transactions) { | } else if ($need_transactions) { | ||||
$non_update = true; | $non_update = true; | ||||
$data = array(); | $data = array(); | ||||
} else { | } else { | ||||
$data = array(); | $data = array(); | ||||
} | } | ||||
$rendered_transactions = idx($data, 'transactions'); | $rendered_transactions = idx($data, 'transactions'); | ||||
Show All 25 Lines | switch ($action) { | ||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
$data = $conpherence->getDisplayData($user); | $data = $conpherence->getDisplayData($user); | ||||
$dropdown_query = id(new AphlictDropdownDataQuery()) | $dropdown_query = id(new AphlictDropdownDataQuery()) | ||||
->setViewer($user); | ->setViewer($user); | ||||
$dropdown_query->execute(); | $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]; | |||||
$mention_sound = $sounds[ConpherenceRoomSettings::SOUND_MENTION]; | |||||
$content = array( | $content = array( | ||||
'non_update' => $non_update, | 'non_update' => $non_update, | ||||
'transactions' => hsprintf('%s', $rendered_transactions), | 'transactions' => hsprintf('%s', $rendered_transactions), | ||||
'conpherence_title' => (string)$data['title'], | 'conpherence_title' => (string)$data['title'], | ||||
'latest_transaction_id' => $new_latest_transaction_id, | 'latest_transaction_id' => $new_latest_transaction_id, | ||||
'nav_item' => $nav_item, | 'nav_item' => $nav_item, | ||||
'conpherence_phid' => $conpherence->getPHID(), | 'conpherence_phid' => $conpherence->getPHID(), | ||||
'header' => $header, | 'header' => $header, | ||||
'people_widget' => $people_widget, | 'people_widget' => $people_widget, | ||||
'aphlictDropdownData' => array( | 'aphlictDropdownData' => array( | ||||
$dropdown_query->getNotificationData(), | $dropdown_query->getNotificationData(), | ||||
$dropdown_query->getConpherenceData(), | $dropdown_query->getConpherenceData(), | ||||
), | ), | ||||
'sound' => array( | 'sound' => array( | ||||
'receive' => $receive_sound, | 'receive' => $receive_sound, | ||||
'mention' => $mention_sound, | |||||
), | ), | ||||
); | ); | ||||
return $content; | return $content; | ||||
} | } | ||||
protected function getSoundForParticipant( | |||||
PhabricatorUser $user, | |||||
ConpherenceParticipant $participant) { | |||||
$sound_key = PhabricatorConpherenceSoundSetting::SETTINGKEY; | |||||
$sound_default = $user->getUserSetting($sound_key); | |||||
$settings = $participant->getSettings(); | |||||
$sounds = idx($settings, 'sounds', array()); | |||||
$map = PhabricatorConpherenceSoundSetting::getDefaultSound($sound_default); | |||||
$receive = idx($sounds, | |||||
ConpherenceRoomSettings::SOUND_RECEIVE, | |||||
$map[ConpherenceRoomSettings::SOUND_RECEIVE]); | |||||
$mention = idx($sounds, | |||||
ConpherenceRoomSettings::SOUND_MENTION, | |||||
$map[ConpherenceRoomSettings::SOUND_MENTION]); | |||||
$sound_map = ConpherenceRoomSettings::getSoundMap(); | |||||
return array( | |||||
ConpherenceRoomSettings::SOUND_RECEIVE => $sound_map[$receive]['rsrc'], | |||||
ConpherenceRoomSettings::SOUND_MENTION => $sound_map[$mention]['rsrc'], | |||||
); | |||||
} | |||||
} | } |