44 new SingleType(ilWorkspaceCopyDefinition::class),
54 return new SingleType(ilWorkspaceCopyDefinition::class);
71 $this->logger->debug(
'Start collecting files!');
72 $this->logger->dump($input);
73 $definition = $input[0];
74 $initiated_by_folder_action = $input[1]->getValue();
75 $object_wps_ids = $definition->getObjectWspIds();
78 foreach ($object_wps_ids as $object_wps_id) {
79 $obj_id = $this->tree->lookupObjectId($object_wps_id);
82 $object_temp_dir =
"";
84 if ($object_type ==
"wfld") {
86 $files_from_folder = $this->
recurseFolder($object_wps_id, $object_name, $object_temp_dir, $num_recursions, $initiated_by_folder_action);
87 $files = array_merge($files, $files_from_folder);
88 } elseif (($object_type ==
"file") and ($this->
getFileDirs($object_wps_id, $object_name, $object_temp_dir) !=
false)) {
89 $files[] = $this->
getFileDirs($object_wps_id, $object_name, $object_temp_dir);
92 $this->logger->debug(
'Collected files:');
93 $this->logger->dump($files);
96 foreach ($files as $file) {
97 $definition->addCopyDefinition($file[
'source_dir'], $file[
'target_dir']);
98 $this->logger->debug(
'Added new copy definition: ' . $file[
'source_dir'] .
' -> ' . $file[
'target_dir']);
101 $is_empty_folder = preg_match_all(
"/\/$/", $file[
'target_dir']);
102 if (!$is_empty_folder) {
106 $definition->setObjectWspIds($object_wps_ids);
107 $definition->setNumFiles($num_files);
112 private function getFileDirs($a_wsp_id, $a_file_name, $a_temp_dir)
116 $user = $DIC->user();
118 if ($ilAccess->checkAccessOfUser($this->tree, $user->getId(),
"read",
"", $a_wsp_id)) {
119 $file =
new ilObjFile($this->tree->lookupObjectId($a_wsp_id),
false);
120 $source_dir = $file->getFile($file->getVersion());
121 if (@!is_file($source_dir)) {
122 $source_dir = $file->
getFile();
126 return $file_dirs = [
127 "source_dir" => $source_dir,
128 "target_dir" => $target_dir
142 private function recurseFolder($a_wsp_id, $a_folder_name, $a_temp_dir, $a_num_recursions, $a_initiated_by_folder_action)
144 $num_recursions = $a_num_recursions + 1;
151 if (($num_recursions <= 1) and ($a_initiated_by_folder_action)) {
152 $temp_dir = $a_temp_dir;
158 $subtree =
$tree->getChildsByTypeFilter($a_wsp_id, array(
"wfld",
"file"));
160 foreach ($subtree as $child) {
161 if (!$ilAccess->checkAccess(
"read",
"", $child[
"child"])) {
164 if ($child[
"type"] ==
"wfld") {
165 $files_from_folder = $this->
recurseFolder($child[
"child"], $child[
'title'], $temp_dir, $num_recursions, $a_initiated_by_folder_action);
166 $files = array_merge($files, $files_from_folder);
167 } elseif (($child[
"type"] ==
"file") and ($this->
getFileDirs($child[
"child"], $child[
'title'], $temp_dir) !=
false)) {
168 $files[] = $this->
getFileDirs($child[
"ref_id"], $child[
'title'], $temp_dir);
172 if (empty($subtree)) {
175 "target_dir" => $temp_dir .
'/'
getFileDirs($a_wsp_id, $a_file_name, $a_temp_dir)
Class ChatMainBarProvider .
getFile($a_hist_entry_id=null)
Access handler for personal workspace.
static _lookupTitle($a_id)
lookup object title
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
Tree handler for personal workspace.
recurseFolder($a_wsp_id, $a_folder_name, $a_temp_dir, $a_num_recursions, $a_initiated_by_folder_action)
Description of class class.
static _lookupType($a_id, $a_reference=false)
lookup object type
getExpectedTimeOfTaskInSeconds()
int the amount of seconds this task usually taskes. If your task-duration scales with the the amount ...
static getLogger($a_component_id)
Get component logger.
run(array $input, \ILIAS\BackgroundTasks\Observer $observer)