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