Getting ready for 1.4.0 RC1
[squirrelmail.git] / src / options_order.php
CommitLineData
221ca7bf 1<?php
895905c0 2
35586184 3/**
4 * options_order.php
5 *
76911253 6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
35586184 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
1c159927 9 * Displays messagelist column order options
35586184 10 *
11 * $Id$
12 */
13
86725763 14/* Path for SquirrelMail required files. */
15define('SM_PATH','../');
16
17/* SquirrelMail required files. */
08185f2a 18require_once(SM_PATH . 'include/validate.php');
86725763 19require_once(SM_PATH . 'functions/display_messages.php');
20require_once(SM_PATH . 'functions/imap.php');
86725763 21require_once(SM_PATH . 'functions/plugin.php');
22require_once(SM_PATH . 'functions/html.php');
221ca7bf 23
fe369c70 24/* get globals */
fe369c70 25if (isset($_GET['num'])) {
26 $num = $_GET['num'];
27}
28if (isset($_GET['method'])) {
29 $method = $_GET['method'];
30}
31elseif (isset($_POST['method'])) {
32 $method = $_POST['method'];
33}
34if (isset($_POST['add'])) {
35 $add = $_POST['add'];
36}
37if (isset($_GET['submit'])) {
38 $submit = $_GET['submit'];
39}
40elseif (isset($_POST['submit'])) {
41 $submit = $_POST['submit'];
42}
43/* end of get globals */
44
32f4e318 45displayPageHeader($color, 'None');
e7db48af 46
6206f6c4 47 echo
48 html_tag( 'table', '', 'center', '', 'width="95%" border="0" cellpadding="1" cellspacing="0"' ) .
545238b1 49 html_tag( 'tr' ) .
50 html_tag( 'td', '', 'center', $color[0] ) .
51 '<b>' . _("Options") . ' - ' . _("Index Order") . '</b>' .
6206f6c4 52 html_tag( 'table', '', '', '', 'width="100%" border="0" cellpadding="8" cellspacing="0"' ) .
545238b1 53 html_tag( 'tr' ) .
54 html_tag( 'td', '', 'center', $color[4] );
32f4e318 55
56 $available[1] = _("Checkbox");
57 $available[2] = _("From");
58 $available[3] = _("Date");
59 $available[4] = _("Subject");
60 $available[5] = _("Flags");
61 $available[6] = _("Size");
62
63 if (! isset($method)) { $method = ''; }
64
65 if ($method == 'up' && $num > 1) {
66 $prev = $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)) {
71 $next = $num++;
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");
78 }
79 for ($j=1,$i=1; $i <= count($index_order); $i++) {
80 if ($i != $num) {
81 $new_ary[$j] = $index_order[$i];
82 $j++;
83 }
84 }
85 $index_order = array();
86 $index_order = $new_ary;
87 if (count($index_order) < 1) {
88 include_once('../src/load_prefs.php');
89 }
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;
96 }
97
98 if ($method) {
99 for ($i=1; $i <= count($index_order); $i++) {
100 setPref($data_dir, $username, "order$i", $index_order[$i]);
101 }
102 }
545238b1 103 echo html_tag( 'table',
104 html_tag( 'tr',
105 html_tag( 'td',
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.")
107 )
108 ) ,
109 '', '', '', 'width="65%" border="0" cellpadding="0" cellspacing="0"' ) . "<br>\n";
32f4e318 110
111 if (count($index_order))
112 {
545238b1 113 echo html_tag( 'table', '', '', '', ' cellspacing="0" cellpadding="0" border="0"' ) . "\n";
32f4e318 114 for ($i=1; $i <= count($index_order); $i++) {
115 $tmp = $index_order[$i];
545238b1 116 echo html_tag( 'tr' );
117 echo html_tag( 'td', '<small><a href="options_order.php?method=up&amp;num=' . $i . '">'. _("up") .'</a></small>' );
118 echo html_tag( 'td', '<small>&nbsp;|&nbsp;</small>' );
119 echo html_tag( 'td', '<small><a href="options_order.php?method=down&amp;num=' . $i . '">'. _("down") .'</a></small>' );
120 echo html_tag( 'td', '<small>&nbsp;|&nbsp;</small>' );
121 echo html_tag( 'td' );
32f4e318 122 /* Always show the subject */
123 if ($tmp != 4)
545238b1 124 echo '<small><a href="options_order.php?method=remove&amp;num=' . $i . '">' . _("remove") . '</a></small>';
125 else
126 echo '&nbsp;';
127 echo '</td>';
128 echo html_tag( 'td', '<small>&nbsp;-&nbsp;</small>' );
129 echo html_tag( 'td', $available[$tmp] );
130 echo '</tr>' . "\n";
32f4e318 131 }
545238b1 132 echo '</table>' . "\n";
32f4e318 133 }
134
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++) {
139 $found = false;
140 for ($j=1; $j <= count($index_order); $j++) {
141 if ($index_order[$j] == $i) {
142 $found = true;
143 }
e7db48af 144 }
32f4e318 145 if (!$found) {
146 echo "<option value=\"$i\">$available[$i]</option>";
147 }
148 }
149 echo '</select>';
150 echo '<input type="hidden" value="add" name="method">';
151 echo '<input type="submit" value="'._("Add").'" name="submit">';
152 echo '</form>';
153 }
154
545238b1 155 echo html_tag( 'p', '<a href="../src/options.php">' . _("Return to options page") . '</a></p><br>' );
5c54e435 156
221ca7bf 157?>
e7db48af 158 </td></tr>
159 </table>
160
161</td></tr>
162</table>
5e9e90fd 163</body></html>