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