ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
5 require_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 ?>