ILIAS  release_7 Revision v7.30-3-g800a261c036
ilExDownloadSubmissionsZipInteraction Class Reference
+ Inheritance diagram for ilExDownloadSubmissionsZipInteraction:
+ Collaboration diagram for ilExDownloadSubmissionsZipInteraction:

Public Member Functions

 __construct ()
 
 getInputTypes ()
 
Returns
Type[] A list of types that are taken as input.
More...
 
 getRemoveOption ()
 @inheritDoc More...
 
 getOutputType ()
 @inheritDoc More...
 
 getOptions (array $input)
 @inheritDoc More...
 
 interaction (array $input, Option $user_selected_option, Bucket $bucket)
 @inheritDoc More...
 
- Public Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractUserInteraction
 getMessage (array $input)
 @inheritDoc More...
 
 canBeSkipped (array $input)
 @inheritDoc More...
 
 getSkippedValue (array $input)
 
 isFinal ()
 
- Public Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
 setInput (array $values)
 
 getOutput ()
 
 getInput ()
 
 getType ()
 
 unfoldTask ()
 Unfold the task. More...
 
 getRemoveOption ()
 
Returns
Option An Option to remove the current task and do some cleanup if possible. This Option is displayed if the Bucket is completed. You do not have to provide an additional Option to remove in your UserInteraction, the remove-Option is added to the list of Options (last position)
See also
self::getAbortOption();
More...
 
 getAbortOption ()
 
Returns
Option In case a Job is failed or did not respond for some time, an Abort-Option is displayed. There is already a Standard-Abort-Option registered, you can override with your own and do some cleanup if possible.
More...
 
 getType ()
 
 getInputTypes ()
 
 getOutputType ()
 
 getOutput ()
 
 setInput (array $values)
 
 getInput ()
 
 unfoldTask ()
 
 getRemoveOption ()
 
 getAbortOption ()
 
 getOptions (array $input)
 
 canBeSkipped (array $input)
 Decide whether the UserInteraction is presented to the user and he has to decide or user UserInteraction is skipped by the TaskManager. More...
 
 getSkippedValue (array $input)
 
 isFinal ()
 
 interaction (array $input, Option $user_selected_option, Bucket $bucket)
 
 getMessage (array $input)
 

Data Fields

const OPTION_DOWNLOAD = 'download'
 
const OPTION_CANCEL = 'cancel'
 
- Data Fields inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
const MAIN_REMOVE = 'bt_main_remove'
 
const MAIN_ABORT = 'bt_main_abort'
 

Private Attributes

 $logger = null
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
 checkTypes ($values)
 
 extractType ($value)
 
- Protected Attributes inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
 $input = []
 
 $output
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilExDownloadSubmissionsZipInteraction::__construct ( )

Definition at line 26 of file class.ilExDownloadSubmissionsZipInteraction.php.

27 {
28 $this->logger = $GLOBALS['DIC']->logger()->exc();
29 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64

References $GLOBALS.

Member Function Documentation

◆ getInputTypes()

ilExDownloadSubmissionsZipInteraction::getInputTypes ( )

Returns
Type[] A list of types that are taken as input.

Implements ILIAS\BackgroundTasks\Task.

Definition at line 35 of file class.ilExDownloadSubmissionsZipInteraction.php.

36 {
37 return [
38 new SingleType(StringValue::class),
39 new SingleType(StringValue::class),
40 ];
41 }

◆ getOptions()

ilExDownloadSubmissionsZipInteraction::getOptions ( array  $input)

◆ getOutputType()

ilExDownloadSubmissionsZipInteraction::getOutputType ( )

@inheritDoc

Implements ILIAS\BackgroundTasks\Task.

Definition at line 56 of file class.ilExDownloadSubmissionsZipInteraction.php.

57 {
58 return new SingleType(StringValue::class);
59 }

◆ getRemoveOption()

ilExDownloadSubmissionsZipInteraction::getRemoveOption ( )

@inheritDoc

Reimplemented from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask.

Definition at line 47 of file class.ilExDownloadSubmissionsZipInteraction.php.

48 {
49 return new UserInteractionOption('remove', self::OPTION_CANCEL);
50 }

◆ interaction()

ilExDownloadSubmissionsZipInteraction::interaction ( array  $input,
Option  $user_selected_option,
Bucket  $bucket 
)

@inheritDoc

Implements ILIAS\BackgroundTasks\Task\UserInteraction.

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

77 {
78 global $DIC;
79 $download_name = $input[0]; //directory name.
80 $zip_name = $input[1]; // zip job
81
82 $this->logger->debug("Interaction -> input[0] download name MUST BE FULL PATH=> " . $download_name->getValue());
83 $this->logger->debug("Interaction -> input[1] zip name MUST BE THE NAME WITHOUT EXTENSION. => " . $zip_name->getValue());
84
85 if ($user_selected_option->getValue() != self::OPTION_DOWNLOAD) {
86 $this->logger->info('Download canceled');
87 // delete zip file
88 $filesystem = $DIC->filesystem()->temp();
89 try {
90 $path = LegacyPathHelper::createRelativePath($download_name->getValue());
91 } catch (InvalidArgumentException $e) {
92 $path = null;
93 }
94 $this->logger->debug("Path: " . $path);
95 if (!is_null($path) && $filesystem->has($path)) {
96 $this->logger->debug("Delete dir: " . dirname($path));
97 $filesystem->deleteDir(dirname($path));
98 }
99
100 return $input;
101 }
102
103 $this->logger->info("Delivering File.");
104
105
106 $zip_name = $zip_name->getValue();
107
108 $ending = substr($zip_name, -4);
109 if ($ending != ".zip") {
110 $zip_name .= ".zip";
111 $this->logger->info("Add .zip extension");
112 }
113
114 //Download_name->getValue should return the complete path to the file
115 //Zip name is just an string
116 $this->logger->debug("Deliver: " . $download_name->getValue());
117 $this->logger->debug("As: " . $zip_name);
118 ilFileDelivery::deliverFileAttached($download_name->getValue(), $zip_name);
119
120 return $input;
121 }
static deliverFileAttached($path_to_file, $download_file_name='', $mime_type='', $delete_file=false)
void
global $DIC
Definition: goto.php:24

References $DIC, Vendor\Package\$e, ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\$input, ilFileDelivery\deliverFileAttached(), and ILIAS\BackgroundTasks\Task\UserInteraction\Option\getValue().

+ Here is the call graph for this function:

Field Documentation

◆ $logger

ilExDownloadSubmissionsZipInteraction::$logger = null
private

◆ OPTION_CANCEL

const ilExDownloadSubmissionsZipInteraction::OPTION_CANCEL = 'cancel'

◆ OPTION_DOWNLOAD

const ilExDownloadSubmissionsZipInteraction::OPTION_DOWNLOAD = 'download'

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