Example #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);
     }
 }
Example #2
0
 /**	
  * Creates a dav collection as a child of this object.
  *
  * @param	string		the name of the collection.
  * @return	ilObjectDAV	returns the created collection, or null if creation failed.
  */
 function createCollection($name)
 {
     global $tree;
     // create and insert Folder in tree
     require_once 'Modules/Folder/classes/class.ilObjFolder.php';
     $newObj = new ilObjFolder(0);
     $newObj->setType($this->getILIASCollectionType());
     $newObj->setTitle($name);
     //$newObj->setDescription('');
     $newObj->create();
     $newObj->createReference();
     $newObj->setPermissions($this->getRefId());
     $newObj->putInTree($this->getRefId());
     require_once 'class.ilObjFolderDAV.php';
     return new ilObjFolderDAV($newObj->getRefId(), $newObj);
 }
 /**
  * Delete a child of media tree 
  * @param	int		mep_item id
  */
 function deleteChild($obj_id)
 {
     $fid = ilMediaPoolItem::lookupForeignId($obj_id);
     $type = ilMediaPoolItem::lookupType($obj_id);
     $title = ilMediaPoolItem::lookupTitle($obj_id);
     $node_data = $this->tree->getNodeData($obj_id);
     $subtree = $this->tree->getSubtree($node_data);
     // delete tree
     if ($this->tree->isInTree($obj_id)) {
         $this->tree->deleteTree($node_data);
     }
     // delete objects
     foreach ($subtree as $node) {
         $fid = ilMediaPoolItem::lookupForeignId($node["child"]);
         if ($node["type"] == "mob") {
             if (ilObject::_lookupType($fid) == "mob") {
                 $obj =& new ilObjMediaObject($fid);
                 $obj->delete();
             }
         }
         if ($node["type"] == "fold") {
             if ($fid > 0 && ilObject::_lookupType($fid) == "fold") {
                 $obj = new ilObjFolder($fid, false);
                 $obj->delete();
             }
         }
         if ($node["type"] == "pg") {
             include_once "./Modules/MediaPool/classes/class.ilMediaPoolPage.php";
             if (ilMediaPoolPage::_exists($node["child"])) {
                 $pg = new ilMediaPoolPage($node["child"]);
                 $pg->delete();
             }
         }
         include_once "./Modules/MediaPool/classes/class.ilMediaPoolItem.php";
         $item = new ilMediaPoolItem($node["child"]);
         $item->delete();
     }
 }
Example #4
0
 /**
  * Creates and inserts container object (folder/category) into tree
  *
  * @author Jan Hippchen
  * @version 1.6.9.07	
  * @param string $name Name of the object
  * @param integer $ref_id ref_id of parent
  * @param string $containerType Fold or Cat
  * @return integer ref_id of containerobject
  */
 function createContainer($name, $ref_id, $containerType, $tree = null, $access_handler = null)
 {
     switch ($containerType) {
         case "Category":
             include_once "./Modules/Category/classes/class.ilObjCategory.php";
             $newObj = new ilObjCategory();
             $newObj->setType("cat");
             break;
         case "Folder":
             include_once "./Modules/Folder/classes/class.ilObjFolder.php";
             $newObj = new ilObjFolder();
             $newObj->setType("fold");
             break;
         case "WorkspaceFolder":
             include_once "./Modules/WorkspaceFolder/classes/class.ilObjWorkspaceFolder.php";
             $newObj = new ilObjWorkspaceFolder();
             break;
     }
     $newObj->setTitle($name);
     $newObj->create();
     // repository
     if (!$access_handler) {
         $newObj->createReference();
         $newObj->putInTree($ref_id);
         $newObj->setPermissions($ref_id);
         if ($newObj->getType() == "cat") {
             global $lng;
             $newObj->addTranslation($name, "", $lng->getLangKey(), $lng->getLangKey());
         }
         self::$new_files[$ref_id][] = $newObj;
         return $newObj->getRefId();
     } else {
         $node_id = $tree->insertObject($ref_id, $newObj->getId());
         $access_handler->setPermissions($ref_id, $node_id);
         return $node_id;
     }
 }