ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCalendarRemoteAccessHandler Class Reference

Handles requests from external calendar applications More...

+ Collaboration diagram for ilCalendarRemoteAccessHandler:

Public Member Functions

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

Protected Member Functions

 initTokenHandler ()
 
 initLimitEnabled ()
 
 initIlias ()
 
 initUser ()
 

Protected Attributes

const LIMITED_QUERY_PARAM = 'limited'
 
Refinery $refinery = null
 
HTTPServices $http = null
 
ilLogger $logger = null
 
ilLanguage $lng = null
 
bool $limit_enabled
 

Private Attributes

ilCalendarAuthenticationToken $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

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

Constructor & Destructor Documentation

◆ __construct()

ilCalendarRemoteAccessHandler::__construct ( )

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

41  {
42  }

Member Function Documentation

◆ getTokenHandler()

ilCalendarRemoteAccessHandler::getTokenHandler ( )

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

References $token_handler.

Referenced by handleRequest(), and initUser().

45  {
46  return $this->token_handler;
47  }
Handles calendar authentication tokens for external calendar subscriptions.
+ Here is the caller graph for this function:

◆ handleRequest()

ilCalendarRemoteAccessHandler::handleRequest ( )

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

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

64  : bool
65  {
66  session_name('ILCALSESSID');
67  $this->initIlias();
68  $logger = $GLOBALS['DIC']->logger()->cal();
69  $this->initTokenHandler();
70  $this->initLimitEnabled();
71 
72  if (!$this->initUser()) {
73  $logger->warning('Calendar token is invalid. Authentication failed.');
74  return false;
75  }
76 
77  if ($this->getTokenHandler()->getIcal() and !$this->getTokenHandler()->isIcalExpired()) {
78  $GLOBALS['DIC']['ilAuthSession']->logout();
79  ilUtil::deliverData($this->getTokenHandler()->getIcal(), 'calendar.ics', 'text/calendar');
80  exit;
81  }
82 
83  if ($this->getTokenHandler()->getSelectionType() == ilCalendarAuthenticationToken::SELECTION_CALENDAR) {
84  #$export = new ilCalendarExport(array($this->getTokenHandler()->getCalendar()));
86  $cats->initialize(ilCalendarCategories::MODE_REMOTE_SELECTED, $this->getTokenHandler()->getCalendar());
87  $export = new ilCalendarExport($cats->getCategories(true), $this->limit_enabled);
88  } else {
91  $export = new ilCalendarExport($cats->getCategories(true), $this->limit_enabled);
92  }
93 
94  $export->export();
95 
96  $this->getTokenHandler()->setIcal($export->getExportString());
97  $this->getTokenHandler()->storeIcal();
98 
99  $GLOBALS['DIC']['ilAuthSession']->logout();
100  ilUtil::deliverData($export->getExportString(), 'calendar.ics', 'text/calendar');
101  exit;
102  }
exit
Definition: login.php:28
warning(string $a_message)
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
Export calendar(s) to ical format
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
static _getInstance($a_usr_id=0)
get singleton instance
+ Here is the call graph for this function:

◆ initIlias()

ilCalendarRemoteAccessHandler::initIlias ( )
protected

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

References $DIC, ilAuthFactory\CONTEXT_CALENDAR_TOKEN, ilContext\CONTEXT_ICAL, ilContext\init(), ilInitialisation\initILIAS(), ILIAS\Repository\lng(), ILIAS\Repository\logger(), and ilAuthFactory\setContext().

Referenced by handleRequest().

130  : void
131  {
132  include_once './Services/Context/classes/class.ilContext.php';
134 
135  include_once './Services/Authentication/classes/class.ilAuthFactory.php';
137 
138  include_once './Services/Init/classes/class.ilInitialisation.php';
140 
141  global $DIC;
142 
143  $this->lng = $DIC->language();
144  $this->lng->loadLanguageModule('dateplaner');
145  $this->logger = $DIC->logger()->cal();
146  }
global $DIC
Definition: feed.php:28
static initILIAS()
ilias initialisation
const CONTEXT_ICAL
static setContext(int $a_context)
set context
static init(string $a_type)
Init context by type.
const CONTEXT_CALENDAR_TOKEN
Calendar authentication with auth token.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initLimitEnabled()

ilCalendarRemoteAccessHandler::initLimitEnabled ( )
protected

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

References $_GET.

Referenced by handleRequest().

125  : void
126  {
127  $this->limit_enabled = (bool) ($_GET[self::LIMITED_QUERY_PARAM] ?? false);
128  }
$_GET['client_id']
Definition: saml1-acs.php:21
+ Here is the caller graph for this function:

◆ initTokenHandler()

ilCalendarRemoteAccessHandler::initTokenHandler ( )
protected

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

References $DIC, $token, ILIAS\FileDelivery\http(), ILIAS\Repository\logger(), ilCalendarAuthenticationToken\lookupUser(), and ILIAS\Repository\refinery().

Referenced by handleRequest().

104  : void
105  {
106  global $DIC;
107 
108  $this->http = $DIC->http();
109  $this->refinery = $DIC->refinery();
110 
111  $token = '';
112  if ($this->http->wrapper()->query()->has('token')) {
113  $token = $this->http->wrapper()->query()->retrieve(
114  'token',
115  $this->refinery->kindlyTo()->string()
116  );
117  }
118  $this->logger->info('Authentication token: ' . $token);
119  $this->token_handler = new ilCalendarAuthenticationToken(
121  $token
122  );
123  }
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.
$token
Definition: xapitoken.php:70
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

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

References $DIC, $GLOBALS, ilObject\_exists(), getTokenHandler(), ilInitialisation\initUserAccount(), and ILIAS\Repository\logger().

Referenced by handleRequest().

148  : bool
149  {
150  global $DIC;
151 
152  if (!$this->getTokenHandler() instanceof ilCalendarAuthenticationToken) {
153  $this->logger->info('Initialisation of authentication token failed');
154  return false;
155  }
156  if (!$this->getTokenHandler()->getUserId()) {
157  $this->logger->info('No user id found for calendar synchronisation');
158  return false;
159  }
160  if (!ilObjUser::_exists($this->getTokenHandler()->getUserId())) {
161  $this->logger->notice('No valid user id found for calendar synchronisation');
162  return false;
163  }
164 
165  $GLOBALS['DIC']['ilAuthSession']->setAuthenticated(true, $this->getTokenHandler()->getUserId());
167 
168  if (!$DIC->user() instanceof ilObjUser) {
169  $this->logger->debug('No user object defined');
170  } else {
171  $this->logger->debug('Current user is: ' . $DIC->user()->getId());
172  }
173  return true;
174  }
global $DIC
Definition: feed.php:28
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Handles calendar authentication tokens for external calendar subscriptions.
static initUserAccount()
Init user with current account id.
+ 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...

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

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

52  : void
53  {
54  // before initialization: $_GET and $_COOKIE is required is unavoidable
55  // in the moment.
56  if ($_GET['client_id']) {
57  $_COOKIE['ilClientId'] = $_GET['client_id'];
58  } else {
59  $path_info_components = explode('/', $_SERVER['PATH_INFO']);
60  $_COOKIE['ilClientId'] = $path_info_components[1];
61  }
62  }
$path_info_components
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: webdav.php:21
$_GET['client_id']
Definition: saml1-acs.php:21
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$_COOKIE[session_name()]
Definition: xapitoken.php:54

Field Documentation

◆ $http

HTTPServices ilCalendarRemoteAccessHandler::$http = null
protected

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

◆ $limit_enabled

bool ilCalendarRemoteAccessHandler::$limit_enabled
protected

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

Referenced by handleRequest().

◆ $lng

ilLanguage ilCalendarRemoteAccessHandler::$lng = null
protected

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

◆ $logger

ilLogger ilCalendarRemoteAccessHandler::$logger = null
protected

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

◆ $refinery

Refinery ilCalendarRemoteAccessHandler::$refinery = null
protected

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

◆ $token_handler

ilCalendarAuthenticationToken ilCalendarRemoteAccessHandler::$token_handler = null
private

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

Referenced by getTokenHandler().

◆ LIMITED_QUERY_PARAM

const ilCalendarRemoteAccessHandler::LIMITED_QUERY_PARAM = 'limited'
protected

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


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