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.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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-2016, 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. else {
  30. // error, this will at least disable page navigation
  31. $OUTPUT->command('set_rowcount', '');
  32. $OUTPUT->send();
  33. }
  34. // Set UIDs and activate navigation buttons
  35. if ($prev) {
  36. $OUTPUT->set_env('prev_uid', $prev);
  37. $OUTPUT->command('enable_command', 'previousmessage', 'firstmessage', true);
  38. }
  39. if ($next) {
  40. $OUTPUT->set_env('next_uid', $next);
  41. $OUTPUT->command('enable_command', 'nextmessage', 'lastmessage', true);
  42. }
  43. if ($first) {
  44. $OUTPUT->set_env('first_uid', $first);
  45. }
  46. if ($last) {
  47. $OUTPUT->set_env('last_uid', $last);
  48. }
  49. // Don't need a real messages count value
  50. $OUTPUT->set_env('messagecount', 1);
  51. // Set rowcount text
  52. $OUTPUT->command('set_rowcount', $RCMAIL->gettext(array(
  53. 'name' => 'messagenrof',
  54. 'vars' => array('nr' => $pos+1, 'count' => $cnt)
  55. )));
  56. $OUTPUT->send();