ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilCalendarRemoteAccessHandler Class Reference

@classDescription Handles requests from external calendar applications More...

+ Collaboration diagram for ilCalendarRemoteAccessHandler:

Public Member Functions

 __construct ()
 Constructor. More...
 
 getTokenHandler ()
 
 parseRequest ()
 Fetch client id, the chosen calendar... More...
 
 handleRequest ()
 Handle Request. More...
 

Protected Member Functions

 initTokenHandler ()
 
 initIlias ()
 
 initUser ()
 Init user. More...
 

Private Attributes

 $token_handler = null
 

Detailed Description

@classDescription Handles requests from external calendar applications

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

Definition at line 34 of file class.ilCalendarRemoteAccessHandler.php.

Constructor & Destructor Documentation

◆ __construct()

ilCalendarRemoteAccessHandler::__construct ( )

Constructor.

Returns

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

43 {
44 }

Member Function Documentation

◆ getTokenHandler()

ilCalendarRemoteAccessHandler::getTokenHandler ( )
Returns
ilCalendarAuthenticationHandler

Definition at line 49 of file class.ilCalendarRemoteAccessHandler.php.

References $token_handler.

Referenced by handleRequest(), and initUser().

+ Here is the caller graph for this function:

◆ handleRequest()

ilCalendarRemoteAccessHandler::handleRequest ( )

Handle Request.

Returns

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

77 {
78 session_name('ILCALSESSID');
79 $this->initIlias();
80 $logger = $GLOBALS['DIC']->logger()->cal();
81 $this->initTokenHandler();
82
83 if(!$this->initUser())
84 {
85 $logger->warning('Calendar token is invalid. Authentication failed.');
86 return false;
87 }
88
89 if($this->getTokenHandler()->getIcal() and !$this->getTokenHandler()->isIcalExpired())
90 {
91 $GLOBALS['DIC']['ilAuthSession']->logout();
92 ilUtil::deliverData($this->getTokenHandler(),'calendar.ics','text/calendar','utf-8');
93 exit;
94 }
95
96 include_once './Services/Calendar/classes/Export/class.ilCalendarExport.php';
97 include_once './Services/Calendar/classes/class.ilCalendarCategories.php';
99 {
101 $cats->initialize(ilCalendarCategories::MODE_REMOTE_SELECTED, $this->getTokenHandler()->getCalendar());
102 $logger->dump($cats->getCategories(true), ilLogLevel::DEBUG);
103 $export = new ilCalendarExport($cats->getCategories(true));
104 }
105 else
106 {
109 $logger->dump($cats->getCategories(true), ilLogLevel::DEBUG);
110 $export = new ilCalendarExport($cats->getCategories(true));
111 }
112
113 $export->export();
114
115 $this->getTokenHandler()->setIcal($export->getExportString());
116 $this->getTokenHandler()->storeIcal();
117
118 $GLOBALS['DIC']['ilAuthSession']->logout();
119 ilUtil::deliverData($export->getExportString(),'calendar.ics','text/calendar','utf-8');
120 exit;
121 }
static _getInstance($a_usr_id=0)
get singleton instance
@classDescription Export calendar(s) to ical format
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.

References $GLOBALS, ilCalendarCategories\_getInstance(), ilLogLevel\DEBUG, ilUtil\deliverData(), exit, getTokenHandler(), initIlias(), initTokenHandler(), initUser(), ilCalendarCategories\MODE_REMOTE_ACCESS, ilCalendarCategories\MODE_REMOTE_SELECTED, and ilCalendarAuthenticationToken\SELECTION_CALENDAR.

+ Here is the call graph for this function:

◆ initIlias()

ilCalendarRemoteAccessHandler::initIlias ( )
protected

Definition at line 133 of file class.ilCalendarRemoteAccessHandler.php.

134 {
135 include_once "Services/Context/classes/class.ilContext.php";
137
138 include_once './Services/Authentication/classes/class.ilAuthFactory.php';
140
141 require_once("Services/Init/classes/class.ilInitialisation.php");
143
144 $GLOBALS['lng']->loadLanguageModule('dateplaner');
145 }
static setContext($a_context)
set context
static init($a_type)
Init context by type.
const CONTEXT_ICAL
static initILIAS()
ilias initialisation

References $GLOBALS, ilAuthFactory\CONTEXT_CALENDAR_TOKEN, ilContext\CONTEXT_ICAL, ilContext\init(), ilInitialisation\initILIAS(), and ilAuthFactory\setContext().

Referenced by handleRequest().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initTokenHandler()

ilCalendarRemoteAccessHandler::initTokenHandler ( )
protected

Definition at line 123 of file class.ilCalendarRemoteAccessHandler.php.

124 {
125 $GLOBALS['DIC']->logger()->cal()->info('Authentication token: ' . $_GET['token']);
126 $this->token_handler = new ilCalendarAuthenticationToken(
128 $_GET['token']
129 );
130 return true;
131 }
$_GET["client_id"]
Handles calendar authentication tokens for external calendar subscriptions.
static lookupUser($a_token)
Lookup user by hash.

References $_GET, $GLOBALS, and ilCalendarAuthenticationToken\lookupUser().

Referenced by handleRequest().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initUser()

ilCalendarRemoteAccessHandler::initUser ( )
protected

Init user.

Returns
boolean

Definition at line 151 of file class.ilCalendarRemoteAccessHandler.php.

152 {
153 if(!$this->getTokenHandler() instanceof ilCalendarAuthenticationToken)
154 {
155 $GLOBALS['DIC']->logger()->cal()->info('Initialisation of authentication token failed');
156 return false;
157 }
158 if(!$this->getTokenHandler()->getUserId())
159 {
160 $GLOBALS['DIC']->logger()->cal()->info('No user id found for calendar synchronisation');
161 return false;
162 }
163 include_once './Services/User/classes/class.ilObjUser.php';
164 if(!ilObjUser::_exists($this->getTokenHandler()->getUserId()))
165 {
166 $GLOBALS['DIC']->logger()->cal()->notice('No valid user id found for calendar synchronisation');
167 return false;
168 }
169
170 include_once './Services/Init/classes/class.ilInitialisation.php';
171 $GLOBALS['DIC']['ilAuthSession']->setAuthenticated(true, $this->getTokenHandler()->getUserId());
172 ilInitialisation::initUserAccount();
173
174 if(!$GLOBALS['DIC']->user() instanceof ilObjUser)
175 {
176 $GLOBALS['DIC']->logger()->cal()->debug('no user object defined');
177 }
178 else
179 {
180 $GLOBALS['DIC']->logger()->cal()->debug('Current user is: ' . $GLOBALS['DIC']->user()->getId());
181 }
182 return true;
183 }
user()
Definition: user.php:4
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public

References $GLOBALS, ilObject\_exists(), getTokenHandler(), and user().

Referenced by handleRequest().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseRequest()

ilCalendarRemoteAccessHandler::parseRequest ( )

Fetch client id, the chosen calendar...

Returns

Definition at line 58 of file class.ilCalendarRemoteAccessHandler.php.

59 {
60 if($_GET['client_id'])
61 {
62 $_COOKIE['ilClientId'] = $_GET['client_id'];
63
64 }
65 else
66 {
67 $path_info_components = explode('/',$_SERVER['PATH_INFO']);
68 $_COOKIE['ilClientId'] = $path_info_components[1];
69 }
70 }
$_COOKIE['ilClientId']
Definition: BPMN2Parser.php:15
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
$path_info_components
Definition: webdav.php:20

References $_COOKIE, $_GET, $_SERVER, and $path_info_components.

Field Documentation

◆ $token_handler

ilCalendarRemoteAccessHandler::$token_handler = null
private

Definition at line 36 of file class.ilCalendarRemoteAccessHandler.php.

Referenced by getTokenHandler().


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