summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-01-13 18:28:08 -0800
committerEvan Prodromou <evan@status.net>2010-01-13 18:28:08 -0800
commitaa23698553b9eeed1397a8c9144b14ca16ca53a4 (patch)
treea833aaa98f9ca133d20d76098e69341e94312cc4
parent085406ea88efd4caaad3933871554dd30a23eba6 (diff)
accept file for initializeinbox.php
-rw-r--r--scripts/initializeinbox.php28
1 files changed, 22 insertions, 6 deletions
diff --git a/scripts/initializeinbox.php b/scripts/initializeinbox.php
index 43afc48eb..bc31cba15 100644
--- a/scripts/initializeinbox.php
+++ b/scripts/initializeinbox.php
@@ -20,17 +20,18 @@
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-$shortoptions = 'i:n:af';
-$longoptions = array('id=', 'nickname=', 'all', 'force');
+$shortoptions = 'i:n:af:';
+$longoptions = array('id=', 'nickname=', 'all', 'file=');
$helptext = <<<END_OF_INITIALIZEINBOX_HELP
initializeinbox.php [options]
initialize the inbox for a user
- -i --id ID of user to update
- -n --nickname nickname of the user to update
- -f --force force update even if user already has a location
- -a --all update all
+ -i --id ID of user to update
+ -n --nickname nickname of the user to update
+ -f FILENAME read list of IDs from FILENAME (1 per line)
+ --file=FILENAME ditto
+ -a --all update all
END_OF_INITIALIZEINBOX_HELP;
@@ -60,6 +61,21 @@ try {
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 {
show_help();
exit(1);