ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilCalendarRemoteAccessHandler Class Reference

@classDescription 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

@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

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.

45 {
47 }
Handles calendar authentication tokens for external calendar subscriptions.

References $token_handler.

Referenced by handleRequest(), and initUser().

+ Here is the caller graph for this function:

◆ handleRequest()

ilCalendarRemoteAccessHandler::handleRequest ( )

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

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 }
static _getInstance($a_usr_id=0)
get singleton instance
@classDescription Export calendar(s) to ical format
warning(string $message, array $context=[])
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
exit
$GLOBALS["DIC"]
Definition: wac.php:54

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

+ Here is the call graph for this function:

◆ initIlias()

ilCalendarRemoteAccessHandler::initIlias ( )
protected

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

130 : void
131 {
135
136 global $DIC;
137
138 $this->lng = $DIC->language();
139 $this->lng->loadLanguageModule('dateplaner');
140 $this->logger = $DIC->logger()->cal();
141 }
const int CONTEXT_CALENDAR_TOKEN
Calendar authentication with auth token.
static setContext(int $a_context)
const CONTEXT_ICAL
static init(string $a_type)
Init context by type.
static initILIAS()
ilias initialisation
global $DIC
Definition: shib_login.php:26

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().

+ 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.

125 : void
126 {
127 $this->limit_enabled = (bool) ($_GET[self::LIMITED_QUERY_PARAM] ?? false);
128 }
$_GET['cmd']
Definition: lti.php:26

References $_GET.

Referenced by handleRequest().

+ Here is the caller graph for this function:

◆ initTokenHandler()

ilCalendarRemoteAccessHandler::initTokenHandler ( )
protected

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

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 }
static http()
Fetches the global http state from ILIAS.
$token
Definition: xapitoken.php:70

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

Referenced by handleRequest().

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

◆ initUser()

ilCalendarRemoteAccessHandler::initUser ( )
protected

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

143 : bool
144 {
145 global $DIC;
146
147 if (!$this->getTokenHandler() instanceof ilCalendarAuthenticationToken) {
148 $this->logger->info('Initialisation of authentication token failed');
149 return false;
150 }
151 if (!$this->getTokenHandler()->getUserId()) {
152 $this->logger->info('No user id found for calendar synchronisation');
153 return false;
154 }
155 if (!ilObjUser::_exists($this->getTokenHandler()->getUserId())) {
156 $this->logger->notice('No valid user id found for calendar synchronisation');
157 return false;
158 }
159
160 $GLOBALS['DIC']['ilAuthSession']->setAuthenticated(true, $this->getTokenHandler()->getUserId());
162
163 if (!$DIC->user() instanceof ilObjUser) {
164 $this->logger->debug('No user object defined');
165 } else {
166 $this->logger->debug('Current user is: ' . $DIC->user()->getId());
167 }
168 return true;
169 }
static initUserAccount()
Init user with current account id.
User class.
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data

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

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...

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

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 }
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
$path_info_components
Definition: webdav.php:23
$_COOKIE[session_name()]
Definition: xapitoken.php:54

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

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.

◆ $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: