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