ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilExDownloadSubmissionsZipInteraction Class Reference
+ Inheritance diagram for ilExDownloadSubmissionsZipInteraction:
+ Collaboration diagram for ilExDownloadSubmissionsZipInteraction:

Public Member Functions

 __construct ()
 
 getInputTypes ()
 
 getRemoveOption ()
 
 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)
 
 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'
 

Protected Attributes

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

Additional Inherited Members

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

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilExDownloadSubmissionsZipInteraction::__construct ( )

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

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

40  {
41  $this->logger = $GLOBALS['DIC']->logger()->exc();
42  }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
+ Here is the call graph for this function:

Member Function Documentation

◆ getInputTypes()

ilExDownloadSubmissionsZipInteraction::getInputTypes ( )
Returns
[]

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
[]

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

Implements ILIAS\BackgroundTasks\Task.

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

◆ interaction()

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

Implements ILIAS\BackgroundTasks\Task\UserInteraction.

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

References $DIC, Vendor\Package\$e, $path, ilFileDelivery\deliverFileAttached(), ILIAS\BackgroundTasks\Task\UserInteraction\Option\getValue(), and ILIAS\Repository\logger().

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  }
$path
Definition: ltiservices.php:32
global $DIC
Definition: feed.php:28
static deliverFileAttached(string $path_to_file, ?string $download_file_name=null, ?string $mime_type=null, bool $delete_file=false)
+ 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: