ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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.

References $DIC.

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

Member Function Documentation

◆ call()

ilCalendarRemoteReader::call ( )
private

call peer

private

Exceptions
ilCurlConnectionException

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

References $res.

Referenced by readIcal().

176  {
177  try {
178  $res = $this->curl->exec();
179  return $res;
180  } catch (ilCurlConnectionException $exc) {
181  throw($exc);
182  }
183  }
foreach($_POST as $key=> $value) $res
+ 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.

References getType(), and importIcal().

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

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

Referenced by import().

112  {
113  // Delete old appointments
114  include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
115  foreach (ilCalendarCategoryAssignments::_getAssignedAppointments(array($cat->getCategoryID())) as $app_id) {
116  include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
117  ilCalendarEntry::_delete($app_id);
118  }
120 
121  // Import new appointments
122  include_once './Services/Calendar/classes/iCal/class.ilICalParser.php';
123  $parser = new ilICalParser($this->ical, ilICalParser::INPUT_STRING);
124  $parser->setCategoryId($cat->getCategoryID());
125  $parser->parse();
126  }
static _delete($a_entry_id)
delete entry
static _deleteByCategoryId($a_cat_id)
Delete assignments by category id.
static _getAssignedAppointments($a_cat_id)
Get assigned apointments.
$parser
Definition: BPMN2Parser.php:23
getCategoryID()
get category id
+ 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.

References ilProxySettings\_getInstance(), getUrl(), replaceWebCalProtocol(), and user().

Referenced by read().

132  {
133  try {
134  $this->replaceWebCalProtocol();
135 
136  $this->curl = new ilCurlConnection($this->getUrl());
137  $this->curl->init();
138 
139  if (ilProxySettings::_getInstance()->isActive()) {
140  $this->curl->setOpt(CURLOPT_HTTPPROXYTUNNEL, true);
141  $this->curl->setOpt(CURLOPT_PROXY, ilProxySettings::_getInstance()->getHost());
142  $this->curl->setOpt(CURLOPT_PROXYPORT, ilProxySettings::_getInstance()->getPort());
143  }
144 
145  $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER, 0);
146  $this->curl->setOpt(CURLOPT_SSL_VERIFYHOST, 0);
147  $this->curl->setOpt(CURLOPT_RETURNTRANSFER, 1);
148 
149  $this->curl->setOpt(CURLOPT_FOLLOWLOCATION, 1);
150  $this->curl->setOpt(CURLOPT_MAXREDIRS, 3);
151 
152  if ($this->user) {
153  $this->curl->setOpt(CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
154  $this->curl->setOpt(CURLOPT_USERPWD, $this->user . ':' . $this->pass);
155  }
156  } catch (Exception $e) {
157  throw $e;
158  }
159  }
user()
Definition: user.php:4
static _getInstance()
Getter for unique instance.
+ 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.

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

74  {
75  $this->initCurl();
76 
77  switch ($this->getType()) {
78  case self::TYPE_ICAL:
79  return $this->readIcal();
80  }
81  }
+ 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.

References call().

Referenced by read().

101  {
102  $this->ical = $this->call();
103  $this->logger->debug($this->ical);
104  return true;
105  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ replaceWebCalProtocol()

ilCalendarRemoteReader::replaceWebCalProtocol ( )
protected

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

References getUrl().

Referenced by initCurl().

162  {
163  if (substr($this->getUrl(), 0, 6) == 'webcal') {
164  $purged = preg_replace('/webcal/', 'http', $this->getUrl(), 1);
165  $this->url = $purged;
166  }
167  }
+ 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.

References user().

Referenced by ilCalendarCategoryGUI\doSynchronisation(), and ilCalendarPresentationGUI\synchroniseExternalCalendars().

48  {
49  $this->user = $a_user;
50  }
user()
Definition: user.php:4
+ Here is the call graph for this function:
+ Here is the caller 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.


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