Differential D15728 Diff 37903 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 105 Lines • ▼ Show 20 Lines | if ($request->isFormPost() || ($action == ConpherenceUpdateActions::LOAD)) { | ||||
| } | } | ||||
| break; | break; | ||||
| case ConpherenceUpdateActions::REMOVE_PERSON: | case ConpherenceUpdateActions::REMOVE_PERSON: | ||||
| if (!$request->isContinueRequest()) { | if (!$request->isContinueRequest()) { | ||||
| // do nothing; we'll display a confirmation dialogue instead | // do nothing; we'll display a confirmation dialogue instead | ||||
| break; | break; | ||||
| } | } | ||||
| $person_phid = $request->getStr('remove_person'); | $person_phid = $request->getStr('remove_person'); | ||||
| if ($person_phid && $person_phid == $user->getPHID()) { | if ($person_phid) { | ||||
| $xactions[] = id(new ConpherenceTransaction()) | $xactions[] = id(new ConpherenceTransaction()) | ||||
| ->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: | ||||
| ▲ Show 20 Lines • Show All 193 Lines • ▼ Show 20 Lines | private function renderAddPersonDialogue( | ||||
| } | } | ||||
| return $view; | return $view; | ||||
| } | } | ||||
| private function renderRemovePersonDialogue( | private function renderRemovePersonDialogue( | ||||
| ConpherenceThread $conpherence) { | ConpherenceThread $conpherence) { | ||||
| $request = $this->getRequest(); | $request = $this->getRequest(); | ||||
| $user = $request->getUser(); | $viewer = $request->getUser(); | ||||
| $remove_person = $request->getStr('remove_person'); | $remove_person = $request->getStr('remove_person'); | ||||
| $participants = $conpherence->getParticipants(); | $participants = $conpherence->getParticipants(); | ||||
| $message = pht('Are you sure you want to leave this room?'); | $removed_user = id(new PhabricatorPeopleQuery()) | ||||
| ->setViewer($viewer) | |||||
| ->withPHIDs(array($remove_person)) | |||||
| ->executeOne(); | |||||
| if (!$removed_user) { | |||||
| return new Aphront404Response(); | |||||
| } | |||||
| $is_self = ($viewer->getPHID() == $removed_user->getPHID()); | |||||
| $is_last = (count($participants) == 1); | |||||
| $test_conpherence = clone $conpherence; | $test_conpherence = clone $conpherence; | ||||
| $test_conpherence->attachParticipants(array()); | $test_conpherence->attachParticipants(array()); | ||||
| if (!PhabricatorPolicyFilter::hasCapability( | $still_visible = PhabricatorPolicyFilter::hasCapability( | ||||
| $user, | $removed_user, | ||||
| $test_conpherence, | $test_conpherence, | ||||
| PhabricatorPolicyCapability::CAN_VIEW)) { | PhabricatorPolicyCapability::CAN_VIEW); | ||||
| if (count($participants) == 1) { | |||||
| $message .= ' '.pht('The room will be inaccessible forever and ever.'); | $body = array(); | ||||
| if ($is_self) { | |||||
| $title = pht('Leave Room'); | |||||
| $body[] = pht( | |||||
| 'Are you sure you want to leave this room?'); | |||||
| } else { | } else { | ||||
| $message .= ' '.pht('Someone else in the room can add you back later.'); | $title = pht('Banish User'); | ||||
| $body[] = pht( | |||||
| 'Banish %s from the realm?', | |||||
| phutil_tag('strong', array(), $removed_user->getUsername())); | |||||
| } | |||||
| if ($still_visible) { | |||||
| if ($is_self) { | |||||
| $body[] = pht( | |||||
| 'You will be able to rejoin the room later.'); | |||||
| } else { | |||||
| $body[] = pht( | |||||
| 'This user will be able to rejoin the room later.'); | |||||
| } | |||||
| } else { | |||||
| if ($is_self) { | |||||
| if ($is_last) { | |||||
| $body[] = pht( | |||||
| 'You are the last member, so you will never be able to rejoin '. | |||||
| 'the room.'); | |||||
| } else { | |||||
| $body[] = pht( | |||||
| 'You will not be able to rejoin the room on your own, but '. | |||||
| 'someone else can invite you later.'); | |||||
| } | |||||
| } else { | |||||
| $body[] = pht( | |||||
| 'This user will not be able to rejoin the room unless invited '. | |||||
| 'again.'); | |||||
| } | } | ||||
| } | } | ||||
| $body = phutil_tag( | |||||
| 'p', | |||||
| array(), | |||||
| $message); | |||||
| require_celerity_resource('conpherence-update-css'); | require_celerity_resource('conpherence-update-css'); | ||||
| return id(new AphrontDialogView()) | |||||
| ->setTitle(pht('Leave Room')) | $dialog = id(new AphrontDialogView()) | ||||
| ->setTitle($title) | |||||
| ->addHiddenInput('action', 'remove_person') | ->addHiddenInput('action', 'remove_person') | ||||
| ->addHiddenInput('remove_person', $remove_person) | ->addHiddenInput('remove_person', $remove_person) | ||||
| ->addHiddenInput( | ->addHiddenInput( | ||||
| 'latest_transaction_id', | 'latest_transaction_id', | ||||
| $request->getInt('latest_transaction_id')) | $request->getInt('latest_transaction_id')) | ||||
| ->addHiddenInput('__continue__', true) | ->addHiddenInput('__continue__', true); | ||||
| ->appendChild($body); | |||||
| foreach ($body as $paragraph) { | |||||
| $dialog->appendParagraph($paragraph); | |||||
| } | |||||
| return $dialog; | |||||
| } | } | ||||
| private function renderMetadataDialogue( | private function renderMetadataDialogue( | ||||
| ConpherenceThread $conpherence, | ConpherenceThread $conpherence, | ||||
| $error_view) { | $error_view) { | ||||
| $request = $this->getRequest(); | $request = $this->getRequest(); | ||||
| $user = $request->getUser(); | $user = $request->getUser(); | ||||
| ▲ Show 20 Lines • Show All 196 Lines • Show Last 20 Lines | |||||