From ddef800ec94dc9d9c7cdc3a81bb1c1fadaad0db2 Mon Sep 17 00:00:00 2001 From: Christopher Vollick Date: Thu, 18 Feb 2010 12:14:34 -0500 Subject: Update Avatar URL Did Weird Stuff. It was only finding the first two avatars and then thinking it was done. I'm not entirely sure why it was doing that. I think maybe all the cloning made it forget where it was or something. Either way, it seems to work now, and really uses less memory. --- scripts/updateavatarurl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/updateavatarurl.php b/scripts/updateavatarurl.php index 617c2e24c..3b6681bae 100644 --- a/scripts/updateavatarurl.php +++ b/scripts/updateavatarurl.php @@ -94,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 . " ". -- cgit v1.2.3-54-g00ecf From e717cba19c1badb97b87e7654e7535d57fa9c9f3 Mon Sep 17 00:00:00 2001 From: Christopher Vollick Date: Thu, 18 Feb 2010 13:44:16 -0500 Subject: Add Script To Update Group Avatar URLs Similar to scripts/updateavatarurl.php. Works for groups. Again, I had to do some weird thing because using clone screwed up the find() iteration. --- scripts/updateavatarurl_group.php | 99 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 scripts/updateavatarurl_group.php (limited to 'scripts') diff --git a/scripts/updateavatarurl_group.php b/scripts/updateavatarurl_group.php new file mode 100644 index 000000000..ada42de20 --- /dev/null +++ b/scripts/updateavatarurl_group.php @@ -0,0 +1,99 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); + +$shortoptions = 'i:n:a'; +$longoptions = array('id=', 'nickname=', 'all'); + +$helptext = <<find()) { + while ($group->fetch()) { + updateGroupAvatars($group); + } + } + } else { + show_help(); + exit(1); + } +} catch (Exception $e) { + print $e->getMessage()."\n"; + exit(1); +} + +function updateGroupAvatars($group) +{ + if (!have_option('q', 'quiet')) { + print "Updating avatars for group '".$group->nickname."' (".$group->id.")..."; + } + + if (empty($group->original_logo)) { + print "(none found)..."; + } else { + // Using clone here was screwing up the group->find() iteration + $orig = User_group::staticGet('id', $group->id); + + $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)); + + if (!$group->update($orig)) { + throw new Exception("Can't update avatars for group " . $group->nickname . "."); + } + } + + if (have_option('v', 'verbose')) { + print "DONE."; + } + if (!have_option('q', 'quiet') || have_option('v', 'verbose')) { + print "\n"; + } +} -- cgit v1.2.3-54-g00ecf From c8ddcbe0d32fb072456587fc554f6b78db672fa7 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 25 Feb 2010 17:56:01 -0800 Subject: init_conversation.php script to copy old notice conversations into the conversation table --- scripts/init_conversation.php | 49 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 scripts/init_conversation.php (limited to 'scripts') diff --git a/scripts/init_conversation.php b/scripts/init_conversation.php new file mode 100755 index 000000000..675e7cabd --- /dev/null +++ b/scripts/init_conversation.php @@ -0,0 +1,49 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); + +require_once INSTALLDIR.'/scripts/commandline.inc'; + +common_log(LOG_INFO, 'Initializing conversation table...'); + +$notice = new Notice(); +$notice->query('select distinct conversation from notice'); + +while ($notice->fetch()) { + $id = $notice->conversation; + + if ($id) { + $uri = common_local_url('conversation', array('id' => $id)); + + // @fixme db_dataobject won't save our value for an autoincrement + // so we're bypassing the insert wrappers + $conv = new Conversation(); + $sql = "insert into conversation (id,uri,created) values(%d,'%s','%s')"; + $sql = sprintf($sql, + $id, + $conv->escape($uri), + $conv->escape(common_sql_now())); + echo "$id "; + $conv->query($sql); + print "... "; + } +} +print "done.\n"; -- cgit v1.2.3-54-g00ecf