accept file for initializeinbox.php
This commit is contained in:
parent
085406ea88
commit
aa23698553
|
@ -20,17 +20,18 @@
|
||||||
|
|
||||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
||||||
|
|
||||||
$shortoptions = 'i:n:af';
|
$shortoptions = 'i:n:af:';
|
||||||
$longoptions = array('id=', 'nickname=', 'all', 'force');
|
$longoptions = array('id=', 'nickname=', 'all', 'file=');
|
||||||
|
|
||||||
$helptext = <<<END_OF_INITIALIZEINBOX_HELP
|
$helptext = <<<END_OF_INITIALIZEINBOX_HELP
|
||||||
initializeinbox.php [options]
|
initializeinbox.php [options]
|
||||||
initialize the inbox for a user
|
initialize the inbox for a user
|
||||||
|
|
||||||
-i --id ID of user to update
|
-i --id ID of user to update
|
||||||
-n --nickname nickname of the user to update
|
-n --nickname nickname of the user to update
|
||||||
-f --force force update even if user already has a location
|
-f FILENAME read list of IDs from FILENAME (1 per line)
|
||||||
-a --all update all
|
--file=FILENAME ditto
|
||||||
|
-a --all update all
|
||||||
|
|
||||||
END_OF_INITIALIZEINBOX_HELP;
|
END_OF_INITIALIZEINBOX_HELP;
|
||||||
|
|
||||||
|
@ -60,6 +61,21 @@ try {
|
||||||
initializeInbox($user);
|
initializeInbox($user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (have_option('f', 'file')) {
|
||||||
|
$filename = get_option_value('f', 'file');
|
||||||
|
if (!file_exists($filename)) {
|
||||||
|
throw new Exception("No such file '$filename'.");
|
||||||
|
} else if (!is_readable($filename)) {
|
||||||
|
throw new Exception("Can't read '$filename'.");
|
||||||
|
}
|
||||||
|
$ids = file($filename);
|
||||||
|
foreach ($ids as $id) {
|
||||||
|
$user = User::staticGet('id', $id);
|
||||||
|
if (empty($user)) {
|
||||||
|
throw new Exception("Can't find user with id '$id'.");
|
||||||
|
}
|
||||||
|
initializeInbox($user);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
show_help();
|
show_help();
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
Loading…
Reference in New Issue