@@ -111,7 +111,7 @@ public function handleRequest(AphrontRequest $request) {
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,38 +321,83 @@ private function renderRemovePersonDialogue(
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. ' );
337
363
} else {
338
- $ message .= ' ' .pht ('Someone else in the room can add you back later. ' );
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
+ }
378
+ } else {
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 (
0 commit comments