-
-
-
-
-
-
-
- 1) {
- $prev = $num-1;
- $tmp = $index_order[$prev];
- $index_order[$prev] = $index_order[$num];
- $index_order[$num] = $tmp;
- } else if ($method == 'down' && $num < count($index_order)) {
- $next = $num++;
- $tmp = $index_order[$next];
- $index_order[$next] = $index_order[$num];
- $index_order[$num] = $tmp;
- } else if ($method == 'remove' && $num) {
- for ($i=1; $i < 8; $i++) {
- removePref($data_dir, $username, "order$i");
- }
- for ($j=1,$i=1; $i <= count($index_order); $i++) {
- if ($i != $num) {
- $new_ary[$j] = $index_order[$i];
- $j++;
- }
- }
- $index_order = array();
- $index_order = $new_ary;
- if (count($index_order) < 1) {
- include_once('../src/load_prefs.php');
- }
- } else if ($method == 'add' && $add) {
- // User should not be able to insert PHP-code here
- $add = str_replace ('', '..', $add);
- $add = ereg_replace ('<.*script.*language.*php.*>', '..', $add);
- $add = str_replace ('<%', '..', $add);
- $index_order[count($index_order)+1] = $add;
+/**
+ * Include the SquirrelMail initialization file.
+ */
+require('../include/init.php');
+
+/* SquirrelMail required files. */
+require_once(SM_PATH . 'functions/forms.php');
+
+/* get globals */
+if (sqgetGlobalVar('num', $num, SQ_GET)) {
+ $num = (int) $num;
+} else {
+ $num = false;
+}
+if (!sqgetGlobalVar('method', $method)) {
+ $method = '';
+} else {
+ $method = htmlspecialchars($method);
+}
+if (!sqgetGlobalVar('positions', $pos, SQ_GET)) {
+ $pos = 0;
+} else {
+ $pos = (int) $pos;
+}
+
+if (!sqgetGlobalVar('account', $account, SQ_GET)) {
+ $iAccount = 0;
+} else {
+ $iAccount = (int) $account;
+}
+
+if (sqgetGlobalVar('mailbox', $mailbox, SQ_GET)) {
+ $aMailboxPrefs = unserialize(getPref($data_dir, $username, "pref_".$iAccount.'_'.$mailbox));
+ if (isset($aMailboxPrefs[MBX_PREF_COLUMNS])) {
+ $index_order = $aMailboxPrefs[MBX_PREF_COLUMNS];
}
+} else {
+ $index_order_ser = getPref($data_dir, $username, 'index_order');
+ if ($index_order_ser) {
+ $index_order=unserialize($index_order_ser);
+ }
+}
+if (!isset($index_order)) {
+ if (isset($internal_date_sort) && $internal_date_sort == false) {
+ $index_order = array(SQM_COL_CHECK,SQM_COL_FROM,SQM_COL_DATE,SQM_COL_FLAGS,SQM_COL_ATTACHMENT,SQM_COL_PRIO,SQM_COL_SUBJ);
+ } else {
+ $index_order = array(SQM_COL_CHECK,SQM_COL_FROM,SQM_COL_INT_DATE,SQM_COL_FLAGS,SQM_COL_ATTACHMENT,SQM_COL_PRIO,SQM_COL_SUBJ);
+ }
+}
+
+if (!sqgetGlobalVar('account', $account, SQ_GET)) {
+ $account = 0; // future work, multiple imap accounts
+} else {
+ $account = (int) $account;
+}
+
+/* end of get globals */
+
+/***************************************************************/
+/* Finally, display whatever page we are supposed to show now. */
+/***************************************************************/
+
+displayPageHeader($color, null, (isset($optpage_data['xtra']) ? $optpage_data['xtra'] : ''));
- if ($method) {
- for ($i=1; $i <= count($index_order); $i++) {
- setPref($data_dir, $username, "order$i", $index_order[$i]);
- }
- }
- echo '' . "\n";
- 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.");
- echo ' |
';
-
- if (count($index_order))
- {
- echo '' . "\n";
- for ($i=1; $i <= count($index_order); $i++) {
- $tmp = $index_order[$i];
- echo '';
- echo "". _("up") ." | \n";
- echo ' | | ' . "\n";
- echo "". _("down") . " | \n";
- echo ' | | ' . "\n";
- echo '';
- // Always show the subject
- if ($tmp != 4)
- echo "" . _("remove") . '';
- echo " | \n";
- echo ' - | ' . "\n";
- echo '' . $available[$tmp] . " | \n";
- echo " \n";
- }
- echo " \n";
- }
-
- if (count($index_order) != count($available)) {
- echo '';
- }
+ }
+}
+
+// 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 ? '&mailbox='.urlencode($mailbox) : '';
- echo '' . _("Return to options page") . ' ';
+$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));
-?>
-
-
+// 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&positions=-1'. $x .'&num=');
+$oTemplate->assign('move_down', $PHP_SELF .'?method=move&positions=1'. $x .'&num=');
+$oTemplate->assign('remove', $PHP_SELF .'?method=remove'. $x .'&num=');
+$oTemplate->assign('add', $PHP_SELF.'?method=add'.$x.'&num=');
+$oTemplate->assign('addField_action', $PHP_SELF);
- |
-
+$oTemplate->display('options_order.tpl');
- |
-