ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilCalendarRemoteAccessHandler Class Reference

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

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.

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

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  }
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.
Export calendar(s) to ical format
static _getInstance($a_usr_id=0)
get singleton instance
+ Here is the call graph for this function:

◆ initIlias()

ilCalendarRemoteAccessHandler::initIlias ( )
protected

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

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

Referenced by handleRequest().

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['lng']->loadLanguageModule('dateplaner');
135  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static initILIAS()
ilias initialisation
const CONTEXT_ICAL
static setContext($a_context)
set context
static init($a_type)
Init context by type.
+ 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.

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

Referenced by handleRequest().

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"]
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static lookupUser($a_token)
Lookup user by hash.
Handles calendar authentication tokens for external calendar subscriptions.
+ 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.

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

Referenced by handleRequest().

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());
159  ilInitialisation::initUserAccount();
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  }
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
user()
Definition: user.php:4
Handles calendar authentication tokens for external calendar subscriptions.
+ 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.

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

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  }
$_COOKIE['client_id']
Definition: server.php:9
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
$_GET["client_id"]
$path_info_components
Definition: webdav.php:20

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: