ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilDownloadZipInteraction Class Reference

Description of class class. More...

+ Inheritance diagram for ilDownloadZipInteraction:
+ Collaboration diagram for ilDownloadZipInteraction:

Public Member Functions

 __construct ()
 
 getInputTypes ()
 
Returns
Type[] A list of types that are taken as input.
More...
 
 getRemoveOption ()
 
 getOutputType ()
 
 getOptions (array $input)
 
 interaction (array $input, Option $user_selected_option, Bucket $bucket)
 
 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...
 
- Public Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractUserInteraction
 getMessage (array $input)
 
 canBeSkipped (array $input)
 
 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...
 

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

ilLogger $logger
 

Additional Inherited Members

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

Detailed Description

Description of class class.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

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

Constructor & Destructor Documentation

◆ __construct()

ilDownloadZipInteraction::__construct ( )

Definition at line 42 of file class.ilDownloadZipInteraction.php.

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

43  {
44  global $DIC;
45  $this->logger = $DIC->logger()->cal();
46  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ canBeSkipped()

ilDownloadZipInteraction::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.

You must return a valid Value then,

Parameters
Value[]$input The input value of this task.
See also
getSkippedValue.

Implements ILIAS\BackgroundTasks\Task\UserInteraction.

Definition at line 128 of file class.ilDownloadZipInteraction.php.

128  : bool
129  {
130  return false;
131  }

◆ getInputTypes()

ilDownloadZipInteraction::getInputTypes ( )

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

Implements ILIAS\BackgroundTasks\Task.

Definition at line 52 of file class.ilDownloadZipInteraction.php.

52  : array
53  {
54  return [
55  new SingleType(StringValue::class),
56  new SingleType(StringValue::class),
57  ];
58  }

◆ getOptions()

ilDownloadZipInteraction::getOptions ( array  $input)

Implements ILIAS\BackgroundTasks\Task\UserInteraction.

Definition at line 83 of file class.ilDownloadZipInteraction.php.

83  : array
84  {
85  return [
86  new UserInteractionOption('download', self::OPTION_DOWNLOAD),
87  ];
88  }

◆ getOutputType()

ilDownloadZipInteraction::getOutputType ( )

Implements ILIAS\BackgroundTasks\Task.

Definition at line 74 of file class.ilDownloadZipInteraction.php.

74  : Type
75  {
76  return new SingleType(StringValue::class);
77  }

◆ getRemoveOption()

ilDownloadZipInteraction::getRemoveOption ( )

◆ interaction()

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

Implements ILIAS\BackgroundTasks\Task\UserInteraction.

Definition at line 94 of file class.ilDownloadZipInteraction.php.

References $DIC, $path, ilFileDelivery\deliverFileAttached(), ILIAS\BackgroundTasks\Task\UserInteraction\Option\getValue(), ILIAS\UI\Implementation\Component\Input\getValue(), ILIAS\Repository\logger(), and null.

94  : Value
95  {
96  global $DIC;
97  $zip_name = $input[1];
98  $download_name = $input[0];
99 
100  $this->logger->debug('User interaction download zip ' . $input[0]->getValue() . ' as '
101  . $input[1]->getValue());
102 
103  if ($user_selected_option->getValue() !== self::OPTION_DOWNLOAD) {
104  $this->logger->info('Download canceled');
105  // delete zip file
106  $filesystem = $DIC->filesystem()->temp();
107 
108  try {
109  $path = LegacyPathHelper::createRelativePath($zip_name->getValue());
110  } catch (InvalidArgumentException) {
111  $path = null;
112  }
113  if (!is_null($path) && $filesystem->has($path)) {
114  $filesystem->deleteDir(dirname($path));
115  }
116 
117  return new ThunkValue();
118  }
119 
120  $this->logger->info("Delivering File.");
121 
122  ilFileDelivery::deliverFileAttached($download_name->getValue(), $zip_name->getValue());
123 
124  return new ThunkValue();
125  }
getValue()
Get the value that is displayed in the input client side.
Definition: Group.php:49
$path
Definition: ltiservices.php:29
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static deliverFileAttached(string $path_to_file, ?string $download_file_name=null, ?string $mime_type=null, bool $delete_file=false)
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Field Documentation

◆ $logger

ilLogger ilDownloadZipInteraction::$logger
private

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

◆ OPTION_CANCEL

const ilDownloadZipInteraction::OPTION_CANCEL = 'cancel'

Definition at line 38 of file class.ilDownloadZipInteraction.php.

◆ OPTION_DOWNLOAD

const ilDownloadZipInteraction::OPTION_DOWNLOAD = 'download'

Definition at line 37 of file class.ilDownloadZipInteraction.php.


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