ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilDownloadContainerFilesBackgroundTask Class Reference

Class ilDownloadContainerFilesBackgroundTask. More...

+ Collaboration diagram for ilDownloadContainerFilesBackgroundTask:

Public Member Functions

 __construct (int $a_usr_id, array $a_object_ref_ids, bool $a_initiated_by_folder_action)
 
 setBucketTitle (string $a_title)
 
 getBucketTitle ()
 
 run ()
 

Protected Attributes

ilLanguage $lng
 
int $user_id
 
array $object_ref_ids
 
bool $initiated_by_folder_action = false
 
TaskFactory $task_factory = null
 
string $bucket_title
 
bool $has_files = false
 

Private Attributes

ilLogger $logger
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilDownloadContainerFilesBackgroundTask::__construct ( int  $a_usr_id,
array  $a_object_ref_ids,
bool  $a_initiated_by_folder_action 
)

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

49 {
50 global $DIC;
51 $this->logger = $DIC->logger()->cal();
52 $this->user_id = $a_usr_id;
53 $this->object_ref_ids = $a_object_ref_ids;
54 $this->initiated_by_folder_action = $a_initiated_by_folder_action;
55 $this->task_factory = $DIC->backgroundTasks()->taskFactory();
56 $this->lng = $DIC->language();
57 }
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\lng(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

Member Function Documentation

◆ getBucketTitle()

ilDownloadContainerFilesBackgroundTask::getBucketTitle ( )

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

64 : string
65 {
66 //TODO: fix ilUtil zip stuff
67 // Error If name starts "-"
68 // error massage from ilUtil->execQuoted = ["","zip error: Invalid command arguments (short option 'a' not supported)"]
69 if ($this->bucket_title[0] === "-") {
70 $this->bucket_title = ltrim($this->bucket_title, "-");
71 }
72
74 }

References $bucket_title.

Referenced by run().

+ Here is the caller graph for this function:

◆ run()

ilDownloadContainerFilesBackgroundTask::run ( )

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

77 : bool
78 {
79 // This is our Bucket
80 $this->logger->info('Started download container files background task');
81 $bucket = new BasicBucket();
82 $bucket->setUserId($this->user_id);
83 $this->logger->debug('Created bucket and set the following user id: ' . $this->user_id);
84
85 // Copy Definition
86 $definition = new ilCopyDefinition();
87 $normalized_name = ilFileUtils::getASCIIFilename($this->getBucketTitle());
88 $definition->setTempDir($normalized_name);
89 $definition->setObjectRefIds($this->object_ref_ids);
90 $this->logger->debug('Created copy definition and added the following tempdir: ' . $normalized_name);
91
92 // Collect all files by the definition and prevent duplicates
93 $collect_job = $this->task_factory->createTask(ilCollectFilesJob::class, [$definition, $this->initiated_by_folder_action]);
94 $this->logger->debug('Collected files based on the following object ids: ');
95 $this->logger->dump($this->object_ref_ids);
96
97 // Check the FileSize
98 $file_size_job = $this->task_factory->createTask(ilCheckSumOfFileSizesJob::class, [$collect_job]);
99
100 // Show problems with file-limit
101 $file_size_interaction = $this->task_factory->createTask(ilSumOfFileSizesTooLargeInteraction::class, [$file_size_job]);
102 $this->logger->debug('Determined the sum of all file sizes');
103
104 // move files from source dir to target directory
105 $copy_job = $this->task_factory->createTask(ilCopyFilesToTempDirectoryJob::class, [$file_size_interaction]);
106
107 // Zip it
108 $zip_job = $this->task_factory->createTask(ilZipJob::class, [$copy_job]);
109 $this->logger->debug('Moved files from source- to target-directory');
110
111 // Download
112 $download_name = new StringValue();
113 $download_name->setValue($normalized_name . '.zip');
114 $download_interaction = $this->task_factory->createTask(ilDownloadZipInteraction::class, [$zip_job, $download_name]);
115 $this->logger->debug('Created a download interaction with the following download name: ' . $download_name->getValue());
116
117 // last task to bucket
118 $bucket->setTask($download_interaction);
119 $bucket->setTitle($this->getBucketTitle());
120 $this->logger->debug('Added last task to bucket and set the following title: ' . $this->getBucketTitle());
121
122 $task_manager = $GLOBALS['DIC']->backgroundTasks()->taskManager();
123 $task_manager->run($bucket);
124 $this->logger->debug('Ran bucket in task manager');
125
126 return true;
127 }
Description of class class.
static getASCIIFilename(string $a_filename)
$GLOBALS["DIC"]
Definition: wac.php:54

References $GLOBALS, ilFileUtils\getASCIIFilename(), getBucketTitle(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ setBucketTitle()

ilDownloadContainerFilesBackgroundTask::setBucketTitle ( string  $a_title)

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

59 : void
60 {
61 $this->bucket_title = $a_title;
62 }

Field Documentation

◆ $bucket_title

string ilDownloadContainerFilesBackgroundTask::$bucket_title
protected

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

Referenced by getBucketTitle().

◆ $has_files

bool ilDownloadContainerFilesBackgroundTask::$has_files = false
protected

◆ $initiated_by_folder_action

bool ilDownloadContainerFilesBackgroundTask::$initiated_by_folder_action = false
protected

◆ $lng

ilLanguage ilDownloadContainerFilesBackgroundTask::$lng
protected

◆ $logger

ilLogger ilDownloadContainerFilesBackgroundTask::$logger
private

◆ $object_ref_ids

array ilDownloadContainerFilesBackgroundTask::$object_ref_ids
protected

◆ $task_factory

TaskFactory ilDownloadContainerFilesBackgroundTask::$task_factory = null
protected

◆ $user_id

int ilDownloadContainerFilesBackgroundTask::$user_id
protected

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