ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
 

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 34 of file class.ilCalendarRemoteReader.php.

35 {
36 $this->url = $a_url;
37 }

Member Function Documentation

◆ call()

ilCalendarRemoteReader::call ( )
private

call peer

@access private

Exceptions
ilCurlConnectionException

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

169 {
170 try {
171 $res = $this->curl->exec();
172 return $res;
173 } catch (ilCurlConnectionException $exc) {
174 throw($exc);
175 }
176 }
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 49 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 54 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 79 of file class.ilCalendarRemoteReader.php.

80 {
81 switch ($this->getType()) {
82 case self::TYPE_ICAL:
83 return $this->importIcal($cat);
84 }
85 }
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 103 of file class.ilCalendarRemoteReader.php.

104 {
105 // Delete old appointments
106 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
108 include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
110 }
112
113 // Import new appointments
114 include_once './Services/Calendar/classes/iCal/class.ilICalParser.php';
116 $parser->setCategoryId($cat->getCategoryID());
117 $parser->parse();
118 }
$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 123 of file class.ilCalendarRemoteReader.php.

124 {
125 try {
126 $this->replaceWebCalProtocol();
127
128 $this->curl = new ilCurlConnection($this->getUrl());
129 $this->curl->init();
130
131 if (ilProxySettings::_getInstance()->isActive()) {
132 $this->curl->setOpt(CURLOPT_HTTPPROXYTUNNEL, true);
133 $this->curl->setOpt(CURLOPT_PROXY, ilProxySettings::_getInstance()->getHost());
134 $this->curl->setOpt(CURLOPT_PROXYPORT, ilProxySettings::_getInstance()->getPort());
135 }
136
137 $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER, 0);
138 $this->curl->setOpt(CURLOPT_SSL_VERIFYHOST, 0);
139 $this->curl->setOpt(CURLOPT_RETURNTRANSFER, 1);
140
141 $this->curl->setOpt(CURLOPT_FOLLOWLOCATION, 1);
142 $this->curl->setOpt(CURLOPT_MAXREDIRS, 3);
143
144 if ($this->user) {
145 $this->curl->setOpt(CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
146 $this->curl->setOpt(CURLOPT_USERPWD, $this->user . ':' . $this->pass);
147 }
148 } catch (Exception $e) {
149 throw $e;
150 }
151 }
user()
Definition: user.php:4
static _getInstance()
Getter for unique instance.

References ilProxySettings\_getInstance(), 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 65 of file class.ilCalendarRemoteReader.php.

66 {
67 $this->initCurl();
68
69 switch ($this->getType()) {
70 case self::TYPE_ICAL:
71 return $this->readIcal();
72 }
73 }

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 92 of file class.ilCalendarRemoteReader.php.

93 {
94 $this->ical = $this->call();
95 $GLOBALS['ilLog']->write(__METHOD__ . ': ' . $this->ical);
96 return true;
97 }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.

References $GLOBALS, and 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 153 of file class.ilCalendarRemoteReader.php.

154 {
155 if (substr($this->getUrl(), 0, 6) == 'webcal') {
156 $purged = preg_replace('/webcal/', 'http', $this->getUrl(), 1);
157 $this->url = $purged;
158 $GLOBALS['ilLog']->write(__METHOD__ . ': Using new url: ' . $this->getUrl());
159 }
160 }

References $GLOBALS, and 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 44 of file class.ilCalendarRemoteReader.php.

45 {
46 $this->pass = $a_pass;
47 }

◆ setUser()

ilCalendarRemoteReader::setUser (   $a_user)

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

40 {
41 $this->user = $a_user;
42 }

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.

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