/**
  * @task role
  */
 public function makeAdminUser(PhabricatorUser $user, $admin)
 {
     $actor = $this->requireActor();
     if (!$user->getID()) {
         throw new Exception('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;
 }
 /**
  * Build a test user to spec.
  */
 private function buildUser($spec)
 {
     $user = new PhabricatorUser();
     switch ($spec) {
         case 'public':
             break;
         case 'user':
             $user->setPHID(1);
             break;
         case 'admin':
             $user->setPHID(1);
             $user->setIsAdmin(true);
             break;
         default:
             throw new Exception("Unknown user spec '{$spec}'.");
     }
     return $user;
 }
        break;
    }
} while (true);
$user->setEmail($email);
$changed_pass = false;
// This disables local echo, so the user's password is not shown as they type
// it.
phutil_passthru('stty -echo');
$password = phutil_console_prompt("Enter a password for this user [blank to leave unchanged]:");
phutil_passthru('stty echo');
if (strlen($password)) {
    $changed_pass = $password;
}
$is_admin = $user->getIsAdmin();
$set_admin = phutil_console_confirm('Should this user be an administrator?', $default_no = !$is_admin);
$user->setIsAdmin($set_admin);
echo "\n\nACCOUNT SUMMARY\n\n";
$tpl = "%12s   %-30s   %-30s\n";
printf($tpl, null, 'OLD VALUE', 'NEW VALUE');
printf($tpl, 'Username', $original->getUsername(), $user->getUsername());
printf($tpl, 'Real Name', $original->getRealName(), $user->getRealName());
printf($tpl, 'Email', $original->getEmail(), $user->getEmail());
printf($tpl, 'Password', null, $changed_pass !== false ? 'Updated' : 'Unchanged');
printf($tpl, 'Admin', $original->getIsAdmin() ? 'Y' : 'N', $user->getIsAdmin() ? 'Y' : 'N');
echo "\n";
if (!phutil_console_confirm("Save these changes?", $default_no = false)) {
    echo "Cancelled.\n";
    exit(1);
}
$user->save();
if ($changed_pass !== false) {