X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=scripts%2Fupdateavatarurl.php;h=3b6681bae907a952b7314ad80f02a4bb24ac99db;hb=f3c822cc1520720a4bb63e3c610076571d90b520;hp=acafa74b0654c3ae35b14b69cd25704e81d4033f;hpb=a6312cb79cabad68d305ca9f4f2e5b3340f03f42;p=quix0rs-gnu-social.git diff --git a/scripts/updateavatarurl.php b/scripts/updateavatarurl.php index acafa74b06..3b6681bae9 100644 --- a/scripts/updateavatarurl.php +++ b/scripts/updateavatarurl.php @@ -60,7 +60,8 @@ try { } } } else { - throw new Exception("You have to provide an ID or nickname or 'all'."); + show_help(); + exit(1); } } catch (Exception $e) { print $e->getMessage()."\n"; @@ -69,6 +70,8 @@ try { function updateAvatars($user) { + $touched = false; + if (!have_option('q', 'quiet')) { print "Updating avatars for user '".$user->nickname."' (".$user->id.")..."; } @@ -91,11 +94,11 @@ function updateAvatars($user) } } - $orig = clone($avatar); + $orig_url = $avatar->url; $avatar->url = Avatar::url($avatar->filename); - if ($avatar->url != $orig->url) { + if ($avatar->url != $orig_url) { $sql = "UPDATE avatar SET url = '" . $avatar->url . "' ". "WHERE profile_id = " . $avatar->profile_id . " ". @@ -108,12 +111,22 @@ function updateAvatars($user) if (!$avatar->query($sql)) { throw new Exception("Can't update avatar for user " . $user->nickname . "."); + } else { + $touched = true; } } } + } + if ($touched) { + $profile = $user->getProfile(); + common_broadcast_profile($profile); } + if (have_option('v', 'verbose')) { - print "DONE.\n"; + print "DONE."; + } + if (!have_option('q', 'quiet') || have_option('v', 'verbose')) { + print "\n"; } }