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