Commit info for scoop/struct:

Modified Files:
	scoop.sql 
Log Message:
Checking in two janra patches. One takes the new user emails out of the code
and puts them into blocks, while the other fixes some error messages coming out
the who's online code. Also including the new, table-bound whos_online box,
since it never made it into the default db.



Index: scoop.sql
===================================================================
RCS file: /cvs/scoop/scoop/struct/scoop.sql,v
retrieving revision 1.190
retrieving revision 1.191
diff -r1.190 -r1.191
361a362,364
> INSERT INTO blocks VALUES ('new_user_email_subject','Welcome to %%sitename%%','1','<P>This block defines the subject line for the email sent to new accounts. It should be short and not have any HTML. Because this is an email it is not processed the way web pages are and the only key recognized is the special key sitename, which is replaced with the contents of the site control <B>sitename</B></P>','Accounts,Emails','default','en');
> INSERT INTO blocks VALUES ('new_user_email','Someone requested a new user account on %%url%%/\nand gave this email address as their contact.\n\nIf this was you, please use the following username and password to log\nin:\n\n	Username: %%nick%%\n	Password: %%pass%%\n%%showprefs%%\nIf it wasn\'t you, please ignore this email. Our system will delete the\naccount automatically if it remains unused. You will not get any\nfurther e-mail from us. The account is free.\n\nWe hope you enjoy %%sitename%%!\n\n-- %%from%%','1','<P>This block contains the body of the email send when new accounts are created. It should not have any HTML. Because this is an email it is not processed the way web pages are and the only keys recognized are:</P>\n<DL>\n <DT>url</DT>\n  <DD>The full URL to the front page of the site.</DD>\n <DT>nick</DT>\n  <DD>The nickname that was just created</DD>\n <DT>pass</DT>\n  <DD>The generated password sent to the new user</DD>\n <DT>showprefs</DT>\n  <DD>If the varia!
 ble <B>show_prefs_on_first_login</B> is set to 1, the contents of the block <B>new_user_email_showprefs</B>, otherwise blank.</DD>\n <DT>from</DT>\n  <DD>The email address the newuser email was sent from. This is the variable <B>new_user_email_from</B> if set, and <B>local_email</B> otherwise.</DD>\n</DL>','Accounts,Emails','default','en');
> INSERT INTO blocks VALUES ('new_user_email_showprefs','After first logging in, you will be automatically redirected to your\nuser preferences page, where you can change your password if you want\nto.','1','<P>This block contains text that will be included in the block <B>new_user_email</B> if the site control <B>show_prefs_on_first_login</B> is set to 1. It should not have any HTML. Since emails are not sent through the usual page processing, this block cannot use any of the normal keys available to most blocks.</P>','Accounts,Emails','default','en');
399c402
< INSERT INTO box VALUES ('whos_online','Who\'s online','## New Who\'s Online Box\r\n## Quite a bit of stuff borrowed from the old one.\r\n\r\n# return if anonymous for now\r\n#return if $S->{UID} == -1;\r\n\r\n# The time stuff can be changed to taste\r\n\r\n# The query\r\n\r\nmy ($rv,$sth) = $S->db_select({\r\n   FROM => \'whos_online\',\r\n   WHAT => \'ip, uid\',\r\n   WHERE => \'last_visit > DATE_SUB(NOW(), INTERVAL 30 MINUTE)\',\r\n   ORDER_BY => \'uid\'\r\n});\r\n\r\nmy %uids;\r\nmy $total;\r\nmy $anontotal;\r\n\r\nwhile (my $s = $sth->fetchrow_hashref()) {\r\n      if ($s->{\'uid\'} == -1) {\r\n        $anontotal++;\r\n        next;\r\n        }\r\n   $total++;\r\n   $uids{ $s->{\'uid\'} }++;\r\n}\r\n\r\n$sth->finish;\r\n\r\nmy @sorted = sort { return 1 if $a == -1; return -1 if $b == -1;\r\nreturn 0; } keys %uids;\r\n\r\nmy $noneonline = \"No one currently online (except you just now, of course).<BR>\";\r\nreturn {content => $noneonline, title => \"Who\'s Online?\"} u!
 nless @sorted;\r\n\r\nmy $out;\r\nmy $hidden;\r\nforeach (@sorted) {\r\n   #$_ = -1 if $_ eq \'anon\';\r\n   if ($S->user_data($_)->{prefs}->{online_cloak}) {\r\n      $hidden++;\r\n      next;\r\n   }\r\n   my $nick = $S->user_data($_)->{nickname};\r\n   $out .= qq~%%dot%%~;\r\n   $out .= qq~ <A HREF=\"%%rootdir%%/user/uid:$_\">~ unless $_ == -1;\r\n   $out .= \' \' if $_ == -1;\r\n   $out .= $nick;\r\n   $out .= \"</A>\" unless $_ == -1;\r\n   $out .= \" ($uids{$_})\" if $uids{$_} > 1;\r\n   $out .= \"<BR>\\n\";\r\n}\r\nif($anontotal){\r\n   my $anon_user_nick = $S->{UI}->{VARS}->{anon_user_nick};\r\n   $out .= \"%%dot%% $anon_user_nick: $anontotal <BR>\";\r\n   }\r\nif ($hidden) {\r\n   $out .= qq~%%dot%% Cloaked Users ($hidden)<p>~;\r\n} else {\r\n   $out .= \'<p>\';\r\n}\r\n$total = $total + $anontotal;\r\n$out .= qq~<small>Note: You may cloak yourself from appearing here in your <A HREF=\"%%rootdir%%/interface/prefs\">Display Preferences</A></small>.~;\r\nreturn {cont!
 ent => $out, title => \"Who\'s Online? ($total)\"};\r\n','','b!
 ox',1);
---
> INSERT INTO box VALUES ('whos_online','Who\'s online','## New Who\'s Online Box\n## Quite a bit of stuff borrowed from the old one.\n\n# return if anonymous for now\nreturn if $S->{UID} == -1;\n\n# The time stuff can be changed to taste\n\n# The query\n\nmy ($rv,$sth) = $S->db_select({\n   FROM => \'whos_online\',\n   WHAT => \'ip, uid\',\n   WHERE => \'last_visit > DATE_SUB(NOW(), INTERVAL 30 MINUTE)\',\n   ORDER_BY => \'uid\'\n});\n\nmy %uids;\nmy $total;\nmy $anontotal;\n\nwhile (my $s = $sth->fetchrow_hashref()) {\n      if ($s->{\'uid\'} == -1) {\n        $anontotal++;\n        next;\n        }\n   $total++;\n   $uids{ $s->{\'uid\'} }++;\n}\n\n$sth->finish;\n\nmy @sorted = sort keys %uids;\n\nmy $out;\nmy $hidden;\nforeach (@sorted) {\n   if ($S->user_data($_)->{prefs}->{online_cloak}) {\n      $hidden++;\n      next;\n   }\n   my $nick = $S->user_data($_)->{nickname};\n   $out .= qq~%%dot%% <A HREF=\"%%rootdir%%/user/uid:$_\">$nick</A>~;\n   $out .= \" ($uids{$_})\" !
 if $uids{$_} > 1;\n   $out .= \"<BR>\\n\";\n}\nif($anontotal){\n   my $anon_user_nick = $S->{UI}->{VARS}->{anon_user_nick};\n   $out .= \"%%dot%% $anon_user_nick ($anontotal)<BR>\";\n   }\nif ($hidden) {\n   $out .= qq~%%dot%% Cloaked Users ($hidden)<p>~;\n} else {\n   $out .= \'<p>\';\n}\n$total = $total + $anontotal;\n$out .= qq~<small>Note: You may cloak yourself from appearing here in your <A HREF=\"%%rootdir%%/interface/prefs\">Display Preferences</A></small>.~;\nreturn {content => $out, title => \"Who\'s Online? ($total)\"};\n','','box',1);
866a870
> INSERT INTO patches VALUES ('1_0-dev',34,'BugFixes','sql');
1598a1603
> INSERT INTO vars VALUES ('new_user_email_from','','<P>This variable is used as the from email address used by Scoop when sending user creation emails. The possible values are any valid email address, or blank. If blank, the email address set in the variable <B>local_email</B> will be used instead.<BR>\nThis email address should probably be one you check regularly.  Since members are sent email from this address, they are likely to think that they can send to it as well, if they have any questions.  If this email address is not valid, nobody will be able to create accounts.</p>','text','General');
1628c1633
<   PRIMARY KEY  (ip)
---
>   PRIMARY KEY  (ip,uid)