ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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.

References read(), and user().

35  {
36  $this->user = $a_user_id;
37  $this->token = $a_token;
38 
39  $this->read();
40  }
user()
Definition: user.php:4
+ Here is the call graph for this function:

Member Function Documentation

◆ add()

ilCalendarAuthenticationToken::add ( )

Add token.

Returns

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

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

192  {
193  global $ilDB;
194 
195  $this->createToken();
196 
197  $query = "INSERT INTO cal_auth_token (user_id,hash,selection,calendar) ".
198  "VALUES ( ".
199  $ilDB->quote($this->getUserId(),'integer').', '.
200  $ilDB->quote($this->getToken(),'text').', '.
201  $ilDB->quote($this->getSelectionType(),'integer').', '.
202  $ilDB->quote($this->getCalendar(),'integer').' '.
203  ')';
204  $ilDB->manipulate($query);
205 
206  return $this->getToken();
207  }
global $ilDB
+ Here is the call graph for this function:

◆ createToken()

ilCalendarAuthenticationToken::createToken ( )
protected

Create a new token.

Returns

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

References getSelectionType(), and getUserId().

Referenced by add().

214  {
215  $this->token = md5($this->getUserId().$this->getSelectionType().rand());
216  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCalendar()

ilCalendarAuthenticationToken::getCalendar ( )

Definition at line 116 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 130 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 81 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 140 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 91 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 170 of file class.ilCalendarAuthenticationToken.php.

References ilCalendarSettings\_getInstance(), and time.

171  {
172  return true;
173 
174  include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
175 
176  if(!ilCalendarSettings::_getInstance()->isSynchronisationCacheEnabled())
177  {
178  return true;
179  }
180  if(!ilCalendarSettings::_getInstance()->getSynchronisationCacheMinutes())
181  {
182  return true;
183  }
184  return time() > ($this->ical_ctime + 60 * ilCalendarSettings::_getInstance()->getSynchronisationCacheMinutes());
185  }
static _getInstance()
get singleton instance
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ 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.

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

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

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  {
53  return $row->hash;
54  }
55  return false;
56  }
global $ilDB
+ 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 63 of file class.ilCalendarAuthenticationToken.php.

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

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

64  {
65  global $ilDB;
66 
67  $query = "SELECT * FROM cal_auth_token ".
68  "WHERE hash = ".$ilDB->quote($a_token,'text');
69  $res = $ilDB->query($query);
70  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
71  {
72  return $row->user_id;
73  }
74  return 0;
75  }
global $ilDB
+ Here is the caller graph for this function:

◆ read()

ilCalendarAuthenticationToken::read ( )
protected

Read key.

Returns

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

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

Referenced by __construct().

223  {
224  global $ilDB;
225 
226  if(!$this->getToken())
227  {
228  $query = "SELECT * FROM cal_auth_token ".
229  "WHERE user_id = ".$ilDB->quote($this->getUserId(),'integer');
230  }
231  else
232  {
233  $query = 'SELECT * FROM cal_auth_token '.
234  'WHERE user_id = '.$ilDB->quote($this->getUserId(),'integer').' '.
235  'AND hash = '.$ilDB->quote($this->getToken(),'text');
236 
237  }
238 
239  $res = $ilDB->query($query);
240  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
241  {
242  $this->token = $row->hash;
243  $this->selection_type = $row->selection;
244  $this->calendar = $row->calendar;
245  $this->ical = $row->ical;
246  $this->ical_ctime = $row->c_time;
247  }
248  return true;
249  }
global $ilDB
+ 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 111 of file class.ilCalendarAuthenticationToken.php.

112  {
113  $this->calendar = $a_cal;
114  }

◆ setIcal()

ilCalendarAuthenticationToken::setIcal (   $ical)

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

References $ical.

122  {
123  $this->ical = $ical;
124  }

◆ setSelectionType()

ilCalendarAuthenticationToken::setSelectionType (   $a_type)

set selection type

Parameters
int$a_type
Returns

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

References $a_type.

Referenced by ilCalendarBlockGUI\showCalendarSubscription().

102  {
103  $this->selection_type = $a_type;
104  }
$a_type
Definition: workflow.php:93
+ Here is the caller graph for this function:

◆ storeIcal()

ilCalendarAuthenticationToken::storeIcal ( )

store ical

Returns

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

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

150  {
151  global $ilDB;
152 
153  $ilDB->update(
154  'cal_auth_token',
155  array(
156  'ical' => array('clob',$this->getIcal()),
157  'c_time' => array('integer',time())
158  ),
159  array(
160  'user_id' => array('integer',$this->getUserId()),
161  'hash' => array('text',$this->getToken())
162  )
163  );
164  }
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ 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: