IMP_Contents::downloadAllList PHP Method

downloadAllList() public method

Get download all list.
public downloadAllList ( ) : array
return array An array of downloadable parts.
    public function downloadAllList()
    {
        $ret = array();
        $this->_buildMessage();
        foreach ($this->_message->partIterator() as $val) {
            if ($val->isAttachment()) {
                $ret[] = $val->getMimeId();
            }
        }
        return $ret;
    }

Usage Example

Example #1
0
 /**
  */
 public function downloadAll()
 {
     global $page_output, $session;
     $headers = $this->_contents->getHeader();
     $zipfile = trim(preg_replace('/[^\\pL\\pN-+_. ]/u', '_', $headers->getValue('subject')), ' _');
     if (empty($zipfile)) {
         $zipfile = _("attachments.zip");
     } else {
         $zipfile .= '.zip';
     }
     $page_output->disableCompression();
     $session->close();
     $tosave = array();
     foreach ($this->_contents->downloadAllList() as $val) {
         $mime = $this->_getRawDownloadPart($val);
         if (!($name = $mime->getName(true))) {
             $name = sprintf(_("part %s"), $val);
         }
         $tosave[] = array('data' => $mime->getContents(array('stream' => true)), 'name' => $name);
     }
     if (empty($tosave)) {
         return array();
     }
     return array('data' => Horde_Compress::factory('Zip')->compress($tosave, array('stream' => true)), 'name' => $zipfile, 'type' => 'application/zip');
 }