Update of /cvs/scoop/scoop/struct
In directory sodium.sabren.com:/tmp/cvs-serv9158/struct

Modified Files:
	scoop.sql 
Log Message:
A few more bugfixes to userprefs stuff. Caching issues, validation tweaks, 
and fixing a bug with pref reset. See the SBM, bugs 118, 119, 120, and 121.

--janra



Index: scoop.sql
===================================================================
RCS file: /cvs/scoop/scoop/struct/scoop.sql,v
retrieving revision 1.200
retrieving revision 1.201
diff -C2 -d -r1.200 -r1.201
*** scoop.sql	17 Aug 2004 19:03:41 -0000	1.200
--- scoop.sql	27 Aug 2004 22:32:52 -0000	1.201
***************
*** 380,384 ****
  INSERT INTO blocks 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 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 INTO blocks 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%%></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>Shown on signup page?</B></TD>\r\n    <TD><INPUT type=\"radio\" name=\"signup\" value=\"normal\"%%pref_signup_normal%%> No\r\n    <BR><INPUT type=\"radio\" name=\"signup\" value=\"signup\"%%pref_signup_signup%%> Yes\r\n    <BR><INPUT type=\"radio\" name=\"signup\" value=!
 \"required\"%%pref_signup_required%%> Yes, and it\'s required</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 type=\"text\" size=\"5\" maxlength=\"5\" name=\"display_order\" value=\"%%pref_order%%\"></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','default','en');
  INSERT INTO blocks 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 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');
--- 380,384 ----
  INSERT INTO blocks 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 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 INTO blocks 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%%></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>Shown on signup page?</B></TD>\r\n    <TD><INPUT type=\"radio\" name=\"signup\" value=\"normal\"%%pref_signup_normal%%> No\r\n    <BR><INPUT type=\"radio\" name=\"signup\" value=\"signup\"%%pref_signup_signup%%> Yes\r\n    <BR><INPUT type=\"radio\" name=\"signup\" value=!
 \"required\"%%pref_signup_required%%> Yes, and it\'s required</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 type=\"text\" size=\"5\" maxlength=\"5\" name=\"display_order\" value=\"%%pref_order%%\"></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>Box or regular expression:
</B>\r\n      <BR>either a perl regex (pipes escaped) or BOX,boxname[,args]</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','default','en');
  INSERT INTO blocks 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 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');
***************
*** 466,469 ****
--- 466,470 ----
  INSERT INTO box 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',0);
  INSERT INTO box 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',0);
+ INSERT INTO box 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);
  
  #
***************
*** 925,928 ****
--- 926,931 ----
  INSERT INTO patches VALUES ('1_1-dev',5,'UserPrefs2','sql');
  INSERT INTO patches VALUES ('1_1-dev',5,NULL,'post');
+ INSERT INTO patches VALUES ('1_1-dev',6,'UserPrefs3','sql');
+ INSERT INTO patches VALUES ('1_1-dev',6,NULL,'post');
  
  #
***************
*** 1082,1086 ****
  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,'normal');
  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,'normal');
! INSERT INTO pref_items VALUES ('start_page','Start page','',0,0,'','','',0,'__main__',0,'\\w+','Interface','%%BOX,startpage_pref,%%value%%%%',12,'selectbox_pref','',1,'normal');
  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,'normal');
  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,'normal');
--- 1085,1089 ----
  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,'normal');
  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,'normal');
! INSERT INTO pref_items VALUES ('start_page','Start page','',0,0,'','','',0,'__main__',0,'BOX,startpage_validation','Interface','%%BOX,startpage_pref,%%value%%%%',12,'selectbox_pref','',1,'normal');
  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,'normal');
  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,'normal');