reverting some templating changes. They broke plugin blocks.
[squirrelmail.git] / src / options.php
index 9607582d80af4ba56ed948fff4fcec6c67bb3a75..3968e12151a30059547193433351b2bb28011a09 100644 (file)
  */
 
 /**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
  */
-define('SM_PATH','../');
+require('../include/init.php');
 
 /* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
-include_once(SM_PATH . 'functions/global.php');
-include_once(SM_PATH . 'functions/display_messages.php');
-include_once(SM_PATH . 'functions/imap.php');
-include_once(SM_PATH . 'functions/options.php');
-include_once(SM_PATH . 'functions/strings.php');
-include_once(SM_PATH . 'functions/html.php');
-include_once(SM_PATH . 'functions/forms.php');
+
+//include(SM_PATH . 'functions/imap_general.php');
+require_once(SM_PATH . 'functions/options.php');
+require_once(SM_PATH . 'functions/forms.php');
 
 /*********************************/
 /*** Build the resultant page. ***/
@@ -74,57 +69,10 @@ function process_optionmode_link($optpage) {
 }
 
 
-/**
- * This function prints out an option page row.
- */
-function print_optionpages_row($leftopt, $rightopt = false) {
-    global $color;
-
-    if ($rightopt) {
-        $rightopt_name = html_tag( 'td', '<a href="' . $rightopt['url'] . '">' . $rightopt['name'] . '</a>', 'left', $color[9], 'valign="top" width="49%"' );
-        $rightopt_desc = html_tag( 'td', $rightopt['desc'], 'left', $color[0], 'valign="top" width="49%"' );
-    } else {
-        $rightopt_name = html_tag( 'td', '&nbsp;', 'left', $color[4], 'valign="top" width="49%"' );
-        $rightopt_desc = html_tag( 'td', '&nbsp;', 'left', $color[4], 'valign="top" width="49%"' );
-    }
-
-    echo
-    html_tag( 'table', "\n" .
-        html_tag( 'tr', "\n" .
-            html_tag( 'td', "\n" .
-                html_tag( 'table', "\n" .
-                    html_tag( 'tr', "\n" .
-                        html_tag( 'td',
-                            '<a href="' . $leftopt['url'] . '">' . $leftopt['name'] . '</a>' ,
-                        'left', $color[9], 'valign="top" width="49%"' ) .
-                        html_tag( 'td',
-                            '&nbsp;' ,
-                        'left', $color[4], 'valign="top" width="2%"' ) . "\n" .
-                        $rightopt_name
-                    ) . "\n" .
-                    html_tag( 'tr', "\n" .
-                        html_tag( 'td',
-                            $leftopt['desc'] ,
-                        'left', $color[0], 'valign="top" width="49%"' ) .
-                        html_tag( 'td',
-                            '&nbsp;' ,
-                        'left', $color[4], 'valign="top" width="2%"' ) . "\n" .
-                        $rightopt_desc
-                    ) ,
-                '', '', 'width="100%" cellpadding="2" cellspacing="0" border="0"' ) ,
-            'left', '', 'valign="top"' )
-        ) ,
-    '', $color[4], 'width="100%" cellpadding="0" cellspacing="5" border="0"' );
-}
 
 /* ---------------------------- main ---------------------------- */
 
 /* get the globals that we may need */
-sqgetGlobalVar('key',       $key,           SQ_COOKIE);
-sqgetGlobalVar('username',  $username,      SQ_SESSION);
-sqgetGlobalVar('onetimepad',$onetimepad,    SQ_SESSION);
-sqgetGlobalVar('delimiter', $delimiter,     SQ_SESSION);
-
 sqgetGlobalVar('optpage',     $optpage);
 sqgetGlobalVar('optmode',     $optmode,      SQ_FORM);
 sqgetGlobalVar('optpage_data',$optpage_data, SQ_POST);
@@ -297,32 +245,35 @@ if ($optpage == SMOPT_PAGE_MAIN) {
     /**********************************************************/
     /* First, display the results of a submission, if needed. */
     /**********************************************************/
+    $notice = '';
     if ($optmode == SMOPT_MODE_SUBMIT) {
         if (!isset($frame_top)) {
             $frame_top = '_top';
         }
 
         if (isset($optpage_save_error) && $optpage_save_error!=array()) {
-            echo "<font color=\"$color[2]\"><b>" . _("Error(s) occurred while saving your options") . "</b></font><br />\n";
-            echo "<ul>\n";
+            $notice = "<font color=\"$color[2]\"><b>" . _("Error(s) occurred while saving your options") . "</b></font><br />\n"
+                ."<ul>\n";
             foreach ($optpage_save_error as $error_message) {
-                echo '<li><small>' . $error_message . "</small></li>\n";
+                $notice.= '<li><small>' . $error_message . "</small></li>\n";
             }
-            echo "</ul>\n";
-            echo '<b>' . _("Some of your preference changes were not applied.") . "</b><br />\n";
+            $notice.= "</ul>\n"
+                . '<b>' . _("Some of your preference changes were not applied.") . "</b><br />\n";
         } else {
             /* Display a message indicating a successful save. */
-            echo '<b>' . _("Successfully Saved Options") . ": $optpage_name</b><br />\n";
+            $notice = '<b>' . _("Successfully Saved Options") . ": $optpage_name</b><br />\n";
         }
 
         /* If $max_refresh != SMOPT_REFRESH_NONE, provide a refresh link. */
         if ( !isset( $max_refresh ) ) {
         } else if ($max_refresh == SMOPT_REFRESH_FOLDERLIST) {
-            echo '<a href="../src/left_main.php" target="left">' . _("Refresh Folder List") . '</a><br />';
+            $notice .= '<a href="../src/left_main.php" target="left">' . _("Refresh Folder List") . '</a><br />';
         } else if ($max_refresh) {
-            echo '<a href="../src/webmail.php?right_frame=options.php" target="' . $frame_top . '">' . _("Refresh Page") . '</a><br />';
+            $notice .= '<a href="../src/webmail.php?right_frame=options.php" target="' . $frame_top . '">' . _("Refresh Page") . '</a><br />';
         }
     }
+    $oTemplate->assign('notice',$notice);
+
     /******************************************/
     /* Build our array of Option Page Blocks. */
     /******************************************/
@@ -396,27 +347,10 @@ if ($optpage == SMOPT_PAGE_MAIN) {
     /********************************************/
     /* Now, print out each option page section. */
     /********************************************/
-    $first_optpage = false;
-    echo html_tag( 'table', '', '', $color[4], 'width="100%" cellpadding="0" cellspacing="5" border="0"' ) . "\n" .
-                html_tag( 'tr' ) . "\n" .
-                    html_tag( 'td', '', 'left', '', 'valign="top"' ) .
-                        html_tag( 'table', '', '', $color[4], 'width="100%" cellpadding="3" cellspacing="0" border="0"' ) . "\n" .
-                            html_tag( 'tr' ) . "\n" .
-                                html_tag( 'td', '', 'left' );
-    foreach ($optpage_blocks as $next_optpage) {
-        if ($first_optpage == false) {
-            $first_optpage = $next_optpage;
-        } else {
-            print_optionpages_row($first_optpage, $next_optpage);
-            $first_optpage = false;
-        }
-    }
 
-    if ($first_optpage != false) {
-        print_optionpages_row($first_optpage);
-    }
-
-    echo "</td></tr></table></td></tr></table>\n";
+    $oTemplate->assign('color',$color);
+    $oTemplate->assign('optpage_blocks',$optpage_blocks);
+    $oTemplate->display('option_groups.tpl');
 
     do_hook('options_link_and_description');
 
@@ -484,13 +418,13 @@ if ($optpage == SMOPT_PAGE_MAIN) {
     if ($bottom_hook_name != '') {
         do_hook($bottom_hook_name);
     }
+    if (isset($max_refresh)) $oTemplate->assign('max_refresh',$max_refresh);
+    $oTemplate->assign('color',$color);
+    $oTemplate->assign('optpage',$optpage);
+    $oTemplate->assign('optpage_name',$optpage_name);
+    $oTemplate->assign('optpage_data',$optpage_data);
+    $oTemplate->assign('optmode',$optmode);
+    $oTemplate->display('options.tpl');
 }
 
-?>
-</td></tr>
-</table>
-</td></tr>
-</table>
-<?php
 $oTemplate->display('footer.tpl');
-?>
\ No newline at end of file