A terrible pile of things done to the code. Did a little bit of SM_PATH
[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/array.php');
22 require_once(SM_PATH . 'functions/plugin.php');
23 require_once(SM_PATH . 'functions/html.php');
24
25 if (! isset($action)) { $action = ''; }
26 if ($action == 'delete' && isset($theid)) {
27 removePref($data_dir, $username, "highlight$theid");
28 } elseif ($action == 'save') {
29 }
30 displayPageHeader($color, 'None');
31
32 echo
33 html_tag( 'table', '', 'center', '', 'width="95%" border="0" cellpadding="1" cellspacing="0"' ) .
34 html_tag( 'tr' ) .
35 html_tag( 'td', '', 'center', $color[0] ) .
36 '<b>' . _("Options") . ' - ' . _("Index Order") . '</b>' .
37 html_tag( 'table', '', '', '', 'width="100%" border="0" cellpadding="8" cellspacing="0"' ) .
38 html_tag( 'tr' ) .
39 html_tag( 'td', '', 'center', $color[4] );
40
41 $available[1] = _("Checkbox");
42 $available[2] = _("From");
43 $available[3] = _("Date");
44 $available[4] = _("Subject");
45 $available[5] = _("Flags");
46 $available[6] = _("Size");
47
48 if (! isset($method)) { $method = ''; }
49
50 if ($method == 'up' && $num > 1) {
51 $prev = $num-1;
52 $tmp = $index_order[$prev];
53 $index_order[$prev] = $index_order[$num];
54 $index_order[$num] = $tmp;
55 } else if ($method == 'down' && $num < count($index_order)) {
56 $next = $num++;
57 $tmp = $index_order[$next];
58 $index_order[$next] = $index_order[$num];
59 $index_order[$num] = $tmp;
60 } else if ($method == 'remove' && $num) {
61 for ($i=1; $i < 8; $i++) {
62 removePref($data_dir, $username, "order$i");
63 }
64 for ($j=1,$i=1; $i <= count($index_order); $i++) {
65 if ($i != $num) {
66 $new_ary[$j] = $index_order[$i];
67 $j++;
68 }
69 }
70 $index_order = array();
71 $index_order = $new_ary;
72 if (count($index_order) < 1) {
73 include_once('../src/load_prefs.php');
74 }
75 } else if ($method == 'add' && $add) {
76 /* User should not be able to insert PHP-code here */
77 $add = str_replace ('<?', '..', $add);
78 $add = ereg_replace ('<.*script.*language.*php.*>', '..', $add);
79 $add = str_replace ('<%', '..', $add);
80 $index_order[count($index_order)+1] = $add;
81 }
82
83 if ($method) {
84 for ($i=1; $i <= count($index_order); $i++) {
85 setPref($data_dir, $username, "order$i", $index_order[$i]);
86 }
87 }
88 echo html_tag( 'table',
89 html_tag( 'tr',
90 html_tag( 'td',
91 _("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.")
92 )
93 ) ,
94 '', '', '', 'width="65%" border="0" cellpadding="0" cellspacing="0"' ) . "<br>\n";
95
96 if (count($index_order))
97 {
98 echo html_tag( 'table', '', '', '', ' cellspacing="0" cellpadding="0" border="0"' ) . "\n";
99 for ($i=1; $i <= count($index_order); $i++) {
100 $tmp = $index_order[$i];
101 echo html_tag( 'tr' );
102 echo html_tag( 'td', '<small><a href="options_order.php?method=up&amp;num=' . $i . '">'. _("up") .'</a></small>' );
103 echo html_tag( 'td', '<small>&nbsp;|&nbsp;</small>' );
104 echo html_tag( 'td', '<small><a href="options_order.php?method=down&amp;num=' . $i . '">'. _("down") .'</a></small>' );
105 echo html_tag( 'td', '<small>&nbsp;|&nbsp;</small>' );
106 echo html_tag( 'td' );
107 /* Always show the subject */
108 if ($tmp != 4)
109 echo '<small><a href="options_order.php?method=remove&amp;num=' . $i . '">' . _("remove") . '</a></small>';
110 else
111 echo '&nbsp;';
112 echo '</td>';
113 echo html_tag( 'td', '<small>&nbsp;-&nbsp;</small>' );
114 echo html_tag( 'td', $available[$tmp] );
115 echo '</tr>' . "\n";
116 }
117 echo '</table>' . "\n";
118 }
119
120 if (count($index_order) != count($available)) {
121 echo '<form name="f" method="post" action="options_order.php">';
122 echo '<select name="add">';
123 for ($i=1; $i <= count($available); $i++) {
124 $found = false;
125 for ($j=1; $j <= count($index_order); $j++) {
126 if ($index_order[$j] == $i) {
127 $found = true;
128 }
129 }
130 if (!$found) {
131 echo "<option value=\"$i\">$available[$i]</option>";
132 }
133 }
134 echo '</select>';
135 echo '<input type="hidden" value="add" name="method">';
136 echo '<input type="submit" value="'._("Add").'" name="submit">';
137 echo '</form>';
138 }
139
140 echo html_tag( 'p', '<a href="../src/options.php">' . _("Return to options page") . '</a></p><br>' );
141
142 ?>
143 </td></tr>
144 </table>
145
146 </td></tr>
147 </table>
148 </body></html>