ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 $rbacsystem, $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 global $lng, $rbacsystem, $ilAccess;
100 include_once "./Services/Utilities/classes/class.ilUtil.php";
101 include_once 'Modules/File/classes/class.ilObjFile.php';
102 include_once 'Modules/File/classes/class.ilFileException.php';
103 if (!$ilAccess->checkAccess("read", "", $this->getRefId()))
104 {
105 $this->ilErr->raiseError(get_class($this)."::downloadFolder(): missing read permission!",$this->ilErr->WARNING);
106 }
107 if (ilObject::_isInTrash($this->getRefId()))
108 {
109 $this->ilErr->raiseError(get_class($this)."::downloadFolder(): object is trashed!",$this->ilErr->WARNING);
110 }
111
112 $zip = PATH_TO_ZIP;
113 $tmpdir = ilUtil::ilTempnam();
114 ilUtil::makeDir($tmpdir);
115 $basename = ilUtil::getAsciiFilename($this->getTitle());
116 $deliverFilename = $basename.".zip";
117 $zipbasedir = $tmpdir.DIRECTORY_SEPARATOR.$basename;
118 $tmpzipfile = $tmpdir.DIRECTORY_SEPARATOR.$deliverFilename;
119
120 try {
121 ilObjFolder::recurseFolder ($this->getRefId(), $this->getTitle(), $tmpdir);
122 ilUtil::zip($zipbasedir, $tmpzipfile);
123 rename($tmpzipfile,$zipfile = ilUtil::ilTempnam());
124 ilUtil::delDir($tmpdir);
125 ilUtil::deliverFile($zipfile,$deliverFilename,'',false,true);
126 } catch (ilFileException $e) {
127 ilUtil::sendInfo($e->getMessage(), true);
128 }
129 }
130
134 function getViewMode()
135 {
137 }
138
143 function addAdditionalSubItemInformation(&$a_item_data)
144 {
145
146 }
147
148}
149
150?>
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
_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 ...