6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Displays messagelist column order options
14 /* Path for SquirrelMail required files. */
15 define('SM_PATH','../');
17 /* SquirrelMail required files. */
18 require_once(SM_PATH
. 'include/validate.php');
19 require_once(SM_PATH
. 'functions/global.php');
20 require_once(SM_PATH
. 'functions/display_messages.php');
21 require_once(SM_PATH
. 'functions/imap.php');
22 require_once(SM_PATH
. 'functions/plugin.php');
23 require_once(SM_PATH
. 'functions/html.php');
26 sqgetGlobalVar('num', $num, SQ_GET
);
27 sqgetGlobalVar('add', $add, SQ_POST
);
29 sqgetGlobalVar('submit', $submit);
30 sqgetGlobalVar('method', $method);
31 /* end of get globals */
33 displayPageHeader($color, 'None');
36 html_tag( 'table', '', 'center', '', 'width="95%" border="0" cellpadding="1" cellspacing="0"' ) .
38 html_tag( 'td', '', 'center', $color[0] ) .
39 '<b>' . _("Options") . ' - ' . _("Index Order") . '</b>' .
40 html_tag( 'table', '', '', '', 'width="100%" border="0" cellpadding="8" cellspacing="0"' ) .
42 html_tag( 'td', '', 'center', $color[4] );
44 $available[1] = _("Checkbox");
45 $available[2] = _("From");
46 $available[3] = _("Date");
47 $available[4] = _("Subject");
48 $available[5] = _("Flags");
49 $available[6] = _("Size");
51 if (! isset($method)) { $method = ''; }
53 if ($method == 'up' && $num > 1) {
55 $tmp = $index_order[$prev];
56 $index_order[$prev] = $index_order[$num];
57 $index_order[$num] = $tmp;
58 } else if ($method == 'down' && $num < count($index_order)) {
60 $tmp = $index_order[$next];
61 $index_order[$next] = $index_order[$num];
62 $index_order[$num] = $tmp;
63 } else if ($method == 'remove' && $num) {
64 for ($i=1; $i < 8; $i++
) {
65 removePref($data_dir, $username, "order$i");
67 for ($j=1,$i=1; $i <= count($index_order); $i++
) {
69 $new_ary[$j] = $index_order[$i];
73 $index_order = array();
74 $index_order = $new_ary;
75 if (count($index_order) < 1) {
76 include_once('../src/load_prefs.php');
78 } else if ($method == 'add' && $add) {
79 /* User should not be able to insert PHP-code here */
80 $add = str_replace ('<?', '..', $add);
81 $add = ereg_replace ('<.*script.*language.*php.*>', '..', $add);
82 $add = str_replace ('<%', '..', $add);
83 $index_order[count($index_order)+
1] = $add;
87 for ($i=1; $i <= count($index_order); $i++
) {
88 setPref($data_dir, $username, "order$i", $index_order[$i]);
91 echo html_tag( 'table',
94 _("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.")
97 '', '', '', 'width="65%" border="0" cellpadding="0" cellspacing="0"' ) . "<br>\n";
99 if (count($index_order))
101 echo html_tag( 'table', '', '', '', ' cellspacing="0" cellpadding="0" border="0"' ) . "\n";
102 for ($i=1; $i <= count($index_order); $i++
) {
103 $tmp = $index_order[$i];
104 echo html_tag( 'tr' );
105 echo html_tag( 'td', '<small><a href="options_order.php?method=up&num=' . $i . '">'. _("up") .'</a></small>' );
106 echo html_tag( 'td', '<small> | </small>' );
107 echo html_tag( 'td', '<small><a href="options_order.php?method=down&num=' . $i . '">'. _("down") .'</a></small>' );
108 echo html_tag( 'td', '<small> | </small>' );
109 echo html_tag( 'td' );
110 /* Always show the subject */
112 echo '<small><a href="options_order.php?method=remove&num=' . $i . '">' . _("remove") . '</a></small>';
116 echo html_tag( 'td', '<small> - </small>' );
117 echo html_tag( 'td', $available[$tmp] );
120 echo '</table>' . "\n";
123 if (count($index_order) != count($available)) {
124 echo '<form name="f" method="post" action="options_order.php">';
125 echo '<select name="add">';
126 for ($i=1; $i <= count($available); $i++
) {
128 for ($j=1; $j <= count($index_order); $j++
) {
129 if ($index_order[$j] == $i) {
134 echo "<option value=\"$i\">$available[$i]</option>";
138 echo '<input type="hidden" value="add" name="method">';
139 echo '<input type="submit" value="'._("Add").'" name="submit">';
143 echo html_tag( 'p', '<a href="../src/options.php">' . _("Return to options page") . '</a></p><br>' );