ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCalendarRemoteReader Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilCalendarRemoteReader:

Public Member Functions

 __construct (string $a_url)
 
 setUser (string $a_user)
 
 setPass (string $a_pass)
 
 getType ()
 
 getUrl ()
 
 read ()
 
 import (ilCalendarCategory $cat)
 

Protected Member Functions

 readIcal ()
 
 importIcal (ilCalendarCategory $cat)
 
 initCurl ()
 
 replaceWebCalProtocol ()
 

Protected Attributes

const TYPE_ICAL = 1
 

Private Member Functions

 call ()
 

Private Attributes

int $type = self::TYPE_ICAL
 
ilCurlConnection $curl = null
 
string $url = ''
 
string $user = ''
 
string $pass = ''
 
string $ical = ''
 
ilLogger $logger
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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 26 of file class.ilCalendarRemoteReader.php.

Constructor & Destructor Documentation

◆ __construct()

ilCalendarRemoteReader::__construct ( string  $a_url)

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

References $DIC, and ILIAS\Repository\logger().

43  {
44  global $DIC;
45 
46  $this->logger = $DIC->logger()->cal();
47  $this->url = $a_url;
48  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ call()

ilCalendarRemoteReader::call ( )
private
Exceptions
ilCurlConnectionException

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

Referenced by readIcal().

148  : string
149  {
150  try {
151  return $this->curl->exec();
152  } catch (ilCurlConnectionException $exc) {
153  throw($exc);
154  }
155  }
+ Here is the caller graph for this function:

◆ getType()

ilCalendarRemoteReader::getType ( )

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

References $type.

Referenced by import(), and read().

60  : int
61  {
62  return $this->type;
63  }
+ Here is the caller graph for this function:

◆ getUrl()

ilCalendarRemoteReader::getUrl ( )

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

References $url.

Referenced by initCurl(), and replaceWebCalProtocol().

65  : string
66  {
67  return $this->url;
68  }
+ Here is the caller graph for this function:

◆ import()

ilCalendarRemoteReader::import ( ilCalendarCategory  $cat)

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

References getType(), and importIcal().

81  : void
82  {
83  switch ($this->getType()) {
84  case self::TYPE_ICAL:
85  $this->importIcal($cat);
86  break;
87  }
88  }
importIcal(ilCalendarCategory $cat)
+ Here is the call graph for this function:

◆ importIcal()

ilCalendarRemoteReader::importIcal ( ilCalendarCategory  $cat)
protected

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

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

Referenced by import().

96  : void
97  {
98  // Delete old appointments
99  foreach (ilCalendarCategoryAssignments::_getAssignedAppointments(array($cat->getCategoryID())) as $app_id) {
100  ilCalendarEntry::_delete($app_id);
101  }
103 
104  // Import new appointments
105  $parser = new ilICalParser($this->ical, ilICalParser::INPUT_STRING);
106  $parser->setCategoryId($cat->getCategoryID());
107  $parser->parse();
108  }
static _delete(int $a_entry_id)
static _getAssignedAppointments(array $a_cat_id)
Get assigned apointments.
static _deleteByCategoryId(int $a_cat_id)
Delete assignments by category id public.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initCurl()

ilCalendarRemoteReader::initCurl ( )
protected
Exceptions
ilCurlConnectionException

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

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

Referenced by read().

113  : void
114  {
115  try {
116  $this->replaceWebCalProtocol();
117 
118  $this->curl = new ilCurlConnection($this->getUrl());
119  $this->curl->init();
120 
121  $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER, 0);
122  $this->curl->setOpt(CURLOPT_SSL_VERIFYHOST, 0);
123  $this->curl->setOpt(CURLOPT_RETURNTRANSFER, 1);
124 
125  $this->curl->setOpt(CURLOPT_FOLLOWLOCATION, 1);
126  $this->curl->setOpt(CURLOPT_MAXREDIRS, 3);
127 
128  if ($this->user) {
129  $this->curl->setOpt(CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
130  $this->curl->setOpt(CURLOPT_USERPWD, $this->user . ':' . $this->pass);
131  }
132  } catch (Exception $e) {
133  throw $e;
134  }
135  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilCalendarRemoteReader::read ( )

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

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

70  : void
71  {
72  $this->initCurl();
73 
74  switch ($this->getType()) {
75  case self::TYPE_ICAL:
76  $this->readIcal();
77  break;
78  }
79  }
+ Here is the call graph for this function:

◆ readIcal()

ilCalendarRemoteReader::readIcal ( )
protected

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

References call(), and ILIAS\Repository\logger().

Referenced by read().

90  : void
91  {
92  $this->ical = $this->call();
93  $this->logger->debug($this->ical);
94  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ replaceWebCalProtocol()

ilCalendarRemoteReader::replaceWebCalProtocol ( )
protected

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

References getUrl().

Referenced by initCurl().

137  : void
138  {
139  if (substr($this->getUrl(), 0, 6) == 'webcal') {
140  $purged = preg_replace('/webcal/', 'http', $this->getUrl(), 1);
141  $this->url = (string) $purged;
142  }
143  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setPass()

ilCalendarRemoteReader::setPass ( string  $a_pass)

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

55  : void
56  {
57  $this->pass = $a_pass;
58  }

◆ setUser()

ilCalendarRemoteReader::setUser ( string  $a_user)

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

References ILIAS\Repository\user().

Referenced by ilCalendarCategoryGUI\doSynchronisation(), and ilCalendarCronRemoteReader\run().

50  : void
51  {
52  $this->user = $a_user;
53  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $curl

ilCurlConnection ilCalendarRemoteReader::$curl = null
private

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

◆ $ical

string ilCalendarRemoteReader::$ical = ''
private

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

◆ $logger

ilLogger ilCalendarRemoteReader::$logger
private

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

◆ $pass

string ilCalendarRemoteReader::$pass = ''
private

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

◆ $type

int ilCalendarRemoteReader::$type = self::TYPE_ICAL
private

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

Referenced by getType().

◆ $url

string ilCalendarRemoteReader::$url = ''
private

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

Referenced by getUrl().

◆ $user

string ilCalendarRemoteReader::$user = ''
private

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

◆ TYPE_ICAL

const ilCalendarRemoteReader::TYPE_ICAL = 1
protected

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


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