Happy New Year
[squirrelmail.git] / src / options_order.php
index 6d4e252bbb070c374030e39c8e47f07e78849930..bf4b8993280f736166793d18730efb6e74780767 100644 (file)
@@ -1,33 +1,26 @@
 <?php
-
 /**
  * options_order.php
  *
- * Copyright (c) 1999-2005 The SquirrelMail Project Team
- * Licensed under the GNU GPL. For full terms see the file COPYING.
- *
  * Displays messagelist column order options
  *
+ * @copyright 1999-2018 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
+ * @subpackage prefs
  */
 
+/** This is the options_order page */
+define('PAGE_NAME', 'options_order');
+
 /**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
  */
-define('SM_PATH','../');
+require('../include/init.php');
 
 /* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/global.php');
-require_once(SM_PATH . 'functions/display_messages.php');
-require_once(SM_PATH . 'functions/imap.php');
-require_once(SM_PATH . 'functions/plugin.php');
-require_once(SM_PATH . 'functions/html.php');
 require_once(SM_PATH . 'functions/forms.php');
-require_once(SM_PATH . 'functions/arrays.php');
-require_once(SM_PATH . 'functions/options.php');
 
 /* get globals */
 if (sqgetGlobalVar('num',       $num,       SQ_GET)) {
@@ -38,7 +31,7 @@ if (sqgetGlobalVar('num',       $num,       SQ_GET)) {
 if (!sqgetGlobalVar('method', $method)) {
     $method = '';
 } else {
-    $method = htmlspecialchars($method);
+    $method = sm_encode_html_special_chars($method);
 }
 if (!sqgetGlobalVar('positions', $pos, SQ_GET)) {
     $pos = 0;
@@ -53,7 +46,7 @@ if (!sqgetGlobalVar('account', $account, SQ_GET)) {
 }
 
 if (sqgetGlobalVar('mailbox', $mailbox, SQ_GET)) {
-   $aMailboxPrefs = unserialize(getPref($data_dir, $username, "pref_".$iAccount.'_'.urldecode($mailbox)));
+   $aMailboxPrefs = unserialize(getPref($data_dir, $username, "pref_".$iAccount.'_'.$mailbox));
    if (isset($aMailboxPrefs[MBX_PREF_COLUMNS])) {
        $index_order = $aMailboxPrefs[MBX_PREF_COLUMNS];
    }
@@ -83,7 +76,7 @@ if (!sqgetGlobalVar('account', $account,  SQ_GET)) {
 /* Finally, display whatever page we are supposed to show now. */
 /***************************************************************/
 
-displayPageHeader($color, 'None', (isset($optpage_data['xtra']) ? $optpage_data['xtra'] : ''));
+displayPageHeader($color, null, (isset($optpage_data['xtra']) ? $optpage_data['xtra'] : ''));
 
 
 /**
@@ -100,7 +93,8 @@ function change_columns_list(&$index_order,$method,$num,$pos=0) {
     switch ($method) {
       case 'move': $r = sqm_array_move_value($index_order,$num,$pos); break;
       case 'add':
-          $index_order[] = (int) $num; $r = true;
+          $index_order[] = (int) $num;
+          $r = true;
           /**
            * flush the cache in order to retrieve the new columns
            */
@@ -132,7 +126,7 @@ $available[SQM_COL_ATTACHMENT] = _("Attachments");
 $available[SQM_COL_INT_DATE]   = _("Received");
 $available[SQM_COL_TO]         = _("To");
 $available[SQM_COL_CC]         = _("Cc");
-$available[SQM_COL_BCC]        = _("bcc");
+$available[SQM_COL_BCC]        = _("Bcc");
 
 if (change_columns_list($index_order,$method,$num,$pos)) {
     if ($method) {
@@ -151,91 +145,22 @@ if (count($index_order) != count($available)) {
     }
 }
 
+// FIXME: why are we using this?  $PHP_SELF is already a global var processed (and therefore trustworthy) by init.php
+sqgetGlobalVar('PHP_SELF', $PHP_SELF, SQ_SERVER);
+$x = isset($mailbox) && $mailbox ? '&amp;mailbox='.urlencode($mailbox) : '';
 
+$oTemplate->assign('fields', $available);
+$oTemplate->assign('current_order', $index_order);
+$oTemplate->assign('not_used', $opts);
+$oTemplate->assign('always_show', array(SQM_COL_SUBJ, SQM_COL_FLAGS));
 
-viewOrderForm($available, $index_order,$opts,urldecode($mailbox));
-
-
-
-// FOOD for html designers
-function viewOrderForm($aColumns, $aOrder, $aOpts, $mailbox) {
-   global $color;
-?>
-
-  <table align="center" width="95%" border="0" cellpadding="1" cellspacing="0">
-    <tr>
-      <td align="center" bgcolor="<?php echo $color[0];?>">
-        <b> <?php echo _("Options");?> - <?php echo _("Index Order");?> </b>
-        <table width="100%" border="0" cellpadding="8" cellspacing="0">
-          <tr>
-            <td align="center" bgcolor="<?php echo $color[4];?>">
-              <table width="65%" border="0" cellpadding="0" cellspacing="0">
-                <tr>
-                  <td>
-                    <?php echo _("The index order is the order that the columns are arranged in the message index. You can add, remove, and move columns around to customize them to fit your needs.");?>
-                  </td>
-                </tr>
-              </table>
-              <br>
-
-<?php if (count($aOrder)) { ?>
-              <table cellspacing="0" cellpadding="0" border="0">
-<?php     foreach($aOrder as $i => $iCol) {
-             $sQuery = "&amp;num=$iCol";
-             if (isset($mailbox) && $mailbox) {
-                 $sQuery .= '&amp;mailbox='.urlencode($mailbox);
-             }
-
-?>
-                <tr>
-<?php         if ($i) { ?>
-                  <td><small><a href="options_order.php?method=move&amp;positions=-1&amp;num=<?php echo $sQuery; ?>"> <?php echo _("up");?> </a></small></td>
-<?php         } else { ?>
-                  <td>&nbsp;</td>
-<?php         } // else ?>
-                  <td><small>&nbsp;|&nbsp;</small></td>
-<?php         if ($i < count($aOrder) -1) { ?>
-                  <td><small><a href="options_order.php?method=move&amp;positions=1&amp;num=<?php echo $sQuery; ?>"> <?php echo _("down");?> </a></small></td>
-<?php         } else { ?>
-                  <td>&nbsp;</td>
-<?php         } // else ?>
-                  <td><small>&nbsp;|&nbsp;</small></td>
-<?php
-              /* Always show the subject */
-              if ($iCol != SQM_COL_SUBJ) {
-?>
-                  <td><small><a href="options_order.php?method=remove&amp;num=<?php echo $sQuery; ?>"> <?php echo _("remove");?> </a></small></td>
-<?php         } else { ?>
-                  <td>&nbsp;</td>
-<?php         } // else ?>
-                  <td><small>&nbsp;|&nbsp;</small></td>
-                  <td><?php echo $aColumns[$iCol]; ?></td>
-                </tr>
-<?php
-          } // foreach
-      } // if
-?>
-              </table>
+// FIXME: (related to the above) $PHP_SELF might already have a query string... don't assume otherwise here by adding the ? sign!!
+$oTemplate->assign('move_up', $PHP_SELF .'?method=move&amp;positions=-1'. $x .'&amp;num=');
+$oTemplate->assign('move_down', $PHP_SELF .'?method=move&amp;positions=1'. $x .'&amp;num=');
+$oTemplate->assign('remove', $PHP_SELF .'?method=remove'. $x .'&amp;num=');
+$oTemplate->assign('add', $PHP_SELF.'?method=add'.$x.'&amp;num=');
+$oTemplate->assign('addField_action', $PHP_SELF);
 
-<?php
-    if (count($aOpts)) {
-        echo addForm('options_order.php', 'get', 'f');
-        echo addSelect('num', $aOpts, '', TRUE);
-        echo addHidden('method', 'add');
-        if (isset($mailbox) && $mailbox) {
-            echo addHidden('mailbox', urlencode($mailbox));
-        }
-        echo addSubmit(_("Add"), 'submit');
-        echo '</form>';
-    }
-?>
-          <p><a href="../src/options.php"><?php echo _("Return to options page");?></a></p><br>
-        </td></tr>
-      </table>
-    </td></tr>
-  </table>
-</body></html>
+$oTemplate->display('options_order.tpl');
 
-<?php
-}
-?>
\ No newline at end of file
+$oTemplate->display('footer.tpl');