ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilCalendarFileHandler.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
11 {
12 
13 
17  public function __construct()
18  {
19  }
20 
26  public function downloadFilesForEvents($a_events)
27  {
28  include_once("./Services/Calendar/classes/FileHandler/class.ilAppointmentFileHandlerFactory.php");
29  foreach ($a_events as $event) {
30 
31  //WARNING!! TODO: it's taken more events than expected....
32  ilLoggerFactory::getRootLogger()->debug("event tile " . $event['event']->getTitle());
33 
35  foreach ($fh->getFiles() as $file) {
36  // just for demonstration we provide only the last file
37  $last_file = $file;
38 
39  // @todo: collect all files
40  }
41 
42  // @todo: copy zip all files using background
43 
44  /*
45  global $DIC;
46 
47  $factory = $DIC->backgroundTasks()->taskFactory();
48  $taskManager = $DIC->backgroundTasks()->taskManager();
49 
50  // We create a bucket that will be scheduled and set the user that should observe the bucket.
51  $bucket = new BasicBucket();
52  $bucket->setUserId($DIC->user()->getId());
53 
54  // Combine the tasks. This will create a task that looks like this: (1 + 1) + (1 + 2).
55  include_once("./Services/Calendar/FileHandler/classes/class.ilCalFileZipJob.php");
56  $a = $factory->createTask(ilCalFileZipJob::class, [$last_file]);
57  // Note the integer 1 will automatically be wrapped in a IntegerValue class. All scalars can be wrapped automatically.
58  // The above is the same as:
59  // $a = $factory->createTask(PlusJob::class, [new IntegerValue(1), new IntegerValue(1)]);
60  //$b = $factory->createTask(PlusJob::class, [1, 2]);
61  //$c = $factory->createTask(PlusJob::class, [$a, $b]);
62 
63  // The last task is a user interaction that allows the user to download the result calculated above.
64  $userInteraction = $factory->createTask(DownloadInteger::class, [$c]);
65 
66  // We put the combined task into the bucket and add some description
67  $bucket->setTask($userInteraction);
68  $bucket->setTitle("Some calculation.");
69  $bucket->setDescription("We calculate 5!");
70 
71  // We schedule the task.
72  $taskManager->run($bucket);
73 
74  // We redirect somewhere.
75  $this->ctrl->redirect($this, "showContent");
76  */
77 
78 
79 
80 
81  // just for demonstration: send last file
82  if (is_file($last_file)) {
83  require_once('./Services/FileDelivery/classes/class.ilFileDelivery.php');
84  global $DIC;
85  $ilClientIniFile = $DIC['ilClientIniFile'];
86 
87  $ilFileDelivery = new ilFileDelivery($last_file);
88  $ilFileDelivery->setDisposition(ilFileDelivery::DISP_ATTACHMENT);
89  //$ilFileDelivery->setMimeType($this->guessFileType($file));
90  $ilFileDelivery->setConvertFileNameToAsci((bool) !$ilClientIniFile->readVariable('file_access', 'disable_ascii'));
91  //$ilFileDelivery->setDownloadFileName();
92  $ilFileDelivery->deliver();
93  exit;
94  }
95  }
96  }
97 }
global $DIC
Definition: saml.php:7
Class ilFileDelivery.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
downloadFilesForEvents($a_events)
Download files for events.
static getRootLogger()
The unique root logger has a fixed error level.