@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.

Allow users to be banished from Conpherence rooms

Summary: Fixes T9348. If you have edit permission, you can kick people out of a room.

Test Plan:
- Kicked people out of a room.
- As an unprivileged user, wasn't able to kick people out of a room.
- Hit most (all?) of the various weird dialog sub-cases.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9348

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

+75 -22
+62 -17
src/applications/conpherence/controller/ConpherenceUpdateController.php
··· 111 111 break; 112 112 } 113 113 $person_phid = $request->getStr('remove_person'); 114 - if ($person_phid && $person_phid == $user->getPHID()) { 114 + if ($person_phid) { 115 115 $xactions[] = id(new ConpherenceTransaction()) 116 116 ->setTransactionType( 117 117 ConpherenceTransaction::TYPE_PARTICIPANTS) ··· 321 321 ConpherenceThread $conpherence) { 322 322 323 323 $request = $this->getRequest(); 324 - $user = $request->getUser(); 324 + $viewer = $request->getUser(); 325 325 $remove_person = $request->getStr('remove_person'); 326 326 $participants = $conpherence->getParticipants(); 327 327 328 - $message = pht('Are you sure you want to leave this room?'); 328 + $removed_user = id(new PhabricatorPeopleQuery()) 329 + ->setViewer($viewer) 330 + ->withPHIDs(array($remove_person)) 331 + ->executeOne(); 332 + if (!$removed_user) { 333 + return new Aphront404Response(); 334 + } 335 + 336 + $is_self = ($viewer->getPHID() == $removed_user->getPHID()); 337 + $is_last = (count($participants) == 1); 338 + 329 339 $test_conpherence = clone $conpherence; 330 340 $test_conpherence->attachParticipants(array()); 331 - if (!PhabricatorPolicyFilter::hasCapability( 332 - $user, 341 + $still_visible = PhabricatorPolicyFilter::hasCapability( 342 + $removed_user, 333 343 $test_conpherence, 334 - PhabricatorPolicyCapability::CAN_VIEW)) { 335 - if (count($participants) == 1) { 336 - $message .= ' '.pht('The room will be inaccessible forever and ever.'); 344 + PhabricatorPolicyCapability::CAN_VIEW); 345 + 346 + $body = array(); 347 + 348 + if ($is_self) { 349 + $title = pht('Leave Room'); 350 + $body[] = pht( 351 + 'Are you sure you want to leave this room?'); 352 + } else { 353 + $title = pht('Banish User'); 354 + $body[] = pht( 355 + 'Banish %s from the realm?', 356 + phutil_tag('strong', array(), $removed_user->getUsername())); 357 + } 358 + 359 + if ($still_visible) { 360 + if ($is_self) { 361 + $body[] = pht( 362 + 'You will be able to rejoin the room later.'); 363 + } else { 364 + $body[] = pht( 365 + 'This user will be able to rejoin the room later.'); 366 + } 367 + } else { 368 + if ($is_self) { 369 + if ($is_last) { 370 + $body[] = pht( 371 + 'You are the last member, so you will never be able to rejoin '. 372 + 'the room.'); 373 + } else { 374 + $body[] = pht( 375 + 'You will not be able to rejoin the room on your own, but '. 376 + 'someone else can invite you later.'); 377 + } 337 378 } else { 338 - $message .= ' '.pht('Someone else in the room can add you back later.'); 379 + $body[] = pht( 380 + 'This user will not be able to rejoin the room unless invited '. 381 + 'again.'); 339 382 } 340 383 } 341 - $body = phutil_tag( 342 - 'p', 343 - array(), 344 - $message); 345 384 346 385 require_celerity_resource('conpherence-update-css'); 347 - return id(new AphrontDialogView()) 348 - ->setTitle(pht('Leave Room')) 386 + 387 + $dialog = id(new AphrontDialogView()) 388 + ->setTitle($title) 349 389 ->addHiddenInput('action', 'remove_person') 350 390 ->addHiddenInput('remove_person', $remove_person) 351 391 ->addHiddenInput( 352 392 'latest_transaction_id', 353 393 $request->getInt('latest_transaction_id')) 354 - ->addHiddenInput('__continue__', true) 355 - ->appendChild($body); 394 + ->addHiddenInput('__continue__', true); 395 + 396 + foreach ($body as $paragraph) { 397 + $dialog->appendParagraph($paragraph); 398 + } 399 + 400 + return $dialog; 356 401 } 357 402 358 403 private function renderMetadataDialogue(
+13 -5
src/applications/conpherence/view/ConpherencePeopleWidgetView.php
··· 5 5 public function render() { 6 6 $conpherence = $this->getConpherence(); 7 7 $widget_data = $conpherence->getWidgetData(); 8 - $user = $this->getUser(); 9 - $conpherence = $this->getConpherence(); 8 + $viewer = $this->getUser(); 9 + 10 10 $participants = $conpherence->getParticipants(); 11 11 $handles = $conpherence->getHandles(); 12 - $head_handles = array_select_keys($handles, array($user->getPHID())); 12 + $head_handles = array_select_keys($handles, array($viewer->getPHID())); 13 13 $handle_list = mpull($handles, 'getName'); 14 14 natcasesort($handle_list); 15 15 $handles = mpull($handles, null, 'getName'); ··· 17 17 $head_handles = mpull($head_handles, null, 'getName'); 18 18 $handles = $head_handles + $handles; 19 19 20 + $can_edit = PhabricatorPolicyFilter::hasCapability( 21 + $viewer, 22 + $conpherence, 23 + PhabricatorPolicyCapability::CAN_EDIT); 24 + 20 25 $body = array(); 21 26 foreach ($handles as $handle) { 22 27 $user_phid = $handle->getPHID(); 23 - $remove_html = ''; 24 - if ($user_phid == $user->getPHID()) { 28 + 29 + if (($user_phid == $viewer->getPHID()) || $can_edit) { 25 30 $icon = id(new PHUIIconView()) 26 31 ->setIcon('fa-times lightbluetext'); 27 32 $remove_html = javelin_tag( ··· 35 40 ), 36 41 ), 37 42 $icon); 43 + } else { 44 + $remove_html = null; 38 45 } 46 + 39 47 $body[] = phutil_tag( 40 48 'div', 41 49 array(