Example #1
0
printf($tpl, pht('Admin'), $original->getIsAdmin() ? 'Y' : 'N', $set_admin ? 'Y' : 'N');
echo "\n";
if (!phutil_console_confirm(pht('Save these changes?'), $default_no = false)) {
    echo pht('Cancelled.') . "\n";
    exit(1);
}
$user->openTransaction();
$editor = new PhabricatorUserEditor();
// TODO: This is wrong, but we have a chicken-and-egg problem when you use
// this script to create the first user.
$editor->setActor($user);
if ($is_new) {
    $email = id(new PhabricatorUserEmail())->setAddress($create_email)->setIsVerified(1);
    // Unconditionally approve new accounts created from the CLI.
    $user->setIsApproved(1);
    $editor->createNewUser($user, $email);
} else {
    if ($verify_email) {
        $user->setIsEmailVerified(1);
        $verify_email->setIsVerified($set_verified ? 1 : 0);
    }
    $editor->updateUser($user, $verify_email);
}
$editor->makeAdminUser($user, $set_admin);
$editor->makeSystemAgentUser($user, $set_system_agent);
if ($changed_pass !== false) {
    $envelope = new PhutilOpaqueEnvelope($changed_pass);
    $editor->changePassword($user, $envelope);
}
$user->saveTransaction();
echo pht('Saved changes.') . "\n";