ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 35 of file class.ilCalendarRemoteReader.php.

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

Member Function Documentation

◆ call()

ilCalendarRemoteReader::call ( )
private

call peer

private

Exceptions
ilCurlConnectionException

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

References $res.

Referenced by readIcal().

171  {
172  try
173  {
174  $res = $this->curl->exec();
175  return $res;
176  }
177  catch(ilCurlConnectionException $exc)
178  {
179  throw($exc);
180  }
181  }
+ Here is the caller graph for this function:

◆ getType()

ilCalendarRemoteReader::getType ( )

Definition at line 50 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 55 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 81 of file class.ilCalendarRemoteReader.php.

References getType(), and importIcal().

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

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

Referenced by import().

107  {
108  // Delete old appointments
109  include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
111  {
112  include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
113  ilCalendarEntry::_delete($app_id);
114  }
116 
117  // Import new appointments
118  include_once './Services/Calendar/classes/iCal/class.ilICalParser.php';
119  $parser = new ilICalParser($this->ical, ilICalParser::INPUT_STRING);
120  $parser->setCategoryId($cat->getCategoryID());
121  $parser->parse();
122  }
static _delete($a_entry_id)
delete entry
Create styles array
The data for the language used.
static _deleteByCategoryId($a_cat_id)
Delete assignments by category id.
static _getAssignedAppointments($a_cat_id)
Get assigned apointments.
$parser
Definition: BPMN2Parser.php:24
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 127 of file class.ilCalendarRemoteReader.php.

References getUrl(), replaceWebCalProtocol(), and user().

Referenced by read().

128  {
129  try {
130 
131  $this->replaceWebCalProtocol();
132 
133  $this->curl = new ilCurlConnection($this->getUrl());
134  $this->curl->init();
135  $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER, 0);
136  $this->curl->setOpt(CURLOPT_SSL_VERIFYHOST, 0);
137  $this->curl->setOpt(CURLOPT_RETURNTRANSFER, 1);
138 
139  $this->curl->setOpt(CURLOPT_FOLLOWLOCATION, 1);
140  $this->curl->setOpt(CURLOPT_MAXREDIRS, 3);
141 
142  if($this->user)
143  {
144  $this->curl->setOpt(CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
145  $this->curl->setOpt(CURLOPT_USERPWD,$this->user.':'.$this->pass);
146  }
147  }
148  catch(Exception $e)
149  {
150  throw $e;
151  }
152  }
user()
Definition: user.php:4
+ 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 66 of file class.ilCalendarRemoteReader.php.

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

67  {
68  $this->initCurl();
69 
70  switch($this->getType())
71  {
72  case self::TYPE_ICAL:
73  return $this->readIcal();
74  }
75  }
+ Here is the call graph for this function:

◆ readIcal()

ilCalendarRemoteReader::readIcal ( )
protected

Read ical.

Exceptions
ilCurlConnectionException

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

References $GLOBALS, and call().

Referenced by read().

96  {
97  $this->ical = $this->call();
98  $GLOBALS['ilLog']->write(__METHOD__.': '.$this->ical);
99  return true;
100  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ replaceWebCalProtocol()

ilCalendarRemoteReader::replaceWebCalProtocol ( )
protected

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

References $GLOBALS, and getUrl().

Referenced by initCurl().

155  {
156  if(substr($this->getUrl(), 0, 6) == 'webcal')
157  {
158  $purged = preg_replace('/webcal/', 'http', $this->getUrl(), 1);
159  $this->url = $purged;
160  $GLOBALS['ilLog']->write(__METHOD__.': Using new url: '. $this->getUrl());
161  }
162  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setPass()

ilCalendarRemoteReader::setPass (   $a_pass)

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

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

◆ setUser()

ilCalendarRemoteReader::setUser (   $a_user)

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

References user().

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

41  {
42  $this->user = $a_user;
43  }
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 22 of file class.ilCalendarRemoteReader.php.

◆ $ical

ilCalendarRemoteReader::$ical
private

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

◆ $pass

ilCalendarRemoteReader::$pass
private

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

◆ $type

ilCalendarRemoteReader::$type = self::TYPE_ICAL
private

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

Referenced by getType().

◆ $url

ilCalendarRemoteReader::$url
private

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

Referenced by getUrl().

◆ $user

ilCalendarRemoteReader::$user
private

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

◆ TYPE_ICAL

const ilCalendarRemoteReader::TYPE_ICAL = 1

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


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