ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilObjWorkspaceFolder.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5require_once "Services/Object/classes/class.ilObject2.php";
6
16{
18
19 function initType()
20 {
21 $this->type = "wfld";
22 }
23
24 function setFolderTree($a_tree)
25 {
26 $this->folder_tree =& $a_tree;
27 }
28
37 public function doCloneObject($a_new_object, $a_target_id, $a_copy_id = 0)
38 {
39
40 }
41
50 public function cloneDependencies($a_target_id,$a_copy_id)
51 {
52
53 }
54
63 private static function recurseFolder ($refid, $title, $tmpdir) {
64 global $tree, $ilAccess;
65
66 $tmpdir = $tmpdir.DIRECTORY_SEPARATOR.ilUtil::getASCIIFilename($title);
67 ilUtil::makeDir($tmpdir);
68
69 $subtree = $tree->getChildsByTypeFilter($refid, array("fold","file"));
70
71 foreach ($subtree as $child)
72 {
73 if (!$ilAccess->checkAccess("read", "", $child["ref_id"]))
74 {
75 continue;
76 }
77 if (ilObject::_isInTrash($child["ref_id"]))
78 {
79 continue;
80 }
81 if ($child["type"] == "fold")
82 {
83 ilObjFolder::recurseFolder ($child["ref_id"], $child["title"], $tmpdir);
84 } else {
85 $newFilename = $tmpdir.DIRECTORY_SEPARATOR.ilUtil::getASCIIFilename($child["title"]);
86 // copy to temporal directory
87 $oldFilename = ilObjFile::_lookupAbsolutePath($child["obj_id"]);
88 if (!copy ($oldFilename, $newFilename))
89 {
90 throw new ilFileException("Could not copy ".$oldFilename." to ".$newFilename);
91 }
92 touch($newFilename, filectime($oldFilename));
93 }
94 }
95
96 }
97
98 public function downloadFolder()
99 {
100 global $ilAccess;
101
102 include_once 'Modules/File/classes/class.ilObjFile.php';
103 include_once 'Modules/File/classes/class.ilFileException.php';
104
105 if (!$ilAccess->checkAccess("read", "", $this->getRefId()))
106 {
107 include_once "Services/Object/exceptions/class.ilObjectException.php";
108 throw new ilObjectException("missing read permission!");
109 }
110 if (ilObject::_isInTrash($this->getRefId()))
111 {
112 include_once "Services/Object/exceptions/class.ilObjectException.php";
113 throw new ilObjectException("object is trashed!");
114 }
115
116 $zip = PATH_TO_ZIP;
117 $tmpdir = ilUtil::ilTempnam();
118 ilUtil::makeDir($tmpdir);
119 $basename = ilUtil::getAsciiFilename($this->getTitle());
120 $deliverFilename = $basename.".zip";
121 $zipbasedir = $tmpdir.DIRECTORY_SEPARATOR.$basename;
122 $tmpzipfile = $tmpdir.DIRECTORY_SEPARATOR.$deliverFilename;
123
124 try {
125 ilObjFolder::recurseFolder ($this->getRefId(), $this->getTitle(), $tmpdir);
126 ilUtil::zip($zipbasedir, $tmpzipfile);
127 rename($tmpzipfile,$zipfile = ilUtil::ilTempnam());
128 ilUtil::delDir($tmpdir);
129 ilUtil::deliverFile($zipfile,$deliverFilename,'',false,true);
130 } catch (ilFileException $e) {
131 ilUtil::sendInfo($e->getMessage(), true);
132 }
133 }
134
138 function getViewMode()
139 {
141 }
142
147 function addAdditionalSubItemInformation(&$a_item_data)
148 {
149
150 }
151
152}
153
154?>
An exception for terminatinating execution or to throw for unit testing.
Class to report exception.
static _lookupAbsolutePath($obj_id, $a_version=null)
return absolute path for version
static recurseFolder($refid, $title, $tmpdir)
private functions which iterates through all folders and files and create an according file structure...
Class ilObjWorkspaceFolder.
cloneDependencies($a_target_id, $a_copy_id)
Clone object dependencies (crs items, preconditions)
static recurseFolder($refid, $title, $tmpdir)
private functions which iterates through all folders and files and create an according file structure...
getViewMode()
Get container view mode.
addAdditionalSubItemInformation(&$a_item_data)
Add additional information to sub item, e.g.
doCloneObject($a_new_object, $a_target_id, $a_copy_id=0)
Clone folder.
Class ilObject2 This is an intermediate progress of ilObject class.
getRefId()
get reference id @access public
getTitle()
get object title @access public
Base exception class for object service.
static _isInTrash($a_ref_id)
checks wether object is in trash
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static zip($a_dir, $a_file, $compress_content=false)
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...