ILIAS  release_7 Revision v7.30-3-g800a261c036
ilDownloadContainerFilesBackgroundTask Class Reference

Class ilDownloadContainerFilesBackgroundTask. More...

+ Collaboration diagram for ilDownloadContainerFilesBackgroundTask:

Public Member Functions

 __construct ($a_usr_id, $a_object_ref_ids, $a_initiated_by_folder_action)
 Constructor. More...
 
 setBucketTitle ($a_title)
 set bucket title. More...
 
 getBucketTitle ()
 return bucket title. More...
 
 run ()
 Run task. More...
 

Protected Attributes

 $user_id
 
 $object_ref_ids
 
 $initiated_by_folder_action = false
 
 $task_factory = null
 
 $bucket_title
 
 $has_files = false
 

Private Attributes

 $logger = null
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilDownloadContainerFilesBackgroundTask::__construct (   $a_usr_id,
  $a_object_ref_ids,
  $a_initiated_by_folder_action 
)

Constructor.

Parameters
type$a_usr_id
int[]$a_object_ref_ids

Definition at line 67 of file class.ilDownloadContainerFilesBackgroundTask.php.

68 {
69 global $DIC;
70 $this->logger = $DIC->logger()->cal();
71 $this->user_id = $a_usr_id;
72 $this->object_ref_ids = $a_object_ref_ids;
73 $this->initiated_by_folder_action = $a_initiated_by_folder_action;
74 $this->task_factory = $DIC->backgroundTasks()->taskFactory();
75 $this->lng = $DIC->language();
76 }
global $DIC
Definition: goto.php:24

References $DIC.

Member Function Documentation

◆ getBucketTitle()

ilDownloadContainerFilesBackgroundTask::getBucketTitle ( )

return bucket title.

Returns
string

Definition at line 95 of file class.ilDownloadContainerFilesBackgroundTask.php.

96 {
97 //TODO: fix ilUtil zip stuff
98 // Error If name starts "-"
99 // error massage from ilUtil->execQuoted = ["","zip error: Invalid command arguments (short option 'a' not supported)"]
100 if (substr($this->bucket_title, 0, 1) === "-") {
101 $this->bucket_title = ltrim($this->bucket_title, "-");
102 }
103
104 return $this->bucket_title;
105 }

References $bucket_title.

Referenced by run().

+ Here is the caller graph for this function:

◆ run()

ilDownloadContainerFilesBackgroundTask::run ( )

Run task.

Returns
bool

Definition at line 113 of file class.ilDownloadContainerFilesBackgroundTask.php.

114 {
115 // This is our Bucket
116 $this->logger->info('Started download container files background task');
117 $bucket = new BasicBucket();
118 $bucket->setUserId($this->user_id);
119 $this->logger->debug('Created bucket and set the following user id: ' . $this->user_id);
120
121 // Copy Definition
122 $definition = new ilCopyDefinition();
123 $normalized_name = ilUtil::getASCIIFilename($this->getBucketTitle());
124 $definition->setTempDir($normalized_name);
125 $definition->setObjectRefIds($this->object_ref_ids);
126 $this->logger->debug('Created copy definition and added the following tempdir: ' . $normalized_name);
127
128 // Collect all files and folders by the definition and prevent duplicates
129 $collect_job = $this->task_factory->createTask(ilCollectFilesJob::class, [$definition, $this->initiated_by_folder_action]);
130 $this->logger->debug('Collected files based on the following object ids: ');
131 $this->logger->dump($this->object_ref_ids);
132
133 // Check the FileSize
134 $file_size_job = $this->task_factory->createTask(ilCheckSumOfFileSizesJob::class, [$collect_job]);
135
136 // Show problems with file-limit
137 $file_size_interaction = $this->task_factory->createTask(ilSumOfFileSizesTooLargeInteraction::class, [$file_size_job]);
138 $this->logger->debug('Determined the sum of all file sizes');
139
140 // move files from source dir to target directory
141 $copy_job = $this->task_factory->createTask(ilCopyFilesToTempDirectoryJob::class, [$file_size_interaction]);
142
143 // Zip it
144 $zip_job = $this->task_factory->createTask(ilZipJob::class, [$copy_job]);
145 $this->logger->debug('Moved files from source- to target-directory');
146
147 // Download
148 $download_name = new StringValue();
149 $download_name->setValue($normalized_name . '.zip');
150 $download_interaction = $this->task_factory->createTask(ilDownloadZipInteraction::class, [$zip_job, $download_name]);
151 $this->logger->debug('Created a download interaction with the following download name: ' . $download_name->getValue());
152
153 // last task to bucket
154 $bucket->setTask($download_interaction);
155 $bucket->setTitle($this->getBucketTitle());
156 $this->logger->debug('Added last task to bucket and set the following title: ' . $this->getBucketTitle());
157
158 $task_manager = $GLOBALS['DIC']->backgroundTasks()->taskManager();
159 $task_manager->run($bucket);
160 $this->logger->debug('Ran bucket in task manager');
161
162 return true;
163 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Description of class class.
static getASCIIFilename($a_filename)
convert utf8 to ascii filename

References $GLOBALS, ilUtil\getASCIIFilename(), and getBucketTitle().

+ Here is the call graph for this function:

◆ setBucketTitle()

ilDownloadContainerFilesBackgroundTask::setBucketTitle (   $a_title)

set bucket title.

Parameters
$a_title

Definition at line 84 of file class.ilDownloadContainerFilesBackgroundTask.php.

85 {
86 $this->bucket_title = $a_title;
87 }

Field Documentation

◆ $bucket_title

ilDownloadContainerFilesBackgroundTask::$bucket_title
protected

Definition at line 52 of file class.ilDownloadContainerFilesBackgroundTask.php.

Referenced by getBucketTitle().

◆ $has_files

ilDownloadContainerFilesBackgroundTask::$has_files = false
protected

◆ $initiated_by_folder_action

ilDownloadContainerFilesBackgroundTask::$initiated_by_folder_action = false
protected

◆ $logger

ilDownloadContainerFilesBackgroundTask::$logger = null
private

◆ $object_ref_ids

ilDownloadContainerFilesBackgroundTask::$object_ref_ids
protected

◆ $task_factory

ilDownloadContainerFilesBackgroundTask::$task_factory = null
protected

◆ $user_id

ilDownloadContainerFilesBackgroundTask::$user_id
protected

The documentation for this class was generated from the following file: