7 * deletes or moves currently displayed message and displays
8 * next or previous message.
10 * Copyright (c) 1999-2002 The SquirrelMail Project Team
11 * Licensed under the GNU GPL. For full terms see the file COPYING.
16 function squirrelmail_plugin_init_delete_move_next() {
17 global $squirrelmail_plugin_hooks;
19 $squirrelmail_plugin_hooks['html_top']['delete_move_next'] = 'delete_move_next_action';
20 $squirrelmail_plugin_hooks['right_main_after_header']['delete_move_next'] = 'delete_move_next_action';
21 $squirrelmail_plugin_hooks['read_body_bottom']['delete_move_next'] = 'delete_move_next_read_b';
22 $squirrelmail_plugin_hooks['read_body_top']['delete_move_next'] = 'delete_move_next_read_t';
23 $squirrelmail_plugin_hooks['options_display_inside']['delete_move_next'] = 'delete_move_next_display_inside';
24 $squirrelmail_plugin_hooks['options_display_save']['delete_move_next'] = 'delete_move_next_display_save';
25 $squirrelmail_plugin_hooks['loading_prefs']['delete_move_next'] = 'delete_move_next_loading_prefs';
30 * Warning: this function relies on the internal representation of
31 * of the message cache for the current mailbox. As such, it is fragile
32 * because the underlying implementation can change. I will present it
33 * to the squirrelmail maintainers as a proposed addition to the API,
34 * perhaps even as inline code to sqimap_mailbox_expunge(). In the
35 * meantime, you have been warned. [alane@geeksrus.net 2001/05/06]
37 function delete_move_del_arr_elem($arr, $index) {
41 for ($i = 0; $i < $lim; $i++
) {
43 $tmp[$j++
] = $arr[$i];
49 function delete_move_show_msg_array() {
52 $keys = array_keys($msort);
53 for ($i = 0; $i < count($keys); $i++
) {
54 echo '<p>key ' . $keys[$i] . ' msgid ' . $msgs[$keys[$i]]['ID'] . '</p>';
59 function delete_move_expunge_from_all($id) {
60 global $msgs, $msort, $sort, $imapConnection, $mailbox;
62 // delete_move_show_msg_array();
65 for ($i = 0; $i < count($msort); $i++
) {
66 if ($msgs[$i]['ID'] == $id) {
68 } elseif ($msgs[$i]['ID'] > $id) {
73 $msgs = delete_move_del_arr_elem($msgs, $delAt);
74 $msort = delete_move_del_arr_elem($msort, $delAt);
84 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
87 function delete_move_next_action() {
93 delete_move_next_delete();
95 delete_move_next_move();
100 function delete_move_next_read_t() {
102 global $delete_move_next_t;
104 if($delete_move_next_t == 'on') {
105 delete_move_next_read('top');
109 function delete_move_next_read_b() {
111 global $delete_move_next_b;
113 if ($delete_move_next_b != 'off') {
114 delete_move_next_read('bottom');
119 function delete_move_next_read($currloc) {
120 global $delete_move_next_formATtop, $delete_move_next_formATbottom,
121 $color, $where, $what, $currentArrayIndex, $passed_id,
122 $urlMailbox, $sort, $startMessage, $delete_id, $move_id,
123 $imapConnection, $auto_expunge, $move_to_trash;
125 if (!(($where && $what) ||
($currentArrayIndex == -1))) {
127 $next = findNextMessage();
128 $prev = findPreviousMessage();
129 $prev_if_del = $prev;
130 $next_if_del = $next;
131 if ($auto_expunge ||
$move_to_trash) {
132 if ($prev_if_del > $passed_id) {
135 if ($next_if_del > $passed_id) {
140 $location = get_location();
141 echo "<base href=\"$location/\">" .
142 '<table cols=1 cellspacing=0 width=100% border=0 cellpadding=2>'.
144 "<td bgcolor=\"$color[9]\" width=100% align=center><small>";
147 echo "<a href=\"read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | ";
149 echo _("Previous") . " | ";
152 echo "<a href=\"read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A> | ";
154 echo _("Next") . " | ";
157 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>" . " | ";
160 echo _("Delete & Prev") . " | ";
163 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>";
165 echo _("Delete & Next");
167 echo '</small></td></tr>';
169 if ($next_if_del < 0) {
170 $next_if_del = $prev_if_del;
172 if (($delete_move_next_formATtop == 'on') && ($currloc == 'top')){
173 if ($next_if_del > 0) {
174 delete_move_next_moveNextForm($next_if_del);
176 delete_move_next_moveRightMainForm();
179 if (($delete_move_next_formATbottom != 'off') && ($currloc == 'bottom')){
180 if ($next_if_del > 0) {
181 delete_move_next_moveNextForm($next_if_del);
183 delete_move_next_moveRightMainForm();
190 function get_move_target_list() {
191 global $imapConnection;
193 $boxes = sqimap_mailbox_list($imapConnection);
194 for ($i = 0; $i < count($boxes); $i++
) {
195 if (!in_array('noselect', $boxes[$i]['flags'])) {
196 $box = $boxes[$i]['unformatted'];
197 $box2 = str_replace(' ', ' ', $boxes[$i]['unformatted-disp']);
198 if ( $box2 == 'INBOX' ) {
201 echo "<option value=\"$box\">$box2</option>\n";
206 function delete_move_next_moveNextForm($next) {
208 global $color, $where, $what, $currentArrayIndex, $passed_id,
209 $urlMailbox, $sort, $startMessage, $delete_id, $move_id,
212 echo '<form action="read_body.php" method="post">'.
214 "<td bgcolor=\"$color[9]\" width=\"100%\" align=\"center\"><small>".
215 "<input type=\"hidden\" name=\"passed_id\" value=\"$next\">".
216 "<input type=\"hidden\" name=\"mailbox\" value=\"$urlMailbox\">".
217 "<input type=\"hidden\" name=\"sort\" value=\"$sort\">".
218 "<input type=\"hidden\" name=\"startMessage\" value=\"$startMessage\">".
219 "<input type=\"hidden\" name=\"show_more\" value=\"0\">".
220 "<input type=\"hidden\" name=\"move_id\" value=\"$passed_id\">".
222 ' <select name="targetMailbox">';
223 get_move_target_list();
225 '<input type="submit" value="' . _("Move") . '">'.
232 function delete_move_next_moveRightMainForm() {
234 global $color, $where, $what, $currentArrayIndex, $passed_id,
235 $urlMailbox, $sort, $startMessage, $delete_id, $move_id,
238 echo '<form action="right_main.php" method="post">' .
240 "<td bgcolor=\"$color[9]\" width=\"100%\" align=\"center\"><small>".
241 "<input type=\"hidden\" name=\"mailbox\" value=\"$urlMailbox\">".
242 "<input type=\"hidden\" name=\"sort\" value=\"$sort\">".
243 "<input type=\"hidden\" name=\"startMessage\" value=\"$startMessage\">".
244 "<input type=\"hidden\" name=\"move_id\" value=\"$passed_id\">".
246 ' <select name="targetMailbox">';
247 get_move_target_list();
249 '<input type=submit value="' . _("Move") . '">'.
258 function delete_move_next_delete() {
259 global $imapConnection, $delete_id, $mailbox, $auto_expunge;
261 sqimap_messages_delete($imapConnection, $delete_id, $delete_id, $mailbox);
263 delete_move_expunge_from_all($delete_id);
264 // sqimap_mailbox_expunge($imapConnection, $mailbox, true);
268 function delete_move_next_move() {
269 global $imapConnection, $move_id, $targetMailbox, $auto_expunge, $mailbox;
272 sqimap_messages_copy($imapConnection, $move_id, $move_id, $targetMailbox);
273 sqimap_messages_flag($imapConnection, $move_id, $move_id, 'Deleted');
275 delete_move_expunge_from_all($move_id);
276 // sqimap_mailbox_expunge($imapConnection, $mailbox, true);
280 function delete_move_next_display_inside() {
281 global $username,$data_dir,
282 $delete_move_next_t, $delete_move_next_formATtop,
283 $delete_move_next_b, $delete_move_next_formATbottom;
285 echo "<tr><td align=right valign=top>\n".
286 _("delete_move_next:") . "</td>\n".
287 "<td><input type=checkbox name=delete_move_next_ti";
289 if ($delete_move_next_t == 'on') {
292 echo '> <- ' . _("display at top").
293 " <input type=checkbox name=delete_move_next_formATtopi";
295 if ($delete_move_next_formATtop == 'on') {
298 echo '> <- ' . _("with move option") . '<br>';
300 echo '<input type=checkbox name=delete_move_next_bi';
301 if($delete_move_next_b != 'off') {
304 echo '> <- ' . _("display at bottom") .
305 '<input type=checkbox name=delete_move_next_formATbottomi';
307 if ($delete_move_next_formATbottom != 'off') {
310 echo '> <- ' . _("with move option") . '<br>'.
314 function delete_move_next_display_save() {
316 global $username,$data_dir,
317 $delete_move_next_ti, $delete_move_next_formATtopi,
318 $delete_move_next_bi, $delete_move_next_formATbottomi;
320 if (isset($delete_move_next_ti)) {
321 setPref($data_dir, $username, 'delete_move_next_t', 'on');
323 setPref($data_dir, $username, 'delete_move_next_t', "off");
326 if (isset($delete_move_next_formATtopi)) {
327 setPref($data_dir, $username, 'delete_move_next_formATtop', 'on');
329 setPref($data_dir, $username, 'delete_move_next_formATtop', "off");
333 if (isset($delete_move_next_bi)) {
334 setPref($data_dir, $username, 'delete_move_next_b', 'on');
336 setPref($data_dir, $username, 'delete_move_next_b', "off");
339 if (isset($delete_move_next_formATbottomi)) {
340 setPref($data_dir, $username, 'delete_move_next_formATbottom', 'on');
342 setPref($data_dir, $username, 'delete_move_next_formATbottom', "off");
348 function delete_move_next_loading_prefs() {
349 global $username,$data_dir,
350 $delete_move_next_t, $delete_move_next_formATtop,
351 $delete_move_next_b, $delete_move_next_formATbottom;
353 $delete_move_next_t = getPref($data_dir, $username, 'delete_move_next_t');
354 $delete_move_next_b = getPref($data_dir, $username, 'delete_move_next_b');
355 $delete_move_next_formATtop = getPref($data_dir, $username, 'delete_move_next_formATtop');
356 $delete_move_next_formATbottom = getPref($data_dir, $username, 'delete_move_next_formATbottom');