4 * StatusNet - a distributed open-source microblogging tool
5 * Copyright (C) 2009, StatusNet, Inc.
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
23 $shortoptions = 'i:n:af';
24 $longoptions = array('id=', 'nickname=', 'all', 'force');
26 $helptext = <<<END_OF_INITIALIZEINBOX_HELP
27 initializeinbox.php [options]
28 initialize the inbox for a user
30 -i --id ID of user to update
31 -n --nickname nickname of the user to update
32 -f --force force update even if user already has a location
35 END_OF_INITIALIZEINBOX_HELP;
37 require_once INSTALLDIR.'/scripts/commandline.inc';
42 if (have_option('i', 'id')) {
43 $id = get_option_value('i', 'id');
44 $user = User::staticGet('id', $id);
46 throw new Exception("Can't find user with id '$id'.");
48 initializeInbox($user);
49 } else if (have_option('n', 'nickname')) {
50 $nickname = get_option_value('n', 'nickname');
51 $user = User::staticGet('nickname', $nickname);
53 throw new Exception("Can't find user with nickname '$nickname'");
55 initializeInbox($user);
56 } else if (have_option('a', 'all')) {
59 while ($user->fetch()) {
60 initializeInbox($user);
67 } catch (Exception $e) {
68 print $e->getMessage()."\n";
72 function initializeInbox($user)
74 if (!have_option('q', 'quiet')) {
75 print "Initializing inbox for $user->nickname...";
78 $inbox = Inbox::staticGet('user_id', $user_id);
81 if (!have_option('q', 'quiet')) {
85 $inbox = Inbox::initialize($user_id);
86 if (!have_option('q', 'quiet')) {