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