4 * StatusNet - a distributed open-source microblogging tool
5 * Copyright (C) 2008-2011, 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__) . '/..'));
24 $longoptions = array();
26 $helptext = <<<END_OF_UPDATEURLS_HELP
27 updateurls.php [options]
28 update stored URLs in the system
30 END_OF_UPDATEURLS_HELP;
32 require_once INSTALLDIR.'/scripts/commandline.inc';
40 function updateUserUrls()
42 printfnq("Updating user URLs...\n");
44 // XXX: only update user URLs where out-of-date
48 while ($user->fetch()) {
49 printfv("Updating user {$user->nickname}...");
51 $profile = $user->getProfile();
53 updateProfileUrl($profile);
54 } catch (Exception $e) {
55 echo "Error updating URLs: " . $e->getMessage();
62 function updateProfileUrl($profile)
64 $orig = clone($profile);
65 $profile->profileurl = common_profile_url($profile->nickname);
66 $profile->update($orig);
69 function updateGroupUrls()
71 printfnq("Updating group URLs...\n");
73 $group = new User_group();
76 while ($group->fetch()) {
78 printfv("Updating group {$group->nickname}...");
79 $orig = User_group::getKV('id', $group->id);
80 if (!empty($group->original_logo)) {
81 $group->original_logo = Avatar::url(basename($group->original_logo));
82 $group->homepage_logo = Avatar::url(basename($group->homepage_logo));
83 $group->stream_logo = Avatar::url(basename($group->stream_logo));
84 $group->mini_logo = Avatar::url(basename($group->mini_logo));
86 // XXX: this is a hack to see if a group is local or not
87 $localUri = common_local_url('groupbyid',
88 array('id' => $group->id));
89 if ($group->getUri() != $localUri) {
90 $group->mainpage = common_local_url('showgroup',
91 array('nickname' => $group->nickname));
93 $group->update($orig);
95 } catch (Exception $e) {
96 echo "Can't update avatars for group " . $group->nickname . ": ". $e->getMessage();