ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilCalendarAuthenticationToken Class Reference

Handles calendar authentication tokens for external calendar subscriptions. More...

+ Collaboration diagram for ilCalendarAuthenticationToken:

Public Member Functions

 __construct ($a_user_id, $a_token='')
 Constructor. More...
 
 getSelectionType ()
 get selection type for key More...
 
 getUserId ()
 Get current user. More...
 
 setSelectionType ($a_type)
 set selection type More...
 
 setCalendar ($a_cal)
 set calendar id More...
 
 getCalendar ()
 
 setIcal ($ical)
 
 getIcal ()
 get stored ical More...
 
 getToken ()
 get token More...
 
 storeIcal ()
 store ical More...
 
 isIcalExpired ()
 Check if cache is disabled or expired. More...
 
 add ()
 Add token. More...
 

Static Public Member Functions

static lookupAuthToken ($a_user_id, $a_selection, $a_calendar=0)
 
static lookupUser ($a_token)
 Lookup user by hash. More...
 

Data Fields

const SELECTION_NONE = 0
 
const SELECTION_PD = 1
 
const SELECTION_CATEGORY = 2
 
const SELECTION_CALENDAR = 3
 

Protected Member Functions

 createToken ()
 Create a new token. More...
 
 read ()
 Read key. More...
 

Private Attributes

 $user = null
 
 $token = ''
 
 $selection_type = 0
 
 $calendar = 0
 
 $ical = null
 
 $ical_ctime = null
 

Detailed Description

Handles calendar authentication tokens for external calendar subscriptions.

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

Definition at line 12 of file class.ilCalendarAuthenticationToken.php.

Constructor & Destructor Documentation

◆ __construct()

ilCalendarAuthenticationToken::__construct (   $a_user_id,
  $a_token = '' 
)

Constructor.

Parameters
int$a_user_id
string$a_hash
Returns
ilCalendarAuthenticationKey

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

35 {
36 $this->user = $a_user_id;
37 $this->token = $a_token;
38
39 $this->read();
40 }
user()
Definition: user.php:4

References read(), and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ add()

ilCalendarAuthenticationToken::add ( )

Add token.

Returns

Definition at line 187 of file class.ilCalendarAuthenticationToken.php.

188 {
189 global $ilDB;
190
191 $this->createToken();
192
193 $query = "INSERT INTO cal_auth_token (user_id,hash,selection,calendar) " .
194 "VALUES ( " .
195 $ilDB->quote($this->getUserId(), 'integer') . ', ' .
196 $ilDB->quote($this->getToken(), 'text') . ', ' .
197 $ilDB->quote($this->getSelectionType(), 'integer') . ', ' .
198 $ilDB->quote($this->getCalendar(), 'integer') . ' ' .
199 ')';
200 $ilDB->manipulate($query);
201
202 return $this->getToken();
203 }
$query
global $ilDB

References $ilDB, $query, createToken(), getCalendar(), getSelectionType(), getToken(), and getUserId().

+ Here is the call graph for this function:

◆ createToken()

ilCalendarAuthenticationToken::createToken ( )
protected

Create a new token.

Returns

Definition at line 209 of file class.ilCalendarAuthenticationToken.php.

210 {
211 $random = new \ilRandom();
212 $this->token = md5($this->getUserId() . $this->getSelectionType() . $random->int());
213 }

References getSelectionType(), and getUserId().

Referenced by add().

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

◆ getCalendar()

ilCalendarAuthenticationToken::getCalendar ( )

Definition at line 114 of file class.ilCalendarAuthenticationToken.php.

References $calendar.

Referenced by add().

+ Here is the caller graph for this function:

◆ getIcal()

ilCalendarAuthenticationToken::getIcal ( )

get stored ical

Returns

Definition at line 128 of file class.ilCalendarAuthenticationToken.php.

References $ical.

Referenced by storeIcal().

+ Here is the caller graph for this function:

◆ getSelectionType()

ilCalendarAuthenticationToken::getSelectionType ( )

get selection type for key

Returns
int selection type

Definition at line 79 of file class.ilCalendarAuthenticationToken.php.

References $selection_type.

Referenced by add(), and createToken().

+ Here is the caller graph for this function:

◆ getToken()

ilCalendarAuthenticationToken::getToken ( )

get token

Returns

Definition at line 138 of file class.ilCalendarAuthenticationToken.php.

References $token.

Referenced by add(), read(), and storeIcal().

+ Here is the caller graph for this function:

◆ getUserId()

ilCalendarAuthenticationToken::getUserId ( )

Get current user.

Returns
int user

Definition at line 89 of file class.ilCalendarAuthenticationToken.php.

References $user.

Referenced by add(), createToken(), read(), and storeIcal().

+ Here is the caller graph for this function:

◆ isIcalExpired()

ilCalendarAuthenticationToken::isIcalExpired ( )

Check if cache is disabled or expired.

Returns

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

169 {
170 return true;
171
172 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
173
174 if (!ilCalendarSettings::_getInstance()->isSynchronisationCacheEnabled()) {
175 return true;
176 }
177 if (!ilCalendarSettings::_getInstance()->getSynchronisationCacheMinutes()) {
178 return true;
179 }
180 return time() > ($this->ical_ctime + 60 * ilCalendarSettings::_getInstance()->getSynchronisationCacheMinutes());
181 }
static _getInstance()
get singleton instance

References ilCalendarSettings\_getInstance().

+ Here is the call graph for this function:

◆ lookupAuthToken()

static ilCalendarAuthenticationToken::lookupAuthToken (   $a_user_id,
  $a_selection,
  $a_calendar = 0 
)
static

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

43 {
44 global $ilDB;
45
46 $query = "SELECT * FROM cal_auth_token " .
47 "WHERE user_id = " . $ilDB->quote($a_user_id, 'integer') . ' ' .
48 "AND selection = " . $ilDB->quote($a_selection, 'integer') . ' ' .
49 "AND calendar = " . $ilDB->quote($a_calendar, 'integer');
50 $res = $ilDB->query($query);
51 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
52 return $row->hash;
53 }
54 return false;
55 }
foreach($_POST as $key=> $value) $res

References $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilCalendarSubscriptionGUI\createToken(), and ilCalendarBlockGUI\showCalendarSubscription().

+ Here is the caller graph for this function:

◆ lookupUser()

static ilCalendarAuthenticationToken::lookupUser (   $a_token)
static

Lookup user by hash.

Parameters
object$a_token
Returns

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

63 {
64 global $ilDB;
65
66 $query = "SELECT * FROM cal_auth_token " .
67 "WHERE hash = " . $ilDB->quote($a_token, 'text');
68 $res = $ilDB->query($query);
69 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
70 return $row->user_id;
71 }
72 return 0;
73 }

References $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilAuthContainerCalendarToken\fetchData(), and ilCalendarRemoteAccessHandler\initTokenHandler().

+ Here is the caller graph for this function:

◆ read()

ilCalendarAuthenticationToken::read ( )
protected

Read key.

Returns

Definition at line 219 of file class.ilCalendarAuthenticationToken.php.

220 {
221 global $ilDB;
222
223 if (!$this->getToken()) {
224 $query = "SELECT * FROM cal_auth_token " .
225 "WHERE user_id = " . $ilDB->quote($this->getUserId(), 'integer');
226 } else {
227 $query = 'SELECT * FROM cal_auth_token ' .
228 'WHERE user_id = ' . $ilDB->quote($this->getUserId(), 'integer') . ' ' .
229 'AND hash = ' . $ilDB->quote($this->getToken(), 'text');
230 }
231
232 $res = $ilDB->query($query);
233 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
234 $this->token = $row->hash;
235 $this->selection_type = $row->selection;
236 $this->calendar = $row->calendar;
237 $this->ical = $row->ical;
238 $this->ical_ctime = $row->c_time;
239 }
240 return true;
241 }

References $ilDB, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, getToken(), and getUserId().

Referenced by __construct().

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

◆ setCalendar()

ilCalendarAuthenticationToken::setCalendar (   $a_cal)

set calendar id

Parameters
object$a_cal
Returns

Definition at line 109 of file class.ilCalendarAuthenticationToken.php.

110 {
111 $this->calendar = $a_cal;
112 }

◆ setIcal()

ilCalendarAuthenticationToken::setIcal (   $ical)

Definition at line 119 of file class.ilCalendarAuthenticationToken.php.

120 {
121 $this->ical = $ical;
122 }

References $ical.

◆ setSelectionType()

ilCalendarAuthenticationToken::setSelectionType (   $a_type)

set selection type

Parameters
int$a_type
Returns

Definition at line 99 of file class.ilCalendarAuthenticationToken.php.

100 {
101 $this->selection_type = $a_type;
102 }
$a_type
Definition: workflow.php:92

References $a_type.

◆ storeIcal()

ilCalendarAuthenticationToken::storeIcal ( )

store ical

Returns

Definition at line 147 of file class.ilCalendarAuthenticationToken.php.

148 {
149 global $ilDB;
150
151 $ilDB->update(
152 'cal_auth_token',
153 array(
154 'ical' => array('clob',$this->getIcal()),
155 'c_time' => array('integer',time())
156 ),
157 array(
158 'user_id' => array('integer',$this->getUserId()),
159 'hash' => array('text',$this->getToken())
160 )
161 );
162 }

References $ilDB, getIcal(), getToken(), and getUserId().

+ Here is the call graph for this function:

Field Documentation

◆ $calendar

ilCalendarAuthenticationToken::$calendar = 0
private

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

Referenced by getCalendar().

◆ $ical

ilCalendarAuthenticationToken::$ical = null
private

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

Referenced by getIcal(), and setIcal().

◆ $ical_ctime

ilCalendarAuthenticationToken::$ical_ctime = null
private

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

◆ $selection_type

ilCalendarAuthenticationToken::$selection_type = 0
private

Definition at line 22 of file class.ilCalendarAuthenticationToken.php.

Referenced by getSelectionType().

◆ $token

ilCalendarAuthenticationToken::$token = ''
private

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

Referenced by getToken().

◆ $user

ilCalendarAuthenticationToken::$user = null
private

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

Referenced by getUserId().

◆ SELECTION_CALENDAR

const ilCalendarAuthenticationToken::SELECTION_CALENDAR = 3

◆ SELECTION_CATEGORY

const ilCalendarAuthenticationToken::SELECTION_CATEGORY = 2

◆ SELECTION_NONE

const ilCalendarAuthenticationToken::SELECTION_NONE = 0

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

◆ SELECTION_PD

const ilCalendarAuthenticationToken::SELECTION_PD = 1

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