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/display_messages.php');
20 require_once(SM_PATH
. 'functions/imap.php');
21 require_once(SM_PATH
. 'functions/plugin.php');
22 require_once(SM_PATH
. 'functions/html.php');
25 if (isset($_GET['num'])) {
28 if (isset($_GET['method'])) {
29 $method = $_GET['method'];
31 elseif (isset($_POST['method'])) {
32 $method = $_POST['method'];
34 if (isset($_POST['add'])) {
37 if (isset($_GET['submit'])) {
38 $submit = $_GET['submit'];
40 elseif (isset($_POST['submit'])) {
41 $submit = $_POST['submit'];
43 /* end of get globals */
45 displayPageHeader($color, 'None');
48 html_tag( 'table', '', 'center', '', 'width="95%" border="0" cellpadding="1" cellspacing="0"' ) .
50 html_tag( 'td', '', 'center', $color[0] ) .
51 '<b>' . _("Options") . ' - ' . _("Index Order") . '</b>' .
52 html_tag( 'table', '', '', '', 'width="100%" border="0" cellpadding="8" cellspacing="0"' ) .
54 html_tag( 'td', '', 'center', $color[4] );
56 $available[1] = _("Checkbox");
57 $available[2] = _("From");
58 $available[3] = _("Date");
59 $available[4] = _("Subject");
60 $available[5] = _("Flags");
61 $available[6] = _("Size");
63 if (! isset($method)) { $method = ''; }
65 if ($method == 'up' && $num > 1) {
67 $tmp = $index_order[$prev];
68 $index_order[$prev] = $index_order[$num];
69 $index_order[$num] = $tmp;
70 } else if ($method == 'down' && $num < count($index_order)) {
72 $tmp = $index_order[$next];
73 $index_order[$next] = $index_order[$num];
74 $index_order[$num] = $tmp;
75 } else if ($method == 'remove' && $num) {
76 for ($i=1; $i < 8; $i++
) {
77 removePref($data_dir, $username, "order$i");
79 for ($j=1,$i=1; $i <= count($index_order); $i++
) {
81 $new_ary[$j] = $index_order[$i];
85 $index_order = array();
86 $index_order = $new_ary;
87 if (count($index_order) < 1) {
88 include_once('../src/load_prefs.php');
90 } else if ($method == 'add' && $add) {
91 /* User should not be able to insert PHP-code here */
92 $add = str_replace ('<?', '..', $add);
93 $add = ereg_replace ('<.*script.*language.*php.*>', '..', $add);
94 $add = str_replace ('<%', '..', $add);
95 $index_order[count($index_order)+
1] = $add;
99 for ($i=1; $i <= count($index_order); $i++
) {
100 setPref($data_dir, $username, "order$i", $index_order[$i]);
103 echo html_tag( 'table',
106 _("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.")
109 '', '', '', 'width="65%" border="0" cellpadding="0" cellspacing="0"' ) . "<br>\n";
111 if (count($index_order))
113 echo html_tag( 'table', '', '', '', ' cellspacing="0" cellpadding="0" border="0"' ) . "\n";
114 for ($i=1; $i <= count($index_order); $i++
) {
115 $tmp = $index_order[$i];
116 echo html_tag( 'tr' );
117 echo html_tag( 'td', '<small><a href="options_order.php?method=up&num=' . $i . '">'. _("up") .'</a></small>' );
118 echo html_tag( 'td', '<small> | </small>' );
119 echo html_tag( 'td', '<small><a href="options_order.php?method=down&num=' . $i . '">'. _("down") .'</a></small>' );
120 echo html_tag( 'td', '<small> | </small>' );
121 echo html_tag( 'td' );
122 /* Always show the subject */
124 echo '<small><a href="options_order.php?method=remove&num=' . $i . '">' . _("remove") . '</a></small>';
128 echo html_tag( 'td', '<small> - </small>' );
129 echo html_tag( 'td', $available[$tmp] );
132 echo '</table>' . "\n";
135 if (count($index_order) != count($available)) {
136 echo '<form name="f" method="post" action="options_order.php">';
137 echo '<select name="add">';
138 for ($i=1; $i <= count($available); $i++
) {
140 for ($j=1; $j <= count($index_order); $j++
) {
141 if ($index_order[$j] == $i) {
146 echo "<option value=\"$i\">$available[$i]</option>";
150 echo '<input type="hidden" value="add" name="method">';
151 echo '<input type="submit" value="'._("Add").'" name="submit">';
155 echo html_tag( 'p', '<a href="../src/options.php">' . _("Return to options page") . '</a></p><br>' );