#!/usr/bin/env php \n"; exit(1); } $username = $argv[1]; $email = $argv[2]; $realname = $argv[3]; $admin = $argv[4]; $admin = id(new PhabricatorUser())->loadOneWhere( 'username = %s', $argv[4]); if (!$admin) { throw new Exception( "Admin user must be the username of a valid Phabricator account, used ". "to send the new user a welcome email."); } $existing_user = id(new PhabricatorUser())->loadOneWhere( 'username = %s', $username); if ($existing_user) { throw new Exception( "There is already a user with the username '{$username}'!"); } $existing_user = id(new PhabricatorUser())->loadOneWhere( 'email = %s', $email); if ($existing_user) { throw new Exception( "There is already a user with the email '{$email}'!"); } $user = new PhabricatorUser(); $user->setUsername($username); $user->setEmail($email); $user->setRealname($realname); $user->save(); $user->sendWelcomeEmail($admin); echo "Created user '{$username}' (realname='{$realname}', email='{$email}').\n";