4 include_once
"Services/BackgroundTask/classes/class.ilZipBackgroundTaskHandler.php";
30 parent::__construct();
39 $obj->setTask($a_task);
42 $obj->setRefIds(
$params[
"ref_ids"]);
46 : $tree->getParentId(
$params[
"ref_ids"][0]);
65 return (
bool)
$settings->get(
"bgtask_download",
false);
85 $this->ref_ids = $a_val;
102 self::initObjectListAction();
104 return "il.BgTask.init('" . static::class .
"', " . $a_ref_id .
");";
113 if(!self::$initialized)
117 $url = $ilCtrl->getLinkTargetByClass(
array(
"ilrepositorygui",
"ilobjfoldergui",
"ilbackgroundtaskhub"),
"",
"",
true,
false);
119 $tpl->addJavaScript(
"Services/BackgroundTask/js/BgTask.js");
120 $tpl->addOnLoadCode(
'il.BgTask.setAjax("'.
$url.
'");');
123 include_once
"Services/UIComponent/Modal/classes/class.ilModalGUI.php";
126 self::$initialized =
true;
135 public function init($a_params = null)
141 $this->
setRefIds(explode(
",", $a_params));
144 $file_count = $total_bytes = 0;
147 include_once
"Services/BackgroundTask/classes/class.ilBackgroundTaskJson.php";
158 if($size_limit_mb > 0 && $total_bytes > $size_limit_mb)
165 include_once
"Services/BackgroundTask/classes/class.ilBackgroundTask.php";
167 $task->setHandlerId(get_class($this));
168 $task->setUserId($ilUser->getId());
172 $task->setSteps($file_count+1);
184 if(
sizeof($existing))
192 sprintf($lng->txt(
"bgtask_download_long"), $file_count,
ilUtil::formatSize($total_bytes)),
226 if($this->task->isToBeCancelled())
237 switch($object->getType())
240 $this->
recurseFolder($ref_id, $object->getTitle(), $tmpdir, $current_step);
244 $this->
copyFile($object->getId(), $object->getTitle(), $tmpdir, $current_step);
249 return $current_step;
268 include_once(
"./Modules/File/classes/class.ilObjFileAccess.php");
271 foreach ($a_ref_ids as
$ref_id)
283 $subtree = $tree->getChildsByTypeFilter($ref_id,
array(
"fold",
"file"));
284 if(count($subtree) > 0)
286 $child_ref_ids =
array();
287 foreach($subtree as $child)
289 $child_ref_ids[] = $child[
"ref_id"];
311 protected function recurseFolder($a_ref_id, $a_title, $a_tmpdir, &$a_current_step)
318 $subtree = $tree->getChildsByTypeFilter($a_ref_id,
array(
"fold",
"file"));
319 foreach($subtree as $child)
322 if($this->task->isToBeCancelled())
332 switch($child[
"type"])
335 $this->
recurseFolder($child[
"ref_id"], $child[
"title"], $tmpdir, $a_current_step);
339 $this->
copyFile($child[
"obj_id"], $child[
"title"], $tmpdir, $a_current_step);
353 protected function copyFile($a_obj_id, $a_title, $a_tmpdir, &$a_current_step)
356 $this->task->setCurrentStep(++$a_current_step);
362 include_once
"Modules/File/classes/class.ilObjFile.php";
364 if(!copy($old_filename, $new_filename))
366 throw new ilFileException(
"Could not copy ".$old_filename.
" to ".$new_filename);
369 touch($new_filename, filectime($old_filename));
382 if(!$ilAccess->checkAccess(
"read",
"",
$ref_id))
407 return (
int)$this->
settings->get(
"bgtask_download_limit", 0);
417 return (
int)$this->
settings->get(
"bgtask_download_tcount", 0);
427 return (
int)$this->
settings->get(
"bgtask_download_tsize", 0);
getTotalSizeThreshold()
Get total size threshold.
Background task handler for folder downloads.
static getFinishedJson($a_task_id, $a_cmd, $a_result)
Get json for finished task.
init($a_params=null)
Init background task.
getFileCountThreshold()
Get file count threshold.
getParams()
Gets the params.
static initObjectListAction()
init js for background download
copyFile($a_obj_id, $a_title, $a_tmpdir, &$a_current_step)
Copies a file to the specified temporary directory.
Background task handler for zip creation.
static _isInTrash($a_ref_id)
checks wether object is in trash
static getProcessingJson($a_task_id, $a_message, $a_steps)
Get json for processing task.
static getActiveByUserId($a_user_id)
static _lookupTitle($a_id)
lookup object title
calculateRecursive($a_ref_ids, &$a_file_count, &$a_file_size)
Calculates the number and size of the files being downloaded recursively.
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
static _lookupFileSize($a_id)
Quickly looks up the file size from the database and returns the number of bytes. ...
static initJS()
Init javascript.
static getFailedJson($a_message)
Get json for failed task.
static _lookupObjId($a_id)
getDownloadSizeLimit()
Get overall download size limit.
__construct()
Constructor.
Class to report exception.
static isActive()
Is folder background download active?
process()
Process the task.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
getTempFolderPath()
Gets the temporary folder path to copy the files and folders to.
static getBlockedJson($a_task_id)
Get json for blocked task.
getRefIds()
Gets the involved reference ids.
recurseFolder($a_ref_id, $a_title, $a_tmpdir, &$a_current_step)
Copies a folder and its files to the specified temporary directory.
setTask(ilBackgroundTask $a_task)
Set current task instance.
static _lookupAbsolutePath($obj_id, $a_version=null)
return absolute path for version
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static getInstanceFromTask(ilBackgroundTask $a_task)
Constructor/Factory.
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.
static getObjectListAction($a_ref_id)
Get object list action.
validateAccess($ref_id)
Check file access.
setRefIds($a_val)
Sets the involved reference ids.