* Got bored and copied all the validate.php and define() stuff to 1.1
[squirrelmail.git] / src / options_order.php
1 <?php
2 /**
3 ** options_highlight.php
4 **
5 ** Copyright (c) 1999-2000 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
7 **
8 ** Displays message highlighting options
9 **
10 ** $Id$
11 **/
12
13 include('../src/validate.php');
14 include('../functions/strings.php');
15 include('../config/config.php');
16 include('../functions/page_header.php');
17 include('../functions/display_messages.php');
18 include('../functions/imap.php');
19 include('../functions/array.php');
20 include('../functions/i18n.php');
21 include('../functions/plugin.php');
22
23
24 if (! isset($action)) { $action = ''; }
25 if ($action == 'delete' && isset($theid)) {
26 removePref($data_dir, $username, "highlight$theid");
27 } else if ($action == 'save') {
28 }
29 include('../src/load_prefs.php');
30 displayPageHeader($color, 'None');
31 ?>
32 <br>
33 <table width=95% align=center border=0 cellpadding=2 cellspacing=0><tr><td bgcolor="<?php echo $color[0] ?>">
34 <center><b><?php echo _("Options") . " - " . _("Index Order"); ?></b></center>
35 </td></tr></table>
36
37 <table width=95% align=center border=0><tr><td>
38 <?php
39
40 $available[1] = _("Checkbox");
41 $available[2] = _("From");
42 $available[3] = _("Date");
43 $available[4] = _("Subject");
44 $available[5] = _("Flags");
45 $available[6] = _("Size");
46
47 if (! isset($method)) { $method = ''; }
48
49 if ($method == 'up' && $num > 1) {
50 $prev = $num-1;
51 $tmp = $index_order[$prev];
52 $index_order[$prev] = $index_order[$num];
53 $index_order[$num] = $tmp;
54 } else if ($method == 'down' && $num < count($index_order)) {
55 $next = $num++;
56 $tmp = $index_order[$next];
57 $index_order[$next] = $index_order[$num];
58 $index_order[$num] = $tmp;
59 } else if ($method == 'remove' && $num) {
60 for ($i=1; $i < 8; $i++) {
61 removePref($data_dir, $username, "order$i");
62 }
63 for ($j=1,$i=1; $i <= count($index_order); $i++) {
64 if ($i != $num) {
65 $new_ary[$j] = $index_order[$i];
66 $j++;
67 }
68 }
69 $index_order = array();
70 $index_order = $new_ary;
71 if (count($index_order) < 1) {
72 include ('../src/load_prefs.php');
73 }
74 } else if ($method == 'add' && $add) {
75 // User should not be able to insert PHP-code here
76 $add = str_replace ('<?', '..', $add);
77 $add = ereg_replace ('<.*script.*language.*php.*>', '..', $add);
78 $add = str_replace ('<%', '..', $add);
79 $index_order[count($index_order)+1] = $add;
80 }
81
82 if ($method) {
83 for ($i=1; $i <= count($index_order); $i++) {
84 setPref($data_dir, $username, "order$i", $index_order[$i]);
85 }
86 }
87 echo '<center>';
88 echo '<table cellspacing="0" cellpadding="0" border="0" width="65%"><tr><td>' . "\n";
89 echo _("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.");
90 echo '</td></tr></table></center><br>';
91
92 if (count($index_order))
93 {
94 echo '<center>';
95 echo '<table cellspacing="0" cellpadding="0" border="0">' . "\n";
96 for ($i=1; $i <= count($index_order); $i++) {
97 $tmp = $index_order[$i];
98 echo '<tr>';
99 echo "<td><small><a href=\"options_order.php?method=up&num=$i\">". _("up") ."</a></small></td>\n";
100 echo '<td><small>&nbsp;|&nbsp;</small></td>' . "\n";
101 echo "<td><small><a href=\"options_order.php?method=down&num=$i\">". _("down") . "</a></small></td>\n";
102 echo '<td><small>&nbsp;|&nbsp;</small></td>' . "\n";
103 echo '<td>';
104 // Always show the subject
105 if ($tmp != 4)
106 echo "<small><a href=\"options_order.php?method=remove&num=$i\">" . _("remove") . '</a></small>';
107 echo "</td>\n";
108 echo '<td><small>&nbsp;-&nbsp;</small></td>' . "\n";
109 echo '<td>' . $available[$tmp] . "</td>\n";
110 echo "</tr>\n";
111 }
112 echo "</table>\n";
113 echo '</center>';
114 }
115
116 if (count($index_order) != count($available)) {
117 echo '<center><form name="f" method="post" action="options_order.php">';
118 echo '<select name="add">';
119 for ($i=1; $i <= count($available); $i++) {
120 $found = false;
121 for ($j=1; $j <= count($index_order); $j++) {
122 if ($index_order[$j] == $i) {
123 $found = true;
124 }
125 }
126 if (!$found) {
127 echo "<option value=\"$i\">$available[$i]</option>";
128 }
129 }
130 echo '</select>';
131 echo '<input type="hidden" value="add" name="method">';
132 echo '<input type="submit" value="'._("Add").'" name="submit">';
133 echo '</form></center>';
134 }
135
136 echo '<br><center><a href="../src/options.php">' . _("Return to options page") . '</a></center>';
137
138 ?>
139 </td></tr></table>
140 </body></html>