ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilDownloadWorkspaceFolderBackgroundTask Class Reference

Background task for downloads. More...

+ Collaboration diagram for ilDownloadWorkspaceFolderBackgroundTask:

Public Member Functions

 __construct (int $a_usr_id, array $a_object_wsp_ids, bool $a_initiated_by_folder_action=false)
 Constructor. More...
 
 setBucketTitle ($a_title)
 set bucket title. More...
 
 getBucketTitle ()
 return bucket title. More...
 
 run ()
 Run task. More...
 

Protected Attributes

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

Private Attributes

 $logger = null
 

Detailed Description

Background task for downloads.

Author
killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 13 of file class.ilDownloadWorkspaceFolderBackgroundTask.php.

Constructor & Destructor Documentation

◆ __construct()

ilDownloadWorkspaceFolderBackgroundTask::__construct ( int  $a_usr_id,
array  $a_object_wsp_ids,
bool  $a_initiated_by_folder_action = false 
)

Constructor.

Parameters
int$a_usr_id
int[]$a_object_wsp_ids
bool$a_initiated_by_folder_action

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

References $DIC, and ilLoggerFactory\getLogger().

60  {
61  global $DIC;
62  $this->logger = ilLoggerFactory::getLogger("pwsp");
63  $this->user_id = $a_usr_id;
64  $this->object_wsp_ids = $a_object_wsp_ids;
65  $this->initiated_by_folder_action = $a_initiated_by_folder_action;
66  $this->task_factory = $DIC->backgroundTasks()->taskFactory();
67  $this->lng = $DIC->language();
68  }
$DIC
Definition: xapitoken.php:46
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

Member Function Documentation

◆ getBucketTitle()

ilDownloadWorkspaceFolderBackgroundTask::getBucketTitle ( )

return bucket title.

Returns
string

Definition at line 87 of file class.ilDownloadWorkspaceFolderBackgroundTask.php.

References $bucket_title.

Referenced by run().

88  {
89  //TODO: fix ilUtil zip stuff
90  // Error If name starts "-"
91  // error massage from ilUtil->execQuoted = ["","zip error: Invalid command arguments (short option 'a' not supported)"]
92  if (substr($this->bucket_title, 0, 1) === "-") {
93  $this->bucket_title = ltrim($this->bucket_title, "-");
94  }
95 
96  return $this->bucket_title;
97  }
+ Here is the caller graph for this function:

◆ run()

ilDownloadWorkspaceFolderBackgroundTask::run ( )

Run task.

Returns
bool

Definition at line 105 of file class.ilDownloadWorkspaceFolderBackgroundTask.php.

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

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

◆ setBucketTitle()

ilDownloadWorkspaceFolderBackgroundTask::setBucketTitle (   $a_title)

set bucket title.

Parameters
$a_title

Definition at line 76 of file class.ilDownloadWorkspaceFolderBackgroundTask.php.

77  {
78  $this->bucket_title = $a_title;
79  }

Field Documentation

◆ $bucket_title

ilDownloadWorkspaceFolderBackgroundTask::$bucket_title
protected

Definition at line 43 of file class.ilDownloadWorkspaceFolderBackgroundTask.php.

Referenced by getBucketTitle().

◆ $has_files

ilDownloadWorkspaceFolderBackgroundTask::$has_files = false
protected

◆ $initiated_by_folder_action

ilDownloadWorkspaceFolderBackgroundTask::$initiated_by_folder_action = false
protected

◆ $logger

ilDownloadWorkspaceFolderBackgroundTask::$logger = null
private

◆ $object_wsp_ids

ilDownloadWorkspaceFolderBackgroundTask::$object_wsp_ids
protected

◆ $task_factory

ilDownloadWorkspaceFolderBackgroundTask::$task_factory = null
protected

◆ $user_id

ilDownloadWorkspaceFolderBackgroundTask::$user_id
protected

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