Obsolete array.php
[squirrelmail.git] / src / options_order.php
1 <?php
2
3 /**
4 * options_order.php
5 *
6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Displays message highlighting 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['action'])) {
26 $action = $_GET['action'];
27 }
28 if (isset($_GET['num'])) {
29 $num = $_GET['num'];
30 }
31 if (isset($_GET['method'])) {
32 $method = $_GET['method'];
33 }
34 elseif (isset($_POST['method'])) {
35 $method = $_POST['method'];
36 }
37 if (isset($_POST['add'])) {
38 $add = $_POST['add'];
39 }
40 if (isset($_GET['submit'])) {
41 $submit = $_GET['submit'];
42 }
43 elseif (isset($_POST['submit'])) {
44 $submit = $_POST['submit'];
45 }
46 /* end of get globals */
47
48 if (! isset($action)) { $action = ''; }
49 if ($action == 'delete' && isset($theid)) {
50 removePref($data_dir, $username, "highlight$theid");
51 } elseif ($action == 'save') {
52 }
53 displayPageHeader($color, 'None');
54
55 echo
56 html_tag( 'table', '', 'center', '', 'width="95%" border="0" cellpadding="1" cellspacing="0"' ) .
57 html_tag( 'tr' ) .
58 html_tag( 'td', '', 'center', $color[0] ) .
59 '<b>' . _("Options") . ' - ' . _("Index Order") . '</b>' .
60 html_tag( 'table', '', '', '', 'width="100%" border="0" cellpadding="8" cellspacing="0"' ) .
61 html_tag( 'tr' ) .
62 html_tag( 'td', '', 'center', $color[4] );
63
64 $available[1] = _("Checkbox");
65 $available[2] = _("From");
66 $available[3] = _("Date");
67 $available[4] = _("Subject");
68 $available[5] = _("Flags");
69 $available[6] = _("Size");
70
71 if (! isset($method)) { $method = ''; }
72
73 if ($method == 'up' && $num > 1) {
74 $prev = $num-1;
75 $tmp = $index_order[$prev];
76 $index_order[$prev] = $index_order[$num];
77 $index_order[$num] = $tmp;
78 } else if ($method == 'down' && $num < count($index_order)) {
79 $next = $num++;
80 $tmp = $index_order[$next];
81 $index_order[$next] = $index_order[$num];
82 $index_order[$num] = $tmp;
83 } else if ($method == 'remove' && $num) {
84 for ($i=1; $i < 8; $i++) {
85 removePref($data_dir, $username, "order$i");
86 }
87 for ($j=1,$i=1; $i <= count($index_order); $i++) {
88 if ($i != $num) {
89 $new_ary[$j] = $index_order[$i];
90 $j++;
91 }
92 }
93 $index_order = array();
94 $index_order = $new_ary;
95 if (count($index_order) < 1) {
96 include_once('../src/load_prefs.php');
97 }
98 } else if ($method == 'add' && $add) {
99 /* User should not be able to insert PHP-code here */
100 $add = str_replace ('<?', '..', $add);
101 $add = ereg_replace ('<.*script.*language.*php.*>', '..', $add);
102 $add = str_replace ('<%', '..', $add);
103 $index_order[count($index_order)+1] = $add;
104 }
105
106 if ($method) {
107 for ($i=1; $i <= count($index_order); $i++) {
108 setPref($data_dir, $username, "order$i", $index_order[$i]);
109 }
110 }
111 echo html_tag( 'table',
112 html_tag( 'tr',
113 html_tag( 'td',
114 _("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.")
115 )
116 ) ,
117 '', '', '', 'width="65%" border="0" cellpadding="0" cellspacing="0"' ) . "<br>\n";
118
119 if (count($index_order))
120 {
121 echo html_tag( 'table', '', '', '', ' cellspacing="0" cellpadding="0" border="0"' ) . "\n";
122 for ($i=1; $i <= count($index_order); $i++) {
123 $tmp = $index_order[$i];
124 echo html_tag( 'tr' );
125 echo html_tag( 'td', '<small><a href="options_order.php?method=up&amp;num=' . $i . '">'. _("up") .'</a></small>' );
126 echo html_tag( 'td', '<small>&nbsp;|&nbsp;</small>' );
127 echo html_tag( 'td', '<small><a href="options_order.php?method=down&amp;num=' . $i . '">'. _("down") .'</a></small>' );
128 echo html_tag( 'td', '<small>&nbsp;|&nbsp;</small>' );
129 echo html_tag( 'td' );
130 /* Always show the subject */
131 if ($tmp != 4)
132 echo '<small><a href="options_order.php?method=remove&amp;num=' . $i . '">' . _("remove") . '</a></small>';
133 else
134 echo '&nbsp;';
135 echo '</td>';
136 echo html_tag( 'td', '<small>&nbsp;-&nbsp;</small>' );
137 echo html_tag( 'td', $available[$tmp] );
138 echo '</tr>' . "\n";
139 }
140 echo '</table>' . "\n";
141 }
142
143 if (count($index_order) != count($available)) {
144 echo '<form name="f" method="post" action="options_order.php">';
145 echo '<select name="add">';
146 for ($i=1; $i <= count($available); $i++) {
147 $found = false;
148 for ($j=1; $j <= count($index_order); $j++) {
149 if ($index_order[$j] == $i) {
150 $found = true;
151 }
152 }
153 if (!$found) {
154 echo "<option value=\"$i\">$available[$i]</option>";
155 }
156 }
157 echo '</select>';
158 echo '<input type="hidden" value="add" name="method">';
159 echo '<input type="submit" value="'._("Add").'" name="submit">';
160 echo '</form>';
161 }
162
163 echo html_tag( 'p', '<a href="../src/options.php">' . _("Return to options page") . '</a></p><br>' );
164
165 ?>
166 </td></tr>
167 </table>
168
169 </td></tr>
170 </table>
171 </body></html>