Added ability to have alternate main page for members
authorDan
Sat, 15 Nov 2008 18:23:25 -0500
changeset 741 a216e412c439
parent 740 098e744df928
child 742 551b6a0aa3b4
Added ability to have alternate main page for members
includes/clientside/static/login.js
includes/functions.php
includes/pageprocess.php
includes/paths.php
includes/template.php
install/upgrade.php
language/english/admin.json
plugins/SpecialAdmin.php
plugins/SpecialUserFuncs.php
plugins/SpecialUserPrefs.php
plugins/admin/PageManager.php
plugins/admin/UserManager.php
--- a/includes/clientside/static/login.js	Sat Nov 15 18:22:13 2008 -0500
+++ b/includes/clientside/static/login.js	Sat Nov 15 18:23:25 2008 -0500
@@ -19,7 +19,14 @@
     return true;
   ajaxLoginInit(function(k)
     {
-      window.location.reload();
+      if ( on_main_page )
+      {
+        window.location = makeUrl(main_page_members);
+      }
+      else
+      {
+        window.location.reload();
+      }
     }, USER_LEVEL_MEMBER);
 }
 
--- a/includes/functions.php	Sat Nov 15 18:22:13 2008 -0500
+++ b/includes/functions.php	Sat Nov 15 18:23:25 2008 -0500
@@ -260,6 +260,27 @@
 }
 
 /**
+ * Returns the full page ID string of the main page.
+ * @return string
+ */
+
+function get_main_page($force_logged_in = false)
+{
+  global $db, $session, $paths, $template, $plugins; // Common objects
+  
+  $logged_in = false;
+  if ( is_object($session) && !$force_logged_in )
+  {
+    $logged_in = $session->user_logged_in;
+  }
+  else if ( $force_logged_in )
+  {
+    $logged_in = true;
+  }
+  return $logged_in ? getConfig('main_page_alt', getConfig('main_page')) : getConfig('main_page');
+}
+
+/**
  * Enano replacement for date(). Accounts for individual users' timezone preferences.
  * @param string Date-formatted string
  * @param int Optional - UNIX timestamp value to use. If omitted, the current time is used.
--- a/includes/pageprocess.php	Sat Nov 15 18:22:13 2008 -0500
+++ b/includes/pageprocess.php	Sat Nov 15 18:23:25 2008 -0500
@@ -359,47 +359,59 @@
         }
       }
     }
-    else // (disabled for compatibility reasons) if ( in_array($this->namespace, array('Article', 'User', 'Project', 'Help', 'File', 'Category')) && $this->page_exists )
+    else
     {
-      // Send as regular page
-      if ( $this->send_headers )
+      $this->send_from_db($strict_no_headers);
+    }
+  }
+  
+  /**
+   * Sends the page through by fetching it from the database.
+   */
+   
+  function send_from_db($strict_no_headers = false)
+  {
+    global $db, $session, $paths, $template, $plugins; // Common objects
+    global $lang;
+    
+    // Send as regular page
+    if ( $this->send_headers )
+    {
+      $template->init_vars($this);
+    }
+    
+    $text = $this->fetch_text();
+    
+    if ( $text == 'err_no_text_rows' )
+    {
+      $this->err_no_rows();
+      return false;
+    }
+    else
+    {
+      $redirect = ( isset($_GET['redirect']) ) ? $_GET['redirect'] : 'YES YOU IDIOT';
+      if ( preg_match('/^#redirect \[\[([^\]]+)\]\]/i', $text, $match) && $redirect != 'no' )
       {
-        $template->init_vars($this);
-      }
-      
-      $text = $this->fetch_text();
-      
-      if ( $text == 'err_no_text_rows' )
-      {
-        $this->err_no_rows();
-        return false;
+        // Redirect page!
+        $page_to = sanitize_page_id($match[1]);
+        $page_id_data = RenderMan::strToPageID($page_to);
+        if ( count($this->redirect_stack) >= 3 )
+        {
+          $this->render( (!$strict_no_headers), '<div class="usermessage"><b>' . $lang->get('page_err_redirects_exceeded') . '</b></div>' );
+        }
+        else
+        {
+          $result = $this->_handle_redirect($page_id_data[0], $page_id_data[1]);
+          if ( $result !== true )
+          {
+            // There was some error during the redirect process - usually an infinite redirect
+            $this->render( (!$strict_no_headers), '<div class="usermessage"><b>' . $result . '</b></div>' );
+          }
+        }
       }
       else
       {
-        $redirect = ( isset($_GET['redirect']) ) ? $_GET['redirect'] : 'YES YOU IDIOT';
-        if ( preg_match('/^#redirect \[\[([^\]]+)\]\]/i', $text, $match) && $redirect != 'no' )
-        {
-          // Redirect page!
-          $page_to = sanitize_page_id($match[1]);
-          $page_id_data = RenderMan::strToPageID($page_to);
-          if ( count($this->redirect_stack) >= 3 )
-          {
-            $this->render( (!$strict_no_headers), '<div class="usermessage"><b>' . $lang->get('page_err_redirects_exceeded') . '</b></div>' );
-          }
-          else
-          {
-            $result = $this->_handle_redirect($page_id_data[0], $page_id_data[1]);
-            if ( $result !== true )
-            {
-              // There was some error during the redirect process - usually an infinite redirect
-              $this->render( (!$strict_no_headers), '<div class="usermessage"><b>' . $result . '</b></div>' );
-            }
-          }
-        }
-        else
-        {
-          $this->render( (!$strict_no_headers) );
-        }
+        $this->render( (!$strict_no_headers) );
       }
     }
   }
@@ -1952,13 +1964,13 @@
     {
       $standard_404 .= ' ' . $lang->get('page_msg_404_create', array(
           'create_flags' => 'href="'.makeUrlNS($this->namespace, $this->page_id, 'do=edit', true).'" onclick="ajaxEditor(); return false;"',
-          'mainpage_link' => makeUrl(getConfig('main_page'), false, true)
+          'mainpage_link' => makeUrl(get_main_page(), false, true)
         ));
     }
     else
     {
       $standard_404 .= ' ' . $lang->get('page_msg_404_gohome', array(
-          'mainpage_link' => makeUrl(getConfig('main_page'), false, true)
+          'mainpage_link' => makeUrl(get_main_page(), false, true)
         ));
     }
     $standard_404 .= '</p>';
@@ -2041,16 +2053,16 @@
       {
         // Display the "home" link first.
         $pathskey = $paths->nslist[ $this->namespace ] . $this->page_id;
-        if ( $pathskey !== getConfig('main_page') )
-          echo '<a href="' . makeUrl(getConfig('main_page'), false, true) . '">';
+        if ( $pathskey !== get_main_page() )
+          echo '<a href="' . makeUrl(get_main_page(), false, true) . '">';
         echo $lang->get('onpage_btn_breadcrumbs_home');
-        if ( $pathskey !== getConfig('main_page') )
+        if ( $pathskey !== get_main_page() )
           echo '</a>';
       }
       foreach ( $breadcrumb_data as $i => $crumb )
       {
         $cumulative = implode('/', array_slice($breadcrumb_data, 0, ( $i + 1 )));
-        if ( $show_home && $cumulative === getConfig('main_page') )
+        if ( $show_home && $cumulative === get_main_page() )
           continue;
         if ( $show_home || $i > 0 )
           echo ' &raquo; ';
--- a/includes/paths.php	Sat Nov 15 18:22:13 2008 -0500
+++ b/includes/paths.php	Sat Nov 15 18:23:25 2008 -0500
@@ -192,7 +192,7 @@
     if ( defined('ENANO_INTERFACE_INDEX') || defined('ENANO_INTERFACE_AJAX') || defined('IN_ENANO_UPGRADE') )
     {
       $title = $this->parse_url(false);
-      if ( empty($title) && getConfig('main_page') != '' )
+      if ( empty($title) && get_main_page() != '' )
       {
         $this->main_page();
       }
@@ -358,9 +358,9 @@
       if($this->namespace == 'Special' && !$this->external_api_page)
       {
         // Can't load nonexistent pages
-        if( is_string(getConfig('main_page')) )
+        if( is_string(get_main_page()) )
         {
-          $main_page = makeUrl(getConfig('main_page'));
+          $main_page = makeUrl(get_main_page());
         }
         else
         {
@@ -408,9 +408,9 @@
   
   function main_page()
   {
-    if( is_string(getConfig('main_page')) )
+    if( is_string(get_main_page()) )
     {
-      $main_page = makeUrl(getConfig('main_page'));
+      $main_page = makeUrl(get_main_page());
     }
     else
     {
--- a/includes/template.php	Sat Nov 15 18:22:13 2008 -0500
+++ b/includes/template.php	Sat Nov 15 18:23:25 2008 -0500
@@ -14,7 +14,7 @@
  
 class template
 {
-  var $tpl_strings, $tpl_bool, $vars_assign_history, $theme, $style, $no_headers, $additional_headers, $sidebar_extra, $sidebar_widgets, $toolbar_menu, $theme_list, $named_theme_list, $default_theme, $default_style, $plugin_blocks, $namespace_string, $style_list, $theme_loaded, $initted_to_page_id, $initted_to_namespace;
+  var $tpl_strings, $tpl_bool, $vars_assign_history, $theme, $style, $no_headers, $additional_headers, $sidebar_extra, $sidebar_widgets, $toolbar_menu, $theme_list, $named_theme_list, $default_theme, $default_style, $plugin_blocks, $plugin_blocks_content, $namespace_string, $style_list, $theme_loaded, $initted_to_page_id, $initted_to_namespace;
   
   var $initted_to_theme = array(
       'theme' => false,
@@ -54,6 +54,7 @@
     $this->toolbar_menu = '';
     $this->additional_headers = '';
     $this->plugin_blocks = Array();
+    $this->plugin_blocks_content = array();
     $this->theme_loaded = false;
     
     $this->theme_list = Array();
@@ -185,7 +186,7 @@
   }
   
   /**
-   * Systematically deletes themes if they're blocked by theme security settings. Called when session->start() finishes.
+   * Systematically deletes themes from available list if they're blocked by theme security settings. Called when session->start() finishes.
    */
   
   function process_theme_acls()
@@ -305,6 +306,7 @@
     
     $parser->assign_vars(Array('TITLE' => '{TITLE}','CONTENT' => $h));
     $this->plugin_blocks[$t] = $parser->run();
+    $this->plugin_blocks_content[$t] = $h;
     $this->sidebar_widgets .= $parser->run();
   }
   function add_header($html)
@@ -344,7 +346,7 @@
         // If it was removed, it's probably blocked by an ACL, or it was uninstalled
         !isset($this->named_theme_list[$this->theme]) ||
         // Check if the theme is disabled
-        ( isset($this->named_theme_list[$this->theme]) && $this->named_theme_list[$this->theme]['enabled'] == 0 ) )
+        ( isset($this->named_theme_list[$this->theme]) && isset($this->named_theme_list[$this->theme]['enabled']) && $this->named_theme_list[$this->theme]['enabled'] == 0 ) )
         // Above all, if it's a system theme, don't inhibit the loading process.
         && !in_array($this->theme, $this->system_themes)
       )
@@ -1105,6 +1107,14 @@
     
     $admin_link = $parser->run();
     
+    $parser->assign_vars(Array(
+        'HREF'=>makeUrlNS('Special', 'EditSidebar'),
+        'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { void(ajaxLoginNavTo(\'Special\', \'EditSidebar\', ' . USER_LEVEL_ADMIN . ')); return false; }"',
+        'TEXT'=>$lang->get('sidebar_btn_editsidebar'),
+      ));
+    
+    $sidebar_link = $parser->run();
+    
     $SID = ($session->sid_super) ? $session->sid_super : '';
     
     $urlname_clean = str_replace('\'', '\\\'', str_replace('\\', '\\\\', dirtify_page_id($local_fullpage)));
@@ -1128,6 +1138,8 @@
       // SKIN DEVELOPERS: The template variable for this code block is {JS_DYNAMIC_VARS}. This MUST be inserted BEFORE the tag that links to the main Javascript lib.
       var title = \''. $urlname_jssafe .'\';
       var physical_title = \'' . $physical_urlname_jssafe . '\';
+      var on_main_page = ' . ( $local_page == get_main_page() ? 'true' : 'false' ) . ';
+      var main_page_members = \'' . addslashes(get_main_page(true)) . '\';
       var page_exists = '. ( ( $local_page_exists) ? 'true' : 'false' ) .';
       var scriptPath = \'' . addslashes(scriptPath) . '\';
       var contentPath = \'' . addslashes(contentPath) . '\';
@@ -1173,39 +1185,40 @@
       $js_dynamic .= "\n    //]]>\n    </script>";
       
     $tpl_strings = Array(
-      'PAGE_NAME'=>htmlspecialchars($local_cdata['name']),
-      'PAGE_URLNAME'=> $urlname_clean,
-      'SITE_NAME'=>htmlspecialchars(getConfig('site_name')),
-      'USERNAME'=>$session->username,
-      'SITE_DESC'=>htmlspecialchars(getConfig('site_desc')),
-      'TOOLBAR'=>$tb,
-      'SCRIPTPATH'=>scriptPath,
-      'CONTENTPATH'=>contentPath,
+      'PAGE_NAME' => htmlspecialchars($local_cdata['name']),
+      'PAGE_URLNAME' =>  $urlname_clean,
+      'SITE_NAME' => htmlspecialchars(getConfig('site_name')),
+      'USERNAME' => $session->username,
+      'SITE_DESC' => htmlspecialchars(getConfig('site_desc')),
+      'TOOLBAR' => $tb,
+      'SCRIPTPATH' => scriptPath,
+      'CONTENTPATH' => contentPath,
       'CDNPATH' => cdnPath,
-      'ADMIN_SID_QUES'=>$asq,
-      'ADMIN_SID_AMP'=>$asa,
-      'ADMIN_SID_AMP_HTML'=>$ash,
-      'ADMIN_SID_AUTO'=>$as2,
-      'ADMIN_SID_RAW'=> ( is_string($session->sid_super) ? $session->sid_super : '' ),
-      'COPYRIGHT'=>RenderMan::parse_internal_links(getConfig('copyright_notice')),
-      'TOOLBAR_EXTRAS'=>$this->toolbar_menu,
-      'REQUEST_URI'=>( defined('ENANO_CLI') ? '' : $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] ),
-      'STYLE_LINK'=>makeUrlNS('Special', 'CSS'.$p, null, true), //contentPath.$paths->nslist['Special'].'CSS' . $p,
-      'LOGIN_LINK'=>$login_link,
-      'LOGOUT_LINK'=>$logout_link,
-      'ADMIN_LINK'=>$admin_link,
-      'THEME_LINK'=>$theme_link,
-      'SEARCH_ACTION'=>makeUrlNS('Special', 'Search'),
-      'INPUT_TITLE'=>( urlSeparator == '&' ? '<input type="hidden" name="title" value="' . htmlspecialchars( $paths->nslist[$local_namespace] . $local_page_id ) . '" />' : ''),
-      'INPUT_AUTH'=>( $session->sid_super ? '<input type="hidden" name="auth"  value="' . $session->sid_super . '" />' : ''),
-      'TEMPLATE_DIR'=>scriptPath.'/themes/'.$this->theme,
-      'THEME_ID'=>$this->theme,
-      'STYLE_ID'=>$this->style,
-      'MAIN_PAGE' => getConfig('main_page'),
+      'ADMIN_SID_QUES' => $asq,
+      'ADMIN_SID_AMP' => $asa,
+      'ADMIN_SID_AMP_HTML' => $ash,
+      'ADMIN_SID_AUTO' => $as2,
+      'ADMIN_SID_RAW' =>  ( is_string($session->sid_super) ? $session->sid_super : '' ),
+      'COPYRIGHT' => RenderMan::parse_internal_links(getConfig('copyright_notice')),
+      'TOOLBAR_EXTRAS' => $this->toolbar_menu,
+      'REQUEST_URI' => ( defined('ENANO_CLI') ? '' : $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] ),
+      'STYLE_LINK' => makeUrlNS('Special', 'CSS'.$p, null, true), //contentPath.$paths->nslist['Special'].'CSS' . $p,
+      'LOGIN_LINK' => $login_link,
+      'LOGOUT_LINK' => $logout_link,
+      'ADMIN_LINK' => $admin_link,
+      'THEME_LINK' => $theme_link,
+      'SIDEBAR_LINK' => $sidebar_link,
+      'SEARCH_ACTION' => makeUrlNS('Special', 'Search'),
+      'INPUT_TITLE' => ( urlSeparator == '&' ? '<input type="hidden" name="title" value="' . htmlspecialchars( $paths->nslist[$local_namespace] . $local_page_id ) . '" />' : ''),
+      'INPUT_AUTH' => ( $session->sid_super ? '<input type="hidden" name="auth"  value="' . $session->sid_super . '" />' : ''),
+      'TEMPLATE_DIR' => scriptPath.'/themes/'.$this->theme,
+      'THEME_ID' => $this->theme,
+      'STYLE_ID' => $this->style,
+      'MAIN_PAGE' => get_main_page(),
       'JS_HEADER' => $js_head,
       'JS_FOOTER' => $js_foot,
-      'JS_DYNAMIC_VARS'=>$js_dynamic,
-      'UNREAD_PMS'=>$session->unread_pms,
+      'JS_DYNAMIC_VARS' => $js_dynamic,
+      'UNREAD_PMS' => $session->unread_pms,
       'URL_ABOUT_ENANO' => makeUrlNS('Special', 'About_Enano', '', true),
       'REPORT_URI' => makeUrl($local_fullpage, 'do=sql_report', true)
       );
@@ -2042,10 +2055,17 @@
    * @return string
    */
    
-  function fetch_block($id)
+  function fetch_block($id, $just_the_innards_maam = false)
   {
-    if(isset($this->plugin_blocks[$id])) return $this->plugin_blocks[$id];
-    else return false;
+    if ( $just_the_innards_maam )
+    {
+      $source =& $this->plugin_blocks_content;
+    }
+    else
+    {
+      $source =& $this->plugin_blocks;
+    }
+    return isset($source[$id]) ? $source[$id] : false;
   }
   
   /**
--- a/install/upgrade.php	Sat Nov 15 18:22:13 2008 -0500
+++ b/install/upgrade.php	Sat Nov 15 18:23:25 2008 -0500
@@ -59,7 +59,7 @@
 if ( enano_version() == installer_enano_version() )
 {
   $ui->show_header();
-  $link_home = makeUrl(getConfig('main_page'), false, true);
+  $link_home = makeUrl(get_main_page(), false, true);
   echo '<h3>' . $lang->get('upgrade_err_current_title') . '</h3>' .
        '<p>' . $lang->get('upgrade_err_current_body', array('mainpage_link' => $link_home)) . '</p>' .
        '<p>' . $lang->get('upgrade_err_current_body_para2', array('mainpage_link' => $link_home)) . '</p>';
@@ -255,7 +255,7 @@
   // demote privileges
   $session->logout(USER_LEVEL_ADMIN);
   
-  $link_home = makeUrl(getConfig('main_page'), false, true);
+  $link_home = makeUrl(get_main_page(), false, true);
   echo '<h3>' . $lang->get('upgrade_post_status_finish_title') . '</h3>';
   echo '<p>' . $lang->get('upgrade_post_status_finish_body', array('mainpage_link' => $link_home)) . '</p>';
 }
--- a/language/english/admin.json	Sat Nov 15 18:22:13 2008 -0500
+++ b/language/english/admin.json	Sat Nov 15 18:23:25 2008 -0500
@@ -242,6 +242,9 @@
       field_site_name: 'Site name:',
       field_site_desc: 'Site description:',
       field_main_page: 'Main page:',
+      field_main_page_option_same: 'Use the same main page for everyone',
+      field_main_page_option_members: 'Use a different main page for members:',
+      field_main_page_members: 'Main page for members:',
       field_copyright: 'Copyright notice shown on pages:',
       field_copyright_hint: 'Hint: To make a copyright symbol (&copy;), type <tt>&amp;copy;</tt>.',
       field_contactemail: 'Contact e-mail',
--- a/plugins/SpecialAdmin.php	Sat Nov 15 18:22:13 2008 -0500
+++ b/plugins/SpecialAdmin.php	Sat Nov 15 18:23:25 2008 -0500
@@ -246,10 +246,16 @@
     // Global site options
     setConfig('site_name', $_POST['site_name']);
     setConfig('site_desc', $_POST['site_desc']);
-    setConfig('main_page', str_replace(' ', '_', $_POST['main_page']));
+    setConfig('main_page', sanitize_page_id($_POST['main_page']));
     setConfig('copyright_notice', $_POST['copyright']);
     setConfig('contact_email', $_POST['contact_email']);
     
+    setConfig('main_page_alt_enable', ( isset($_POST['main_page_alt_enable']) && $_POST['main_page_alt_enable'] === '1' ? '1' : '0' ));
+    if ( !empty($_POST['main_page_alt']) )
+    {
+      setConfig('main_page_alt', sanitize_page_id($_POST['main_page_alt']));
+    }
+    
     // Wiki mode
     if(isset($_POST['wikimode']))                setConfig('wiki_mode', '1');
     else                                         setConfig('wiki_mode', '0');
@@ -413,14 +419,76 @@
     <!-- Global options -->
     
       <tr><th colspan="2"><?php echo $lang->get('acpgc_heading_main'); ?></th></tr>
-      <tr><th colspan="2" class="subhead"><?php echo $lang->get('acpgc_heading_submain'); ?></th></tr>
+      
+      <tr>
+        <th colspan="2" class="subhead"><?php echo $lang->get('acpgc_heading_submain'); ?></th>
+      </tr>
+      
+      <!-- site name -->
+      
+      <tr>
+        <td class="row1" style="width: 50%;">
+          <?php echo $lang->get('acpgc_field_site_name'); ?>
+        </td>
+        <td class="row1" style="width: 50%;">
+          <input type="text" name="site_name" size="30" value="<?php echo htmlspecialchars(getConfig('site_name')); ?>" />
+        </td>
+      </tr>
+      
+      <!-- site tagline -->
+      <tr>
+        <td class="row2">
+          <?php echo $lang->get('acpgc_field_site_desc'); ?>
+        </td>
+        <td class="row2">
+          <input type="text" name="site_desc" size="30" value="<?php echo htmlspecialchars(getConfig('site_desc')); ?>" />
+        </td>
+      </tr>
       
-      <tr><td class="row1" style="width: 50%;"><?php echo $lang->get('acpgc_field_site_name'); ?></td>  <td class="row1" style="width: 50%;"><input type="text" name="site_name" size="30" value="<?php echo htmlspecialchars(getConfig('site_name')); ?>" /></td></tr>
-      <tr><td class="row2"><?php echo $lang->get('acpgc_field_site_desc'); ?></td>               <td class="row2"><input type="text" name="site_desc" size="30" value="<?php echo htmlspecialchars(getConfig('site_desc')); ?>" /></td></tr>
-      <tr><td class="row1"><?php echo $lang->get('acpgc_field_main_page'); ?></td>                      <td class="row1"><?php echo $template->pagename_field('main_page', sanitize_page_id(getConfig('main_page'))); ?></td></tr>
-      <tr><td class="row2"><?php echo $lang->get('acpgc_field_copyright'); ?></td><td class="row2"><input type="text" name="copyright" size="30" value="<?php echo htmlspecialchars(getConfig('copyright_notice')); ?>" /></td></tr>
-      <tr><td class="row1" colspan="2"><?php echo $lang->get('acpgc_field_copyright_hint'); ?></td></tr>
-      <tr><td class="row2"><?php echo $lang->get('acpgc_field_contactemail'); ?><br /><small><?php echo $lang->get('acpgc_field_contactemail_hint'); ?></small></td><td class="row2"><input name="contact_email" type="text" size="40" value="<?php echo htmlspecialchars(getConfig('contact_email')); ?>" /></td></tr>
+      <!-- main page -->
+      <tr>
+        <td class="row1">
+          <?php echo $lang->get('acpgc_field_main_page'); ?></td>
+        <td class="row1">
+          <?php echo $template->pagename_field('main_page', sanitize_page_id(getConfig('main_page'))); ?><br />
+            <label><input type="radio" name="main_page_alt_enable" value="0" onclick="$('#main_page_alt_tr').hide();" <?php if ( getConfig('main_page_alt_enable', '0') == '0' ) echo 'checked="checked" '; ?>/> <?php echo $lang->get('acpgc_field_main_page_option_same'); ?></label><br />
+            <label><input type="radio" name="main_page_alt_enable" value="1" onclick="$('#main_page_alt_tr').show();" <?php if ( getConfig('main_page_alt_enable', '0') == '1' ) echo 'checked="checked" '; ?>/> <?php echo $lang->get('acpgc_field_main_page_option_members'); ?></label>
+        </td>
+      </tr>
+      <tr id="main_page_alt_tr"<?php if ( getConfig('main_page_alt_enable', '0') == '0' ) echo ' style="display: none;"'; ?>>
+        <td class="row3">
+          <?php echo $lang->get('acpgc_field_main_page_members'); ?>
+        </td>
+        <td class="row3">
+          <?php echo $template->pagename_field('main_page_alt', sanitize_page_id(getConfig('main_page_alt', /* default alt to current main page */ getConfig('main_page', 'Main_Page')))); ?>
+        </td>
+      </tr>
+      
+      <!-- copyright notice -->
+      <tr>
+        <td class="row2">
+            <?php echo $lang->get('acpgc_field_copyright'); ?>
+        </td>
+        <td class="row2">
+          <input type="text" name="copyright" size="30" value="<?php echo htmlspecialchars(getConfig('copyright_notice')); ?>" />
+        </td>
+      </tr>
+      <tr>
+        <td class="row1" colspan="2">
+          <?php echo $lang->get('acpgc_field_copyright_hint'); ?>
+        </td>
+      </tr>
+      
+      <!-- contact e-mail -->
+      <tr>
+        <td class="row2">
+          <?php echo $lang->get('acpgc_field_contactemail'); ?><br />
+          <small><?php echo $lang->get('acpgc_field_contactemail_hint'); ?></small>
+        </td>
+        <td class="row2">
+          <input name="contact_email" type="text" size="40" value="<?php echo htmlspecialchars(getConfig('contact_email')); ?>" />
+        </td>
+      </tr>
       
     <!-- Wiki mode -->
       
@@ -2084,7 +2152,7 @@
   
   $session->logout(USER_LEVEL_ADMIN);
   echo '<h3>' . $lang->get('acplo_heading_main') . '</h3>
-         <p>' . $lang->get('acplo_msg_logout_complete', array('mainpage_link' => makeUrl(getConfig('main_page')))) . '</p>';
+         <p>' . $lang->get('acplo_msg_logout_complete', array('mainpage_link' => makeUrl(get_main_page()))) . '</p>';
 }
 
 function page_Special_Administration()
@@ -2534,11 +2602,14 @@
           </form>
           
           <script type="text/javascript">
-            var divs = getElementsByClassName(document, 'div', 'sbadd_block');
-            for(var i in divs)
-            {
-              if(divs[i].id != 'blocktype_<?php echo BLOCK_WIKIFORMAT; ?>') setTimeout("document.getElementById('"+divs[i].id+"').style.display = 'none';", 500);
-            }
+            addOnloadHook(function()
+              {
+                var divs = getElementsByClassName(document, 'div', 'sbadd_block');
+                for(var i in divs)
+                {
+                  if(divs[i].id != 'blocktype_<?php echo BLOCK_WIKIFORMAT; ?>') setTimeout("document.getElementById('"+divs[i].id+"').style.display = 'none';", 500);
+                }
+              });
           </script>
           
           <?php
@@ -2769,7 +2840,8 @@
           break;
         case BLOCK_PLUGIN:
           $parser = $template->makeParserText($vars['sidebar_section_raw']);
-          $c = ($template->fetch_block($row['block_content'])) ? $template->fetch_block($row['block_content']) : $lang->get('sbedit_msg_plugin_not_loaded');
+          $c = ($template->fetch_block($row['block_content'], true)) ? $template->fetch_block($row['block_content'], true) : $lang->get('sbedit_msg_plugin_not_loaded');
+          
           break;
       }
       $c = preg_replace('/\{(restrict|hideif) ([a-z0-9_\(\)\|&! ]+)\}/', '', $c);
@@ -2804,7 +2876,7 @@
             <input type="submit" name="save" style="font-weight: bold;" value="' . $lang->get('etc_save_changes') . '" />
             <input type="submit" name="revert" style="font-weight: normal;" value="' . $lang->get('sbedit_btn_revert') . '" onclick="return confirm($lang.get(\'sbedit_msg_discard_order_confirm\'))" />
             <br />
-            <a href="'.makeUrl($paths->page, 'action=new&id=0', true).'">' . $lang->get('sbedit_btn_create_new_stage1') . '</a>  |  <a href="'.makeUrl(getConfig('main_page'), false, true).'">' . $lang->get('sbedit_btn_main_page') . '</a>
+            <a href="'.makeUrl($paths->page, 'action=new&id=0', true).'">' . $lang->get('sbedit_btn_create_new_stage1') . '</a>  |  <a href="'.makeUrl(get_main_page(), false, true).'">' . $lang->get('sbedit_btn_main_page') . '</a>
           </div>
         </form>
          ';
--- a/plugins/SpecialUserFuncs.php	Sat Nov 15 18:22:13 2008 -0500
+++ b/plugins/SpecialUserFuncs.php	Sat Nov 15 18:23:25 2008 -0500
@@ -624,7 +624,7 @@
             'username' => $session->username,
             'redir_target' => $lang->get('user_login_success_body_mainpage')
           );
-        redirect( makeUrl(getConfig('main_page'), false, true), $lang->get('user_login_success_title'), $lang->get('user_login_success_body', $subst) );
+        redirect( makeUrl(get_main_page(), false, true), $lang->get('user_login_success_title'), $lang->get('user_login_success_body', $subst) );
       }
     }
     else
@@ -674,7 +674,7 @@
   $l = $session->logout();
   if ( $l == 'success' )
   {
-    $url = makeUrl(getConfig('main_page'), false, true);
+    $url = makeUrl(get_main_page(), false, true);
     if ( $paths->getParam(1) )
     {
       $pi = explode('/', $paths->getAllParams());
@@ -1442,7 +1442,7 @@
       $ret = ( isset($_POST['return_to']) ) ? $_POST['return_to'] : $paths->getParam(0);
       if ( !$ret )
       {
-        $ret = getConfig('main_page');
+        $ret = get_main_page();
       }
       ?>
         <form action="<?php echo makeUrl($paths->page); ?>" method="post">
@@ -1665,7 +1665,7 @@
       if($q)
       {
         $session->login_without_crypto($row['username'], $data);
-        echo '<p>' . $lang->get('userfuncs_passreset_stage2_success', array('url_mainpage' => makeUrl(getConfig('main_page')))) . '</p>';
+        echo '<p>' . $lang->get('userfuncs_passreset_stage2_success', array('url_mainpage' => makeUrl(get_main_page()))) . '</p>';
       }
       else
       {
--- a/plugins/SpecialUserPrefs.php	Sat Nov 15 18:22:13 2008 -0500
+++ b/plugins/SpecialUserPrefs.php	Sat Nov 15 18:23:25 2008 -0500
@@ -269,11 +269,11 @@
               {
                 if ( getConfig('account_activation') == 'user' )
                 {
-                  redirect(makeUrl(getConfig('main_page')), $lang->get('usercp_emailpassword_msg_profile_success'), $lang->get('usercp_emailpassword_msg_need_activ_user'), 20);
+                  redirect(makeUrl(get_main_page()), $lang->get('usercp_emailpassword_msg_profile_success'), $lang->get('usercp_emailpassword_msg_need_activ_user'), 20);
                 }
                 else if ( getConfig('account_activation') == 'admin' )
                 {
-                  redirect(makeUrl(getConfig('main_page')), $lang->get('usercp_emailpassword_msg_profile_success'), $lang->get('usercp_emailpassword_msg_need_activ_admin'), 20);
+                  redirect(makeUrl(get_main_page()), $lang->get('usercp_emailpassword_msg_profile_success'), $lang->get('usercp_emailpassword_msg_need_activ_admin'), 20);
                 }
               }
               $session->login_without_crypto($session->username, $newpass);
@@ -298,11 +298,11 @@
               {
                 if ( getConfig('account_activation') == 'user' )
                 {
-                  redirect(makeUrl(getConfig('main_page')), $lang->get('usercp_emailpassword_msg_profile_success'), $lang->get('usercp_emailpassword_msg_need_activ_user'), 20);
+                  redirect(makeUrl(get_main_page()), $lang->get('usercp_emailpassword_msg_profile_success'), $lang->get('usercp_emailpassword_msg_need_activ_user'), 20);
                 }
                 else if ( getConfig('account_activation') == 'admin' )
                 {
-                  redirect(makeUrl(getConfig('main_page')), $lang->get('usercp_emailpassword_msg_profile_success'), $lang->get('usercp_emailpassword_msg_need_activ_admin'), 20);
+                  redirect(makeUrl(get_main_page()), $lang->get('usercp_emailpassword_msg_profile_success'), $lang->get('usercp_emailpassword_msg_need_activ_admin'), 20);
                 }
               }
               else
--- a/plugins/admin/PageManager.php	Sat Nov 15 18:22:13 2008 -0500
+++ b/plugins/admin/PageManager.php	Sat Nov 15 18:23:25 2008 -0500
@@ -149,7 +149,7 @@
             // Field: page URL string
             $page_urlname = $_POST['page_urlname'];
             $page_urlname = trim($_POST['page_urlname']);
-            if ( empty($page_urlname) && getConfig('main_page') !== '' )
+            if ( empty($page_urlname) && get_main_page() !== '' )
             {
               $errors[] = $lang->get('acppm_err_invalid_url_string');
             }
--- a/plugins/admin/UserManager.php	Sat Nov 15 18:22:13 2008 -0500
+++ b/plugins/admin/UserManager.php	Sat Nov 15 18:23:25 2008 -0500
@@ -1114,24 +1114,24 @@
                         {
                           case 'keep':
                           case 'remove':
-                            $('avatar_upload_http_{UUID}').object.style.display = 'none';
-                            $('avatar_upload_file_{UUID}').object.style.display = 'none';
-                            $('avatar_upload_gravatar_{UUID}').object.style.display = 'none';
+                            \$dynano('avatar_upload_http_{UUID}').object.style.display = 'none';
+                            \$dynano('avatar_upload_file_{UUID}').object.style.display = 'none';
+                            \$dynano('avatar_upload_gravatar_{UUID}').object.style.display = 'none';
                             break;
                           case 'set_http':
-                            $('avatar_upload_http_{UUID}').object.style.display = 'block';
-                            $('avatar_upload_file_{UUID}').object.style.display = 'none';
-                            $('avatar_upload_gravatar_{UUID}').object.style.display = 'none';
+                            \$dynano('avatar_upload_http_{UUID}').object.style.display = 'block';
+                            \$dynano('avatar_upload_file_{UUID}').object.style.display = 'none';
+                            \$dynano('avatar_upload_gravatar_{UUID}').object.style.display = 'none';
                             break;
                           case 'set_file':
-                            $('avatar_upload_http_{UUID}').object.style.display = 'none';
-                            $('avatar_upload_file_{UUID}').object.style.display = 'block';
-                            $('avatar_upload_gravatar_{UUID}').object.style.display = 'none';
+                            \$dynano('avatar_upload_http_{UUID}').object.style.display = 'none';
+                            \$dynano('avatar_upload_file_{UUID}').object.style.display = 'block';
+                            \$dynano('avatar_upload_gravatar_{UUID}').object.style.display = 'none';
                             break;
                           case 'set_gravatar':
-                            $('avatar_upload_gravatar_{UUID}').object.style.display = 'block';
-                            $('avatar_upload_http_{UUID}').object.style.display = 'none';
-                            $('avatar_upload_file_{UUID}').object.style.display = 'none';
+                            \$dynano('avatar_upload_gravatar_{UUID}').object.style.display = 'block';
+                            \$dynano('avatar_upload_http_{UUID}').object.style.display = 'none';
+                            \$dynano('avatar_upload_file_{UUID}').object.style.display = 'none';
                             break;
                         }
                       }