squirrelmail-webmail  1.4.22
About: SquirrelMail is a standards-based webmail package with strong MIME support, address books, and folder manipulation (written in PHP4).
  Fossies Dox: squirrelmail-webmail-1.4.22.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

setup.php
Go to the documentation of this file.
1 <?php
2 
18 //FIXME: all functionality needs to be moved out of the setup.php file!
19 
26 
27  $squirrelmail_plugin_hooks['html_top']['delete_move_next'] = 'delete_move_next_action';
28  $squirrelmail_plugin_hooks['right_main_after_header']['delete_move_next'] = 'delete_move_next_action';
29  $squirrelmail_plugin_hooks['read_body_bottom']['delete_move_next'] = 'delete_move_next_read_b';
30  $squirrelmail_plugin_hooks['read_body_menu_bottom']['delete_move_next'] = 'delete_move_next_read_t';
31  $squirrelmail_plugin_hooks['options_display_inside']['delete_move_next'] = 'delete_move_next_display_inside';
32  $squirrelmail_plugin_hooks['options_display_save']['delete_move_next'] = 'delete_move_next_display_save';
33  $squirrelmail_plugin_hooks['loading_prefs']['delete_move_next'] = 'delete_move_next_loading_prefs';
34 }
35 
36 /* fixes the sort_array for the prev_del/next_del links when
37  * using server side sorting or thread sorting
38  */
39 
40 function fix_sort_array () {
42  $thread_sort_messages,
44 
45  // Got to grab this out of prefs, since it isn't saved from mailbox_view.php
46  if ($allow_thread_sort) {
47  $thread_sort_messages = getPref($data_dir, $username, "thread_$mailbox",0);
48  }
49 
50  switch (true) {
51  case ($allow_thread_sort && $thread_sort_messages):
52  $server_sort_array = get_thread_sort($imapConnection);
53  break;
54  case ($allow_server_sort):
56  break;
57  case ($uid_support):
59  break;
60  default:
61  break;
62  }
63 }
64 
65 /*
66  * Warning: this function relies on the internal representation of
67  * of the message cache for the current mailbox. As such, it is fragile
68  * because the underlying implementation can change. I will present it
69  * to the squirrelmail maintainers as a proposed addition to the API,
70  * perhaps even as inline code to sqimap_mailbox_expunge(). In the
71  * meantime, you have been warned. [alane@geeksrus.net 2001/05/06]
72  */
73 
74 function delete_move_del_arr_elem($arr, $index) {
75  $tmp = array();
76  $j = 0;
77  foreach ($arr as $v) {
78  if ($j != $index) {
79  $tmp[] = $v;
80  }
81  $j++;
82  }
83  return $tmp;
84 }
85 
87  global $msort, $msgs;
88  $keys = array_keys($msort);
89  for ($i = 0; $i < count($keys); $i++) {
90  echo '<p>key ' . $keys[$i] . ' msgid ' . $msgs[$keys[$i]]['ID'] . '</p>';
91  }
92 }
93 
95  global $msgs, $msort, $sort, $imapConnection, $mailbox, $uid_support;
96  $delAt = -1;
97 
98  if(isset($msort) && count($msort) > 0) {
99  for ($i = 0; $i < count($msort); $i++) {
100  if ($msgs[$i]['ID'] == $id) {
101  $delAt = $i;
102  } elseif ($msgs[$i]['ID'] > $id) {
103  if (!$uid_support) {
104  $msgs[$i]['ID']--;
105  }
106  }
107  }
108 
110  $msort = delete_move_del_arr_elem($msort, $delAt);
111  if ($sort < 6) {
112  if ($sort % 2) {
113  asort($msort);
114  } else {
115  arsort($msort);
116  }
117  }
118  sqsession_register($msgs, 'msgs');
119  sqsession_register($msort, 'msort');
120  }
121 
123 }
124 
126 
127  if ( sqgetGlobalVar('unread_id', $unread_id, SQ_GET) ) {
129  } else if ( sqgetGlobalVar('delete_id', $delete_id, SQ_GET) ) {
131  fix_sort_array();
132  } else if ( sqgetGlobalVar('move_id', $move_id, SQ_POST) ) {
134  fix_sort_array();
135  }
136 }
137 
139 
140  global $delete_move_next_t;
141 
142  if($delete_move_next_t == 'on') {
143  delete_move_next_read('top');
144  }
145 }
146 
148 
149  global $delete_move_next_b;
150 
151  if ($delete_move_next_b != 'off') {
152  delete_move_next_read('bottom');
153  }
154 }
155 
156 function delete_move_next_read($currloc) {
157  global $delete_move_next_formATtop, $delete_move_next_formATbottom,
158  $color, $where, $what, $currentArrayIndex, $passed_id,
159  $mailbox, $sort, $startMessage, $delete_id, $move_id,
161  $uid_support, $passed_ent_id, $delete_move_next_show_unread;
162 
163  $urlMailbox = urlencode($mailbox);
164 
165  if (!isset($passed_ent_id)) $passed_ent_id = 0;
166 
167  if (!(($where && $what) || ($currentArrayIndex == -1)) && !$passed_ent_id) {
168  $next = findNextMessage($passed_id);
169  $prev = findPreviousMessage($mbx_response['EXISTS'], $passed_id);
170  $prev_if_del = $prev;
171  $next_if_del = $next;
173  if ($prev_if_del > $passed_id) {
174  $prev_if_del--;
175  }
176  if ($next_if_del > $passed_id) {
177  $next_if_del--;
178  }
179  }
180 
181  /* Base is illegal within documents
182  * $location = get_location();
183  * echo "<base href=\"$location/\">" . */
184  echo '<table cellspacing="0" width="100%" border="0" cellpadding="2">'.
185  '<tr>'.
186  "<td bgcolor=\"$color[9]\" width=\"100%\" align=\"center\"><small>";
187 
188  if ($prev > 0){
189  echo "<a href=\"read_body.php?passed_id=$prev_if_del&amp;mailbox=$urlMailbox&amp;sort=$sort&amp;startMessage=$startMessage&amp;show_more=0&amp;delete_id=$passed_id&amp;smtoken=" . sm_generate_security_token() . "\">" . _("Delete &amp; Prev") . "</a>" . "&nbsp;|&nbsp;";
190  if ($delete_move_next_show_unread == 'on') {
191  echo "<a href=\"read_body.php?passed_id=$prev_if_del&amp;mailbox=$urlMailbox&amp;sort=$sort&amp;startMessage=$startMessage&amp;show_more=0&amp;unread_id=$passed_id&amp;smtoken=" . sm_generate_security_token() . "\">" . _("Unread &amp; Prev") . "</a>" . "&nbsp;|&nbsp;";
192  }
193  }
194  else {
195  echo _("Delete &amp; Prev") . "&nbsp;|&nbsp;";
196  if ($delete_move_next_show_unread == 'on') {
197  echo _("Unread &amp; Prev") . "&nbsp;|&nbsp;";
198  }
199  }
200  if ($next > 0){
201  if ($delete_move_next_show_unread == 'on') {
202  echo "<a href=\"read_body.php?passed_id=$next_if_del&amp;mailbox=$urlMailbox&amp;sort=$sort&amp;startMessage=$startMessage&amp;show_more=0&amp;unread_id=$passed_id&amp;smtoken=" . sm_generate_security_token() . "\">" . _("Unread &amp; Next") . "</a>&nbsp;|&nbsp;";
203  }
204  echo "<a href=\"read_body.php?passed_id=$next_if_del&amp;mailbox=$urlMailbox&amp;sort=$sort&amp;startMessage=$startMessage&amp;show_more=0&amp;delete_id=$passed_id&amp;smtoken=" . sm_generate_security_token() . "\">" . _("Delete &amp; Next") . "</a>";
205  } else {
206  if ($delete_move_next_show_unread == 'on') {
207  echo _("Unread &amp; Next") . "&nbsp;|&nbsp;";
208  }
209  echo _("Delete &amp; Next");
210  }
211  echo '</small></td></tr>';
212 
213  if ($next_if_del < 0) {
214  $next_if_del = $prev_if_del;
215  }
216  if (($delete_move_next_formATtop == 'on') && ($currloc == 'top')) {
217  if ($next_if_del > 0) {
218  delete_move_next_moveNextForm($next_if_del);
219  } else {
221  }
222  }
223  if (($delete_move_next_formATbottom != 'off') && ($currloc == 'bottom')) {
224  if ($next_if_del > 0) {
225  delete_move_next_moveNextForm($next_if_del);
226  } else {
228  }
229  }
230  echo '</table>';
231  }
232 }
233 
235  global $imapConnection, $lastTargetMailbox;
236  if (isset($lastTargetMailbox) && !empty($lastTargetMailbox)) {
237  echo sqimap_mailbox_option_list($imapConnection, array(strtolower($lastTargetMailbox)));
238  }
239  else {
241  }
242 }
243 
245 
246  global $color, $where, $what, $currentArrayIndex, $passed_id,
247  $mailbox, $sort, $startMessage, $delete_id, $move_id,
249 
250  $urlMailbox = urlencode($mailbox);
251 
252  echo '<tr>'.
253  "<td bgcolor=\"$color[9]\" width=\"100%\" align=\"center\">".
254  "<form action=\"read_body.php?mailbox=$urlMailbox&amp;sort=$sort&amp;startMessage=$startMessage&amp;passed_id=$next\" method=\"post\"><small>".
255  "<input type=\"hidden\" name=\"show_more\" value=\"0\">".
256  "<input type=\"hidden\" name=\"move_id\" value=\"$passed_id\">".
257  "<input type=\"hidden\" name=\"smtoken\" value=\"" . sm_generate_security_token() . "\">".
258  _("Move to:") .
259  ' <select name="targetMailbox">';
261  echo '</select> '.
262  '<input type="submit" value="' . _("Move") . '">'.
263  '</small>'.
264  '</form>'.
265  '</td>'.
266  '</tr>';
267 }
268 
270 
271  global $color, $where, $what, $currentArrayIndex, $passed_id,
272  $mailbox, $sort, $startMessage, $delete_id, $move_id,
274 
275  $urlMailbox = urlencode($mailbox);
276 
277  echo '<tr>' .
278  "<td bgcolor=\"$color[9]\" width=\"100%\" align=\"center\">".
279  "<form action=\"right_main.php?mailbox=$urlMailbox&amp;sort=$sort&amp;startMessage=$startMessage\" method=\"post\"><small>" .
280  "<input type=\"hidden\" name=\"move_id\" value=\"$passed_id\">".
281  "<input type=\"hidden\" name=\"smtoken\" value=\"" . sm_generate_security_token() . "\">".
282  _("Move to:") .
283  ' <select name="targetMailbox">';
285  echo ' </select>' .
286  '<input type=submit value="' . _("Move") . '">'.
287  '</small>'.
288  '</form>' .
289  '</td>'.
290  '</tr>';
291 }
292 
294  global $imapConnection;
295 
296  sqgetGlobalVar('unread_id', $unread_id, SQ_GET);
297  if (!sqgetGlobalVar('smtoken',$submitted_token, SQ_GET)) {
298  $submitted_token = '';
299  }
300 
301  // first, validate security token
302  sm_validate_security_token($submitted_token, 3600, TRUE);
303 
304  sqimap_toggle_flag($imapConnection, $unread_id, '\\Seen', false, true);
305 }
306 
309 
310  sqgetGlobalVar('delete_id', $delete_id, SQ_GET);
311  sqgetGlobalVar('mailbox', $mailbox, SQ_GET);
312  if (!sqgetGlobalVar('smtoken',$submitted_token, SQ_GET)) {
313  $submitted_token = '';
314  }
315 
316  // first, validate security token
317  sm_validate_security_token($submitted_token, 3600, TRUE);
318 
320  if ($auto_expunge) {
321  delete_move_expunge_from_all($delete_id);
322  // sqimap_mailbox_expunge($imapConnection, $mailbox, true);
323  }
324 }
325 
327  global $imapConnection, $mailbox, $auto_expunge, $lastTargetMailbox;
328 
329  sqgetGlobalVar('move_id', $move_id, SQ_POST);
330  sqgetGlobalVar('mailbox', $mailbox, SQ_FORM);
331  sqgetGlobalVar('targetMailbox', $targetMailbox, SQ_POST);
332  if (!sqgetGlobalVar('smtoken',$submitted_token, SQ_POST)) {
333  $submitted_token = '';
334  }
335 
336  // first, validate security token
337  sm_validate_security_token($submitted_token, 3600, TRUE);
338 
339  // Move message
340  sqimap_msgs_list_move($imapConnection, $move_id, $targetMailbox);
341  if ($auto_expunge) {
343  // sqimap_mailbox_expunge($imapConnection, $mailbox, true);
344  }
345 
346  if ($targetMailbox != $lastTargetMailbox) {
347  $lastTargetMailbox = $targetMailbox;
348  sqsession_register($lastTargetMailbox, 'lastTargetMailbox');
349  }
350 }
351 
353  global $username,$data_dir, $delete_move_next_show_unread,
354  $delete_move_next_t, $delete_move_next_formATtop,
355  $delete_move_next_b, $delete_move_next_formATbottom;
356 
357  echo "<tr>" . html_tag('td',_("Delete/Unread/Move/Next Buttons:"),'right','','valign="top"') . "\n".
358  '<td><input type="checkbox" name="delete_move_next_ti" id="delete_move_next_ti"';
359 
360  if ($delete_move_next_t == 'on') {
361  echo ' checked="checked"';
362  }
363  echo '><label for="delete_move_next_ti"> ' . _("Display at top").
364  '</label> <input type="checkbox" name="delete_move_next_formATtopi" id="delete_move_next_formATtopi"';
365 
366  if ($delete_move_next_formATtop == 'on') {
367  echo ' checked="checked"';
368  }
369  echo '><label for="delete_move_next_formATtopi"> ' . _("with move option") . '</label><br>';
370 
371  echo '<input type="checkbox" name="delete_move_next_bi" id="delete_move_next_bi"';
372  if($delete_move_next_b != 'off') {
373  echo ' checked="checked"';
374  }
375  echo '><label for="delete_move_next_bi"> ' . _("Display at bottom") .
376  '</label> <input type="checkbox" name="delete_move_next_formATbottomi" id="delete_move_next_formATbottomi"';
377 
378  if ($delete_move_next_formATbottom != 'off') {
379  echo ' checked="checked"';
380  }
381  echo '><label for="delete_move_next_formATbottomi"> ' . _("with move option") . '</label><br>'.
382  '<input type="checkbox" name="delete_move_next_show_unread" id="delete_move_next_show_unread"';
383  if($delete_move_next_show_unread != 'off') {
384  echo ' checked="checked"';
385  }
386  echo '><label for="delete_move_next_show_unread"> ' . _("Show unread options") .
387  "</label></td></tr>\n";
388 }
389 
391 
392  global $username,$data_dir;
393 
394  if ( sqgetGlobalVar('delete_move_next_ti', $delete_move_next_ti, SQ_POST) ) {
395  setPref($data_dir, $username, 'delete_move_next_t', 'on');
396  } else {
397  setPref($data_dir, $username, 'delete_move_next_t', "off");
398  }
399 
400  if ( sqgetGlobalVar('delete_move_next_formATtopi', $delete_move_next_formATtopi, SQ_POST) ) {
401  setPref($data_dir, $username, 'delete_move_next_formATtop', 'on');
402  } else {
403  setPref($data_dir, $username, 'delete_move_next_formATtop', "off");
404  }
405 
406 
407  if ( sqgetGlobalVar('delete_move_next_bi', $delete_move_next_bi, SQ_POST) ) {
408  setPref($data_dir, $username, 'delete_move_next_b', 'on');
409  } else {
410  setPref($data_dir, $username, 'delete_move_next_b', "off");
411  }
412 
413  if ( sqgetGlobalVar('delete_move_next_formATbottomi', $delete_move_next_formATbottomi, SQ_POST) ) {
414  setPref($data_dir, $username, 'delete_move_next_formATbottom', 'on');
415  } else {
416  setPref($data_dir, $username, 'delete_move_next_formATbottom', "off");
417  }
418 
419  if ( sqgetGlobalVar('delete_move_next_show_unread', $delete_move_next_show_unread, SQ_POST) ) {
420  setPref($data_dir, $username, 'delete_move_next_show_unread', 'on');
421  } else {
422  setPref($data_dir, $username, 'delete_move_next_show_unread', "off");
423  }
424 }
425 
427  global $username,$data_dir, $delete_move_next_show_unread,
428  $delete_move_next_t, $delete_move_next_formATtop,
429  $delete_move_next_b, $delete_move_next_formATbottom;
430 
431  $delete_move_next_t = getPref($data_dir, $username, 'delete_move_next_t');
432  $delete_move_next_b = getPref($data_dir, $username, 'delete_move_next_b');
433  $delete_move_next_formATtop = getPref($data_dir, $username, 'delete_move_next_formATtop');
434  $delete_move_next_formATbottom = getPref($data_dir, $username, 'delete_move_next_formATbottom');
435  $delete_move_next_show_unread = getPref($data_dir, $username, 'delete_move_next_show_unread');
436 
437 }
438 
elseif
if(! sqgetGlobalVar('sound', $sound, SQ_GET)) elseif($sound=='(none)')
Definition: testsound.php:25
sqgetGlobalVar
sqgetGlobalVar($name, &$value, $search=SQ_INORDER)
Definition: global.php:344
$imapConnection
$imapConnection
Definition: message_details_bottom.php:74
getPref
getPref($data_dir, $username, $string, $default='')
Definition: db_prefs.php:316
sqimap_mailbox_expunge
sqimap_mailbox_expunge($imap_stream, $mailbox, $handle_errors=true, $id='')
Definition: imap_mailbox.php:198
html_tag
html_tag( $tag, $val='', $align='', $bgcolor='', $xtra='')
Definition: html.php:27
delete_move_next_moveNextForm
delete_move_next_moveNextForm($next)
Definition: setup.php:244
findNextMessage
findNextMessage($passed_id)
Definition: read_body.php:39
delete_move_next_loading_prefs
delete_move_next_loading_prefs()
Definition: setup.php:426
delete_move_next_action
delete_move_next_action()
Definition: setup.php:125
$data_dir
$data_dir
Definition: config_default.php:499
squirrelmail_plugin_init_delete_move_next
squirrelmail_plugin_init_delete_move_next()
Definition: setup.php:24
$id
$id
Definition: move_messages.php:190
sqimap_toggle_flag
sqimap_toggle_flag($imap_stream, $id, $flag, $set, $handle_errors)
Definition: imap_messages.php:1173
$mailbox
$mailbox
Definition: options.php:28
delete_move_next_unread
delete_move_next_unread()
Definition: setup.php:293
setPref
setPref($data_dir, $username, $string, $set_to)
Definition: db_prefs.php:352
get_move_target_list
get_move_target_list()
Definition: setup.php:234
fix_sort_array
fix_sort_array()
Definition: setup.php:40
sqimap_get_sort_order
sqimap_get_sort_order($imap_stream, $sort, $mbxresponse)
Definition: imap_messages.php:135
delete_move_next_delete
delete_move_next_delete()
Definition: setup.php:307
delete_move_next_move
delete_move_next_move()
Definition: setup.php:326
$username
global $username
Definition: validate.php:55
delete_move_next_moveRightMainForm
delete_move_next_moveRightMainForm()
Definition: setup.php:269
$sort
$sort
Definition: load_prefs.php:170
$uid_support
$uid_support
Definition: config_default.php:643
sm_validate_security_token
sm_validate_security_token($token, $validity_period=0, $show_error=FALSE)
Definition: strings.php:1405
delete_move_next_display_inside
delete_move_next_display_inside()
Definition: setup.php:352
delete_move_next_read_t
delete_move_next_read_t()
Definition: setup.php:138
$mbx_response
$mbx_response
Definition: download.php:52
sqimap_msgs_list_move
sqimap_msgs_list_move($imap_stream, $id, $mailbox, $handle_errors=true)
Definition: imap_messages.php:56
$squirrelmail_plugin_hooks
global $squirrelmail_plugin_hooks
Definition: plugin.php:17
delete_move_next_read_b
delete_move_next_read_b()
Definition: setup.php:147
get_thread_sort
get_thread_sort($imap_stream)
Definition: imap_messages.php:380
sqimap_msgs_list_delete
sqimap_msgs_list_delete($imap_stream, $mailbox, $id)
Definition: imap_messages.php:73
$allow_thread_sort
$allow_thread_sort
Definition: config_default.php:615
sm_generate_security_token
sm_generate_security_token()
Definition: strings.php:1340
SQ_GET
const SQ_GET
Definition: global.php:16
delete_move_show_msg_array
delete_move_show_msg_array()
Definition: setup.php:86
$j
for($i=0; $i< $numboxes; $i++) $j
Definition: empty_trash.php:72
sqimap_mailbox_option_list
sqimap_mailbox_option_list($imap_stream, $show_selected=0, $folder_skip=0, $boxes=0, $flag='noselect', $use_long_format=false)
Definition: imap_mailbox.php:521
sqimap_get_php_sort_order
sqimap_get_php_sort_order($imap_stream, $mbxresponse)
Definition: imap_messages.php:232
delete_move_del_arr_elem
delete_move_del_arr_elem($arr, $index)
Definition: setup.php:74
SQ_POST
const SQ_POST
Definition: global.php:17
sqsession_register
sqsession_register($var, $name)
Definition: global.php:289
_
_($str)
Definition: gettext.php:160
$allow_server_sort
$allow_server_sort
Definition: config_default.php:625
SQ_FORM
const SQ_FORM
Definition: global.php:21
$color
$color
Definition: load_prefs.php:28
delete_move_next_read
delete_move_next_read($currloc)
Definition: setup.php:156
delete_move_expunge_from_all
delete_move_expunge_from_all($id)
Definition: setup.php:94
$msgs
if(isset($sendreceipt)) $msgs[$passed_id]['FLAG_SEEN']
Definition: read_body.php:852
findPreviousMessage
findPreviousMessage($numMessages, $passed_id)
Definition: read_body.php:77
$move_to_trash
$move_to_trash
Definition: load_prefs.php:84
delete_move_next_display_save
delete_move_next_display_save()
Definition: setup.php:390
$auto_expunge
$auto_expunge
Definition: config_default.php:397