ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 72 of file class.ilCalendarRemoteAccessHandler.php.

73 {
74 session_name('ILCALSESSID');
75 $this->initIlias();
76 $logger = $GLOBALS['DIC']->logger()->cal();
77 $this->initTokenHandler();
78
79 if (!$this->initUser()) {
80 $logger->warning('Calendar token is invalid. Authentication failed.');
81 return false;
82 }
83
84 if ($this->getTokenHandler()->getIcal() and !$this->getTokenHandler()->isIcalExpired()) {
85 $GLOBALS['DIC']['ilAuthSession']->logout();
86 ilUtil::deliverData($this->getTokenHandler(), 'calendar.ics', 'text/calendar', 'utf-8');
87 exit;
88 }
89
90 include_once './Services/Calendar/classes/Export/class.ilCalendarExport.php';
91 include_once './Services/Calendar/classes/class.ilCalendarCategories.php';
92 if ($this->getTokenHandler()->getSelectionType() == ilCalendarAuthenticationToken::SELECTION_CALENDAR) {
93 #$export = new ilCalendarExport(array($this->getTokenHandler()->getCalendar()));
95 $cats->initialize(ilCalendarCategories::MODE_REMOTE_SELECTED, $this->getTokenHandler()->getCalendar());
96 $export = new ilCalendarExport($cats->getCategories(true));
97 } else {
100 $export = new ilCalendarExport($cats->getCategories(true));
101 }
102
103 $export->export();
104
105 $this->getTokenHandler()->setIcal($export->getExportString());
106 $this->getTokenHandler()->storeIcal();
107
108 $GLOBALS['DIC']['ilAuthSession']->logout();
109 ilUtil::deliverData($export->getExportString(), 'calendar.ics', 'text/calendar', 'utf-8');
110 exit;
111 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
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.
exit
Definition: login.php:29

References $GLOBALS, ilCalendarCategories\_getInstance(), 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 123 of file class.ilCalendarRemoteAccessHandler.php.

124 {
125 include_once "Services/Context/classes/class.ilContext.php";
127
128 include_once './Services/Authentication/classes/class.ilAuthFactory.php';
130
131 require_once("Services/Init/classes/class.ilInitialisation.php");
133
134 $GLOBALS['DIC']['lng']->loadLanguageModule('dateplaner');
135 }
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 113 of file class.ilCalendarRemoteAccessHandler.php.

114 {
115 $GLOBALS['DIC']->logger()->cal()->info('Authentication token: ' . $_GET['token']);
116 $this->token_handler = new ilCalendarAuthenticationToken(
118 $_GET['token']
119 );
120 return true;
121 }
$_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 141 of file class.ilCalendarRemoteAccessHandler.php.

142 {
143 if (!$this->getTokenHandler() instanceof ilCalendarAuthenticationToken) {
144 $GLOBALS['DIC']->logger()->cal()->info('Initialisation of authentication token failed');
145 return false;
146 }
147 if (!$this->getTokenHandler()->getUserId()) {
148 $GLOBALS['DIC']->logger()->cal()->info('No user id found for calendar synchronisation');
149 return false;
150 }
151 include_once './Services/User/classes/class.ilObjUser.php';
152 if (!ilObjUser::_exists($this->getTokenHandler()->getUserId())) {
153 $GLOBALS['DIC']->logger()->cal()->notice('No valid user id found for calendar synchronisation');
154 return false;
155 }
156
157 include_once './Services/Init/classes/class.ilInitialisation.php';
158 $GLOBALS['DIC']['ilAuthSession']->setAuthenticated(true, $this->getTokenHandler()->getUserId());
160
161 if (!$GLOBALS['DIC']->user() instanceof ilObjUser) {
162 $GLOBALS['DIC']->logger()->cal()->debug('no user object defined');
163 } else {
164 $GLOBALS['DIC']->logger()->cal()->debug('Current user is: ' . $GLOBALS['DIC']->user()->getId());
165 }
166 return true;
167 }
user()
Definition: user.php:4
static initUserAccount()
Init user with current account id.
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(), ilInitialisation\initUserAccount(), 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 $_COOKIE['ilClientId'] = $_GET['client_id'];
62 } else {
63 $path_info_components = explode('/', $_SERVER['PATH_INFO']);
64 $_COOKIE['ilClientId'] = $path_info_components[1];
65 }
66 }
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$path_info_components
Definition: webdav.php:16
$_COOKIE[session_name()]
Definition: xapitoken.php:39

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: