Formatting changes.
[squirrelmail.git] / src / options_order.php
1 <?php
2
3 /**
4 * options_order.php
5 *
6 * Copyright (c) 1999-2001 The SquirrelMail Development 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 /*****************************************************************/
15 /*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!! ***/
16 /*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION. ***/
17 /*** + Base level indent should begin at left margin, as ***/
18 /*** the require_once below looks. ***/
19 /*** + All identation should consist of four space blocks ***/
20 /*** + Tab characters are evil. ***/
21 /*** + all comments should use "slash-star ... star-slash" ***/
22 /*** style -- no pound characters, no slash-slash style ***/
23 /*** + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD ***/
24 /*** ALWAYS USE { AND } CHARACTERS!!! ***/
25 /*** + Please use ' instead of ", when possible. Note " ***/
26 /*** should always be used in _( ) function calls. ***/
27 /*** Thank you for your help making the SM code more readable. ***/
28 /*****************************************************************/
29
30 require_once('../src/validate.php');
31 require_once('../functions/display_messages.php');
32 require_once('../functions/imap.php');
33 require_once('../functions/array.php');
34 require_once('../functions/plugin.php');
35
36
37 if (! isset($action)) { $action = ''; }
38 if ($action == 'delete' && isset($theid)) {
39 removePref($data_dir, $username, "highlight$theid");
40 } else if ($action == 'save') {
41 }
42 displayPageHeader($color, 'None');
43 ?>
44 <br>
45 <table width=95% align=center border=0 cellpadding=2 cellspacing=0>
46 <tr><td align="center" bgcolor="<?php echo $color[0] ?>">
47
48 <b><?php echo _("Options") . " - " . _("Index Order"); ?></b>
49
50 <table width="100%" border="0" cellpadding="1" cellspacing="1">
51 <tr><td bgcolor="<?php echo $color[4] ?>" align="center"><br>
52
53 <table width=100% cellpadding=2 cellspacing=0 border=0>
54 <?php
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 '<table cellspacing="0" cellpadding="0" border="0" width="65%"><tr><td>' . "\n";
104 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.");
105 echo '</td></tr></table><br>';
106
107 if (count($index_order))
108 {
109 echo '<table cellspacing="0" cellpadding="0" border="0">' . "\n";
110 for ($i=1; $i <= count($index_order); $i++) {
111 $tmp = $index_order[$i];
112 echo '<tr>';
113 echo "<td><small><a href=\"options_order.php?method=up&num=$i\">". _("up") ."</a></small></td>\n";
114 echo '<td><small>&nbsp;|&nbsp;</small></td>' . "\n";
115 echo "<td><small><a href=\"options_order.php?method=down&num=$i\">". _("down") . "</a></small></td>\n";
116 echo '<td><small>&nbsp;|&nbsp;</small></td>' . "\n";
117 echo '<td>';
118 // Always show the subject
119 if ($tmp != 4)
120 echo "<small><a href=\"options_order.php?method=remove&num=$i\">" . _("remove") . '</a></small>';
121 echo "</td>\n";
122 echo '<td><small>&nbsp;-&nbsp;</small></td>' . "\n";
123 echo '<td>' . $available[$tmp] . "</td>\n";
124 echo "</tr>\n";
125 }
126 echo "</table>\n";
127 }
128
129 if (count($index_order) != count($available)) {
130 echo '<form name="f" method="post" action="options_order.php">';
131 echo '<select name="add">';
132 for ($i=1; $i <= count($available); $i++) {
133 $found = false;
134 for ($j=1; $j <= count($index_order); $j++) {
135 if ($index_order[$j] == $i) {
136 $found = true;
137 }
138 }
139 if (!$found) {
140 echo "<option value=\"$i\">$available[$i]</option>";
141 }
142 }
143 echo '</select>';
144 echo '<input type="hidden" value="add" name="method">';
145 echo '<input type="submit" value="'._("Add").'" name="submit">';
146 echo '</form>';
147 }
148
149 echo '<p><a href="../src/options.php">' . _("Return to options page") . '</a></p><br>';
150
151 ?>
152 </td></tr>
153 </table>
154
155 </td></tr>
156 </table>
157
158 </td></tr>
159 </table>
160 </body></html>