$longoptions = array('nickname=', 'password=', 'fullname=', 'email=');
$helptext = <<<END_OF_REGISTERUSER_HELP
-deleteuser.php [options]
-deletes a user from the database
+registeruser.php [options]
+registers a user in the database
-n --nickname nickname of the new user
-w --password password of the new user
END_OF_REGISTERUSER_HELP;
-require_once INSTALLDIR.'/scripts/commandline.inc';
+require_once INSTALLDIR.'/scripts/commandline.inc.php';
$nickname = get_option_value('n', 'nickname');
$password = get_option_value('w', 'password');
try {
- $user = User::staticGet('nickname', $nickname);
+ $user = User::getKV('nickname', $nickname);
if (!empty($user)) {
throw new Exception("A user named '$nickname' already exists.");
$user->email = $email;
- if (!$user->updateKeys($orig)) {
- print "Failed!\n";
- throw new Exception("Can't update email address.");
- }
+ // Throws exception on failure.
+ $user->updateWithKeys($orig);
}
} catch (Exception $e) {