Ejemplo n.º 1
0
 public function downloadFolder()
 {
     global $lng, $rbacsystem, $ilAccess;
     include_once "./Services/Utilities/classes/class.ilUtil.php";
     include_once 'Modules/File/classes/class.ilObjFile.php';
     include_once 'Modules/File/classes/class.ilFileException.php';
     if (!$ilAccess->checkAccess("read", "", $this->getRefId())) {
         $this->ilErr->raiseError(get_class($this) . "::downloadFolder(): missing read permission!", $this->ilErr->WARNING);
     }
     if (ilObject::_isInTrash($this->getRefId())) {
         $this->ilErr->raiseError(get_class($this) . "::downloadFolder(): object is trashed!", $this->ilErr->WARNING);
     }
     $zip = PATH_TO_ZIP;
     $tmpdir = ilUtil::ilTempnam();
     ilUtil::makeDir($tmpdir);
     $basename = ilUtil::getAsciiFilename($this->getTitle());
     $deliverFilename = $basename . ".zip";
     $zipbasedir = $tmpdir . DIRECTORY_SEPARATOR . $basename;
     $tmpzipfile = $tmpdir . DIRECTORY_SEPARATOR . $deliverFilename;
     try {
         ilObjFolder::recurseFolder($this->getRefId(), $this->getTitle(), $tmpdir);
         ilUtil::zip($zipbasedir, $tmpzipfile);
         rename($tmpzipfile, $zipfile = ilUtil::ilTempnam());
         ilUtil::delDir($tmpdir);
         ilUtil::deliverFile($zipfile, $deliverFilename, '', false, true);
     } catch (ilFileException $e) {
         ilUtil::sendInfo($e->getMessage(), true);
     }
 }