Update of /cvs/scoop/scoop/struct/patch-files/1.0-1.1
In directory lithium.sabren.com:/tmp/cvs-serv9339/struct/patch-files/1.0-1.1

Added Files:
	README VERSION patch-01-MultiPolls.sql patch-02-Sessions.sql 
	patch-03-CommentPost.sql patch-04-UserPrefs.sql 
	patch-05-UserPrefs2.sql patch-06-UserPrefs3.sql 
	patch-07-SpecialPage.sql patch-08-Calendar.sql 
	patch-09-Diary.sql patch-10-CalendarUpdates.sql 
	patch-11-SignupWithPass.sql patch-12-RemoveComments.sql 
	patch-13-RemoveForumZilla.sql patch-14-PostThrottle.sql 
	patch-15-StoryForm.sql patch-16-MacroPerms.sql 
	patch-17-NavBar.sql patch-18-EditorialComment.sql 
	patch-19-StoryVoteMessage.sql patch-20-StoryPosting.sql 
	patch-21-Tags.sql patch-22-SharedDB.sql patch-23-MinMax.sql 
	patch-24-CommentFixes.sql patch-25-UserFile.sql 
	patch-26-UserMenu.sql patch-27-SpecialAdmin.sql 
	patch-28-RequireTags.sql patch-29-TUPerms.sql 
	patch-30-TagEnhancements.sql patch-31-TagPermUpdate.sql 
	script-04-post.pl script-04-pre.pl script-05-post.pl 
	script-06-post.pl script-08-post.pl script-09-post.pl 
	script-16-post.pl 
Log Message:
Setting up the 1.0-1.1 upgrade directory. -ct


--- NEW FILE: patch-26-UserMenu.sql ---
-- MySQL dump 10.9
--
-- Host: 10.250.27.101    Database: thebes
-- ------------------------------------------------------
-- Server version	4.1.11-Debian_3-log
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Dumping data for table `box`
--
-- WHERE:  boxid = 'userpref_menu'


/*!40000 ALTER TABLE `box` DISABLE KEYS */;
LOCK TABLES `box` WRITE;
INSERT IGNORE INTO `box` (`boxid`, `title`, `content`, `description`, `template`, `user_choose`) VALUES ('userpref_menu_file_pref','','my $edit = 0;\r\nmy $return = \'\';\r\nmy $nick = $S->param->{nick};\r\nmy $tool = $S->param->{tool} || \'info\';\r\nmy $admin_edit = \'\';\r\n\r\n# first, do we have permission to edit \r\n# this user\'s prefs?\r\n\r\nif ( $S->{UID} == $S->param->{uid} || $S->have_perm(\'edit_user\') ) {\r\n  $edit = 1;\r\n}\r\n\r\n$admin_edit = qq{[<A href=\"%%rootdir%%/user/$nick/prefs\">edit user</A>]} if ($S->have_perm(\'edit_user\'));\r\n\r\n# links to create\r\nmy $links = \"<P>$admin_edit ${nick}\'s \";\r\n\r\n# user info pages\r\nif ( $tool eq \'info\' ) {\r\n  $links .= qq{\r\n     <A href=\"%%rootdir%%/user/$nick\">Info</A>};\r\n  $links .= qq{\r\n     <A href=\"%%rootdir%%/user/$nick/comments\">Comments</A>};\r\n  $links .= qq{\r\n     <A href=\"%%rootdir%%/user/$nick/stories\">Stories</A>};\r\n\r\n  if ( $S->{UI}->{VARS}->{use_diaries} ) {\r\n   !
  $links .= qq{\r\n     <A href=\"%%rootdir%%/user/$nick/diary\">Diary</A>};\r\n  }\r\n\r\n  if ( $S->{UI}->{VARS}->{use_ratings} ) {\r\n    $links .= qq{\r\n     <A href=\"%%rootdir%%/user/$nick/ratings\">Ratings</A>};\r\n  }\r\nmy $udata = $S->user_data($S->param->{\'uid\'});\r\n#  if ( $S->{UI}->{VARS}->{allow_uploads} ) {\r\nif($S->{UI}->{VARS}->{allow_uploads} && (($S->have_perm(\'view_user_files\') && $S->have_perm(\'upload_user\', $udata->{\'perm_group\'})) || $S->have_perm(\'upload_admin\')) ) {\r\n    $links .= qq{\r\n     <A href=\"%%rootdir%%/user/$nick/files\">Files</A>};\r\n  }\r\n\r\n  if ( $S->{UI}->{VARS}->{use_ads} ) {\r\n    $links .= qq{\r\n     <A href=\"%%rootdir%%/user/$nick/ads\">Ads</A>};\r\n  }\r\n\r\n  $return = $links . \"</P>\";\r\n} elsif ( $edit && $tool eq \'prefs\' ) {\r\n  my %editlinks;\r\n  my ($rv, $sth) = $S->db_select({\r\n               WHAT => \'page, perm_edit\',\r\n               FROM => \'pref_items\',\r\n               GROUP_BY => !
 \'page\'\r\n  });\r\n  while (my $item = $sth->fetchrow_hashref()) {\r
\n     $editlinks{\"$item->{page}\"} = \"%%rootdir%%/user/$nick/prefs/$item->{page} $item->{perm_edit}\";\r\n  }\r\n  $sth->finish;\r\n  $links .= qq{\r\n     <A href=\"%%rootdir%%/user/$nick/prefs/Protected\">Email and Password</A>};\r\n\r\n  foreach my $item (sort {$b cmp $a} keys %editlinks) {\r\n    my $c = 0;\r\n    my ($rv2, $sth2) = $S->db_select({\r\n        WHAT => \'perm_edit\',\r\n        FROM => \'pref_items\',\r\n        WHERE => \"page = \'$item\'\"\r\n        });\r\n    while(my $i = $sth2->fetchrow_hashref()) {\r\n        $c++ if ($S->have_perm($i->{perm_edit}) || !$i->{perm_edit});\r\n        }\r\n    $sth2->finish;\r\n    $links .= ($c) ? qq{\r\n   <A href=\"$editlinks{$item}\">$item</A>} : \'\';\r\n  }\r\n  $return = $links . \"</P>\";\r\n}\r\n\r\nreturn $return;\r\n','navigation for user pref pages','empty_box',0);
UNLOCK TABLES;
/*!40000 ALTER TABLE `box` ENABLE KEYS */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;


--- NEW FILE: patch-20-StoryPosting.sql ---
UPDATE blocks SET bid = 'diary_post_message' WHERE bid = 'diary_submission_message';
INSERT INTO blocks VALUES ('post_message','<P><FONT SIZE=\"+1\">Your entry has been automatically posted</FONT></P>','1','<P>This block is displayed below the story body when it has been auto-posted. It should be self-contained HTML.</P>','Stories','default','en');
UPDATE blocks SET block=REPLACE(block,'ACTION=\"/\"','ACTION=\"%%rootdir%%/\"') WHERE bid='edit_story_form';


--- NEW FILE: patch-19-StoryVoteMessage.sql ---
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('story_already_post_msg','<P><B>This story has already been posted. It must have gone up while you were voting. Thanks for your vote anyway!</B></P>','1','<P>This message is displayed when a user has just voted on a story that was posted after they started reading it but before they voted. There are no special keys.</P>','Stories','default','en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('story_post_message','<P><B>You\'re the straw that broke the camel\'s back!</B><BR>Your vote put this story over the threshold, and it should now appear on the %%where%% page. Enjoy!</P>','1','<P>This message is displayed when a user has just voted on a story and that vote caused the story to reach the post threshold. The special key <B>where</B> is replaced by either "front" or "section", depending on how the votes were cast.</P>','Stories','default','en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('story_dumped_message','<P><b>You were the last vote,</b> and the voters have decided that this story will be hidden. Thank you for voting.</P>','1','<P>This message is displayed when a user has just voted and that vote caused the story to reach the hide threshold. There are no special keys.</P>','Stories','default','en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('story_autopost_message','<P><B>You were the last vote. We\'ve considered the votes and comments, and decided the story should be %%status%%. Thank you!</B></P>','1','<P>This message is displayed when a user has just voted and the auto-post calculations have been triggered. The special key <B>status</B> will contain either "posted" or "hidden", depending on the auto-post calculation results.','Stories','default','en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('story_spam_vote_msg','<P><B>Your vote was recorded for consideration.</B></P>', '1', '<P>This message is displayed when a user has pressed the "Spam" button on a story in the edit queue. There are no special keys.</P>', 'Stories', 'default', 'en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('story_vote_msg','<P><B>Your vote (%%vote%%) was recorded.</B><BR>This story currently has a total score of %%curr_score%%.</P>', '1', '<P>This message is displayed when a user votes on a story. There are two special keys:</P>\n<DL>\n <DT>vote</DT>\n  <DD>The vote cast by the user.</DD>\n <DT>curr_score</DT>\n  <DD>The story\'s current score.</DD>\n</DL>', 'Stories', 'default', 'en');


--- NEW FILE: patch-09-Diary.sql ---
DELETE from vars WHERE name='use_diaries';

--- NEW FILE: patch-06-UserPrefs3.sql ---
INSERT INTO box (boxid,title,content,description,template,user_choose) VALUES ('startpage_validation','','if ( $S->{SECTION_DATA}->{$ARGS[1]} || $ARGS[1] eq \'__main__\' || $ARGS[1] eq \'__all__\' ) {\n  return '';\n} else {\n  return "Start Page not valid<BR>";\n}','validates the start page pref','empty_box','0');
UPDATE pref_items set regex='BOX,startpage_validation' WHERE prefname='start_page';


--- NEW FILE: script-05-post.pl ---
#!/usr/bin/perl

use strict;
use Getopt::Std;
use DBI;

my $args = &get_args();

my $db_user = $args->{u};
my $db_pass = $args->{p};
my $db_port = $args->{o};
my $db_name = $args->{d};
my $db_host = $args->{h};

my $QUIET = $args->{q} || 0;

my $dsn = "DBI:mysql:database=$db_name:host=$db_host:port=$db_port";
my $dbh = DBI->connect($dsn, $db_user, $db_pass);

my ($query, $sth, $rv);
my $default;
$|++;

my $block;
$block = &grab_block($dbh,'comment_not_logged_in');
$block =~ s/\$anon/%%anon_user_nick%%/;
&update_block($dbh,'comment_not_logged_in',$block);

$block = &grab_block($dbh,'comment_post_form');
$block =~ s/%%rootdir%%\/#here/%%rootdir%%\/comments\/%%sid%%\/%%pid%%\/post#here/;
&update_block($dbh,'comment_post_form',$block);

$block = &grab_block($dbh,'commentreply_display');
$block =~ s/100\\%/100%/;
&update_block($dbh,'commentreply_display',$block);

$block = &grab_block($dbh,'comment_posted_display');
$block =~ s/100\\%/100%/;
&update_block($dbh,'comment_posted_display',$block);

$block = &grab_block($dbh,'new_user_html');
$block =~ s/required_prefs/signup_prefs/;
&update_block($dbh,'new_user_html',$block);

$block = &grab_box($dbh,'userpref_menu');
$block =~ s/>Protected</>Email and Password</;
&update_box($dbh,'userpref_menu',$block);

# utility functions follow from here

sub delete_var {
	my ($dbh, $id) = @_;
	my $query = "DELETE FROM vars WHERE name=" . $dbh->quote($id);
	my $sth = $dbh->prepare($query);
	$sth->execute;
	$sth->finish;
}

sub grab_var {
	my ($dbh, $id) = @_;
	my $query = "SELECT value FROM vars WHERE name = " . $dbh->quote($id);
	my $sth = $dbh->prepare($query);
	$sth->execute;
	my ($contents) = $sth->fetchrow_array;
	$sth->finish;
	return $contents;
}

sub update_var {
	my ($dbh, $id, $contents) = @_;
	my $query = "UPDATE vars SET value = ? WHERE name = ?";
	my $sth = $dbh->prepare($query);
	$sth->execute($contents, $id);
	$sth->finish;
}

sub grab_block {
	my ($dbh, $bid) = @_;
	my $query = "SELECT block FROM blocks WHERE bid = " . $dbh->quote($bid);
	my $sth = $dbh->prepare($query);
	$sth->execute;
	my ($contents) = $sth->fetchrow_array;
	$sth->finish;
	return $contents;
}

sub update_block {
	my ($dbh, $bid, $contents) = @_;
	my $query = "UPDATE blocks SET block = ? WHERE bid = ?";
	my $sth = $dbh->prepare($query);
	$sth->execute($contents, $bid);
	$sth->finish;
}

sub grab_box {
	my ($dbh, $box) = @_;
	my $query = "SELECT content FROM box WHERE boxid = " . $dbh->quote($box);
	my $sth = $dbh->prepare($query);
	$sth->execute;
	my ($contents) = $sth->fetchrow_array;
	$sth->finish;
	return $contents;
}

sub update_box {
	my ($dbh, $box, $contents) = @_;
	my $query = "UPDATE box SET content = ? WHERE boxid = ?";
	my $sth = $dbh->prepare($query);
	$sth->execute($contents, $box);
	$sth->finish;
}

sub mesg {
	print @_ unless $QUIET;
}

sub get_args {
    my %info;
    my @neededargs;

    getopts("u:p:d:h:o:vqD", \%info);

    # now first generate an array of hashrefs that tell us what we
    # still need to get
    foreach my $arg ( qw( u p d h o ) ) {
        next if ( $info{$arg} and $info{$arg} ne '' );

        if( $arg eq 'u' ) {
            push( @neededargs, {arg     => 'u',
                                q       => 'db username? ',
                                default => 'nobody'} );
        } elsif( $arg eq 'p' ) {
            push( @neededargs, {arg     => 'p',
                                q       => 'db password? ',
                                default => 'password'} );
        } elsif( $arg eq 'd' ) {
            push( @neededargs, {arg     => 'd',
                                q       => 'db name? ',
                                default => 'scoop'} );
        } elsif( $arg eq 'h' ) {
            push( @neededargs, {arg     => 'h',
                                q       => 'db hostname? ',
                                default => 'localhost'} );
        } elsif( $arg eq 'o' ) {
            push( @neededargs, {arg     => 'o',
                                q       => 'db port? ',
                                default => '3306'} );
        }
    }

    foreach my $h ( @neededargs ) {
        my $answer = '';

        print "$h->{q}"."[$h->{default}] ";
        chomp( $answer = <STDIN> );

        $answer = $h->{default} unless( $answer && $answer ne '' );

        $info{ $h->{arg} } = $answer;
    }

    return \%info;
}

--- NEW FILE: patch-10-CalendarUpdates.sql ---
INSERT INTO blocks VALUES ('anonymous_rsvp_form','<FIELDSET>\r\n<LEGEND>RSVP</LEGEND>\r\nPlease <a href=\"/login\">sign in</a> or <a href=\"/newuser\">create an account</a> to RSVP.\r\n</FIELDSET>\r\n','1','','Calendars and Events','default','en');
INSERT INTO blocks VALUES ('calendar_monthly_one_week','<TR>\r\n %%wk%%week%%_d1%%\r\n %%wk%%week%%_d2%%\r\n %%wk%%week%%_d3%%\r\n %%wk%%week%%_d4%%\r\n %%wk%%week%%_d5%%\r\n %%wk%%week%%_d6%%\r\n %%wk%%week%%_d7%%\r\n <td style=\"width: 20px;\"><a href=\"%%rootdir%%/calendar/weekly/%%cal_id%%/%%wk%%week%%%%\">W<br>E<br>E<br>K</a></td>\r\n</TR>','1','','Calendars and Events','default','en');
INSERT INTO blocks VALUES ('calendar_css','/* calendar stuff */\r\n\r\n.cal_head { }\r\n\r\n.cal_head ul  {\r\n               border: 0;\r\n               margin-top: 10px;\r\n               margin-left: 0;\r\n               padding-left: 0;\r\n               list-style-type: none;\r\n               text-align: center;\r\n               }\r\n\r\n.cal_head ul li  {\r\n               display: inline;\r\n               text-align: center;\r\n               float: left;\r\n               padding: 0;\r\n               margin: 0;\r\n               }\r\n\r\n.cal_head ul li a  {\r\n               border: 1px solid #006;\r\n               margin: 0;\r\n               padding: 5px;\r\n               color: #3B3B3B;\r\n               text-decoration: none;\r\n               display: block;\r\n               text-align: center;\r\n               font: normal 10px/18px \"Lucida Grande\", \"Lucida Sans Unicode\", verdana, lucida, sans-serif;\r\n               }\r\n\r\n.cal_head ul li a:ho!
 ver  {\r\n                color: #fff;\r\n                background: #3B3B3B;\r\n                }\r\n\r\n.cal_head UL LI A#current { background-color: #ff0000;\r\n                            color: #ffffff;\r\n                            font-weight: bold; }\r\n\r\n.cal_body {  }\r\n\r\n.cal_body TD { border-top: 1px solid black;\r\n               border-left: 1px solid black;\r\n               border-right: 0px;\r\n               border-bottom: 0px;\r\n               padding: 3px; \r\n               height: 25px;\r\n             }\r\n\r\n.cal_body TD { width: 100px;\r\n               height: 100px;\r\n             }\r\n\r\n.cal_body TH { border-right: 0px;\r\n               border-bottom: 0px;\r\n             }\r\n\r\n.cal_mini_body TD,TH { border: 1px solid black;\r\n                  padding: 1px; \r\n                  height: 5px;\r\n                }\r\n.cal_mini_body TD { width: 10px;\r\n               height: 10px;\r\n             }\r\n\r\n.cal_day_head { height: 2!
 5px; }\r\n\r\n.cal_body #today { background-color: #eeeeee; }\r\n.cal_
body #other_month { background-color: #cccccc; }\r\n\r\n.date_number a { font-size: 12px; \r\n               border-right: 1px solid black;\r\n               border-bottom: 1px solid black;\r\n               padding: 3px;\r\n               min-wdth: 14px;\r\n               margin-left: -3px;\r\n               margin-top -3px;\r\n}\r\n\r\n.tinylink   { font-size: 9px;\r\n              font-weight: normal;\r\n              font-stretch: wider;\r\n            }\r\n\r\n.event_body { border: 1px solid #222; \r\n              background-color: #F5F5CE;\r\n              margin-left: 25px;\r\n              margin-right:25px;\r\n            }\r\n\r\n.event_title { background-color: #9E7B1B;\r\n               color: #fff;\r\n               font-size: 15px;\r\n               font-weight: bold;\r\n               padding-top:5px;\r\n               padding-bottom:6px;\r\n             }\r\n\r\n.event_details { padding-left: 10px;\r\n                 padding-right:10px;\r\n               }\!
 r\n\r\n.child_event_list { padding-left: 10px;\r\n                    padding-right:10px;\r\n                    margin-left: 25px;\r\n                    margin-right:25px;\r\n\r\n               }','1','','CSS','default','en');
INSERT INTO blocks VALUES ('css_includes','<LINK rel=\"stylesheet\" type=\"text/css\" href=\"%%rootdir%%/css/main\">\r\n<LINK rel=\"stylesheet\" type=\"text/css\" href=\"%%rootdir%%/css/calendar\">','1','','CSS','default','en');

UPDATE blocks SET block = '<table border=0 cellpadding=0 cellspacing=0 width=\"100%\"><tr><td>\r\n<DIV class=\"cal_head\">\r\n<div class=\"title\">%%calendar_title%% - %%dow%% <a href=\"%%rootdir%%/calendar/monthly/%%cal_id%%/%%year%%-%%monthnum%%\">%%month%%</a> %%day_num%%, %%year%%</div>\r\n%%BOX,calendar_actions%%\r\n<table align=\"center\" border=0 cellpadding=0 cellspacing=0><tr><td>\r\n<UL>\r\n%%BOX,calendar_datenav%%\r\n</UL>\r\n</td></tr></table>\r\n</DIV>\r\n</td></tr></table>\r\n<p>\r\n<DIV class=\"cal_body\">\r\n\r\n<table width=\"100%\" border=0 cellpadding=0 cellspacing=0 style=\"border-right: 1px solid black; border-bottom: 1px solid black;\">\r\n<tr>%%day%%</tr>\r\n</table>\r\n</div>' WHERE bid = 'calendar_body_daily';
UPDATE blocks SET block = '<table border=0 cellpadding=0 cellspacing=0 width=\"100%\"><tr><td>\r\n<DIV class=\"cal_head\">\r\n<div class=\"title\">%%calendar_title%% - %%longdate%%</div>\r\n%%BOX,calendar_actions%%\r\n<table align=\"center\" border=0 cellpadding=0 cellspacing=0><tr><td>\r\n<UL>\r\n%%BOX,calendar_datenav%%\r\n</UL>\r\n</td></tr></table>\r\n</DIV>\r\n</td></tr></table>\r\n<p>\r\n<DIV class=\"cal_body\">\r\n\r\n<TABLE width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" style=\"border-right: 1px solid black; border-bottom: 1px solid black;\">\r\n<TR>\r\n <TH>Monday</TH>\r\n <TH>Tuesday</TH>\r\n <TH>Wednesday</TH>\r\n <TH>Thursday</TH>\r\n <TH>Friday</TH>\r\n <TH>Saturday</TH>\r\n <TH>Sunday</TH>\r\n <TH> </TH>\r\n</TR>\r\n%%rows%%\r\n</TABLE>\r\n</DIV>\r\n%%subscribe_link%%' WHERE bid = 'calendar_body_monthly';
UPDATE blocks SET block = '<TD%%hilight%% valign=\"top\"><DIV class=\"cal_day\">\r\n<DIV class=\"date_number\"><A href=\"%%rootdir%%/calendar/daily/%%cal_id%%/%%year%%-%%month%%-%%date_number%%\">%%date_number%%</A></DIV>\r\n%%events%%\r\n</DIV></TD>' WHERE bid = 'calendar_body_one_day';
UPDATE blocks SET block = '<table border=0 cellpadding=0 cellspacing=0 width=\"100%\"><tr><td>\r\n<DIV class=\"cal_head\">\r\n<div class=\"title\">%%calendar_title%% - Week starting %%dow%% <a href=\"%%rootdir%%/calendar/monthly/%%cal_id%%/%%year%%-%%monthnum%%\">%%month%%</a> %%day_num%%, %%year%%</div>\r\n%%BOX,calendar_actions%%\r\n<table align=\"center\" border=0 cellpadding=0 cellspacing=0><tr><td>\r\n<UL>\r\n%%BOX,calendar_datenav%%\r\n</UL>\r\n</td></tr></table>\r\n</DIV>\r\n</td></tr></table>\r\n<p>\r\n\r\n\r\n<DIV class=\"cal_body\">\r\n\r\n<TABLE width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" style=\"border-right: 1px solid black; border-bottom: 1px solid black;\">\r\n<TR>\r\n <TH>Monday</TH>\r\n <TH>Tuesday</TH>\r\n <TH>Wednesday</TH>\r\n <TH>Thursday</TH>\r\n <TH>Friday</TH>\r\n <TH>Saturday</TH>\r\n <TH>Sunday</TH>\r\n</TR>\r\n<TR>\r\n %%d1%%\r\n %%d2%%\r\n %%d3%%\r\n %%d4%%\r\n %%d5%%\r\n %%d6%%\r\n %%d7%%\r\n</TR>\r\n\r\n</TABLE>\r\n</div>' WHERE bid = 'ca!
 lendar_body_weekly';
UPDATE blocks SET block = '<LI><A href=\"%%link_url%%\"%%css_id%%>%%nav_link%%</A></LI>' WHERE bid = 'calendar_navigation_item';
UPDATE box SET content = 'my $content = \'\';\r\nmy $view = $S->cgi->param(\'view\') || $S->pref(\'calendar_view\');\r\nmy @date = $S->_get_date_array($S->cgi->param(\'date\'));\r\nmy $nav_items = $S->_calendar_date_navigation($view, at date);\r\n\r\nmy $prefix = \'&lt;&lt; \';\r\nmy $suffix = \'\';\r\nmy $stage = \'before\';\r\n\r\nforeach my $item (@$nav_items) {\r\n  warn \"Item is $item->{link_url}\\n\";\r\n  my $keys = {}; # keys for interpolation\r\n  my $string = $S->{UI}->{BLOCKS}->{calendar_navigation_item};\r\n  $keys->{link_url} = $item->{link_url};\r\n\r\n  #link text\r\n  my $text;\r\n  if ( $view eq \'monthly\' ) {\r\n    my $year = $date[0];\r\n	$year -= 1 if ($item->{date_array}->[1] > $date[1] && $stage eq \'before\');\r\n	$year += 1 if ($item->{date_array}->[1] < $date[1] && $stage eq \'after\');\r\n	$text = Date::Calc::Month_to_Text($item->{date_array}->[1]) . \" \" . $year;\r\n    warn \"Date is $text\\n\";\r\n  } else {\r\n    $text = Date::Calc::Date_to_Te!
 xt(@{$item->{date_array}});\r\n  }\r\n  $keys->{nav_link} = \"$prefix$text$suffix\";\r\n\r\n  if ($item->{current}) {\r\n    $keys->{css_id} = $S->{UI}->{BLOCKS}->{calendar_navigation_hilight};\r\n    $keys->{nav_link} = $text;\r\n    $prefix = \'\';\r\n    $suffix = \' &gt;&gt;\';\r\n	$stage = \'after\'\r\n  }\r\n  $content .= $S->interpolate($string,$keys);\r\n}\r\n\r\n\r\nreturn $content;' WHERE boxid = 'calendar_datenav';
UPDATE box SET content = 'my ($sub_link, $content, $newevent, $modevents, $edit_cal);\r\nmy $cal_id = $S->cgi->param(\'calendar\');\r\n\r\nif ( $cal_id ) {\r\n  # viewing a particular calendar\r\n  if ($S->have_calendar_perm(\'edit\',$cal_id)) {\r\n    $edit_cal = qq{<A href=\"%%rootdir%%/editcalendar/settings/$cal_id\">Edit this calendar</A>};\r\n  }\r\n  if ($S->have_calendar_perm(\'submit\',$cal_id)) {\r\n    $newevent = qq{<A href=\"%%rootdir%%/submitevent/submit/$cal_id\">Submit new event</A>};\r\n  }\r\n  if ( $S->have_calendar_perm(\'moderate\',$cal_id) ) {\r\n    $modevents = qq{<A href=\"%%rootdir%%/editcalendar/moderate/$cal_id\">Moderate submitted events</A>};\r\n  }  \r\n} elsif ($S->have_perm(\'edit_own_calendar\')) {\r\n  # personal calendar view\r\n  $edit_cal = qq{<A href=\"%%rootdir%%/editcalendar\">Edit your calendar</A>} if $S->var(\'allow_user_calendars\');\r\n  my $cals = $S->_cal_submit_list();\r\n  my $use_submit = 0;\r\n  foreach ( @$cals ) {\r\n    i!
 f ( $S->pref(\"calendar_${_}_subscribe\") ) {\r\n      $use_submit = 1;\r\n      next;\r\n    }\r\n  }\r\n  if ( $use_submit ) {\r\n    $newevent = qq{<A href=\"%%rootdir%%/submitevent/submit\">Submit new event</A>};\r\n  }\r\n}\r\n\r\nmy @list;\r\nfor ($newevent, $modevents, $edit_cal, $sub_link) {\r\n	push @list, $_ if ($_);\r\n}\r\nmy $list = join(\' :: \', @list);\r\n$content = qq{\r\n<DIV class=\"cal_actions\">\r\n$list\r\n</DIV>};\r\n\r\nreturn $content;\r\n' WHERE boxid = 'calendar_actions';

--- NEW FILE: patch-15-StoryForm.sql ---
INSERT INTO blocks VALUES ('submit_page_title','Submit Story','1','','','default','en');
INSERT INTO blocks VALUES ('story_list_title','Story List','1','','','default','en');
INSERT INTO blocks VALUES ('archive_list_title','Archived Stories','1','','','default','en');
INSERT INTO blocks VALUES ('pending_list_title','Pending Stories','1','','','default','en');

UPDATE admin_tools SET perm = 'story_admin,edit_my_stories' WHERE tool = 'story';
UPDATE vars SET value=CONCAT(value, ',\r\nedit_my_stories,\r\nstory_time_update') WHERE name='perms';

UPDATE blocks SET block = 'poll:<br><br>\r\nPolls are not required, but if you want one, fill in a question and some answers.' WHERE bid = 'attach_poll_message';

INSERT INTO blocks VALUES ('edit_story_form','<FORM NAME=\"editstory\" ACTION=\"/\" METHOD=\"POST\" enctype=\"multipart/form-data\">\r\n%%hidden_form_data%%\r\n<table width=\"100%\" border=0 cellpadding=\"8\" cellspacing=0>\r\n<tr>\r\n<td valign=\"top\" colspan=\"2\">%%guidelines%%</td>\r\n</tr>\r\n<tr>\r\n<td valign=\"top\" colspan=\"2\">%%all_buttons%%</td>\r\n</tr>\r\n<tr>\r\n<td valign=\"top\">post&nbsp;to:</td>\r\n<td valign=\"top\">%%section_select%% %%topic_select%% %%postmode_select%%</td>\r\n</tr>\r\n%%edit_queue%%\r\n<tr>\r\n<td valign=\"top\">title:</td>\r\n<td valign=\"top\"><INPUT TYPE=\"text\" NAME=\"title\" VALUE=\"%%title%%\" SIZE=50><br>\r\n%%dept%%</td>\r\n</tr>\r\n%%notes%%\r\n<tr>\r\n<td valign=\"top\">intro:</td>\r\n<td valign=\"top\"><TEXTAREA NAME=\"introtext\" COLS=\"%%textarea_cols%%\" ROWS=\"%%textarea_rows%%\" WRAP=\"soft\">%%introtext%%</TEXTAREA></td>\r\n</tr>\r\n<tr>\r\n<td valign=\"top\">body:</td>\r\n<td valign=\"top\"><TEXTAREA NAME=\"bodytex!
 t\" COLS=\"%%textarea_cols%%\" ROWS=\"%%textarea_rows%%\" WRAP=\"soft\">%%bodytext%%</TEXTAREA></td>\r\n</tr>\r\n%%upload_page%%\r\n%%spellcheck%%\r\n<tr>\r\n<td></td>\r\n<td valign=\"top\">%%displaystatus_select%% %%commentstatus_select%% %%edit_category_select%%\r\n</td>\r\n</tr>\r\n%%time_update%%\r\n<tr>\r\n<td>%%poll_message%%</td>\r\n<td>%%poll_form%%</td>\r\n</tr>\r\n<tr>\r\n<td valign=\"top\" colspan=\"2\">%%all_buttons%%</td>\r\n</tr>\r\n</table>\r\n</FORM>','1','The main form for submitting and editing stories. This one has a lot of permitted special keys. Here goes:\r\n\r\n<ul>\r\n<li> allowed_html_intro: the string for what html is allowed in intro. Optional.\r\n<li> allowed_html_body: likewise, for the body field\r\n<li> notes: Block \"story_edit_notes\" -- traditionally for the ED and UPDATE explanations\r\n<li> tid: Topic id of story\r\n<li> section: section id of story\r\n<li> parent: section id of parent section, if there is one\r\n<li> topic_select: The se!
 lector for topics. Generated internally based on perms and vars. REQUI
RED -- it will be a hidden field if you\'re not using topics, but you must have it.\r\n<li> displaystatus_select: Selector for displaystatus. Generated based on perms\r\n<li> commentstatus_select: Obvious\r\n<li> edit_category_select: If you\'re using edit categories, this\'ll be the selector\r\n<li> postmode_select: Selector for posting mode, like \"front page\", \"editing\" etc\r\n<li> all_buttons: The set of currently allowed and relevant buttons. Very required.\r\n<li> aid: uid of author\r\n<li> hidden_form_data: various bits of hdden stuff for the form that scoop needs to track. Very required.\r\n<li> title: Text of the title -- use your own html form element, just include this for \"value\"\r\n<li> dept: Dept field, formatted by block \"story_edit_dept\". Included if show_dept is turned on\r\n<li> upload_page: Story upload form, if you\'re using that.\r\n<li> spellcheck: Spellcheck element, if used. Formatted in block story_edit_spellcheck\r\n<li> edit_queue: Post to e!
 dit queue element, if you\'re using that. Formatted in block story_edit_editqueue\r\n<li> time_update: Update timestamp to now button, if you have permission. Formatted in block story_edit_timeupdate, subject to perm \"story_time_update\"\r\n<li> update_txt: block story_edit_updatetxt\r\n<li> edit_txt: block story_edit_edittxt\r\n<li> textarea_cols: textarea columns, based on perfs and stuff\r\n<li> textarea_rows: textarea rows, likewise\r\n<li> poll_message: Poll into message, from attach_poll_message, if you\'re using polls\r\n<li> poll_form: Poll form, if you\'re using polls\r\n<li> introtext: introtext of the story\r\n<li> bodytext: body text of the story\r\n<li> guidelines: The block \"submission_guidelines\", included for user-level story submit\r\n</ul>','Admin Pages','default','en');
INSERT INTO blocks VALUES ('poll_form_multi','<INPUT type=\"checkbox\" name=\"is_multiple_choice\" value=\"1\"%%allow_multiple%%> Allow multiple selections in poll','1','Allow multiple choice portion of the poll edit form. Included if var \"allow_multiple_choice\" is on.','Polls','default','en');
INSERT INTO blocks VALUES ('poll_form_question','%%last_update%%\r\n%%attached_to%%\r\n%%current%%\r\n%%hidden_form_input%%\r\n%%multiple_choice%%\r\n<p>\r\nPoll Question:<br>\r\n<INPUT type=\"text\" size=\"30\" name=\"question\" value=\"%%question%%\"><br><br>\r\nPoll Answers:<br>\r\n\r\n','1','','Polls','default','en');
INSERT INTO blocks VALUES ('edit_story_archive_success','<table>\r\n<TR><TD>%%norm_font%%<B>Story archived.</B>%%norm_font_end%%</TD></TR>\r\n</table>','1','','Stories','default','en');
INSERT INTO blocks VALUES ('edit_story_archive_fail','<table>\r\n<TR><TD>%%norm_font%%<B>Could not archive story.</B>%%norm_font_end%%</TD></TR>\r\n</table>','1','','Stories','default','en');
INSERT INTO blocks VALUES ('edit_story_deleted','<table>\r\n<TR><TD>%%norm_font%%<B>Story deleted.</B>%%norm_font_end%%</TD></TR>\r\n</table>','1','','Stories','default','en');
INSERT INTO blocks VALUES ('story_edit_updatetxt','<br>Insert <B>[UPDATE]</B> to create an \"[Update]\"','1','','Stories','default','en');
INSERT INTO blocks VALUES ('story_edit_edittxt','<br>Insert <B>[ED]</B> to create an \"[editor\'s note]\"','1','','Stories','default','en');
INSERT INTO blocks VALUES ('story_edit_notes','<TR>\r\n  <TD>\r\n    special functions:\r\n  </td>\r\n  <td>\r\n    Insert <B>[UPDATE]</B> to create an \"[Update]\"<br>\r\n    Insert <B>[ED]</B> to create an \"[editor\'s note]\"\r\n  </TD>\r\n</TR>','1','','Stories','default','en');
INSERT INTO blocks VALUES ('edit_story_admin_page','<div class=\"title\">Edit Story</div>\r\n<div class=\"error\">%%error%%</div>\r\n%%story%%\r\n<p>\r\n%%edit_form%%','1','','Admin Pages','default','en');
INSERT INTO blocks VALUES ('story_edit_spellcheck','<tr>\r\n<td valign=\"top\">spellcheck:</td>\r\n<td valign=\"top\"><INPUT TYPE=\"checkbox\" NAME=\"spellcheck\" VALUE=\"on\"%%check%%></td>\r\n</tr>\r\n','1','','Admin Pages','default','en');
INSERT INTO blocks VALUES ('story_edit_editqueue','<tr>\r\n<td></td>\r\n<td><INPUT TYPE=\"checkbox\" NAME=\"edit_in_queue\" VALUE=\"1\" %%check%%> Request editorial feedback</td>\r\n</tr>\r\n','1','','Stories','default','en');
INSERT INTO blocks VALUES ('story_edit_timeupdate','<tr>\r\n<td valign=\"top\">update timestamp:</td>\r\n<td valign=\"top\"><input type=\"checkbox\" name=\"timeupdate\" value=\"now\"></td>\r\n</tr>','1','','Stories','default','en');
INSERT INTO blocks VALUES ('story_edit_upload','<tr>\r\n  <td>&nbsp;</td>\r\n  <td>%%form%%</td>\r\n</tr>','1','Story submit form element for file uploads. Special key |form| will be replaced with the form, if used.','','default','en');
INSERT INTO blocks VALUES ('story_edit_dept','<tr>\r\n<td>department:</td>\r\n<td><INPUT TYPE=\"text\" NAME=\"dept\" VALUE=\"%%dept%%\" SIZE=50></td>\r\n</tr>','1','','Stories','default','en');
INSERT INTO blocks VALUES ('story_hide_message','Story %%sid%% hidden.','1','','Stories','default','en');
INSERT INTO blocks VALUES ('story_delete_message','Story %%sid%% deleted.','1','','Stories','default','en');

INSERT INTO box VALUES ('admin_tools_new','Admin Tools','my $content;\r\n\r\nmy @tools = sort { $a->{pos} <=> $b->{pos} } values %{ $S->{ADMIN_TOOLS} };\r\n\r\nforeach my $t (@tools) {\r\n        my $perm = $t->{perm};\r\n        if ($t->{perm} =~ /,/) {\r\n          $t->{perm} =~ /^(.*?),/;\r\n          $perm = $1;\r\n        }\r\n	if ( $S->have_perm($perm) ) {\r\n		$content .= qq|\r\n	%%dot%% <a class=\"light\" href=\"%%rootdir%%/admin/$t->{tool}\">$t->{menuname}</a><br>|;\r\n	}\r\n}\r\n\r\nif ($S->have_perm(\'edit_user\')) {\r\n $content .= qq{<br>\r\n <FORM NAME=\"uedit\" METHOD=\"GET\" ACTION=\"%%rootdir%%/\">\r\n Edit User:<BR>\r\n <INPUT TYPE=\"hidden\" NAME=\"op\" VALUE=\"user\">\r\n <SMALL><INPUT TYPE=\"text\" NAME=\"nick\" VALUE=\"\" SIZE=10>\r\n <INPUT TYPE=\"SUBMIT\" NAME=\"tool\" VALUE=\"prefs\">\r\n <INPUT TYPE=\"SUBMIT\" NAME=\"tool\" VALUE=\"info\">\r\n </SMALL></FORM>};\r\n}\r\n\r\nreturn \'\' unless $content;\r\n\r\nreturn $content;\r\n','Admin Tools box','!
 box',0);

--- NEW FILE: patch-28-RequireTags.sql ---
INSERT INTO `vars` (`name`, `value`, `description`, `type`, `category`) VALUES ('require_tags','0','If this var is set, users <b>must</b> submit at least one tag when they submit a story.','bool','Tags');

--- NEW FILE: VERSION ---
# partial version file
# to keep track of the tree these patches
# were made for
return "1_1-dev";

--- NEW FILE: README ---
This just lists the order that you need to apply these patches, and the dates
on which they were added to scoop. 

The upgrade-db.pl in scripts/ will (hopefully) do all this for you. Try running
it first.

Apply them to your database in the order below with
mysql -u root -p <scoopdb> < patch-NN-Name.sql

Run the scripts with 
./script-NN-(pre|post).pl

If there are scripts and patches with the same number, run the -pre script
first, then apply the patch, then run the -post script

Don't apply patches dated earlier than when you installed scoop, or when you
created the scoop database with scoop.sql  These patches are all in the
scoop.sql file already


Jul  2 13:32 patch-01-MultiPolls.sql
	Allows "approval voting" in polls as an option.

Jul  6 01:44 patch-02-Sessions.sql
	Drops and re-creates the sessions table to be compatible with the new
	Scoop::Sessions module.

Jul 18 12:15 patch-03-CommentPost.sql
	Moves the comment post form to a block

Aug 4 14:17 patch-04-UserPrefs.sql
	New flexible user preferences. Both -pre and -post scripts are required

Aug 17 11:30 patch-05-UserPrefs2.sql
	Bugfixes and small feature additions for the above userprefs patch.

Aug 27 13:30 patch-06-UserPrefs3.sql
	More bugfixes: fixed a caching issue and added the ability to use a box
	for validation instead of a regex, if desired. If you want both, put
	the regex in the box.

Jan 15 9:50 patch-07-SpecialPage.sql
	Moves the special page formatting to a block

Jan 21 09:30 patch-08-Calendar.sql
        Adds a very featureful collaborative event calendar module. Docs remain to
        be written, unfortunately, but here's all the funtionality, anyway.

Jan 22 19:20 patch-09-Diary.sql
	Removes the use_diaries var and uses the section perms instead.

Jan 25 10:10 patch-10-CalendarUpdates.sql
        Updates and bugfixes to the Calendar module. Adds a separate calendar_css
        block, and a css_includes block, which should be called in place of the
        existing css LINK REL in your templates. Makes keeping CSS up to date much
        easier.

Jan 25 12:11 patch-11-SignupWithPass.sql
        Mainly adds a new signup method where the user chooses their own password.
        Works a lot more smoothly than the old way. If you install fresh, it's the default.
        If not, you need to edit a bunch of Accounts blocks and turn on 
        "signup_with_password" var. This patch also adds CT's iplookup tools, and
        flexible date formatting.

Jan 27 11:30 patch-12-RemoveComments.sql
	Adds the ability to "remove" (in addition to the old "delete") comments. 
	"Remove" replaces the comment with a note saying the comment had been deleted, 
	but doesn't change the comment threading.

Jan 27 2:42 patch-13-RemoveForumZilla.sql
	Drops the boxes, blocks, and ops that support ForumZilla.

Jan 28 3:57 patch-14-PostThrottle.sql
        Bugfix for problems in the post throttling code, moves content out of code.

Feb 03 10:36 patch-15-StoryForm.sql
        Moves story posting forms entirely into blocks. This will make it a lot
        easier to add extra fields or customizations to stories. Also, there's 
        a new admin_tools box that handles a change in admin tools to allow for 
        more than one perm per tool. Updated here as admin_tools_new to not clobber 
        custom boxes.

Feb 11 2:00 patch-16-MacroPerms.sql
	Adds the ability to restrict macros by location and user group, using the same 
	syntax as the allowed_html block. The script fixes a small bug in one of the 
	userpref boxes.

May 26 10:30 patch-17-NavBar.sql
	Moves the story nav bar from hard coded HTML into blocks.

May 26 11:25 patch-18-EditoralComment.sql
	Fixes comment type toggling in edit queue stories.

May 26 12:05 patch-19-StoryVoteMessage.sql
	Move the story vote messages from code into blocks.

May 27 6:45 patch-20-StoryPosting.sql
	Updates the story post messages and the story post form action

Sep 9 4:30 patch-21-Tags.sql
	Adds tag categorization.

Oct 6 1:25 patch-22-SharedDB.sql
	Adds shared database support.

Oct 14 13:08 patch-23-MinMax.sql
			 patch-24-CommentFixes.sql
			 patch-25-UserFile.sql
			 patch-26-UserMenu.sql
	A bunch of patches being checked in at the same time here. 
	Patch 23 has some fixes for min/max characters in a story's intro and fixes
	for blank titles.
	Patch 24 has miscellaneous comment fixes.
	Patch 25 adds some permissions to eliminate file permission quirks.
	Patch 26 adds a copy of the userpref menu that fixes the file permission
	quirks and fixes the issue where the user pref menu would display pref
	pages on the menu that exist even if the user can't view or modify any of
	those prefs.  Because modifying an exisiting userpref_menu is bad, this
	adds a box called 'userpref_menu_file_pref' with these fixes. From this
	box, site administrators can add the fixes to their existing userpref_menu
	boxes without destroying the existing box.

Dec 17 21:00 patch-27-SpecialAdmin.sql
	Moves the special pages admin form to a block and adds the ability to see
	special pages as if the pageid were an op.

Jan 13 2006 13:38 patch-28-RequireTags.sql
	Adds a var to enable requiring tags for story posting.

Jan 13 15:50 patch-29-TUPerms.sql
	Adds a var to add perms that can be specifically checked by
	$S->have_perm() for trusted users, so we can use just that var and
	$S->have_perm, rather than mucking about with TRUSTLEV and super_mojo.

Jan 15 11:20 patch-30-TagEnhancements.sql
	Adds ops, boxes, and perms for adding and editing existing story tags,
	as well as an op for easily changing the order tags are displayed. If
	you upgrade to this, it is recommended that you make a "tag_template"
	block for the tag op from the index_template and add the 
	"tag_sort_change" box above |CONTENT|. Additionally, you should add the
	"tag_listing" box to your story_template - above the first
	"comment_controls" box is a good place.

Jan 15 14:53 patch-31-TagPermUpdate.sql
	Adds a perm, 'edit_story_tags', that was left out of patch 30. If you
	wish to allow trusted users, but not others, edit story tags, add
	'edit_story_tags' to the var 'tu_perms'.

Any problems, email scoop-help at lists.kuro5hin.org (don't forget to join!)
join here: http://lists.kuro5hin.org/mailman/listinfo/scoop-help
or if you irc look in #scoop on irc.slashnet.org.


--- NEW FILE: patch-03-CommentPost.sql ---
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('commentreply_display', '<table cellpadding="1" cellspacing="0" border="0" width="100\\%">\r\n  <tr>\r\n    <td bgcolor="%%title_bgcolor%%" width="100%">\r\n      %%title_font%%<b>Replying To:</b>%%title_font_end%%\r\n    </td>\r\n  </tr>\r\n  <tr>\r\n    <td>\r\n      %%replying_to%%\r\n    </td>\r\n  </tr>\r\n  <tr>\r\n    <td>\r\n      %%post_form%%\r\n    </td>\r\n  </tr>\r\n</table>\r\n', '1', '<P>This block lays out the comment post form. It recognises the following special keys:</P>\n<DL>\n <DT>replying_to</DT>\n  <DD>The story or comment the user is replying to.</DD>\n <DT>post_form</DT>\n  <DD>The actual comment posting form. This is laid out in the block <B>comment_post_form</B>.</DD>\n</DL>', 'Comments', 'default', 'en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('comment_not_logged_in', '<P>%%norm_font%%You are not logged in. If you don\'t have a user account yet, by all means <A HREF="%%rootdir%%/newuser">go make one</A>! If you do have one, you can post as "yourself" by filling in your nickname and password below. Otherwise, your comment will be posted as <B>$anon</B>.%%norm_font_end%%</P>\r\n\r\n<P>%%norm_font%%<A HREF="%%rootdir%%/newuser">Create Account</A>\r\n<BR>Nickname: <INPUT TYPE="text" SIZE="30" NAME="uname">\r\n<BR>Password: <INPUT TYPE="password" SIZE="30" NAME="pass">%%norm_font_end%%</P>\r\n', '1', '<P>This block contains the message and login form shown when an anonymous user tries to post a comment (if anonymous users can post comments). There are no special keys. The login form must have fields named "uname" and "pass".</P>', 'Comments', 'default', 'en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('comment_posted_display', '%%comment_controls%%\r\n<table cellpadding="1" cellspacing="0" border="0" width="100\\%">\r\n  <tr>\r\n    <td BGCOLOR="%%title_bgcolor%%">\r\n      %%title_font%%%%post_msg%%%%title_font_end%%\r\n    </td>\r\n  </tr>\r\n  <tr>\r\n    <td>\r\n      %%new_comment%%\r\n    </td>\r\n  </tr>\r\n</table>\r\n', '1', '<P>This block lays out the comment display after the comment has been posted. The special keys are:</P>\n<DL>\n <DT>comment_controls</DT>\n  <DD>the comment display options</DD>\n <DT>post_msg</DT>\n  <DD>If the user is untrusted (has a mojo below <B>rating_min</B>) the block <B>untrusted_post_message</B> is displayed here, otherwise the block <B>comment_posted_message</B></DD>\n <DT>new_comment</DT>\n  <DD>The comment just posted.</DD>\n</DL>', 'Comments', 'default', 'en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('comment_post_form', '<FORM NAME="postcomment" ACTION="%%rootdir%%/#here" METHOD="POST">\r\n  <TABLE WIDTH="100%" BORDER=0 CELLPADDING=0 CELLSPACING=0>\r\n    <TR>\r\n      <TD BGCOLOR="%%title_bgcolor%%" WIDTH="100%">\r\n        %%preview_msg%%\r\n      </TD>\r\n    </TR>\r\n    <TR>\r\n      <TD>\r\n        %%COMM_ERR%%\r\n        <P><!-- begin previewed comment -->\r\n        %%PRE_COMMENT%%\r\n        <!-- end previewed comment -->\r\n      </TD>\r\n    </TR>\r\n    <TR>\r\n      <TD BGCOLOR="%%title_bgcolor%%" WIDTH="100%">\r\n        <A NAME="%%here%%"><B>Post Comment</B></A>\r\n      </TD>\r\n    </TR>\r\n    <TR>\r\n      <TD>\r\n        <P>%%norm_font%%%%not_logged_in%%%%norm_font_end%%</P>\r\n        <P>%%norm_font%%%%commentdisclaimer%%%%norm_font_end%%</P>\r\n        %%formkey_element%%\r\n        <P>%%norm_font%%%%post_as%%%%norm_font_end%%</P>\r\n        %%pending_form%%\r\n   !
    </TD>\r\n    </TR>\r\n    <TR>\r\n      <TD>\r\n        %%norm_font%%Subject:%%norm_font_end%%<BR>\r\n        %%norm_font%%<INPUT TYPE="text" size=50 name="subject" VALUE="%%subject%%" maxlength=50>%%norm_font_end%%\r\n      </TD>\r\n    </TR>\r\n    <TR>\r\n      <TD>\r\n        %%norm_font%%Comment:%%norm_font_end%%<BR>\r\n        %%norm_font%%<TEXTAREA NAME="comment" COLS=%%textarea_cols%% ROWS=%%textarea_rows%% WRAP="soft">%%comment_body%%</TEXTAREA>%%norm_font_end%%\r\n      </TD>\r\n    </TR>\r\n    <TR>\r\n      <TD>\r\n        %%spellcheck_form%%\r\n      </TD>\r\n    </TR>\r\n    <TR>\r\n      <TD>\r\n        %%sig_behavior_form%%\r\n      </TD>\r\n    </TR>\r\n    <TR>\r\n      <TD>%%norm_font%%\r\n        <INPUT TYPE="submit" NAME="preview" VALUE="Preview">\r\n        %%post_opt%%\r\n        <INPUT TYPE="submit" NAME="post" VALUE="Post">\r\n        %%norm_font_end%%\r\n      </TD>\r\n    </TR>\r\n    <TR>\r\n      <TD>\r\n        %%allow_tags%%\r\n      </TD>\!
 r\n    </TR>\r\n  </TABLE>\r\n</FORM>', '1', '<P>This block lays out t
he comment post form. The following form elements are used:</P>\n<DL>\n <DT>subject</DT>\n  <DD>The form field for the comment subject. Generally a regular text input.</DD>\n <DT>comment</DT>\n  <DD>The form field for the comment body. Generally a textarea.</DD>\n <DT>preview</DT>\n  <DD>The "preview" button. Value can be anything that isn\'t a perl false value (zero or empty string)</DD>\n <DT>post</DT>\n  <DD>The "post" button. Value can be anything that isn\'t a perl false value (zero or empty string)</DD>\n</DL>\n<P>The following special keys are used:</P>\n<DL>\n <DT>sid</DT>\n  <DD>The sid of the story the comment will be attached to</DD>\n <DT>pid</DT>\n  <DD>The comment ID of the comment being replied to</DD>\n <DT>preview_msg</DT>\n  <DD>The contents of the block <B>comment_preview_msg</B>, if there\'s a comment currently being previewed.</DD>\n <DT>COMM_ERR</DT>\n  <DD>Any error messages generated during the post or preview process.</DD>\n <DT>PRE_COMMENT</DT>\n  <!
 DD>The formatted comment being previewed</DD>\n <DT>here</DT>\n  <DD>Either "here" (if there\'s no comment being previewed) or "there" (if there is) so that the anchors work out properly</DD>\n <DT>not_logged_in</DT>\n  <DD>The contents of the block <B>comment_not_logged_in</B> if the user is not currently logged in</DD>\n <DT>formkey_element</DT>\n  <DD>The formkey for the comment post form</DD>\n <DT>post_as</DT>\n  <DD>If anonymous users are allowed to post and the user is logged in, this is a selectbox that allows the user to choose whether to post anonymously or not</DD>\n <DT>pending_form</DT>\n  <DD>If the story is still in the queue, this is a selectbox that allows the user to choose whether to post an editorial or topical comment.</DD>\n <DT>subject</DT>\n  <DD>The comment\'s subject, used as a default value for the subject form element</DD>\n <DT>textarea_cols</DT>\n  <DD>The user preference for size of the textarea</DD>\n <DT>textarea_rows</DT>\n  <DD>The user pr!
 eference for size of the textarea</DD>\n <DT>comment_body</DT>\n  <DD>
The comment\'s body, used as a default value for the comment form element</DD>\n <DT>spellcheck_form</DT>\n  <DD>The contents of the block <B>spellcheck_form_item</B> if spellcheck is turned on</DD>\n <DT>sig_behavior_form</DT>\n  <DD>A form element that allows users to choose whether or how to display their sig, if permitted and if they have a sig</DD>\n <DT>post_opt</DT>\n  <DD>A form element that allows users to choose which post mode (plain text, autoformat, html) they want to use</DD>\n <DT>allow_tags</DT>\n  <DD>The "allowed HTML"</DD>\n</DL>', 'Comments', 'default', 'en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('comment_preview_msg', '%%title_font%%<A NAME="here">Preview Comment</A>%%title_font_end%%', '1', '<P>This is the "Preview Comment" title bar. Make sure it has an anchor named "here" in it. There are no special keys.</P>', 'Comments', 'default', 'en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('spellcheck_form_item', '%%norm_font%%Spellcheck text (will force "Preview"): <INPUT TYPE="checkbox" NAME="spellcheck" VALUE="on"%%checked%%>%%norm_font_end%%', '1', '<P>This is the form element displayed when spellcheck is available. There is one special key, checked, which makes the checkbox pre-checked or not, depending on user action or preferences.</P>', 'Comments', 'default', 'en');
UPDATE blocks SET block='<A NAME="here">Comment posted!</A> Thank you for contributing.' WHERE bid='comment_posted_message';
UPDATE blocks SET description='<P>This block is displayed after a user has successfully posted a message. It should contain a message telling the user so. There are no special keys.</P>' WHERE bid='comment_posted_message';

--- NEW FILE: patch-04-UserPrefs.sql ---
-- Table structure for userprefs definitions

CREATE TABLE pref_items (
  prefname varchar(32) NOT NULL default '',
  title varchar(50) NOT NULL default '',
  description text,
  visible int(1) default '0',
  html int(1) default '0',
  perm_view varchar(32),
  perm_edit varchar(32),
  var varchar(32),
  req_tu int(1) default '0',
  default_value text,
  length int(5),
  regex text,
  page varchar(50),
  field text,
  display_order int(5),
  template varchar(30),
  display_fmt text,
  enabled int(1) default '1',
  required int(1) default '0',
  PRIMARY KEY (prefname),
  KEY page_idx (page)
);
-- field req_tu is "temporary" until perms are re-done so that TU status can give somebody arbitrary perms, one of which is seeing hidden comments

-- pref_items data
-- default values for some prefs will be pulled from vars in the -post script 
-- but are set to sensible values here in case of missing vars in the target db.

-- User Info page stuff
INSERT INTO pref_items VALUES ('admin_notes', 'Admin Notes', 'Information about the user that only site administrators can see', '1', '1', 'edit_user', 'edit_user', 'allow_admin_notes', '0', '', '', '', 'User Info', '<textarea COLS="50" ROWS="5" NAME="admin_notes" WRAP="soft">%%value%%</textarea>','3', 'text_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('fakeemail', 'Email', 'This is the address that will be displayed in comments and in your user info. It will not be used to email forgotten passwords. You may want to add some kind of spam protection so that harvesters cannot parse it.', '1', '0', '', '', '', '0', '', '50', '', 'User Info', '<input TYPE="text" SIZE="50" NAME="fakeemail" VALUE="%%value%%">', '5', 'text_pref', '<A href="mailto:%%value%%">%%value%%</A>', '1', '0');
INSERT INTO pref_items VALUES ('homepage', 'Homepage', 'If you have a homepage, enter the address here and it will be added to your comments and user info. The full path is required: remember the "http://"!', '1', '0', '', '', '', '0', '', '100', '^http', 'User Info', '<input TYPE="text" SIZE="50" NAME="homepage" VALUE="%%value%%">', '6', 'text_pref', '<A href="%%value%%">%%value%%</A>', '1', '0');
INSERT INTO pref_items VALUES ('bio', 'Bio', 'Enter any kind of biographical information you want other users to see about yourself here.', '1', '1', '', '', '', '0', '', '255', '', 'User Info', '<textarea COLS="50" ROWS="5" WRAP="soft" NAME="bio">%%value%%</textarea>', '7', 'text_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('publickey', 'Public Key', 'If you have a PGP/GPG public key (used for encrypting and signing email), paste it in here.', '1', '0', '', '', '', '0', '', '', '', 'User Info', '<textarea COLS="50" ROWS="5" NAME="publickey">%%value%%</textarea>', '8', 'text_pref', '<pre>%%value%%</pre>', '1', '0');

-- Interface page stuff
INSERT INTO pref_items VALUES ('upload_user_quota', 'Disk Quota', 'The maximum amount of space this user can take up with his uploaded files (in kb)', '0', '0', '', 'edit_user', 'allow_uploads', '0', '0', '', '\\d+', 'Interface', '<INPUT type="text" name="upload_user_quota" value="%%value%%" size="5">', '0', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('upload_max_file_size', 'Max File Size', 'The maximum size a single file can be (in kb)', '0', '0', '', 'edit_user', 'allow_uploads', '0', '0', '', '\\d+', 'Interface', '<INPUT type="text" name="upload_max_file_size" value="%%value%%" size="5">', '0', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('digest', 'Story Digest', 'Story headlines and intros can be emailed to you at your real email address on the schedule you choose.', '0', '0', '', '', 'enable_story_digests', '0', 'Never', '10', '(Never|Daily|Weekly|Monthly)', 'Interface', '%%BOX,pref_selectbox,digest,%%value%%,Never,Daily,Weekly,Monthly%%', '1', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('time_zone', 'Your Time Zone', 'Setting your (non-daylight savings) time zone here will make the site display all times and dates in your local time', '0', '0', '', '', '', '0', 'est', '4', '[a-zA-z]+', 'Interface', '%%BOX,time_zone_pref,%%value%%%%', '2', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('maxstories', 'Number of story summaries to show', '(on front page)', '0', '0', '', '', '', '0', '8', '3', '\\d+', 'Interface', '<input type="text" size="5" name="maxstories" value="%%value%%">', '3', 'text_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('maxtitles', 'Number of story titles to show', '(in "older stories" box)', '0', '0', '', '', '', '0', '10', '3', '\\d+', 'Interface', '<input type="text" size="5" name="maxtitles" value="%%value%%">', '4', 'text_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('textarea_cols', 'Text box width', 'This allows you to set how big of a text box you have to type stories and comments into.', '0', '0', '', '', '', '0', '60', '4', '\\d+', 'Interface', '<input type="text" size="5" name="textarea_cols" value="%%value%%">', '5', 'text_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('textarea_rows', 'Text box height', 'This allows you to set how big of a text box you have to type stories and comments into.', '0', '0', '', '', '', '0', '20', '4', '\\d+', 'Interface', '<input type="text" size="5" name="textarea_rows" value="%%value%%">', '6', 'text_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('norm_font_face', 'Font Face', '', '0', '0', '', '', '', '0', 'verdana, arial, helvetica, sans-serif', '', '[a-zA-z,\\s]', 'Interface', '<input type="text" size="30" name="norm_font_face" value="%%value%%" />', '7', 'text_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('norm_font_size', 'Font Size', '', '0', '0', '', '', '', '0', '2', '5', '\\w+', 'Interface', '<input type="text" size="5" name="norm_font_size" value="%%value%%">', '8', 'text_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('showad', 'Show ads', '', '0', '0', '', 'ad_opt_out', 'use_ads', '0', 'All', '16', '^(on|off)$', 'Interface', '%%BOX,pref_checkbox,showad,%%value%%%%', '9', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('ad_open_new_win', 'Open advertisement clicks in new window', '', '0', '0', '', '', 'use_ads', '0', 'off', '3', '^(on|off)$', 'Interface', '%%BOX,pref_checkbox,ad_open_new_win,%%value%%%%', '10', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('show_topic', 'Show topic images with stories', '', '0', '0', '', '', 'use_topics', '0', 'on', '3', '^(on|off)$', 'Interface', '%%BOX,pref_checkbox,show_topic,%%value%%%%', '11', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('start_page', 'Start page', '', '0', '0', '', '', '', '0', '__main__', '', '\\w+', 'Interface', '%%BOX,startpage_pref,%%value%%%%', '12', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('online_cloak', 'Hide yourself in the Who\'s Online box', '', '0', '0', '', '', 'use_whosonline', '0', 'off', '3', '^(on|off)$', 'Interface', '%%BOX,pref_checkbox,online_cloak,%%value%%%%', '13', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('dynamic_interface', 'Use dynamic interface elements', 'This turns on javascript-driven items such as dynamic comment mode', '0', '0', '', '', 'allow_dynamic_comment_mode', '0', 'off', '3', '^(on|off)$', 'Interface', '%%BOX,pref_checkbox,dynamic_interface,%%value%%%%', '14', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('spellcheck_default', 'Spellcheck posts by default', '', '0', '0', '', 'use_spellcheck', 'spellcheck_enabled', '0', 'off', '3', '^(on|off)$', 'Interface', '%%BOX,pref_checkbox,spellcheck_default,%%value%%%%', '15', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('speling', 'Spelling variant', '', '0', '0', '', 'use_spellcheck', 'spellcheck_enabled', '0', 'American', '8', '(American|Canadian|British)', 'Interface', '%%BOX,pref_selectbox,speling,%%value%%,American,Canadian,British%%', '16', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('imagedir', 'Preferred image server', 'Choose an image server closest to you for the quickest page load times', '0', '0', '', '', 'use_alt_image_servers', '0', '/images', '', '', 'Interface', '%%BOX,img_server_pref,%%value%%%%', '17', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('theme', 'Use which theme', '', '0', '0', '', '', 'allow_user_themes', '0', '', '', '\\w+', 'Interface', '%%BOX,user_theme_pref,%%value%%%%', '18', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('cookie_expire', 'Cookie Expiry', 'How long does your login cookie last?', '0', '0', '', '', '', '', '2592000', '', '', 'Interface', '%%BOX,cookie_expire_pref,%%value%%%%', '19', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('displayed_boxes', 'Boxes', '', '0', '0', '', '', '', '', 'hotlist_box,poll_box,rdf_feeds,whos_online', '', '', 'Interface', '%%BOX,box_pref,%%value%%%%', '20', 'text_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('max_rdf_titles', 'Maximum headlines per feed', '', '0', '0', '', '', 'use_rdf_feeds', '0', '15', '2', '\\d+', 'Interface', '<input type="text" name="max_rdf_titles" value="%%value%%" size="5">', '21', 'text_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('rdf_feeds', 'External Feeds', '[<a href="%%rootdir%%/submitrdf">Submit New Feed</A>]', '0', '0', '', '', 'use_rdf_feeds', '', '', '', '', 'Interface', '%%BOX,rdf_pref,%%value%%%%', '22', 'text_pref', '', '1', '0');

-- Comment prefs page stuff
INSERT INTO pref_items VALUES ('commentmode', 'Comment display mode', '', '0', '0', '', '', '', '0', 'threaded', '', '(use_overflow|minimal|dminimal|threaded|dthreaded|nested|flat|flat_unthread)', 'Comments', '%%BOX,commentmode_pref,%%value%%%%', '1', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('commentmode_overflow_at', 'Change to overflow mode at', '', '0', '0', '', '', '', '0', '200', '', '\\d+', 'Comments', '<input type="text" size="10" name="commentmode_overflow_at" value="%%value%%">', '2', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('commentmode_overflow', 'Comment display mode (overflow)', 'Comment display modes:\n<UL>\n <LI>flat (unthreaded): straight chronological order</LI>\n <LI>flat: comments and replies grouped, but not indented</LI>\n <LI>minimal: titles only, replies indented</LI>\n <LI>threaded: top-level comments expanded, all other titles only, replies indented</LI>\n <LI>nested: all comments shown in full, replies indented</LI>\n</UL>', '0', '0', '', '', '', '0', 'threaded', '', '(minimal|dminimal|threaded|dthreaded|nested|flat|flat_unthread)', 'Comments', '%%BOX,commentmode_overflow_pref,%%value%%%%', '3', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('commenttype', 'Types of comments to display', '', '0', '0', '', '', '', '0', 'mixed', '10', '(mixed|topical|editorial|all|none)', 'Comments', '%%BOX,pref_selectbox,commenttype,%%value%%,mixed,topical,editorial,all,none%%', '4', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('commentrating', 'Sorting based on comment ratings', '', '0', '0', '', '', 'use_ratings', '0', 'highest', '15', '(unrate_highest|highest|lowest|dontcare)', 'Comments', '%%BOX,rating_order_pref,%%value%%%%', '5', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('commentorder', 'Sorting based on comment age', '', '0', '0', '', '', '', '0', 'oldest', '6', '(newest|oldest)', 'Comments', '%%BOX,pref_selectbox,commentorder,%%value%%,newest,oldest%%', '6', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('ratingchoice', 'Rate comments', '', '0', '0', '', 'comment_rate', 'use_ratings', '0', 'yes', '4', '(yes|no|hide)', 'Comments', '%%BOX,pref_selectbox,ratingchoice,%%value%%,yes,no,hide%%', '7', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('hidingchoice', 'Show hidden comments', '', '0', '0', '', '', 'use_ratings', '1', 'yes', '11', '(yes|no|untilrating)', 'Comments', '%%BOX,show_hidden_pref,%%value%%%%', '8', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('posttype', 'Post mode', '', '0', '0', '', '', '', '0', 'auto', '4', '(text|html|auto)', 'Comments', '%%BOX,postmode_pref,%%value%%%%', '9', 'selectbox_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('sig', 'Signature', 'This will get attached to your comments. Sigs are typically used for quotations or links', '0', '1', '', 'comment_post', '', '0', '', '160', '', 'Comments', '<textarea COLS="50" ROWS="5" WRAP="soft" NAME="sig">%%value%%</textarea>', '10', 'text_pref', '', '1', '0');
INSERT INTO pref_items VALUES ('sig_behavior', 'Signature type', '', '0', '0', '', 'comment_post', 'allow_sig_behavior', '0', 'retroactive', '11', '(retroactive|sticky|none)', 'Comments', '%%BOX,pref_selectbox,sig_behavior,%%value%%,retroactive,sticky,none%%', '11', 'selectbox_pref', '', '1', '0');

-- changes to users table
-- data in these fields will be fetched from users table and put into userprefs table in -pre script

ALTER TABLE users DROP COLUMN fakeemail;
ALTER TABLE users DROP COLUMN homepage;
ALTER TABLE users DROP COLUMN bio;
ALTER TABLE users DROP COLUMN publickey;
ALTER TABLE users DROP COLUMN admin_notes;
ALTER TABLE users DROP COLUMN sig;

-- fields that don't seem to be used at all 
-- (all null, blank, or 0 in the db, not used in code or box as far as I can tell)
ALTER TABLE users DROP COLUMN realname;
ALTER TABLE users DROP COLUMN mode;
ALTER TABLE users DROP COLUMN posttype;
ALTER TABLE users DROP COLUMN mailreplies;
ALTER TABLE users DROP COLUMN threshold;
ALTER TABLE users DROP COLUMN score;
ALTER TABLE users DROP COLUMN points;
ALTER TABLE users DROP COLUMN commentsort;
ALTER TABLE users DROP COLUMN defaultpoints;
ALTER TABLE users DROP COLUMN perms;

-- admin tools entry
INSERT INTO admin_tools (tool, pos, dispname, menuname, perm, func, is_box) VALUES ('prefs', '21', 'User Preferences', 'User Preferences', 'edit_prefs', 'edit_prefs', '0');

-- new blocks
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('invalid_user_msg', 'Sorry, I can\'t seem to find that user', '1', '<P>The error message displayed when somebody requests a page for a user that doesn\'t exist</P>', 'Accounts', 'default', 'en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('selectbox_pref', '<DIV class="item">\r\n<P><B>%%required%%%%title%%:</B> %%control%%\r\n<BR>%%description%%</P>\r\n</DIV>', '1', '<P>The preference item template generally used for selectboxes. This should be a self-contained bit of HTML as it is used to display a single user preference, both on the user info page and the preferences edit forms. The following special keys are recognised:</P>\n<DL>\n <DT>required</DT>\n  <DD>If the preference is required, the contents of <B>required_pref_marker</B>, otherwise blank</DD>\n <DT>title</DT>\n  <DD>The displayed title of the preference, as set in the User Preferences Admin Tool</DD>\n <DT>control</DT>\n  <DD>On the preferences edit form, this is the form field required for the preference, as set in the User Preferences Admin Tool. On the user info page, this is the value of the preference</DD>\n <DT>description</DT>\n  <DD>On the preferences edit!
  form, this is the description as entered in the User Preferences Admin Tool. On the user info page, this is not displayed.</DD>\n <DT>allowed_html</DT>\n  <DD>If the preference supports HTML, displays the "Allowed HTML" string.</DD>\n</DL>', 'Accounts', 'default', 'en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('text_pref', '<DIV class="item">\r\n<P><B>%%required%%%%title%%:</B> %%description%%\r\n<BR>%%allowed_html%%\r\n<BR>%%control%%</P>\r\n</DIV>', '1', '<P>The preference item template generally used for text boxes. This should be a self-contained bit of HTML as it is used to display a single user preference, both on the user info page and the preferences edit forms. The following special keys are recognised:</P>\n<DL>\n <DT>required</DT>\n  <DD>If the preference is required, the contents of <B>required_pref_marker</B>, otherwise blank</DD>\n <DT>title</DT>\n  <DD>The displayed title of the preference, as set in the User Preferences Admin Tool</DD>\n <DT>control</DT>\n  <DD>On the preferences edit form, this is the form field required for the preference, as set in the User Preferences Admin Tool. On the user info page, this is the value of the preference</DD>\n <DT>description</DT>\n  <DD>On th!
 e preferences edit form, this is the description as entered in the User Preferences Admin Tool. On the user info page, this is not displayed.</DD>\n <DT>allowed_html</DT>\n  <DD>If the preference supports HTML, displays the "Allowed HTML" string.</DD>\n</DL>', 'Accounts', 'default', 'en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('user_admin', '<DIV class="admin_prefs">\r\n<P><B>Nickname:</B> <INPUT type="text" length="30" name="nickname" value="%%nickname%%">\r\n</P>\r\n<P><B>User ID:</B> %%uid%%</P>\r\n<P><B>User group:</B> %%BOX,user_group_box,%%perm_group%%%%</P>\r\n<P><B>Original Email:</B> %%origemail%%</P>\r\n<P><B>Created At:</B> %%creation_time%%</P>\r\n<P><B>Original IP:</B> %%creation_ip%%</P>\r\n<P><B>User\'s current mojo:</B> %%mojo%%</P>\r\n</DIV>', '1', '<P>This block displays admin-only user info on the Protected user preference page. This should be a self-contained block of HTML. It is displayed just above the real email and password fields on the Protected user preference page for users with the <B>edit_user</B> perm only. The following special keys are recognised:</P>\n<DL>\n <DT>nickname</DT>\n  <DD>The nickname of the user being edited</DD>\n <DT>perm_group</DT>\n  <DD>The current group of the us!
 er being edited</DD>\n <DT>origemail</DT>\n  <DD>The email address used when the account was created</DD>\n <DT>creation_time</DT>\n  <DD>The date and time the account was created</DD>\n <DT>creation_ip</DT>\n  <DD>The IP address the account was created from</DD>\n <DT>mojo</DT>\n  <DD>The user\'s current mojo</DD>\n</DL>', 'Accounts', 'default', 'en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('user_pass', '<DIV class="prefs">\r\n<P><B><font color="#ff0000">Protected settings</font></B>\r\n%%passwd%%\r\n<P><B>Real Email:</B> <INPUT type="text" name="realemail" value="%%realemail%%">\r\n<BR>This is the address that will be used to email forgotten passwords. It will not be shown anywhere. Please do not insert any kind of spam protection here, or you will not be able to get a new password!</P>\r\n\r\n<P><B>New Password:</B> Leave both fields blank for no change. This is asked twice to detect typos.\r\n<BR>New Password: <INPUT TYPE="password" SIZE="30" NAME="pass1">\r\n<BR>Confirm: <INPUT TYPE="password" SIZE="30" NAME="pass2">\r\n</DIV>', '1', '<P>This block displays the user portion of the Protected user preferences page. The following special keys are recognised:</P>\n<DL>\n <DT>passwd</DT>\n  <DD>The entire form field for password entry. If it is a user\'s first login, the form fi!
 eld is hidden.</DD>\n <DT>realemail</DT>\n  <DD>The current value of the user\'s real email</DD>\n</DL>', 'Accounts', 'default', 'en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('user_info_page', '%%title_font%%User Info%%title_font_end%%\r\n%%BOX,userpref_menu%%\r\n<DIV>\r\n%%trusted_msg%%\r\n%%BOX,subscriber%%\r\n%%itemlist%%\r\n</DIV>', '1', '<P>This block contains the content column template for the displayed user info page. It should be self-contained HTML and contain the page title (the title bar most pages have, just under the header). The following special keys are recognised:</P>\n<DL>\n <DT>trusted_msg</DT>\n  <DD>If the user is trusted and viewing his own user info page, the contents of the block <B>trusted_info_message</B> are displayed.</DD>\n <DT>itemlist</DT>\n  <DD>Those user preferences which are visible and have some value, each formatted by their pref template</DD>\n</DL>', 'Accounts', 'default', 'en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('user_pref_page', '%%title_font%%User Preferences: %%page%%%%title_font_end%%\r\n%%BOX,userpref_menu%%\r\n%%message%%\r\n<DIV>\r\n<FORM action="%%rootdir%%/user/%%nick%%/prefs/%%page%%" method="post">\r\n%%formkey%%\r\n\r\n%%itemlist%%\r\n\r\n<INPUT type="submit" name="write" value="Save Preferences">\r\n%%userpref_reset%%\r\n</FORM>\r\n</DIV>', '1', '<P>This block contains the content column template for the user preference edit pages. It should be self-contained HTML and contain the page title (the title bar most pages have, just under the header). The following special keys are recognised:</P>\n<DL>\n <DT>page</DT>\n  <DD>The name of the preference page currently being edited</DD>\n <DT>nick</DT>\n  <DD>The nickname of the user currently being edited</DD>\n <DT>formkey</DT>\n  <DD>A formkey, for a bit of security (mostly against double-clicks on the save button)</DD>\n <DT>message</DT>\n !
  <DD>Any status or error messages generated by an attempt to save or reset the preferences</DD>\n <DT>itemlist</DT>\n  <DD>The preferences for this page, formatted by their pref item templates</DD>\n <DT>userpref_reset</DT>\n  <DD>The contents of the block <B>userpref_reset</B> (a reset button) if the current page is anything other than Protected; the Protected page has no reset button.</DD>\n</DL>', 'Accounts', 'default', 'en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('firstlogin_message', '<p><b>Welcome to %%sitename%%!</b> As this is your first login, you probably want to change your password below or some of the settings on the other preference pages. None of these changes are required, but we do recommend at least changing your password. Enjoy your stay.</p>\r\n<p>If you don\'t want to make any changes, you can <a href="%%rootdir%%/">go to the front page</a>.</p>', '1', '<P>This block is displayed at the top of the Protected settings page the first time a user logs in, if the variable <B>show_prefs_on_first_login</B> is on. It should be self-contained HTML that encourages the new user to change his password and explore the other preference pages. There are no special keys.</P>', 'Accounts', 'default', 'en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('formkey_err', 'Invalid form key. You probably tried to save your settings more than once. Do not hit "BACK"! If you are certain that your settings have not been saved, try to save them from this screen.', '1', '<P>The error message displayed if there is a formkey error, such as a user double-clicking a button or going too long between loading the form and submitting it.</P>', 'Accounts', 'default', 'en');
INSERT IGNORE INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('empty_box', '%%content%%', '1', '<P>A box template with nothing but the content special key</P>', 'Box Templates', 'default', 'en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('edit_prefs','%%title_font%%Edit User Preferences%%title_font_end%%\r\n\r\n<P>%%err_font%%%%update_msg%%%%err_font_end%%</P>\r\n\r\n<FORM action="%%rootdir%%/admin/prefs" method="post">\r\n<INPUT type="submit" name="save" value="Save">\r\n<INPUT type="submit" name="get" value="Get">\r\n\r\n<TABLE border="0">\r\n  <TR>\r\n    <TD><B>Select Preference:</B></TD>\r\n    <TD>%%pref_selectbox%%</TD>\r\n  </TR>\r\n  <TR>\r\n    <TD colspan="2"><B>Delete:</B> <INPUT type="checkbox" name="delete" value="1"> Many prefs should be disabled (not deleted) if you want to prevent users from changing them, as Scoop requires their default values in order to run correctly.</TD>\r\n  </TR>\r\n  <TR>\r\n    <TD><B>Name:</B></TD>\r\n    <TD><INPUT type="text" size="20" maxlength="32" name="prefname" value="%%pref_name%%"> <B>Enabled:</B><INPUT type="checkbox" name="enabled" value="1"%%pref_enabled%%> <B>Required:!
 </B><INPUT type="checkbox" name="required" value="1"%%pref_required%%></TD>\r\n  </TR>\r\n  <TR>\r\n    <TD><B>Title:</B></TD>\r\n    <TD><INPUT type="text" size="50" maxlength="50" name="title" value="%%pref_title%%"></TD>\r\n  </TR>\r\n  <TR>\r\n    <TD><B>Description:</B>\r\n      <BR>The description may contain any HTML or normal block reference.</TD>\r\n    <TD><TEXTAREA rows="%%rows%%" cols="%%cols%%" name="description">%%pref_desc%%</TEXTAREA></TD>\r\n  </TR>\r\n  <TR>\r\n    <TD><B>Default Value:</B></TD>\r\n    <TD><INPUT type="text" size="30" name="default_value" value="%%pref_default%%"></TD>\r\n  </TR>\r\n  <TR>\r\n    <TD colspan="2">&nbsp;</TD>\r\n  </TR>\r\n  <TR>\r\n    <TD colspan="2"><B>Preference Display Settings</B></TD>\r\n  </TR>\r\n  <TR>\r\n    <TD><B>Preferences page:</B></TD>\r\n    <TD><INPUT type="text" size="20" maxlength="50" name="page" value="%%pref_page%%"></TD>\r\n  </TR>\r\n  <TR>\r\n    <TD><B>Order on page:</B></TD>\r\n    <TD><INPUT typ!
 e="text" size="5" maxlength="5" name="display_order" value="%%pref_ord
er%%"></TD>\r\n  </TR>\r\n  <TR>\r\n    <TD><B>Control to display:</B>\r\n      <BR>Special key <I>value</I> is the current value of the preference</TD>\r\n    <TD><INPUT type="text" size="50" name="field" value="%%pref_field%%"></TD>\r\n  </TR>\r\n  <TR>\r\n    <TD><B>Template:</B></TD>\r\n    <TD>%%pref_template%%</TD>\r\n  </TR>\r\n  <TR>\r\n    <TD><B>Visible on public user info page?</B></TD>\r\n    <TD><INPUT type="checkbox" name="visible" value="1"%%pref_visible%%></TD>\r\n  </TR>\r\n  <TR>\r\n    <TD><B>Formatting to apply to value</B></TD>\r\n    <TD><INPUT type="text" name="display_fmt" value="%%pref_fmt%%" size="50"></TD>\r\n  </TR>\r\n  <TR>\r\n    <TD colspan="2">&nbsp;</TD>\r\n  </TR>\r\n  <TR>\r\n    <TD colspan="2"><B>Requires</B></TD>\r\n  </TR>\r\n  <TR>\r\n    <TD><B>Site Control:</B></TD>\r\n    <TD>%%pref_var%%</TD>\r\n  </TR>\r\n  <TR>\r\n    <TD><B>Perm to view:</B></TD>\r\n    <TD>%%pref_perm_view%%</TD>\r\n  </TR>\r\n  <TR>\r\n    <TD><B>Perm to edit!
 :</B></TD>\r\n    <TD>%%pref_perm_edit%%</TD>\r\n  </TR>\r\n  <TR>\r\n  <TD><B>Trusted User status:</B></TD>\r\n    <TD><INPUT type="checkbox" name="req_tu" value="1"%%pref_tu%%></TD>\r\n  </TR>\r\n  <TR>\r\n    <TD colspan="2">&nbsp;</TD>\r\n  </TR>\r\n  <TR>\r\n    <TD colspan="2"><B>Validation</B> (blank to allow anything)</TD>\r\n  </TR>\r\n  <TR>\r\n    <TD><B>HTML allowed?</B></TD>\r\n    <TD><INPUT type="checkbox" name="html" value="1"%%pref_html%%></TD>\r\n  </TR>\r\n  <TR>\r\n    <TD><B>Field length:</B></TD>\r\n    <TD><INPUT type="text" size="5" maxlength="5" name="length" value="%%pref_length%%"></TD>\r\n  </TR>\r\n  <TR>\r\n    <TD><B>Regular expression:</B>\r\n      <BR>Perl regexp - but you must escape pipes</TD>\r\n    <TD><INPUT type="text" size="50" name="regex" value="%%pref_regex%%"></TD>\r\n  </TR>\r\n</TABLE>\r\n\r\n<INPUT type="submit" name="save" value="Save">\r\n<INPUT type="submit" name="get" value="Get">\r\n</FORM>\r\n','1','','Admin Pages','defau!
 lt','en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('userpref_reset', '<INPUT type="submit" name="reset" value="Reset Preferences">', '1', '<P>This block contains the reset button for the userpref pages. The button must be named "reset" but you can otherwise change how it looks.</p>', 'Accounts', 'default', 'en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('userpref_oldpass_field', 'You must enter your account password to change protected settings.\r\n<BR><B>Password:</B><INPUT TYPE="password" SIZE="30" NAME="verify_me"></P>\r\n', '1', '<P>This block is the description and form element in which the user enters his old password to change protected settings. On the user\'s first login, the block <B>userpref_oldpass_hidden</B> is used instead.</P>', 'Accounts', 'default', 'en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('userpref_oldpass_hidden', '<INPUT TYPE="hidden" NAME="verify_me" value="%%pass%%">', '1', '<P>This block is the hidden form element containing the user\'s old password. It is only used on the user\'s first login; the block <B>userpref_oldpass_field</B> is used the rest of the time.</P>', 'Accounts', 'default', 'en');
INSERT INTO blocks (bid, block, aid, description, category, theme, language) VALUES ('required_pref_marker', '<FONT color="#ff0000">*</FONT>', '1', '', 'Accounts', 'default', 'en');

-- new boxes 
INSERT INTO box (boxid, title, content, description, template) VALUES ('userpref_menu', '', 'my $edit = 0;\r\nmy $return = \'\';\r\nmy $nick = $S->param->{nick};\r\nmy $tool = $S->param->{tool} || \'info\';\r\nmy $admin_edit = \'\';\r\n\r\n# first, do we have permission to edit \r\n# this user\'s prefs?\r\n\r\nif ( $S->{UID} == $S->param->{uid} || $S->have_perm(\'edit_user\') ) {\r\n  $edit = 1;\r\n}\r\n\r\n$admin_edit = qq{[<A href="%%rootdir%%/user/$nick/prefs">edit user</A>]} if ($S->have_perm(\'edit_user\'));\r\n\r\n# links to create\r\nmy $links = "<P>$admin_edit ${nick}\'s ";\r\n\r\n# user info pages\r\nif ( $tool eq \'info\' ) {\r\n  $links .= qq{\r\n     <A href="%%rootdir%%/user/$nick">Info</A>};\r\n  $links .= qq{\r\n     <A href="%%rootdir%%/user/$nick/comments">Comments</A>};\r\n  $links .= qq{\r\n     <A href="%%rootdir%%/user/$nick/stories">Stories</A>};\r\n\r\n  if ( $S->{UI}->{VARS}->{use_diaries} ) {\r\n    $links .= qq{\r\n     <A href="%%rootdir%%/user/$ni!
 ck/diary">Diary</A>};\r\n  }\r\n\r\n  if ( $S->{UI}->{VARS}->{use_ratings} ) {\r\n    $links .= qq{\r\n     <A href="%%rootdir%%/user/$nick/ratings">Ratings</A>};\r\n  }\r\n\r\n  if ( $S->{UI}->{VARS}->{allow_uploads} ) {\r\n    $links .= qq{\r\n     <A href="%%rootdir%%/user/$nick/files">Files</A>};\r\n  }\r\n\r\n  if ( $S->{UI}->{VARS}->{use_ads} ) {\r\n    $links .= qq{\r\n     <A href="%%rootdir%%/user/$nick/ads">Ads</A>};\r\n  }\r\n\r\n  $return = $links . "</P>";\r\n} elsif ( $edit && $tool eq \'prefs\' ) {\r\n  my %editlinks;\r\n  my ($rv, $sth) = $S->db_select({\r\n               WHAT => \'page\',\r\n               FROM => \'pref_items\',\r\n               GROUP_BY => \'page\'\r\n  });\r\n  while (my ($item) = $sth->fetchrow_array()) {\r\n    $editlinks{"$item"} = "%%rootdir%%/user/$nick/prefs/$item";\r\n  }\r\n  $links .= qq{\r\n     <A href="%%rootdir%%/user/$nick/prefs/Protected">Protected</A>};\r\n\r\n  foreach my $item (sort {$b cmp $a} keys %editlinks) {\r\n  !
   $links .= qq{\r\n   <A href="$editlinks{$item}">$item</A>};\r\n  }\r
\n  $return = $links . "</P>";\r\n}\r\n\r\nreturn $return;\r\n', 'navigation for user pref pages', 'empty_box');
INSERT INTO box (boxid, title, content, description, template) VALUES ('pref_selectbox', '', 'my $prefname = shift @ARGS;\r\nmy $choice = shift @ARGS;\r\nmy @choices = @ARGS;\r\n\r\nmy $select = qq{\r\n      <SELECT name="$prefname" size="1">};\r\n\r\nforeach my $c (@choices) {\r\n  my $checked = ($c eq $choice) ? \' SELECTED\' : \'\';\r\n  $select .= qq{\r\n        <OPTION value="$c"$checked>$c</OPTION>};\r\n}\r\n\r\n$select .= qq{\r\n      </SELECT>};\r\n\r\nreturn $select;', 'Generic select box for user preferences. takes parameters name,value,option1,option2,...\r\nNot suitable for select boxes with code-generated option lists.', 'empty_box');
INSERT INTO box (boxid, title, content, description, template) VALUES ('pref_checkbox', '', 'my $prefname = $ARGS[0];\r\nmy $choice = $ARGS[1];\r\n\r\nmy $selected = ($choice eq \'on\') ? \' CHECKED\' : \'\';\r\n\r\nreturn qq{<INPUT type="checkbox" name="$prefname" value="on"$selected>};', 'a generic checkbox. Takes two arguments, the pref name and the current pref value.', 'empty_box');
INSERT INTO box (boxid, title, content, description, template) VALUES ('time_zone_pref', '', 'my %zones = $S->_timezone_hash();\r\nmy $S_zone = $ARGS[0];\r\n\r\nmy $select = qq{\r\n      <SELECT name="time_zone" size="1">};\r\n\r\nforeach my $zone (sort keys %zones) {\r\n  my $z = uc($zone);\r\n  my $selected = \'\';\r\n  if ($z eq $S_zone) {\r\n    $selected = \' SELECTED\';\r\n  }\r\n  $select .= qq{\r\n         <OPTION value="$z"$selected>[$z] $zones{$zone}</OPTION>};\r\n}\r\n\r\n$select .= "\r\n      </SELECT>";\r\n\r\nreturn $select;', 'timezone selectbox', 'empty_box');
INSERT INTO box (boxid, title, content, description, template) VALUES ('startpage_pref', '', 'my $choice = $ARGS[0];\r\n\r\nmy @choices = sort keys %{ $S->{SECTION_DATA} };\r\nunshift(@choices, \'__main__\', \'__all__\');\r\n\r\nmy $select = qq{\r\n      <SELECT name="start_page" size="1"};\r\n\r\nforeach my $c (@choices) {\r\n  my $name;\r\n  if ( $c eq \'__main__\' ) {\r\n    $name = \'Front Page\';\r\n  } elsif ( $c eq \'__all__\' ) {\r\n    $name = \'Everything\';\r\n  } else {\r\n    $name = $S->{SECTION_DATA}->{$c}->{title};\r\n  }\r\n  my $checked = ($c eq $choice) ? \' SELECTED\' : \'\';\r\n  $select .= qq{\r\n        <OPTION value="$c"$checked>$name</OPTION>};\r\n}\r\n\r\n$select .= qq{\r\n      </SELECT>};\r\nreturn $select;', '', 'empty_box');
INSERT INTO box (boxid, title, content, description, template) VALUES ('img_server_pref','','my $current = $ARGS[0];\r\n\r\nreturn unless $S->var(\'image_mirrors\');\r\nmy @mirrors = split /\\n/, $S->var(\'image_mirrors\');\r\nmy $default_imgdir = $S->{PREF_ITEMS}->{imagedir}->{default_value};\r\n\r\nmy (%servers, $name, $url);\r\n\r\nforeach my $server (@mirrors) {\r\n ($name, $url) = split /,/, $server;\r\n $url =~ s/\\r//;\r\n $servers{$name} = $url;\r\n}\r\n\r\nmy $selected = ( $current eq $default_imgdir ) ? \' SELECTED\' : \'\';\r\n\r\nmy $select = qq{\r\n      <SELECT name=\"imagedir\" size=\"1\">\r\n        <OPTION value=\"$default_imgdir\"$selected>Default</OPTION>};\r\n\r\nforeach my $server (sort keys %servers) {\r\n  $selected = ( $current eq $servers{$server} ) ? \' SELECTED\' : \'\';\r\n  $select .= qq{\r\n         <OPTION value=\"$servers{$server}\"$selected>$server</A>};\r\n}\r\n\r\n$select .= qq{\r\n      </SELECT>};\r\n\r\nreturn $select;','','empty_box');
INSERT INTO box (boxid, title, content, description, template) VALUES ('user_theme_pref', '', 'my $choice = $ARGS[0];\r\nmy $themes = $S->{UI}->{VARS}->{user_themes};\r\nmy @themes = split ( /,\\s*/, $themes );\r\n\r\nmy $select = qq{\r\n      <SELECT name="theme">};\r\n\r\nunless ( $S->{PREF_ITEMS}->{theme}->{default_value} ) {\r\n  my $checked = ($choice eq \'\') ? \' SELECTED\' : \'\';\r\n  $select .= qq{\r\n        <OPTION value=""$checked>none</OPTION>};\r\n}\r\n\r\nforeach my $t (@themes) {\r\n  my $checked = ($t eq $choice) ? \' SELECTED\' : \'\';\r\n  $select .= qq{\r\n        <OPTION value="$t"$checked>$t</OPTION>};\r\n}\r\n\r\n$select .= qq{\r\n      </SELECT>};\r\n\r\nreturn $select;', '', 'empty_box');
INSERT INTO box (boxid, title, content, description, template) VALUES ('box_pref', '', 'my @choice = @ARGS;\r\n\r\nmy %boxes = %{$S->{BOX_DATA}};\r\nmy $current_prefs;\r\nmy $return = \'\';\r\n\r\n# convert the comma-separated list into a hash\r\nforeach my $i (@choice) {\r\n  $current_prefs->{$i} = 1;\r\n}\r\n\r\nmy $col = 0;\r\n\r\nforeach my $c (keys %boxes) {\r\n  next unless $boxes{$c}->{user_choose};\r\n  $return .= qq{\r\n    <TR>} unless $col;\r\n  my $checked = $current_prefs->{$c} ? " CHECKED" : "";\r\n  $return .= qq{\r\n      <TD><input type="checkbox" name="displayed_boxes" value="$c"$checked /></TD>\r\n      <TD>$boxes{$c}->{title}</TD>};\r\n  $return .= qq{\r\n    </TR>} if $col;\r\n  $col = ($col) ? "0" : "1";\r\n}\r\n\r\n$return .= "<TD></TD><TD></TD></TR>" if $col;\r\n\r\n$return = qq{\r\n<TABLE border="0">\r\n$return\r\n</TABLE>};\r\n\r\nreturn $return;', '', 'empty_box');
INSERT INTO box (boxid, title, content, description, template) VALUES ('rdf_pref', '', 'my @choice = @ARGS;\r\n\r\nmy $channels = $S->rdf_channels();\r\nmy $current_prefs;\r\nmy $return = \'\';\r\n\r\n# convert the comma-separated list into a hash\r\nforeach my $i (@choice) {\r\n  $current_prefs->{$i} = 1;\r\n}\r\n\r\nmy $col = 0;\r\n\r\nforeach my $c (@{$channels}) {\r\n  $return .= qq{\r\n    <TR>} unless $col;\r\n  next unless $c->{enabled} && $c->{title} && !$c->{submitted};\r\n  my $checked = $current_prefs->{$c->{rid}} ? " CHECKED" : "";\r\n  $return .= qq{\r\n      <TD><input type="checkbox" name="rdf_feeds" value="$c->{rid}"$checked /></TD>\r\n      <TD><a href="%%rootdir%%/special/rdf_preview/?rdf=$c->{rid}">$c->{title}</a></TD>};\r\n  $return .= qq{\r\n    </TR>} if $col;\r\n  $col = ($col) ? "0" : "1";\r\n}\r\n\r\n$return .= "<TD></TD><TD></TD></TR>" if $col;\r\n\r\n$return = qq{\r\n<TABLE border="0">\r\n$return\r\n</TABLE>};\r\n\r\nreturn $return;', '', 'empty_bo!
 x');
INSERT INTO box (boxid, title, content, description, template) VALUES ('rating_order_pref', '', 'my $choice = $ARGS[0];\r\n\r\nmy %choices = ( "unrate_highest", "Unrated, then Highest", "highest", "Highest rated first", "lowest", "Lowest rated first", "dontcare", "Ignore ratings" );\r\n\r\nmy $select = qq{\r\n      <SELECT name="commentrating" size="1">};\r\n\r\nforeach my $c (keys %choices) {\r\n  my $checked = ($c eq $choice) ? \' SELECTED\' : \'\';\r\n  $select .= qq{\r\n        <OPTION value="$c"$checked>$choices{$c}</OPTION>};\r\n}\r\n\r\n$select .= qq{\r\n      </SELECT>};\r\n\r\nreturn $select;', '', 'empty_box');
INSERT INTO box (boxid, title, content, description, template) VALUES ('postmode_pref', '', 'my $choice = $ARGS[0];\r\n\r\nmy %choices = ( "text", "Plain Text", "html", "HTML Formatted", "auto", "Autoformat" );\r\n\r\nmy $select = qq{\r\n      <SELECT name="posttype" size="1">};\r\n\r\nforeach my $c (keys %choices) {\r\n  my $checked = ($c eq $choice) ? \' SELECTED\' : \'\';\r\n  $select .= qq{\r\n        <OPTION value="$c"$checked>$choices{$c}</OPTION>};\r\n}\r\n\r\n$select .= qq{\r\n      </SELECT>};\r\n\r\nreturn $select;', '', 'empty_box');
INSERT INTO box (boxid, title, content, description, template) VALUES ('show_hidden_pref', '', 'my $current = $ARGS[0];\r\n\r\nmy $choices = {\r\n    \'yes\' => \'Yes\',\r\n    \'no\' => \'No\',\r\n    \'untilrating\' => "Show until I\'ve rated"\r\n};\r\n\r\nmy $select = qq{\r\n      <SELECT name="hidingchoice" size="1">};\r\n\r\nforeach my $choice (keys %{$choices}) {\r\n    my $selected = $choice eq $current ? \' SELECTED\' : \'\';\r\n    $select .= qq{\r\n        <OPTION value="$choice"$selected>$choices->{$choice}</OPTION>};\r\n}\r\n\r\n$select .= qq{\r\n      </SELECT>};\r\n\r\nreturn $select;', '', 'empty_box');
INSERT INTO box (boxid, title, content, description, template) VALUES ('user_group_box','','my ($curr_id) = $ARGS[0];\r\n\r\nmy ($rv, $sth) = $S->db_select({\r\n  WHAT => \'perm_group_id\',\r\n  FROM => \'perm_groups\',\r\n  DEBUG => 0});\r\n\r\nmy $selector = qq{\r\n<SELECT NAME="perm_group_id" SIZE=1>};\r\n\r\nmy $selected = \'\';\r\n\r\nwhile (my $group = $sth->fetchrow()) {\r\n  $selected = \'\';\r\n  $selected = " SELECTED" if ($group eq $curr_id);\r\n  $selector .= qq{\r\n  <OPTION VALUE="$group"$selected>$group};\r\n}\r\n\r\n$selector .= "</SELECT>";\r\n\r\nreturn $selector;\r\n','','empty_box');
INSERT INTO box (boxid, title, content, description, template) VALUES ('subscriber','','return unless ($S->{UID} == $S->param->{uid});\r\nreturn unless ($S->have_perm(\'allow_subscription\'));\r\nreturn unless ($S->{UI}->{VARS}->{use_subscriptions});\r\n\r\nmy $user = $S->user_data($S->{UID});\r\n\r\nwarn "(subscriber) active subscription? $user->{sub}->{active}";\r\n\r\nif ( $user->{sub}->{active} ) {\r\n  my $expires = $user->{sub}->{expires};\r\n  my $now = time;\r\n  my $remaining_days = (int((($expires - $now) / 86400)) + 1);\r\n  return qq{Thank you for subscribing. Your subscription expires in $remaining_days days};\r\n} else {\r\n  return qq{\r\n<P>You are not currently a subscriber. Why not <A href="%%rootdir%%/subscribe">become one</A>?};\r\n}','','empty_box');
INSERT INTO box (boxid, title, content, description, template) VALUES ('commentmode_overflow_pref', '', 'my $choice = $ARGS[0];\r\n\r\nmy %choices = ( "minimal", "Minimal", "threaded", "Threaded", "nested", "Nested", "flat", "Flat", "flat_unthread", "Flat (unthread)" );\r\n\r\nif ( $S->var(\'allow_dynamic_comment_mode\') && $S->pref(\'dynamic_interface\') eq \'on\' ) {\r\n  $choices{\'dminimal\'} = "Dynamic Minimal";\r\n  $choices{\'dthreaded\'} = "Dynamic Threaded";\r\n} else {\r\n  $choice =~ s/^d//;\r\n}\r\n\r\nmy $select = qq{\r\n      <SELECT name="commentmode_overflow" size="1">};\r\n\r\nforeach my $c (sort keys %choices) {\r\n  my $checked = ($c eq $choice) ? \' SELECTED\' : \'\';\r\n  $select .= qq{\r\n        <OPTION value="$c"$checked>$choices{$c}</OPTION>};\r\n}\r\n\r\n$select .= qq{\r\n      </SELECT>};\r\n\r\nreturn $select;', '', 'empty_box');
INSERT INTO box (boxid, title, content, description, template) VALUES ('commentmode_pref', '', 'my $choice = $ARGS[0];\r\n\r\nmy %choices = ( "use_overflow", "Always use overflow mode", "minimal", "Minimal", "threaded", "Threaded", "nested", "Nested", "flat", "Flat", "flat_unthread", "Flat (unthreaded)" );\r\n\r\nif ( $S->var(\'allow_dynamic_comment_mode\') && $S->pref(\'dynamic_interface\') eq \'on\' ) {\r\n  $choices{\'dminimal\'} = "Dynamic Minimal";\r\n  $choices{\'dthreaded\'} = "Dynamic Threaded";\r\n} else {\r\n  $choice =~ s/^d//;\r\n}\r\n\r\nmy $select = qq{\r\n      <SELECT name="commentmode" size="1">};\r\n\r\nforeach my $c (sort keys %choices) {\r\n  my $checked = ($c eq $choice) ? \' SELECTED\' : \'\';\r\n  $select .= qq{\r\n        <OPTION value="$c"$checked>$choices{$c}</OPTION>};\r\n}\r\n\r\n$select .= qq{\r\n      </SELECT>};\r\n\r\nreturn $select;', '', 'empty_box');
INSERT INTO box (boxid, title, content, description, template) VALUES ('cookie_expire_pref', '', 'my $choice = $ARGS[0];\r\n\r\nmy %choices = ( "3600", "1 hour", "86400", "1 day", "604800", "1 week", "1209600", "2 weeks", "2592000", "1 month (30 days)", "5184000", "2 months" );\r\n\r\nmy $select = qq{\r\n      <SELECT name="cookie_expire" size="1">};\r\n\r\nforeach my $c (sort {$a <=> $b} keys %choices) {\r\n  my $checked = ($c eq $choice) ? \' SELECTED\' : \'\';\r\n  $select .= qq{\r\n        <OPTION value="$c"$checked>$choices{$c}</OPTION>};\r\n}\r\n\r\n$select .= qq{\r\n      </SELECT>};\r\n\r\nreturn $select;', '', 'empty_box');

-- new vars
INSERT INTO vars (name, value, description, type, category) VALUES ('use_alt_image_dir', '1', '<P>This variable determines whether or not Scoop will use the alternate image servers listed in the variable <B>image_mirrors</B>. Turning this on when there are no alternate image servers listed will have no effect.</p>', 'bool', 'General');
INSERT INTO vars (name, value, description, type, category) VALUES ('use_ratings', '1', '<P>This variable turns the entire rating system on and off. FIXME: not implemented yet.</P>', 'bool', 'Comments');
INSERT INTO vars (name, value, description, type, category) VALUES ('image_mirrors','Australia,http://au.example.com/images\r\nEurope,http://www.bigmirrorsite.fi/scoopsite/images','<P>This variable defines the names and URLs of any alternate image servers you may have, so the users can choose an image server closer to them if necessary. This variable has no effect unless the variable <B>use_alt_image_dir</B> is set to 1.</P>\r\n\r\n<P>The format for this variable is one image mirror per line; each line consists of a descriptive name, a comma, and the URL of the mirrored image directory, without a trailing slash. The default value is invalid.</P>\r\n\r\n<P>The default value for the image directory is set in the User Preferences Admin Tool, in the \'imagedir\' preference.</P>','tarea','General');
INSERT INTO vars (name, value, description, type, category) VALUES ('first_login_page_order', 'Protected, User Info', '<P>This variable determines which prefs page(s) the user sees first when first logging in, if the variable <B>show_prefs_on_first_login</b> is set. The possible values are any list of valid prefs page names, separated by commas. The default value is \'Protected, User Info\'. This value is strongly recommended as it encourages the user to change his password immediately.</p>', 'text', 'General');

-- get rid of interface op since we don't need it anymore
DELETE FROM ops WHERE op='interface';
-- get rid of default_uid var, since defaults for all prefs can be set in the new tool
DELETE FROM vars WHERE name='default_uid';
-- get rid of font face/size blocks
DELETE FROM blocks WHERE bid='norm_font_face';
DELETE FROM blocks WHERE bid='norm_font_size';

-- add perms ad_opt_out, edit_prefs
UPDATE vars SET value = CONCAT(value,',\nad_opt_out,\nedit_prefs') WHERE name='perms';
UPDATE perm_groups SET group_perms = CONCAT(group_perms,',ad_opt_out,edit_prefs') WHERE perm_group_id IN ('Superuser','Admins','Editors');

-- add hook pref_change
UPDATE vars SET value = CONCAT(value,'\npref_change(uid,pref,newvalue)') WHERE name='hooks';

-- change description of var time_zone
UPDATE vars SET description='<P>This variable tells Scoop which time zone the server\'s clock is set to.  The possible values are any valid time zone string.  The default value is EST.<BR>\nIf this variable is set incorrectly, all display times will be wrong, leading to much confusion.</p>' WHERE name='time_zone';
-- change description of the block norm_font
UPDATE blocks SET description='<P>This block is used extensively in the default install. It should be a complete opening tag, or blank. It must match the closing tag set in the block <B>norm_font_end</b>. The following special keys are recognised:</p>\n<DL>\n <DT>norm_font_face</DT>\n  <DD>The font face specification set in a user\'s prefs or, if not set, the default value for that preference as set in the User Preferences Admin Tool.</DD>\n <DT>norm_font_size</DT>\n  <DD>The font size specification set in a user\'s prefs or, if not set, the default value for that preference as set in the User Preferences Admin Tool.</DD>\n</DL>' WHERE bid='norm_font';


--- NEW FILE: patch-23-MinMax.sql ---
-- MySQL dump 10.9
--
-- Host: 10.250.27.101    Database: thebes
-- ------------------------------------------------------
-- Server version	4.1.11-Debian_3-log
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Dumping data for table `vars`
--
-- WHERE:  name IN ('max_title_len', 'min_intro_words', 'min_intro_chars')


/*!40000 ALTER TABLE `vars` DISABLE KEYS */;
LOCK TABLES `vars` WRITE;
INSERT INTO `vars` (`name`, `value`, `description`, `type`, `category`) VALUES ('max_title_len','100','The maximum length in characters a title can be.','num','Stories'),('min_intro_chars','0','The minimum number of characters that can be used in a story. The default is 0, which disables use of this. It works much the same as min_intro_words. Only one of the two should be used.','num','Stories'),('min_intro_words','300','The minimum number of words that can be used in a story. The default is 300. 0 disables this feature. It works much the same as min_intro_chars. Only one of the two should be used.','num','Stories');
UNLOCK TABLES;
/*!40000 ALTER TABLE `vars` ENABLE KEYS */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- MySQL dump 10.9
--
-- Host: 10.250.27.101    Database: thebes
-- ------------------------------------------------------
-- Server version	4.1.11-Debian_3-log
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Dumping data for table `blocks`
--
-- WHERE:  bid in ('max_intro_warning', 'min_intro_warning')


/*!40000 ALTER TABLE `blocks` DISABLE KEYS */;
LOCK TABLES `blocks` WRITE;
INSERT INTO `blocks` (`bid`, `block`, `aid`, `description`, `category`, `theme`, `language`) VALUES ('max_intro_warning','<p>Hey, you didn\'t read the rules! You have too much text in the introtext box. Please edit your submission accordingly and use the bodytext box for the bulk of your diary.</p>','1','A warning message for users who have too much stuff in their intro.','Stories','default','en'),('min_intro_warning','<p>Sorry, your story/diary is not long enough. Please edit it so it has more content.</p>\r\n\r\nThe minumum is __MININTRO__ __UNIT__.','1','','Stories','default','en');
UNLOCK TABLES;
/*!40000 ALTER TABLE `blocks` ENABLE KEYS */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

UPDATE vars SET value = CONCAT(value,',\nevade_intro_limits') WHERE name = 'perms';
UPDATE perm_groups SET group_perms = CONCAT(group_perms,',evade_intro_limits') WHERE perm_group_id IN ('Superuser','Admins','Editors');

--- NEW FILE: patch-25-UserFile.sql ---
UPDATE vars SET value = CONCAT(value,',\nview_user_files') WHERE name = 'perms';
UPDATE perm_groups SET group_perms = CONCAT(group_perms,',view_user_files') WHERE perm_group_id IN ('Superuser','Admins','Editors','Advertisers','Users');

--- NEW FILE: patch-02-Sessions.sql ---
DROP TABLE sessions;

CREATE TABLE sessions (
	session_id VARCHAR(32) NOT NULL,
	item VARCHAR(255) NOT NULL,
	value TEXT,
	serialized INT(1) DEFAULT 0,
	last_update DATETIME,
	PRIMARY KEY (session_id, item)
);

--- NEW FILE: patch-17-NavBar.sql ---
INSERT INTO blocks (bid,block,aid,description,category,theme,language) VALUES ('navbar','<TABLE WIDTH="100%" BORDER=0 CELLPADDING=0 CELLSPACING=0>\n  <TR BGCOLOR="%%story_nav_bg%%">\n    <TD WIDTH="100%" ALIGN="center">\n      %%smallfont%%%%last%%%%sep%%%%next%%%%smallfont_end%%\n    </TD>\n  </TR>\n</TABLE>','1','<P>This provides the overall layout for the story navigation bar which links to the previous and next stories at the bottom of the story text and should be a self-contained block of HTML. This navigation bar can be turned off entirely using the Site Control <B>disable_story_navbar</B>. The special keys are:</P>\n<DL>\n <DT>last</DT>\n  <DD>The previous story. This is formatted using the block <B>navbar_last</B></DD>\n <DT>next</DT>\n  <DD>The next story. This is formatted using the block <B>navbar_next</B></DD>\n <DT>sep</DT>\n  <DD>A separator, only shown if both "last" and "next" above are used. (The most recent story, for example, will only have a "last" entry,!
  as there is no "next" story yet.)</DD>\n</DL>','Stories','default','en');
INSERT INTO blocks (bid,block,aid,description,category,theme,language) VALUES ('navbar_comments',' (%%num%% comments)','1','<P>This displays the number of comments attached to a story listed in the story navigation bar, if the current user can read comments in the story\'s section. The special key <B>num</B> is replaced with the number of comments in the relevant story.','Stories','default','en');
INSERT INTO blocks (bid,block,aid,description,category,theme,language) VALUES ('navbar_last','<B>&lt;</B> <A HREF="%%rootdir%%/story/%%sid%%">%%title%%</A> %%comments%%','1','<P>This formats the "last story" entry in the story navigation bar. The special keys are:</P>\n<DL>\n <DT>sid</DT>\n  <DD>The story ID of the "last story"</DD>\n <DT>title</DT>\n  <DD>The title of the "last story"</DD>\n <DT>comments</DT>\n  <DD>The contents of <B>navbar_comments</B>, if the user has permission to view comments on the "last story"</DD>\n</DL>','Stories','default','en');
INSERT INTO blocks (bid,block,aid,description,category,theme,language) VALUES ('navbar_next','<A HREF="%%rootdir%%/story/%%sid%%">%%title%%</A> %%comments%% <B>&gt;</B> ','1','<P>This formats the "next story" entry in the story navigation bar. The special keys are:</P>\n<DL>\n <DT>sid</DT>\n  <DD>The story ID of the "next story"</DD>\n <DT>title</DT>\n  <DD>The title of the "next story"</DD>\n <DT>comments</DT>\n  <DD>The contents of <B>navbar_comments</B>, if the user has permission to view comments on the "next story"</DD>\n</DL>','Stories','default','en');
INSERT INTO blocks (bid,block,aid,description,category,theme,language) VALUES ('navbar_sep',' | ','1','<P>This is the divider used to separate the "next" and "last" stories in the story navigation bar, if both have an entry. (The most recent story, for example, will only have a "last" entry, as there is no "next" story yet.) There are no special keys.</P>','Stories','default','en');


--- NEW FILE: patch-24-CommentFixes.sql ---
INSERT INTO blocks VALUES ('comment_ip_display','From: <a href=\"/iplookup/%%ip%%\">%%ip%%</a>','19','Format for the IP display/link attached to comments. \r\n<p>\r\nSpecial keys:\r\n<ul><li>ip: Replaced with the ip</li></ul>','Comments','default','en');
INSERT INTO blocks VALUES ('delimiter_default_start','<UL>','1','','Comments','default','en');
INSERT INTO blocks VALUES ('delimiter_default_levelstart','<UL>','1','','Comments','default','en');
INSERT INTO blocks VALUES ('delimiter_default_end','</UL>','1','','Comments','default','en');
INSERT INTO blocks VALUES ('delimiter_default_levelend','</UL>','1','','Comments','default','en');
INSERT INTO blocks VALUES ('delimiter_default_itemstart','<LI>','1','','Comments','default','en');
INSERT INTO blocks VALUES ('delimiter_default_itemend','</LI>','1','','Comments','default','en');
INSERT INTO blocks VALUES ('delimiter_dyn_start','<DIV STYLE="margin-left: 2.5em">','1','','Comments','default','en');
INSERT INTO blocks VALUES ('delimiter_dyn_itemstart','<TABLE><TR>\r\n<TD VALIGN="top">%%norm_font%%<TT><A ID="toggle!cid!" STYLE="text-decoration:none" HREF="javascript:void(toggle(!cid!))">$text</A></TT>&nbsp;%%norm_font_end%%</TD>\r\n<TD><DIV CLASS="$class" ID="content!cid!">','1','','Comments','default','en');
INSERT INTO blocks VALUES ('delimiter_dyn_end','</DIV>','1','','Comments','default','en');
INSERT INTO blocks VALUES ('delimiter_dyn_itemend','</DIV></TD></TR></TABLE>','1','','Comments','default','en');
INSERT INTO blocks VALUES ('delimiter_nested_start','<DL>','1','','Comments','default','en');
INSERT INTO blocks VALUES ('delimiter_nested_levelstart','<DT></DT><DD>','1','','Comments','default','en');
INSERT INTO blocks VALUES ('delimiter_nested_end','</DL>','1','','Comments','default','en');
INSERT INTO blocks VALUES ('delimiter_nested_levelend','</DD>','1','','Comments','default','en');
INSERT INTO blocks VALUES ('comment_search_item','<B>%%count%%) <A HREF=\"%%rootdir%%/comments/%%sid%%/%%cid%%#%%cid%%\">%%subject%%</A></B>\r\n[<A HREF=\"%%rootdir%%/comments/%%sid%%/%%cid%%?mode=alone;showrate=1#%%cid%%\">%%score%% / %%num_rate%%</A>]\r\nReplies: <B>%%replies%%</B>\r\n<BR>posted by <A HREF=\"%%rootdir%%/user/%%urlnick%%\">%%nick%%</A> on %%ftime%%\r\n<BR>\r\nattached to <a href=\"%%attached_link%%\">%%attached_title%%</a>\r\n<p>','19','Formatting for an item in a comment search result list.\r\n<p>\r\nSpecial keys:\r\n<ul>\r\n<li> count: the result number\r\n<li> sid: story id\r\n<li> cid: comment id\r\n<li> pid: parent comments id (or 0)\r\n<li> uid: uid fo the poster\r\n<li> nick: nickname of the poster\r\n<li> urlnick: nickname of the poster escaped for url use (like \"/user/|urlnick|\")\r\n<li> date: comment posting date (raw)\r\n<li> ftime: comment post date (formatted and timezone adjusted)\r\n<li> subject: comment subject\r\n<li> comment: comment tex!
 t\r\n<li> score: rating score\r\n<li> num_rate: number of ratings\r\n<li> rank: rank value (if you\'re using mysql fulltext search)\r\n<li> attached_link: url for the story or poll the comment is attached to\r\n<li> attached_title: title of the story or poll the comment is attached to\r\n</ul>','Comments','default','en');
INSERT INTO vars VALUES ('use_editorial_comments','0','Use editorial type comments at all. If unchecked, we won\'t include anything that refers to ed comments.','bool','Comments');

--- NEW FILE: patch-30-TagEnhancements.sql ---
-- MySQL dump 10.9
--
-- Host: 10.250.27.101    Database: thebes
-- ------------------------------------------------------
-- Server version	4.1.11-Debian_3-log
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Dumping data for table `box`
--
-- WHERE:  boxid in ('addtag', 'tag_listing', 'tag_page_order', 'tag_sort_change')


/*!40000 ALTER TABLE `box` DISABLE KEYS */;
LOCK TABLES `box` WRITE;
INSERT INTO `box` (`boxid`, `title`, `content`, `description`, `template`, `user_choose`) VALUES ('addtag','','my $sid = $S->cgi->param(\'sid\');\r\nmy $tagsave = $S->cgi->param(\'tagsave\');\r\nmy $newtags = $S->cgi->param(\'newtags\');\r\nreturn \"Error! No sid provided!\" if !$sid;\r\nmy $content;\r\n\r\n# I would, of course, prefer not to give\r\n# TUs extra privileges, but sometimes I guess\r\n# it must be done.\r\nmy $alltags;\r\nmy $subval;\r\nif ($S->have_perm(\'edit_story_tags\')){\r\n    $newtags ||= $S->get_tags_as_string($sid);\r\n    $alltags = $newtags;\r\n    $subval = \"Add/Edit\";\r\n    }\r\nelse {\r\n    $alltags = $S->get_tags_as_string($sid) . \", $newtags\";\r\n    $subval = \"Add\";\r\n    }\r\n#my $alltags = $S->get_tags_as_string($sid) . \", #$newtags\";\r\n$alltags =~ s/,$//;\r\n\r\n# if we\'re adding tags, add them and clear the new\r\n# tags var\r\nif($tagsave && $newtags){\r\n    $S->save_tags($sid, $alltags);\r\n    $content .= \"<p>Tags <b>$new!
 tags</b> added.</p>\";\r\n    $newtags = \'\';\r\n    # and if we\'ve added tags, we\'re heading\r\n    # back to whence we came.\r\n    my $url = $S->{UI}->{VARS}->{site_url}   \r\n        . $S->{UI}->{VARS}->{rootdir} . \"/\"\r\n        . \"story/$sid\";\r\n    $S->{APACHE}->headers_out->{\'Location\'} = $url;\r\n    $S->{HEADERS_ONLY}=1;\r\n    }\r\nmy $curtags = $S->tag_display($sid);\r\n$content = \"Current $curtags\" . $content;\r\n\r\nmy $tagform = qq~\r\n<p><form name=\"addtag\" action=\"%%rootdir%%/addtag\" method=\"POST\">$subval Tags: (use commas to separate tags) <input type=\"hidden\" name=\"sid\" value=\"$sid\"><input type=\"text\" name=\"newtags\" size=\"30\" value=\"$newtags\"> <input type=\"submit\" name=\"tagsave\" value=\"$subval Tags\"></p></form></p><p>\r\n\'/\' characters are not allowed in tags, and will be converted to \'-\'.</p>\r\n~;\r\nreturn $content . $tagform;','','empty_box',0),('tag_listing','','my $sid = $S->cgi->param(\'sid\');\r\nmy $tags !
 = $S->tag_display($sid);\r\nmy $content = \"$tags\";\r\n# if we can po
st comments, we can tag.\r\nif($S->have_perm(\'comment_post\')){\r\n    my $addlink = ($S->have_perm(\'edit_story_tags\')) ? qq~ :: <a href=\"/addtag/$sid\">Add/Edit Tags to this Story</a>~ : qq~ :: <a href=\"/addtag/$sid\">Add Tags to this Story</a>~;\r\n    $content .= $addlink;\r\n    }\r\nreturn $content;','','empty_box',0),('tag_page_order','','my $switch = $S->cgi->param(\'switch\');\r\n\r\nif($S->{UID} > 0){\r\n    $S->pref(\'tag_sort\', $switch); # nice and easy\r\n    }\r\nelse { # not so easy\r\n    $S->session(\'tag_sort\', $switch);\r\n    }\r\nmy $url = $S->{UI}->{VARS}->{site_url} . \r\n          $S->{UI}->{VARS}->{rootdir} . \"/\" \r\n          . \"tag\";\r\n\r\n		$S->{APACHE}->headers_out->{\'Location\'} = $url;\r\n$S->{HEADERS_ONLY}=1;\r\n\r\nreturn;','','empty_box',0),('tag_sort_change','','# change the default ordering for the \"All Tags\"\r\n# page\r\n# don\'t display if we\'re not looking at the \"All\r\n# Tags\" page, though.\r\nreturn if $S->cgi->param!
 (\'tag\');\r\n\r\nmy $switchto = ($S->pref(\'tag_sort\') eq \'alpha\') ? \"count\" : \"alpha\";\r\n# and if we\'re