| 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 | /*****************************************************************/ |
| 15 | /*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!! ***/ |
| 16 | /*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION. ***/ |
| 17 | /*** + Base level indent should begin at left margin, as ***/ |
| 18 | /*** the require_once below looks. ***/ |
| 19 | /*** + All identation should consist of four space blocks ***/ |
| 20 | /*** + Tab characters are evil. ***/ |
| 21 | /*** + all comments should use "slash-star ... star-slash" ***/ |
| 22 | /*** style -- no pound characters, no slash-slash style ***/ |
| 23 | /*** + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD ***/ |
| 24 | /*** ALWAYS USE { AND } CHARACTERS!!! ***/ |
| 25 | /*** + Please use ' instead of ", when possible. Note " ***/ |
| 26 | /*** should always be used in _( ) function calls. ***/ |
| 27 | /*** Thank you for your help making the SM code more readable. ***/ |
| 28 | /*****************************************************************/ |
| 29 | |
| 30 | require_once('../src/validate.php'); |
| 31 | require_once('../functions/display_messages.php'); |
| 32 | require_once('../functions/imap.php'); |
| 33 | require_once('../functions/array.php'); |
| 34 | require_once('../functions/plugin.php'); |
| 35 | |
| 36 | |
| 37 | if (! isset($action)) { $action = ''; } |
| 38 | if ($action == 'delete' && isset($theid)) { |
| 39 | removePref($data_dir, $username, "highlight$theid"); |
| 40 | } else if ($action == 'save') { |
| 41 | } |
| 42 | displayPageHeader($color, 'None'); |
| 43 | ?> |
| 44 | <br> |
| 45 | <table width="95%" align=center border=0 cellpadding=2 cellspacing=0> |
| 46 | <tr><td align="center" bgcolor="<?php echo $color[0] ?>"> |
| 47 | |
| 48 | <b><?php echo _("Options") . " - " . _("Index Order"); ?></b> |
| 49 | |
| 50 | <table width="100%" border="0" cellpadding="1" cellspacing="1"> |
| 51 | <tr><td bgcolor="<?php echo $color[4] ?>" align="center"><br> |
| 52 | <?php |
| 53 | |
| 54 | $available[1] = _("Checkbox"); |
| 55 | $available[2] = _("From"); |
| 56 | $available[3] = _("Date"); |
| 57 | $available[4] = _("Subject"); |
| 58 | $available[5] = _("Flags"); |
| 59 | $available[6] = _("Size"); |
| 60 | |
| 61 | if (! isset($method)) { $method = ''; } |
| 62 | |
| 63 | if ($method == 'up' && $num > 1) { |
| 64 | $prev = $num-1; |
| 65 | $tmp = $index_order[$prev]; |
| 66 | $index_order[$prev] = $index_order[$num]; |
| 67 | $index_order[$num] = $tmp; |
| 68 | } else if ($method == 'down' && $num < count($index_order)) { |
| 69 | $next = $num++; |
| 70 | $tmp = $index_order[$next]; |
| 71 | $index_order[$next] = $index_order[$num]; |
| 72 | $index_order[$num] = $tmp; |
| 73 | } else if ($method == 'remove' && $num) { |
| 74 | for ($i=1; $i < 8; $i++) { |
| 75 | removePref($data_dir, $username, "order$i"); |
| 76 | } |
| 77 | for ($j=1,$i=1; $i <= count($index_order); $i++) { |
| 78 | if ($i != $num) { |
| 79 | $new_ary[$j] = $index_order[$i]; |
| 80 | $j++; |
| 81 | } |
| 82 | } |
| 83 | $index_order = array(); |
| 84 | $index_order = $new_ary; |
| 85 | if (count($index_order) < 1) { |
| 86 | include_once('../src/load_prefs.php'); |
| 87 | } |
| 88 | } else if ($method == 'add' && $add) { |
| 89 | // User should not be able to insert PHP-code here |
| 90 | $add = str_replace ('<?', '..', $add); |
| 91 | $add = ereg_replace ('<.*script.*language.*php.*>', '..', $add); |
| 92 | $add = str_replace ('<%', '..', $add); |
| 93 | $index_order[count($index_order)+1] = $add; |
| 94 | } |
| 95 | |
| 96 | if ($method) { |
| 97 | for ($i=1; $i <= count($index_order); $i++) { |
| 98 | setPref($data_dir, $username, "order$i", $index_order[$i]); |
| 99 | } |
| 100 | } |
| 101 | echo '<table cellspacing="0" cellpadding="0" border="0" width="65%"><tr><td>' . "\n"; |
| 102 | echo _("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."); |
| 103 | echo '</td></tr></table><br>'; |
| 104 | |
| 105 | if (count($index_order)) |
| 106 | { |
| 107 | echo '<table cellspacing="0" cellpadding="0" border="0">' . "\n"; |
| 108 | for ($i=1; $i <= count($index_order); $i++) { |
| 109 | $tmp = $index_order[$i]; |
| 110 | echo '<tr>'; |
| 111 | echo "<td><small><a href=\"options_order.php?method=up&num=$i\">". _("up") ."</a></small></td>\n"; |
| 112 | echo '<td><small> | </small></td>' . "\n"; |
| 113 | echo "<td><small><a href=\"options_order.php?method=down&num=$i\">". _("down") . "</a></small></td>\n"; |
| 114 | echo '<td><small> | </small></td>' . "\n"; |
| 115 | echo '<td>'; |
| 116 | // Always show the subject |
| 117 | if ($tmp != 4) |
| 118 | echo "<small><a href=\"options_order.php?method=remove&num=$i\">" . _("remove") . '</a></small>'; |
| 119 | echo "</td>\n"; |
| 120 | echo '<td><small> - </small></td>' . "\n"; |
| 121 | echo '<td>' . $available[$tmp] . "</td>\n"; |
| 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 '<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> |