Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/editor/PhabricatorUserEditor.php
Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | public function updateUser( | ||||
$user->saveTransaction(); | $user->saveTransaction(); | ||||
return $this; | return $this; | ||||
} | } | ||||
/* -( Editing Roles )------------------------------------------------------ */ | /* -( Editing Roles )------------------------------------------------------ */ | ||||
/** | |||||
* @task role | |||||
*/ | |||||
public function makeAdminUser(PhabricatorUser $user, $admin) { | |||||
$actor = $this->requireActor(); | |||||
if (!$user->getID()) { | |||||
throw new Exception(pht('User has not been created yet!')); | |||||
} | |||||
$user->openTransaction(); | |||||
$user->beginWriteLocking(); | |||||
$user->reload(); | |||||
if ($user->getIsAdmin() == $admin) { | |||||
$user->endWriteLocking(); | |||||
$user->killTransaction(); | |||||
return $this; | |||||
} | |||||
$log = PhabricatorUserLog::initializeNewLog( | |||||
$actor, | |||||
$user->getPHID(), | |||||
PhabricatorUserLog::ACTION_ADMIN); | |||||
$log->setOldValue($user->getIsAdmin()); | |||||
$log->setNewValue($admin); | |||||
$user->setIsAdmin((int)$admin); | |||||
$user->save(); | |||||
$log->save(); | |||||
$user->endWriteLocking(); | |||||
$user->saveTransaction(); | |||||
return $this; | |||||
} | |||||
/** | /** | ||||
* @task role | * @task role | ||||
*/ | */ | ||||
public function makeSystemAgentUser(PhabricatorUser $user, $system_agent) { | public function makeSystemAgentUser(PhabricatorUser $user, $system_agent) { | ||||
$actor = $this->requireActor(); | $actor = $this->requireActor(); | ||||
if (!$user->getID()) { | if (!$user->getID()) { | ||||
throw new Exception(pht('User has not been created yet!')); | throw new Exception(pht('User has not been created yet!')); | ||||
▲ Show 20 Lines • Show All 420 Lines • Show Last 20 Lines |