add an option to run a command as the site owner
This commit is contained in:
parent
65766a0ebe
commit
642adc3b00
|
@ -20,8 +20,8 @@
|
||||||
|
|
||||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
||||||
|
|
||||||
$shortoptions = 'i:n:';
|
$shortoptions = 'i:n:o';
|
||||||
$longoptions = array('id=', 'nickname=');
|
$longoptions = array('id=', 'nickname=', 'owner');
|
||||||
|
|
||||||
$helptext = <<<END_OF_USERROLE_HELP
|
$helptext = <<<END_OF_USERROLE_HELP
|
||||||
command.php [options] [command line]
|
command.php [options] [command line]
|
||||||
|
@ -29,13 +29,12 @@ Perform commands on behalf of a user, such as sub, unsub, join, drop
|
||||||
|
|
||||||
-i --id ID of the user
|
-i --id ID of the user
|
||||||
-n --nickname nickname of the user
|
-n --nickname nickname of the user
|
||||||
|
-o --owner use the site owner
|
||||||
|
|
||||||
END_OF_USERROLE_HELP;
|
END_OF_USERROLE_HELP;
|
||||||
|
|
||||||
require_once INSTALLDIR.'/scripts/commandline.inc';
|
require_once INSTALLDIR.'/scripts/commandline.inc';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function interpretCommand($user, $body)
|
function interpretCommand($user, $body)
|
||||||
{
|
{
|
||||||
$inter = new CommandInterpreter();
|
$inter = new CommandInterpreter();
|
||||||
|
@ -50,8 +49,6 @@ function interpretCommand($user, $body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (have_option('i', 'id')) {
|
if (have_option('i', 'id')) {
|
||||||
$id = get_option_value('i', 'id');
|
$id = get_option_value('i', 'id');
|
||||||
$user = User::staticGet('id', $id);
|
$user = User::staticGet('id', $id);
|
||||||
|
@ -66,6 +63,12 @@ if (have_option('i', 'id')) {
|
||||||
print "Can't find user with nickname '$nickname'\n";
|
print "Can't find user with nickname '$nickname'\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
} else if (have_option('o', 'owner')) {
|
||||||
|
$user = User::siteOwner();
|
||||||
|
if (empty($user)) {
|
||||||
|
print "Site has no owner.\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
print "You must provide either an ID or a nickname.\n\n";
|
print "You must provide either an ID or a nickname.\n\n";
|
||||||
print $helptext;
|
print $helptext;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user