From b25e59a11fb5eb6ea97d8b9c6081d1e1585febb3 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 13 Jan 2010 00:25:43 -0800 Subject: add a script for initializing inboxes --- scripts/initializeinbox.php | 94 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 scripts/initializeinbox.php (limited to 'scripts') diff --git a/scripts/initializeinbox.php b/scripts/initializeinbox.php new file mode 100644 index 000000000..43afc48eb --- /dev/null +++ b/scripts/initializeinbox.php @@ -0,0 +1,94 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); + +$shortoptions = 'i:n:af'; +$longoptions = array('id=', 'nickname=', 'all', 'force'); + +$helptext = <<find()) { + while ($user->fetch()) { + initializeInbox($user); + } + } + } else { + show_help(); + exit(1); + } +} catch (Exception $e) { + print $e->getMessage()."\n"; + exit(1); +} + +function initializeInbox($user) +{ + if (!have_option('q', 'quiet')) { + print "Initializing inbox for $user->nickname..."; + } + + $inbox = Inbox::staticGet('user_id', $user_id); + + if (!empty($inbox)) { + if (!have_option('q', 'quiet')) { + print "SKIP\n"; + } + } else { + $inbox = Inbox::initialize($user_id); + if (!have_option('q', 'quiet')) { + if (empty($inbox)) { + print "ERR\n"; + } else { + print "DONE\n"; + } + } + } +} -- cgit v1.2.3-54-g00ecf