ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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)
 
- 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)
 
 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 }
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.

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($zip_name->getValue());
91 } catch (InvalidArgumentException $e) {
92 $path = null;
93 }
94 if (!is_null($path) && $filesystem->has($path)) {
95 $filesystem->deleteDir(dirname($path));
96 }
97
98 return $input;
99 }
100
101 $this->logger->info("Delivering File.");
102
103
104 $zip_name = $zip_name->getValue();
105
106 $ending = substr($zip_name, -4);
107 if ($ending != ".zip") {
108 $zip_name .= ".zip";
109 $this->logger->info("Add .zip extension");
110 }
111
112 //Download_name->getValue should return the complete path to the file
113 //Zip name is just an string
114 ilFileDelivery::deliverFileAttached($download_name->getValue(), $zip_name);
115
116 return $input;
117 }
$path
Definition: aliased.php:25
static deliverFileAttached($path_to_file, $download_file_name='', $mime_type='', $delete_file=false)
void
global $DIC
Definition: saml.php:7

References $DIC, ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\$input, $path, 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: