[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorPeopleDisableController 4 extends PhabricatorPeopleController { 5 6 private $id; 7 private $via; 8 9 public function willProcessRequest(array $data) { 10 $this->id = $data['id']; 11 $this->via = $data['via']; 12 } 13 14 public function processRequest() { 15 $request = $this->getRequest(); 16 $admin = $request->getUser(); 17 18 $user = id(new PhabricatorPeopleQuery()) 19 ->setViewer($admin) 20 ->withIDs(array($this->id)) 21 ->executeOne(); 22 if (!$user) { 23 return new Aphront404Response(); 24 } 25 26 // NOTE: We reach this controller via the administrative "Disable User" 27 // on profiles and also via the "X" action on the approval queue. We do 28 // things slightly differently depending on the context the actor is in. 29 30 $is_disapprove = ($this->via == 'disapprove'); 31 if ($is_disapprove) { 32 $done_uri = $this->getApplicationURI('query/approval/'); 33 $should_disable = true; 34 } else { 35 $done_uri = '/p/'.$user->getUsername().'/'; 36 $should_disable = !$user->getIsDisabled(); 37 } 38 39 if ($admin->getPHID() == $user->getPHID()) { 40 return $this->newDialog() 41 ->setTitle(pht('Something Stays Your Hand')) 42 ->appendParagraph( 43 pht( 44 'Try as you might, you find you can not disable your '. 45 'own account.')) 46 ->addCancelButton($done_uri, pht('Curses!')); 47 } 48 49 if ($request->isFormPost()) { 50 id(new PhabricatorUserEditor()) 51 ->setActor($admin) 52 ->disableUser($user, $should_disable); 53 54 return id(new AphrontRedirectResponse())->setURI($done_uri); 55 } 56 57 if ($should_disable) { 58 $title = pht('Disable User?'); 59 $short_title = pht('Disable User'); 60 61 $body = pht( 62 'Disable %s? They will no longer be able to access Phabricator or '. 63 'receive email.', 64 phutil_tag('strong', array(), $user->getUsername())); 65 66 $submit = pht('Disable User'); 67 } else { 68 $title = pht('Enable User?'); 69 $short_title = pht('Enable User'); 70 71 $body = pht( 72 'Enable %s? They will be able to access Phabricator and receive '. 73 'email again.', 74 phutil_tag('strong', array(), $user->getUsername())); 75 76 $submit = pht('Enable User'); 77 } 78 79 return $this->newDialog() 80 ->setTitle($title) 81 ->setShortTitle($short_title) 82 ->appendParagraph($body) 83 ->addCancelButton($done_uri) 84 ->addSubmitButton($submit); 85 } 86 87 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |