Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   1  <?php
   2  /**
   3   * Copyright 2011-2017 Horde LLC (http://www.horde.org/)
   4   *
   5   * See the enclosed file LICENSE for license information (LGPL). If you
   6   * did not receive this file, see http://www.horde.org/licenses/lgpl21.
   7   *
   8   * @category  Horde
   9   * @copyright 2011-2017 Horde LLC
  10   * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
  11   * @package   Imap_Client
  12   */
  13  
  14  /**
  15   * Wrapper around Ids object that correctly handles POP3 UID strings.
  16   *
  17   * @author    Michael Slusarz <slusarz@horde.org>
  18   * @category  Horde
  19   * @copyright 2011-2017 Horde LLC
  20   * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
  21   * @package   Imap_Client
  22   */
  23  class Horde_Imap_Client_Ids_Pop3 extends Horde_Imap_Client_Ids
  24  {
  25      /**
  26       */
  27      protected function _sort(&$ids)
  28      {
  29          /* There is no guarantee of POP3 UIDL order - IDs need to be unique,
  30           * but there is no requirement they need be incrementing. RFC
  31           * 1939[7] */
  32      }
  33  
  34      /**
  35       * Create a POP3 message sequence string.
  36       *
  37       * Index Format: UID1[SPACE]UID2...
  38       *
  39       * @param boolean $sort  Not used in this class.
  40       *
  41       * @return string  The POP3 message sequence string.
  42       */
  43      protected function _toSequenceString($sort = true)
  44      {
  45          /* $sort is ignored - see _sort(). */
  46  
  47          /* Use space as delimiter as it is the only printable ASCII character
  48           * that is not allowed as part of the UID (RFC 1939 [7]). */
  49          return implode(' ', count($this->_ids) > 25000 ? array_unique($this->_ids) : array_keys(array_flip($this->_ids)));
  50      }
  51  
  52      /**
  53       * Parse a POP3 message sequence string into a list of indices.
  54       *
  55       * @param string $str  The POP3 message sequence string.
  56       *
  57       * @return array  An array of UIDs.
  58       */
  59      protected function _fromSequenceString($str)
  60      {
  61          return explode(' ', trim($str));
  62      }
  63  
  64  }