[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class UserDisableConduitAPIMethod extends UserConduitAPIMethod { 4 5 public function getAPIMethodName() { 6 return 'user.disable'; 7 } 8 9 public function getMethodDescription() { 10 return 'Permanently disable specified users (admin only).'; 11 } 12 13 public function defineParamTypes() { 14 return array( 15 'phids' => 'required list<phid>', 16 ); 17 } 18 19 public function defineReturnType() { 20 return 'void'; 21 } 22 23 public function defineErrorTypes() { 24 return array( 25 'ERR-PERMISSIONS' => 'Only admins can call this method.', 26 'ERR-BAD-PHID' => 'Non existent user PHID.', 27 ); 28 } 29 30 protected function execute(ConduitAPIRequest $request) { 31 $actor = $request->getUser(); 32 if (!$actor->getIsAdmin()) { 33 throw new ConduitException('ERR-PERMISSIONS'); 34 } 35 36 $phids = $request->getValue('phids'); 37 38 $users = id(new PhabricatorUser())->loadAllWhere( 39 'phid IN (%Ls)', 40 $phids); 41 42 if (count($phids) != count($users)) { 43 throw new ConduitException('ERR-BAD-PHID'); 44 } 45 46 foreach ($users as $user) { 47 id(new PhabricatorUserEditor()) 48 ->setActor($actor) 49 ->disableUser($user, true); 50 } 51 } 52 53 }
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 |