svnno****@sourc*****
svnno****@sourc*****
2009年 2月 23日 (月) 18:57:28 JST
Revision: 1033 http://svn.sourceforge.jp/view?root=slashdotjp&view=rev&rev=1033 Author: tach Date: 2009-02-23 18:57:28 +0900 (Mon, 23 Feb 2009) Log Message: ----------- add fix-discussion-url command to fix url column in discussions table Added Paths: ----------- slashjp/trunk/bin/fix-discussion-url -------------- next part -------------- Added: slashjp/trunk/bin/fix-discussion-url =================================================================== --- slashjp/trunk/bin/fix-discussion-url (rev 0) +++ slashjp/trunk/bin/fix-discussion-url 2009-02-23 09:57:28 UTC (rev 1033) @@ -0,0 +1,51 @@ +#!/usr/bin/perl +# +# (slash-)fix-discussion-url - fix discussions.url field for slash +# + +use Slash; +use Slash::Utility; +use Slash::DB; + +# debug +use Data::Dumper; + +my %opts; +$opts{'u'} ||= 'slash'; + +createEnvironment($opts{'u'}); + +my $slashdb = getCurrentDB(); +my $constants = getCurrentStatic(); +my $gSkin = $slashdb->getSkin($constants->{mainpage_skid}); + +my $where = ''; +my $other = ''; + +$discussions = $slashdb->sqlSelectAllHashrefArray( + "id,discussion_kinds.name AS kind,url", + "discussions JOIN discussion_kinds USING (dkid)", + $where, + $other); + +foreach my $discussion (@$discussions) { + my $url; + if ($discussion->{kind} eq "journal") { + next unless ($discussion->{url} =~ m!/journal\.pl\?op=display&id=(\d+?)&uid=(\d+?)!); + my ($id, $uid) = ($1, $2); + my $nickname = fixparam($slashdb->getUser($uid, 'nickname')); + $url = "$gSkin->{rootdir}/~$nickname/journal/$id"; + } elsif ($discussion->{kind} eq "poll") { + next unless ($discussion->{url} =~ m!/\bqid=(\d+?)\b!); + my $qid = $1; + $url = "$gSkin->{rootdir}/polls/$qid?aid=-1"; + } else { + next; + } + + if ($url) { + $slashdb->sqlUpdate('discussions', { url => $url }, "id=$discussion->{id}"); + } + print "BEFORE: $discussion->{url}\n"; + print "AFTER : $url\n\n"; +} Property changes on: slashjp/trunk/bin/fix-discussion-url ___________________________________________________________________ Added: svn:executable + *