123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <?php
- define('INSTALLDIR', dirname(__DIR__));
- define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
- $shortoptions = '';
- $longoptions = array();
- $helptext = <<<END_OF_UPDATEURLS_HELP
- updateurls.php [options]
- update stored URLs in the system
- END_OF_UPDATEURLS_HELP;
- require_once INSTALLDIR.'/scripts/commandline.inc';
- function main()
- {
- updateUserUrls();
- updateGroupUrls();
- }
- function updateUserUrls()
- {
- printfnq("Updating user URLs...\n");
-
- $user = new User();
- if ($user->find()) {
- while ($user->fetch()) {
- printfv("Updating user {$user->nickname}...");
- try {
- $profile = $user->getProfile();
- updateProfileUrl($profile);
- } catch (Exception $e) {
- echo "Error updating URLs: " . $e->getMessage();
- }
- printfv("DONE.");
- }
- }
- }
- function updateProfileUrl($profile)
- {
- $orig = clone($profile);
- $profile->profileurl = common_profile_url($profile->nickname);
- $profile->update($orig);
- }
- function updateGroupUrls()
- {
- printfnq("Updating group URLs...\n");
- $group = new User_group();
- if ($group->find()) {
- while ($group->fetch()) {
- try {
- printfv("Updating group {$group->nickname}...");
- $orig = User_group::getKV('id', $group->id);
- if (!empty($group->original_logo)) {
- $group->original_logo = Avatar::url(basename($group->original_logo));
- $group->homepage_logo = Avatar::url(basename($group->homepage_logo));
- $group->stream_logo = Avatar::url(basename($group->stream_logo));
- $group->mini_logo = Avatar::url(basename($group->mini_logo));
- }
-
- $localUri = common_local_url('groupbyid',
- array('id' => $group->id));
- if ($group->getUri() != $localUri) {
- $group->mainpage = common_local_url('showgroup',
- array('nickname' => $group->nickname));
- }
- $group->update($orig);
- printfv("DONE.");
- } catch (Exception $e) {
- echo "Can't update avatars for group " . $group->nickname . ": ". $e->getMessage();
- }
- }
- }
- }
- main();
|