setMimeId() public method

Alter the MIME ID of this part.
public setMimeId ( string $mimeid )
$mimeid string The MIME ID.
Example #1
0
 /**
  * Function used to find a specific MIME part by ID and perform an action
  * on it.
  *
  * @param string $id                  The MIME ID.
  * @param string $action              The action to perform ('get',
  *                                    'remove', or 'alter').
  * @param Horde_Mime_Part $mime_part  The object to use for 'alter'.
  *
  * @return mixed  See calling functions.
  */
 protected function _partAction($id, $action, $mime_part = null)
 {
     $this_id = $this->getMimeId();
     /* Need strcmp() because, e.g., '2.0' == '2'. */
     if ($action === 'get' && strcmp($id, $this_id) === 0) {
         return $this;
     }
     if ($this->_reindex) {
         $this->buildMimeIds(is_null($this_id) ? '1' : $this_id);
     }
     foreach ($this->_parts as $key => $val) {
         $partid = $val->getMimeId();
         if (($match = strcmp($id, $partid) === 0) || strpos($id, $partid . '.') === 0 || strrchr($partid, '.') === '.0') {
             switch ($action) {
                 case 'alter':
                     if ($match) {
                         $mime_part->setMimeId($partid);
                         $this->_parts[$key] = $mime_part;
                         return true;
                     }
                     return $val->alterPart($id, $mime_part);
                 case 'get':
                     return $match ? $val : $val->getPart($id);
                 case 'remove':
                     if ($match) {
                         unset($this->_parts[$key]);
                         $this->_reindex = true;
                         return true;
                     }
                     return $val->removePart($id);
             }
         }
     }
     return $action === 'get' ? null : false;
 }
Example #2
0
 /**
  * Function used to find a specific MIME part by ID and perform an action
  * on it.
  *
  * @param string $id                  The MIME ID.
  * @param string $action              The action to perform ('get',
  *                                    'remove', or 'alter').
  * @param Horde_Mime_Part $mime_part  The object to use for 'alter'.
  *
  * @return mixed  See calling functions.
  */
 protected function _partAction($id, $action, $mime_part = null)
 {
     $this_id = $this->getMimeId();
     /* Need strcmp() because, e.g., '2.0' == '2'. */
     if ($action == 'get' && strcmp($id, $this_id) === 0) {
         return $this;
     }
     if ($this->_reindex) {
         $this->buildMimeIds(is_null($this_id) ? '1' : $this_id);
     }
     foreach (array_keys($this->_parts) as $val) {
         $partid = $this->_parts[$val]->getMimeId();
         if (strcmp($id, $partid) === 0) {
             switch ($action) {
                 case 'alter':
                     $mime_part->setMimeId($this->_parts[$val]->getMimeId());
                     $this->_parts[$val] = $mime_part;
                     return true;
                 case 'get':
                     return $this->_parts[$val];
                 case 'remove':
                     unset($this->_parts[$val]);
                     $this->_reindex = true;
                     return true;
             }
         }
         if (strpos($id, $partid . '.') === 0 || strrchr($partid, '.') === '.0') {
             return $this->_parts[$val]->_partAction($id, $action, $mime_part);
         }
     }
     return $action == 'get' ? null : false;
 }