You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pagenav.inc 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. +-----------------------------------------------------------------------+
  4. | program/steps/mail/pagenav.inc |
  5. | |
  6. | This file is part of the Roundcube Webmail client |
  7. | Copyright (C) 2005-2009, The Roundcube Dev Team |
  8. | |
  9. | Licensed under the GNU General Public License version 3 or |
  10. | any later version with exceptions for skins & plugins. |
  11. | See the README file for a full license statement. |
  12. | |
  13. | PURPOSE: |
  14. | Updates message page navigation controls |
  15. | |
  16. +-----------------------------------------------------------------------+
  17. | Author: Aleksander Machniak <alec@alec.pl> |
  18. +-----------------------------------------------------------------------+
  19. */
  20. $uid = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_GET);
  21. $index = $RCMAIL->storage->index(null, rcmail_sort_column(), rcmail_sort_order());
  22. $cnt = $index->count_messages();
  23. if ($cnt && ($pos = $index->exists($uid, true)) !== false) {
  24. $prev = $pos ? $index->get_element($pos-1) : 0;
  25. $first = $pos ? $index->get_element('FIRST') : 0;
  26. $next = $pos < $cnt-1 ? $index->get_element($pos+1) : 0;
  27. $last = $pos < $cnt-1 ? $index->get_element('LAST') : 0;
  28. }
  29. // Set UIDs and activate navigation buttons
  30. if ($prev) {
  31. $OUTPUT->set_env('prev_uid', $prev);
  32. $OUTPUT->command('enable_command', 'previousmessage', 'firstmessage', true);
  33. }
  34. if ($next) {
  35. $OUTPUT->set_env('next_uid', $next);
  36. $OUTPUT->command('enable_command', 'nextmessage', 'lastmessage', true);
  37. }
  38. if ($first) {
  39. $OUTPUT->set_env('first_uid', $first);
  40. }
  41. if ($last) {
  42. $OUTPUT->set_env('last_uid', $last);
  43. }
  44. // Don't need a real messages count value
  45. $OUTPUT->set_env('messagecount', 1);
  46. // Set rowcount text
  47. $OUTPUT->command('set_rowcount', $RCMAIL->gettext(array(
  48. 'name' => 'messagenrof',
  49. 'vars' => array('nr' => $pos+1, 'count' => $cnt)
  50. )));
  51. $OUTPUT->send();