0e5d31e5cba63c9a2de6dacf9649031e46d4bfbc
[squirrelmail.git] / src / options_order.php
1 <?php
2
3 /**
4 * options_order.php
5 *
6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Displays messagelist column order options
10 *
11 * $Id$
12 */
13
14 /* Path for SquirrelMail required files. */
15 define('SM_PATH','../');
16
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');
23
24 /* get globals */
25 if (isset($_GET['num'])) {
26 $num = $_GET['num'];
27 }
28 if (isset($_GET['method'])) {
29 $method = $_GET['method'];
30 }
31 elseif (isset($_POST['method'])) {
32 $method = $_POST['method'];
33 }
34 if (isset($_POST['add'])) {
35 $add = $_POST['add'];
36 }
37 if (isset($_GET['submit'])) {
38 $submit = $_GET['submit'];
39 }
40 elseif (isset($_POST['submit'])) {
41 $submit = $_POST['submit'];
42 }
43 /* end of get globals */
44
45 displayPageHeader($color, 'None');
46
47 echo
48 html_tag( 'table', '', 'center', '', 'width="95%" border="0" cellpadding="1" cellspacing="0"' ) .
49 html_tag( 'tr' ) .
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"' ) .
53 html_tag( 'tr' ) .
54 html_tag( 'td', '', 'center', $color[4] );
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 }
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";
110
111 if (count($index_order))
112 {
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&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' );
122 /* Always show the subject */
123 if ($tmp != 4)
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";
131 }
132 echo '</table>' . "\n";
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 }
144 }
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
155 echo html_tag( 'p', '<a href="../src/options.php">' . _("Return to options page") . '</a></p><br>' );
156
157 ?>
158 </td></tr>
159 </table>
160
161 </td></tr>
162 </table>
163 </body></html>