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', dirname(__DIR__));
22 define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
25 $longoptions = array();
27 $helptext = <<<END_OF_UPDATEURLS_HELP
28 updateurls.php [options]
29 update stored URLs in the system
31 END_OF_UPDATEURLS_HELP;
33 require_once INSTALLDIR.'/scripts/commandline.inc';
41 function updateUserUrls()
43 printfnq("Updating user URLs...\n");
45 // XXX: only update user URLs where out-of-date
49 while ($user->fetch()) {
50 printfv("Updating user {$user->nickname}...");
52 $profile = $user->getProfile();
54 updateProfileUrl($profile);
55 } catch (Exception $e) {
56 echo "Error updating URLs: " . $e->getMessage();
63 function updateProfileUrl($profile)
65 $orig = clone($profile);
66 $profile->profileurl = common_profile_url($profile->nickname);
67 $profile->update($orig);
70 function updateGroupUrls()
72 printfnq("Updating group URLs...\n");
74 $group = new User_group();
77 while ($group->fetch()) {
79 printfv("Updating group {$group->nickname}...");
80 $orig = User_group::getKV('id', $group->id);
81 if (!empty($group->original_logo)) {
82 $group->original_logo = Avatar::url(basename($group->original_logo));
83 $group->homepage_logo = Avatar::url(basename($group->homepage_logo));
84 $group->stream_logo = Avatar::url(basename($group->stream_logo));
85 $group->mini_logo = Avatar::url(basename($group->mini_logo));
87 // XXX: this is a hack to see if a group is local or not
88 $localUri = common_local_url('groupbyid',
89 array('id' => $group->id));
90 if ($group->getUri() != $localUri) {
91 $group->mainpage = common_local_url('showgroup',
92 array('nickname' => $group->nickname));
94 $group->update($orig);
96 } catch (Exception $e) {
97 echo "Can't update avatars for group " . $group->nickname . ": ". $e->getMessage();