|
@@ -0,0 +1,364 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+/**
|
|
|
+ * setup.php
|
|
|
+ *
|
|
|
+ * delete_move_next
|
|
|
+ * deletes or moves currently displayed message and displays
|
|
|
+ * next or previous message.
|
|
|
+ *
|
|
|
+ * Copyright (c) 1999-2002 The SquirrelMail Project Team
|
|
|
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
|
|
|
+ *
|
|
|
+ * $Id$
|
|
|
+ */
|
|
|
+
|
|
|
+function squirrelmail_plugin_init_delete_move_next() {
|
|
|
+ global $squirrelmail_plugin_hooks;
|
|
|
+
|
|
|
+ $squirrelmail_plugin_hooks['html_top']['delete_move_next'] = 'delete_move_next_action';
|
|
|
+ $squirrelmail_plugin_hooks['right_main_after_header']['delete_move_next'] = 'delete_move_next_action';
|
|
|
+ $squirrelmail_plugin_hooks['read_body_bottom']['delete_move_next'] = 'delete_move_next_read_b';
|
|
|
+ $squirrelmail_plugin_hooks['read_body_top']['delete_move_next'] = 'delete_move_next_read_t';
|
|
|
+ $squirrelmail_plugin_hooks['options_display_inside']['delete_move_next'] = 'delete_move_next_display_inside';
|
|
|
+ $squirrelmail_plugin_hooks['options_display_save']['delete_move_next'] = 'delete_move_next_display_save';
|
|
|
+ $squirrelmail_plugin_hooks['loading_prefs']['delete_move_next'] = 'delete_move_next_loading_prefs';
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/*
|
|
|
+ * Warning: this function relies on the internal representation of
|
|
|
+ * of the message cache for the current mailbox. As such, it is fragile
|
|
|
+ * because the underlying implementation can change. I will present it
|
|
|
+ * to the squirrelmail maintainers as a proposed addition to the API,
|
|
|
+ * perhaps even as inline code to sqimap_mailbox_expunge(). In the
|
|
|
+ * meantime, you have been warned. [alane@geeksrus.net 2001/05/06]
|
|
|
+ */
|
|
|
+function delete_move_del_arr_elem($arr, $index) {
|
|
|
+ $tmp = array();
|
|
|
+ $lim = count($arr);
|
|
|
+ $j = 0;
|
|
|
+ for ($i = 0; $i < $lim; $i++) {
|
|
|
+ if ($i != $index) {
|
|
|
+ $tmp[$j++] = $arr[$i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $tmp;
|
|
|
+}
|
|
|
+
|
|
|
+function delete_move_show_msg_array() {
|
|
|
+ global $msort, $msgs;
|
|
|
+
|
|
|
+ $keys = array_keys($msort);
|
|
|
+ for ($i = 0; $i < count($keys); $i++) {
|
|
|
+ echo '<p>key ' . $keys[$i] . ' msgid ' . $msgs[$keys[$i]]['ID'] . '</p>';
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+function delete_move_expunge_from_all($id) {
|
|
|
+ global $msgs, $msort, $sort, $imapConnection, $mailbox;
|
|
|
+
|
|
|
+ // delete_move_show_msg_array();
|
|
|
+
|
|
|
+ $delAt = -1;
|
|
|
+ for ($i = 0; $i < count($msort); $i++) {
|
|
|
+ if ($msgs[$i]['ID'] == $id) {
|
|
|
+ $delAt = $i;
|
|
|
+ } elseif ($msgs[$i]['ID'] > $id) {
|
|
|
+ $msgs[$i]['ID']--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $msgs = delete_move_del_arr_elem($msgs, $delAt);
|
|
|
+ $msort = delete_move_del_arr_elem($msort, $delAt);
|
|
|
+
|
|
|
+ if ($sort < 6) {
|
|
|
+ if ($sort % 2) {
|
|
|
+ asort($msort);
|
|
|
+ } else {
|
|
|
+ arsort($msort);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // delete_move_show_msg_array();
|
|
|
+
|
|
|
+ sqimap_mailbox_expunge($imapConnection, $mailbox, true);
|
|
|
+}
|
|
|
+
|
|
|
+function delete_move_next_action() {
|
|
|
+
|
|
|
+ global $PHP_SELF,
|
|
|
+ $delete_id, $move_id;
|
|
|
+
|
|
|
+ if ($delete_id) {
|
|
|
+ delete_move_next_delete();
|
|
|
+ } elseif ($move_id) {
|
|
|
+ delete_move_next_move();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+function delete_move_next_read_t() {
|
|
|
+
|
|
|
+ global $delete_move_next_t;
|
|
|
+
|
|
|
+ if($delete_move_next_t == 'on') {
|
|
|
+ delete_move_next_read('top');
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function delete_move_next_read_b() {
|
|
|
+
|
|
|
+ global $delete_move_next_b;
|
|
|
+
|
|
|
+ if ($delete_move_next_b != 'off') {
|
|
|
+ delete_move_next_read('bottom');
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+function delete_move_next_read($currloc) {
|
|
|
+ global $delete_move_next_formATtop, $delete_move_next_formATbottom,
|
|
|
+ $color, $where, $what, $currentArrayIndex, $passed_id,
|
|
|
+ $urlMailbox, $sort, $startMessage, $delete_id, $move_id,
|
|
|
+ $imapConnection, $auto_expunge, $move_to_trash;
|
|
|
+
|
|
|
+ if (!(($where && $what) || ($currentArrayIndex == -1))) {
|
|
|
+
|
|
|
+ $next = findNextMessage();
|
|
|
+ $prev = findPreviousMessage();
|
|
|
+ $prev_if_del = $prev;
|
|
|
+ $next_if_del = $next;
|
|
|
+ if ($auto_expunge || $move_to_trash) {
|
|
|
+ if ($prev_if_del > $passed_id) {
|
|
|
+ $prev_if_del--;
|
|
|
+ }
|
|
|
+ if ($next_if_del > $passed_id) {
|
|
|
+ $next_if_del--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $location = get_location();
|
|
|
+ echo "<base href=\"$location/\">" .
|
|
|
+ '<table cols=1 cellspacing=0 width=100% border=0 cellpadding=2>'.
|
|
|
+ '<tr>'.
|
|
|
+ "<td bgcolor=\"$color[9]\" width=100% align=center><small>";
|
|
|
+
|
|
|
+ if ($prev > 0) {
|
|
|
+ echo "<a href=\"read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | ";
|
|
|
+ } else {
|
|
|
+ echo _("Previous") . " | ";
|
|
|
+ }
|
|
|
+ if ($next > 0) {
|
|
|
+ echo "<a href=\"read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A> | ";
|
|
|
+ } else {
|
|
|
+ echo _("Next") . " | ";
|
|
|
+ }
|
|
|
+ if ($prev > 0){
|
|
|
+ echo "<a href=\"read_body.php?passed_id=$prev_if_del&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0&delete_id=$passed_id\">" . _("Delete & Prev") . "</a>" . " | ";
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ echo _("Delete & Prev") . " | ";
|
|
|
+ }
|
|
|
+ if ($next > 0){
|
|
|
+ echo "<a href=\"read_body.php?passed_id=$next_if_del&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0&delete_id=$passed_id\">" . _("Delete & Next") . "</a>";
|
|
|
+ } else {
|
|
|
+ echo _("Delete & Next");
|
|
|
+ }
|
|
|
+ echo '</small></td></tr>';
|
|
|
+
|
|
|
+ if ($next_if_del < 0) {
|
|
|
+ $next_if_del = $prev_if_del;
|
|
|
+ }
|
|
|
+ if (($delete_move_next_formATtop == 'on') && ($currloc == 'top')){
|
|
|
+ if ($next_if_del > 0) {
|
|
|
+ delete_move_next_moveNextForm($next_if_del);
|
|
|
+ } else {
|
|
|
+ delete_move_next_moveRightMainForm();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (($delete_move_next_formATbottom != 'off') && ($currloc == 'bottom')){
|
|
|
+ if ($next_if_del > 0) {
|
|
|
+ delete_move_next_moveNextForm($next_if_del);
|
|
|
+ } else {
|
|
|
+ delete_move_next_moveRightMainForm();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ echo '</table>';
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function get_move_target_list() {
|
|
|
+ global $imapConnection;
|
|
|
+
|
|
|
+ $boxes = sqimap_mailbox_list($imapConnection);
|
|
|
+ for ($i = 0; $i < count($boxes); $i++) {
|
|
|
+ if (!in_array('noselect', $boxes[$i]['flags'])) {
|
|
|
+ $box = $boxes[$i]['unformatted'];
|
|
|
+ $box2 = str_replace(' ', ' ', $boxes[$i]['unformatted-disp']);
|
|
|
+ echo " <option value=\"$box\">$box2\n";
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function delete_move_next_moveNextForm($next) {
|
|
|
+
|
|
|
+ global $color, $where, $what, $currentArrayIndex, $passed_id,
|
|
|
+ $urlMailbox, $sort, $startMessage, $delete_id, $move_id,
|
|
|
+ $imapConnection;
|
|
|
+
|
|
|
+?>
|
|
|
+ <tr>
|
|
|
+ <form action="<?php echo "read_body.php"?>" method="get">
|
|
|
+ <td bgcolor="<?php echo $color[9] ?>" width=100% align=center><small>
|
|
|
+ <input type="hidden" name="passed_id" value="<?php echo $next ?>">
|
|
|
+ <input type="hidden" name="mailbox" value="<?php echo $urlMailbox ?>">
|
|
|
+ <input type="hidden" name="sort" value="<?php echo $sort ?>">
|
|
|
+ <input type="hidden" name="startMessage" value="<?php echo $startMessage ?>">
|
|
|
+ <input type="hidden" name="show_more" value="0">
|
|
|
+ <input type="hidden" name="move_id" value="<?php echo $passed_id ?>">
|
|
|
+ Move to:
|
|
|
+ <select name="targetMailbox">
|
|
|
+ <?php get_move_target_list(); ?></select>
|
|
|
+ <input type=submit value="Move">
|
|
|
+ </small>
|
|
|
+ </td>
|
|
|
+ </form>
|
|
|
+ </tr>
|
|
|
+
|
|
|
+<?php
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+function delete_move_next_moveRightMainForm() {
|
|
|
+
|
|
|
+ global $color, $where, $what, $currentArrayIndex, $passed_id,
|
|
|
+ $urlMailbox, $sort, $startMessage, $delete_id, $move_id,
|
|
|
+ $imapConnection;
|
|
|
+
|
|
|
+?>
|
|
|
+ <tr>
|
|
|
+ <form action="<?php echo "right_main.php"?>" method="get">
|
|
|
+ <td bgcolor="<?php echo $color[9] ?>" width=100% align=center><small>
|
|
|
+ <input type="hidden" name="mailbox" value="<?php echo $urlMailbox ?>">
|
|
|
+ <input type="hidden" name="sort" value="<?php echo $sort ?>">
|
|
|
+ <input type="hidden" name="startMessage" value="<?php echo $startMessage ?>">
|
|
|
+ <input type="hidden" name="move_id" value="<?php echo $passed_id ?>">
|
|
|
+ Move to:
|
|
|
+ <select name="targetMailbox">
|
|
|
+ <?php get_move_target_list(); ?></select>
|
|
|
+ <input type=submit value="Move">
|
|
|
+ </small>
|
|
|
+ </td>
|
|
|
+ </form>
|
|
|
+ </tr>
|
|
|
+
|
|
|
+<?php
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+function delete_move_next_delete() {
|
|
|
+ global $imapConnection, $delete_id, $mailbox, $auto_expunge;
|
|
|
+
|
|
|
+ sqimap_messages_delete($imapConnection, $delete_id, $delete_id, $mailbox);
|
|
|
+ if ($auto_expunge){
|
|
|
+ delete_move_expunge_from_all($delete_id);
|
|
|
+ // sqimap_mailbox_expunge($imapConnection, $mailbox, true);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function delete_move_next_move() {
|
|
|
+ global $imapConnection, $move_id, $targetMailbox, $auto_expunge, $mailbox;
|
|
|
+
|
|
|
+ // Move message
|
|
|
+ sqimap_messages_copy($imapConnection, $move_id, $move_id, $targetMailbox);
|
|
|
+ sqimap_messages_flag($imapConnection, $move_id, $move_id, 'Deleted');
|
|
|
+ if ($auto_expunge) {
|
|
|
+ delete_move_expunge_from_all($move_id);
|
|
|
+ // sqimap_mailbox_expunge($imapConnection, $mailbox, true);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function delete_move_next_display_inside() {
|
|
|
+ global $username,$data_dir,
|
|
|
+ $delete_move_next_t, $delete_move_next_formATtop,
|
|
|
+ $delete_move_next_b, $delete_move_next_formATbottom;
|
|
|
+
|
|
|
+ echo "<tr><td align=right valign=top>\n".
|
|
|
+ _("delete_move_next:") . "</td>\n".
|
|
|
+ "<td><input type=checkbox name=delete_move_next_ti";
|
|
|
+
|
|
|
+ if ($delete_move_next_t == 'on') {
|
|
|
+ echo " checked";
|
|
|
+ }
|
|
|
+ echo '> <- ' . _("display at top").
|
|
|
+ " <input type=checkbox name=delete_move_next_formATtopi";
|
|
|
+
|
|
|
+ if ($delete_move_next_formATtop == 'on') {
|
|
|
+ echo ' checked';
|
|
|
+ }
|
|
|
+ echo '> <- ' . _("with move option") . '<br>';
|
|
|
+
|
|
|
+ echo '<input type=checkbox name=delete_move_next_bi';
|
|
|
+ if($delete_move_next_b != 'off') {
|
|
|
+ echo ' checked';
|
|
|
+ }
|
|
|
+ echo '> <- ' . _("display at bottom") .
|
|
|
+ '<input type=checkbox name=delete_move_next_formATbottomi';
|
|
|
+
|
|
|
+ if ($delete_move_next_formATbottom != 'off') {
|
|
|
+ echo ' checked';
|
|
|
+ }
|
|
|
+ echo '> <- ' . _("with move option") . '<br>'.
|
|
|
+ "</td></tr>\n";
|
|
|
+}
|
|
|
+
|
|
|
+function delete_move_next_display_save() {
|
|
|
+
|
|
|
+ global $username,$data_dir,
|
|
|
+ $delete_move_next_ti, $delete_move_next_formATtopi,
|
|
|
+ $delete_move_next_bi, $delete_move_next_formATbottomi;
|
|
|
+
|
|
|
+ if (isset($delete_move_next_ti)) {
|
|
|
+ setPref($data_dir, $username, 'delete_move_next_t', 'on');
|
|
|
+ } else {
|
|
|
+ setPref($data_dir, $username, 'delete_move_next_t', "off");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($delete_move_next_formATtopi)) {
|
|
|
+ setPref($data_dir, $username, 'delete_move_next_formATtop', 'on');
|
|
|
+ } else {
|
|
|
+ setPref($data_dir, $username, 'delete_move_next_formATtop', "off");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (isset($delete_move_next_bi)) {
|
|
|
+ setPref($data_dir, $username, 'delete_move_next_b', 'on');
|
|
|
+ } else {
|
|
|
+ setPref($data_dir, $username, 'delete_move_next_b', "off");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($delete_move_next_formATbottomi)) {
|
|
|
+ setPref($data_dir, $username, 'delete_move_next_formATbottom', 'on');
|
|
|
+ } else {
|
|
|
+ setPref($data_dir, $username, 'delete_move_next_formATbottom', "off");
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+function delete_move_next_loading_prefs() {
|
|
|
+ global $username,$data_dir,
|
|
|
+ $delete_move_next_t, $delete_move_next_formATtop,
|
|
|
+ $delete_move_next_b, $delete_move_next_formATbottom;
|
|
|
+
|
|
|
+ $delete_move_next_t = getPref($data_dir, $username, 'delete_move_next_t');
|
|
|
+ $delete_move_next_b = getPref($data_dir, $username, 'delete_move_next_b');
|
|
|
+ $delete_move_next_formATtop = getPref($data_dir, $username, 'delete_move_next_formATtop');
|
|
|
+ $delete_move_next_formATbottom = getPref($data_dir, $username, 'delete_move_next_formATbottom');
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+?>
|