#!/usr/bin/env php . */ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); $shortoptions = 'i:n:af:'; $longoptions = array('id=', 'nickname=', 'all', 'file='); $helptext = <<find()) { while ($user->fetch()) { 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)) { print "Can't find user with id '$id'.\n"; } 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 ($inbox && !empty($inbox->fake)) { if (!have_option('q', 'quiet')) { echo "(replacing faux cached inbox)"; } $inbox = false; } 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"; } } } }