ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilExDownloadSubmissionsZipInteraction Class Reference
+ Inheritance diagram for ilExDownloadSubmissionsZipInteraction:
+ Collaboration diagram for ilExDownloadSubmissionsZipInteraction:

Public Member Functions

 __construct ()
 
 getInputTypes ()
 
 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...
 
 getOutputType ()
 
 getOptions (array $input)
 
 interaction (array $input, Option $user_selected_option, Bucket $bucket)
 
- 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'
 

Protected Attributes

ilLogger $logger
 
- Protected Attributes inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
array $input = []
 
Value $output
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
 checkTypes (array $values)
 
 extractType ($value)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilExDownloadSubmissionsZipInteraction::__construct ( )

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

40 {
41 $this->logger = $GLOBALS['DIC']->logger()->exc();
42 }
$GLOBALS["DIC"]
Definition: wac.php:54

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

+ Here is the call graph for this function:

Member Function Documentation

◆ getInputTypes()

ilExDownloadSubmissionsZipInteraction::getInputTypes ( )
Returns
\ILIAS\BackgroundTasks\Types\SingleType[]

Implements ILIAS\BackgroundTasks\Task.

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

48 : array
49 {
50 return [
51 new SingleType(StringValue::class),
52 new SingleType(StringValue::class),
53 ];
54 }

◆ getOptions()

ilExDownloadSubmissionsZipInteraction::getOptions ( array  $input)
Returns
\ILIAS\BackgroundTasks\Implementation\Tasks\UserInteraction\UserInteractionOption[]

Implements ILIAS\BackgroundTasks\Task\UserInteraction.

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

69 : array
70 {
71 return [
72 new UserInteractionOption('download', self::OPTION_DOWNLOAD),
73 ];
74 }

◆ getOutputType()

ilExDownloadSubmissionsZipInteraction::getOutputType ( )

Implements ILIAS\BackgroundTasks\Task.

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

61 : Type
62 {
63 return new SingleType(StringValue::class);
64 }

◆ getRemoveOption()

ilExDownloadSubmissionsZipInteraction::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();

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

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

56 : Option
57 {
58 return new UserInteractionOption('remove', self::OPTION_CANCEL);
59 }

◆ interaction()

ilExDownloadSubmissionsZipInteraction::interaction ( array  $input,
Option  $user_selected_option,
Bucket  $bucket 
)
Parameters
Value[]$inputThe input value of this task.
Option$user_selected_optionThe Option the user chose.
Bucket$bucketNotify the bucket about your progress!

Implements ILIAS\BackgroundTasks\Task\UserInteraction.

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

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

References $DIC, Vendor\Package\$e, $path, and ILIAS\Repository\logger().

+ Here is the call graph for this function:

Field Documentation

◆ $logger

ilLogger ilExDownloadSubmissionsZipInteraction::$logger
protected

◆ 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: