ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilCalendarRemoteAccessHandler.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24include_once './Services/Calendar/classes/class.ilCalendarAuthenticationToken.php';
25
35{
36 private $token_handler = null;
37
42 public function __construct()
43 {
44 }
45
46 public function getTokenHandler()
47 {
49 }
50
55 public function parseRequest()
56 {
57 if($_GET['client_id'])
58 {
59 $_COOKIE['ilClientId'] = $_GET['client_id'];
60
61 }
62 else
63 {
64 $path_info_components = explode('/',$_SERVER['PATH_INFO']);
65 $_COOKIE['ilClientId'] = $path_info_components[1];
66 }
67 }
68
73 public function handleRequest()
74 {
75 $this->initIlias();
76 $this->initTokenHandler();
77
78 if($this->getTokenHandler()->getIcal() and !$this->getTokenHandler()->isIcalExpired())
79 {
80 ilUtil::deliverData($this->getTokenHandler(),'calendar.ics','text/calendar','utf-8');
81 }
82
83 include_once './Services/Calendar/classes/Export/class.ilCalendarExport.php';
84 include_once './Services/Calendar/classes/class.ilCalendarCategories.php';
86 {
87 #$export = new ilCalendarExport(array($this->getTokenHandler()->getCalendar()));
89 $cats->initialize(ilCalendarCategories::MODE_REMOTE_SELECTED, $this->getTokenHandler()->getCalendar());
90 $export = new ilCalendarExport($cats->getCategories(true));
91 }
92 else
93 {
96 $export = new ilCalendarExport($cats->getCategories(true));
97 }
98
99 $export->export();
100
101 $this->getTokenHandler()->setIcal($export->getExportString());
102 $this->getTokenHandler()->storeIcal();
103
104 $GLOBALS['ilAuth']->logout();
105 ilUtil::deliverData($export->getExportString(),'calendar.ics','text/calendar','utf-8');
106 #echo $export->getExportString();
107 #echo nl2br($export->getExportString());
108
109 #$fp = fopen('ilias.ics', 'w');
110 #fwrite($fp,$export->getExportString());
111 exit;
112 }
113
114 protected function initTokenHandler()
115 {
116 $this->token_handler = new ilCalendarAuthenticationToken(
118 $_GET['token']
119 );
120 return true;
121 }
122
123 protected function initIlias()
124 {
125 include_once "Services/Context/classes/class.ilContext.php";
127
128 include_once './Services/Authentication/classes/class.ilAuthFactory.php';
130
131 $_POST['username'] = 'cal_auth_token';
132 $_POST['password'] = 'cal_auth_token';
133
134 require_once("Services/Init/classes/class.ilInitialisation.php");
136
137 $GLOBALS['lng']->loadLanguageModule('dateplaner');
138 }
139}
140?>
$_GET["client_id"]
static setContext($a_context)
set context
Handles calendar authentication tokens for external calendar subscriptions.
static lookupUser($a_token)
Lookup user by hash.
static _getInstance($a_usr_id=0)
get singleton instance
@classDescription Export calendar(s) to ical format
@classDescription Handles requests from external calendar applications
parseRequest()
Fetch client id, the chosen calendar...
static init($a_type)
Init context by type.
const CONTEXT_ICAL
static initILIAS()
ilias initialisation
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
$_POST['username']
Definition: cron.php:12
$_COOKIE["ilClientId"]
Definition: cron.php:11
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
exit
Definition: login.php:54
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
$path_info_components
Definition: webdav.php:20