Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.
   1  <?php
   2  /**
   3   * Copyright 2015-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 2015-2017 Horde LLC
  10   * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
  11   * @package   Mime
  12   */
  13  
  14  /**
  15   * This class represents the Content-ID header value (RFC 2045 [7]).
  16   *
  17   * @author    Michael Slusarz <slusarz@horde.org>
  18   * @category  Horde
  19   * @copyright 2015-2017 Horde LLC
  20   * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
  21   * @package   Mime
  22   * @since     2.8.0
  23   */
  24  class Horde_Mime_Headers_ContentId
  25  extends Horde_Mime_Headers_Element_Single
  26  implements Horde_Mime_Headers_Extension_Mime
  27  {
  28      /**
  29       * Creates a Content-ID header conforming to RFC 2045 [7].
  30       *
  31       * @return Horde_Mime_Headers_ContentId  Content-ID header object.
  32       */
  33      public static function create()
  34      {
  35          return new self(
  36              null,
  37              strval(new Horde_Support_Randomid()) . '@' . gethostname()
  38          );
  39      }
  40  
  41      /**
  42       */
  43      public function __construct($name, $value)
  44      {
  45          parent::__construct('Content-ID', $value);
  46      }
  47  
  48      /**
  49       */
  50      protected function _setValue($value)
  51      {
  52          parent::_setValue($value);
  53  
  54          $val = $this->value;
  55          $cid = '<' . ltrim(rtrim($val, '>'), '<') . '>';
  56  
  57          if ($cid !== $val) {
  58              parent::_setValue($cid);
  59          }
  60      }
  61  
  62      /**
  63       */
  64      public static function getHandles()
  65      {
  66          return array(
  67              'content-id'
  68          );
  69      }
  70  
  71  }