mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 22:10:55 +01:00
ef85f49adc
Summary: This commit doesn't change license of any file. It just makes the license implicit (inherited from LICENSE file in the root directory). We are removing the headers for these reasons: - It wastes space in editors, less code is visible in editor upon opening a file. - It brings noise to diff of the first change of any file every year. - It confuses Git file copy detection when creating small files. - We don't have an explicit license header in other files (JS, CSS, images, documentation). - Using license header in every file is not obligatory: http://www.apache.org/dev/apply-license.html#new. This change is approved by Alma Chao (Lead Open Source and IP Counsel at Facebook). Test Plan: Verified that the license survived only in LICENSE file and that it didn't modify externals. Reviewers: epriestley, davidrecordon Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2035 Differential Revision: https://secure.phabricator.com/D3886
56 lines
1.3 KiB
PHP
Executable file
56 lines
1.3 KiB
PHP
Executable file
#!/usr/bin/env php
|
|
<?php
|
|
|
|
$root = dirname(dirname(dirname(__FILE__)));
|
|
require_once $root.'/scripts/__init_script__.php';
|
|
|
|
if ($argc !== 5) {
|
|
echo "usage: add_user.php <username> <email> <realname> <admin_user>\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_email = id(new PhabricatorUserEmail())->loadOneWhere(
|
|
'address = %s',
|
|
$email);
|
|
if ($existing_email) {
|
|
throw new Exception(
|
|
"There is already a user with the email '{$email}'!");
|
|
}
|
|
|
|
$user = new PhabricatorUser();
|
|
$user->setUsername($username);
|
|
$user->setRealname($realname);
|
|
|
|
$email_object = id(new PhabricatorUserEmail())
|
|
->setAddress($email)
|
|
->setIsVerified(1);
|
|
|
|
id(new PhabricatorUserEditor())
|
|
->setActor($admin)
|
|
->createNewUser($user, $email_object);
|
|
|
|
$user->sendWelcomeEmail($admin);
|
|
|
|
echo "Created user '{$username}' (realname='{$realname}', email='{$email}').\n";
|