Received is a better word in this instance.
[squirrelmail.git] / src / options_order.php
CommitLineData
221ca7bf 1<?php
895905c0 2
35586184 3/**
4 * options_order.php
5 *
82d304a0 6 * Copyright (c) 1999-2004 The SquirrelMail Project Team
35586184 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
1c159927 9 * Displays messagelist column order options
35586184 10 *
30967a1e 11 * @version $Id$
8f6f9ba5 12 * @package squirrelmail
35586184 13 */
14
30967a1e 15/**
16 * Path for SquirrelMail required files.
17 * @ignore
18 */
86725763 19define('SM_PATH','../');
20
21/* SquirrelMail required files. */
08185f2a 22require_once(SM_PATH . 'include/validate.php');
1e12d1ff 23require_once(SM_PATH . 'functions/global.php');
86725763 24require_once(SM_PATH . 'functions/display_messages.php');
25require_once(SM_PATH . 'functions/imap.php');
86725763 26require_once(SM_PATH . 'functions/plugin.php');
27require_once(SM_PATH . 'functions/html.php');
64c9e87e 28require_once(SM_PATH . 'functions/forms.php');
221ca7bf 29
fe369c70 30/* get globals */
1e12d1ff 31sqgetGlobalVar('num', $num, SQ_GET);
32sqgetGlobalVar('add', $add, SQ_POST);
33
34sqgetGlobalVar('submit', $submit);
35sqgetGlobalVar('method', $method);
fe369c70 36/* end of get globals */
37
32f4e318 38displayPageHeader($color, 'None');
e7db48af 39
6206f6c4 40 echo
41 html_tag( 'table', '', 'center', '', 'width="95%" border="0" cellpadding="1" cellspacing="0"' ) .
545238b1 42 html_tag( 'tr' ) .
43 html_tag( 'td', '', 'center', $color[0] ) .
44 '<b>' . _("Options") . ' - ' . _("Index Order") . '</b>' .
6206f6c4 45 html_tag( 'table', '', '', '', 'width="100%" border="0" cellpadding="8" cellspacing="0"' ) .
545238b1 46 html_tag( 'tr' ) .
47 html_tag( 'td', '', 'center', $color[4] );
32f4e318 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 }
545238b1 96 echo html_tag( 'table',
97 html_tag( 'tr',
98 html_tag( 'td',
99aaff8b 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.")
545238b1 100 )
101 ) ,
39bfea8f 102 '', '', '', 'width="65%" border="0" cellpadding="0" cellspacing="0"' ) . "<br />\n";
32f4e318 103
104 if (count($index_order))
105 {
545238b1 106 echo html_tag( 'table', '', '', '', ' cellspacing="0" cellpadding="0" border="0"' ) . "\n";
32f4e318 107 for ($i=1; $i <= count($index_order); $i++) {
108 $tmp = $index_order[$i];
545238b1 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' );
32f4e318 115 /* Always show the subject */
116 if ($tmp != 4)
545238b1 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";
32f4e318 124 }
545238b1 125 echo '</table>' . "\n";
32f4e318 126 }
127
128 if (count($index_order) != count($available)) {
64c9e87e 129
130 $opts = array();
32f4e318 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 }
e7db48af 137 }
32f4e318 138 if (!$found) {
64c9e87e 139 $opts[$i] = $available[$i];
32f4e318 140 }
141 }
64c9e87e 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');
32f4e318 147 echo '</form>';
148 }
149
39bfea8f 150 echo html_tag( 'p', '<a href="../src/options.php">' . _("Return to options page") . '</a></p><br />' );
5c54e435 151
221ca7bf 152?>
e7db48af 153 </td></tr>
154 </table>
155
156</td></tr>
157</table>
dcc1cc82 158</body></html>