ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilCalendarRemoteReader Class Reference

Reader for remote ical calendars. More...

+ Collaboration diagram for ilCalendarRemoteReader:

Public Member Functions

 __construct ($a_url)
 Constructor init curl. More...
 
 setUser ($a_user)
 
 setPass ($a_pass)
 
 getType ()
 
 getUrl ()
 
 read ()
 Read ical format. More...
 
 import (ilCalendarCategory $cat)
 Import appointments in calendar. More...
 

Data Fields

const TYPE_ICAL = 1
 

Protected Member Functions

 readIcal ()
 Read ical. More...
 
 importIcal (ilCalendarCategory $cat)
 Import ical in calendar. More...
 
 initCurl ()
 Init curl connection. More...
 
 replaceWebCalProtocol ()
 

Private Member Functions

 call ()
 call peer More...
 

Private Attributes

 $type = self::TYPE_ICAL
 
 $curl = null
 
 $url
 
 $user
 
 $pass
 
 $ical
 
 $logger
 

Detailed Description

Reader for remote ical calendars.

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

Definition at line 14 of file class.ilCalendarRemoteReader.php.

Constructor & Destructor Documentation

◆ __construct()

ilCalendarRemoteReader::__construct (   $a_url)

Constructor init curl.

Definition at line 39 of file class.ilCalendarRemoteReader.php.

40 {
41 global $DIC;
42
43 $this->logger = $DIC->logger();
44 $this->url = $a_url;
45 }
$DIC
Definition: xapitoken.php:46

References $DIC.

Member Function Documentation

◆ call()

ilCalendarRemoteReader::call ( )
private

call peer

@access private

Exceptions
ilCurlConnectionException

Definition at line 169 of file class.ilCalendarRemoteReader.php.

170 {
171 try {
172 $res = $this->curl->exec();
173 return $res;
174 } catch (ilCurlConnectionException $exc) {
175 throw($exc);
176 }
177 }
foreach($_POST as $key=> $value) $res

References $res.

Referenced by readIcal().

+ Here is the caller graph for this function:

◆ getType()

ilCalendarRemoteReader::getType ( )

Definition at line 57 of file class.ilCalendarRemoteReader.php.

References $type.

Referenced by import(), and read().

+ Here is the caller graph for this function:

◆ getUrl()

ilCalendarRemoteReader::getUrl ( )

Definition at line 62 of file class.ilCalendarRemoteReader.php.

References $url.

Referenced by initCurl(), and replaceWebCalProtocol().

+ Here is the caller graph for this function:

◆ import()

ilCalendarRemoteReader::import ( ilCalendarCategory  $cat)

Import appointments in calendar.

Returns
type

Definition at line 87 of file class.ilCalendarRemoteReader.php.

88 {
89 switch ($this->getType()) {
90 case self::TYPE_ICAL:
91 return $this->importIcal($cat);
92 }
93 }
importIcal(ilCalendarCategory $cat)
Import ical in calendar.

References getType(), importIcal(), and TYPE_ICAL.

+ Here is the call graph for this function:

◆ importIcal()

ilCalendarRemoteReader::importIcal ( ilCalendarCategory  $cat)
protected

Import ical in calendar.

Parameters
ilCalendarCategory$cat

Definition at line 111 of file class.ilCalendarRemoteReader.php.

112 {
113 // Delete old appointments
114 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
116 include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
118 }
120
121 // Import new appointments
122 include_once './Services/Calendar/classes/iCal/class.ilICalParser.php';
124 $parser->setCategoryId($cat->getCategoryID());
125 $parser->parse();
126 }
$parser
Definition: BPMN2Parser.php:23
static _getAssignedAppointments($a_cat_id)
Get assigned apointments.
static _deleteByCategoryId($a_cat_id)
Delete assignments by category id.
static _delete($a_entry_id)
delete entry

References $parser, ilCalendarEntry\_delete(), ilCalendarCategoryAssignments\_deleteByCategoryId(), ilCalendarCategoryAssignments\_getAssignedAppointments(), ilCalendarCategory\getCategoryID(), and ilICalParser\INPUT_STRING.

Referenced by import().

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

◆ initCurl()

ilCalendarRemoteReader::initCurl ( )
protected

Init curl connection.

Definition at line 131 of file class.ilCalendarRemoteReader.php.

132 {
133 try {
134 $this->replaceWebCalProtocol();
135
136 $this->curl = new ilCurlConnection($this->getUrl());
137 $this->curl->init();
138
139 $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER, 0);
140 $this->curl->setOpt(CURLOPT_SSL_VERIFYHOST, 0);
141 $this->curl->setOpt(CURLOPT_RETURNTRANSFER, 1);
142
143 $this->curl->setOpt(CURLOPT_FOLLOWLOCATION, 1);
144 $this->curl->setOpt(CURLOPT_MAXREDIRS, 3);
145
146 if ($this->user) {
147 $this->curl->setOpt(CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
148 $this->curl->setOpt(CURLOPT_USERPWD, $this->user . ':' . $this->pass);
149 }
150 } catch (Exception $e) {
151 throw $e;
152 }
153 }
user()
Definition: user.php:4

References Vendor\Package\$e, getUrl(), replaceWebCalProtocol(), and user().

Referenced by read().

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

◆ read()

ilCalendarRemoteReader::read ( )

Read ical format.

Exceptions
sonething

Definition at line 73 of file class.ilCalendarRemoteReader.php.

74 {
75 $this->initCurl();
76
77 switch ($this->getType()) {
78 case self::TYPE_ICAL:
79 return $this->readIcal();
80 }
81 }

References getType(), initCurl(), readIcal(), and TYPE_ICAL.

+ Here is the call graph for this function:

◆ readIcal()

ilCalendarRemoteReader::readIcal ( )
protected

Read ical.

Exceptions
ilCurlConnectionException

Definition at line 100 of file class.ilCalendarRemoteReader.php.

101 {
102 $this->ical = $this->call();
103 $this->logger->debug($this->ical);
104 return true;
105 }

References call().

Referenced by read().

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

◆ replaceWebCalProtocol()

ilCalendarRemoteReader::replaceWebCalProtocol ( )
protected

Definition at line 155 of file class.ilCalendarRemoteReader.php.

156 {
157 if (substr($this->getUrl(), 0, 6) == 'webcal') {
158 $purged = preg_replace('/webcal/', 'http', $this->getUrl(), 1);
159 $this->url = $purged;
160 }
161 }

References getUrl().

Referenced by initCurl().

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

◆ setPass()

ilCalendarRemoteReader::setPass (   $a_pass)

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

53 {
54 $this->pass = $a_pass;
55 }

◆ setUser()

ilCalendarRemoteReader::setUser (   $a_user)

Definition at line 47 of file class.ilCalendarRemoteReader.php.

48 {
49 $this->user = $a_user;
50 }

References user().

+ Here is the call graph for this function:

Field Documentation

◆ $curl

ilCalendarRemoteReader::$curl = null
private

Definition at line 21 of file class.ilCalendarRemoteReader.php.

◆ $ical

ilCalendarRemoteReader::$ical
private

Definition at line 27 of file class.ilCalendarRemoteReader.php.

◆ $logger

ilCalendarRemoteReader::$logger
private

Definition at line 32 of file class.ilCalendarRemoteReader.php.

◆ $pass

ilCalendarRemoteReader::$pass
private

Definition at line 25 of file class.ilCalendarRemoteReader.php.

◆ $type

ilCalendarRemoteReader::$type = self::TYPE_ICAL
private

Definition at line 19 of file class.ilCalendarRemoteReader.php.

Referenced by getType().

◆ $url

ilCalendarRemoteReader::$url
private

Definition at line 23 of file class.ilCalendarRemoteReader.php.

Referenced by getUrl().

◆ $user

ilCalendarRemoteReader::$user
private

Definition at line 24 of file class.ilCalendarRemoteReader.php.

◆ TYPE_ICAL

const ilCalendarRemoteReader::TYPE_ICAL = 1

Definition at line 16 of file class.ilCalendarRemoteReader.php.

Referenced by import(), and read().


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