ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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.
 getSelectionType ()
 get selection type for key
 getUserId ()
 Get current user.
 setSelectionType ($a_type)
 set selection type
 setCalendar ($a_cal)
 set calendar id
 getCalendar ()
 setIcal ($ical)
 getIcal ()
 get stored ical
 getToken ()
 get token
 storeIcal ()
 store ical
 isIcalExpired ()
 Check if cache is disabled or expired.
 add ()
 Add token.

Static Public Member Functions

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

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.
 read ()
 Read key.

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

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().

{
$this->user = $a_user_id;
$this->token = $a_token;
$this->read();
}

+ Here is the call graph for this function:

Member Function Documentation

ilCalendarAuthenticationToken::add ( )

Add token.

Returns

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

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

{
global $ilDB;
$this->createToken();
$query = "INSERT INTO cal_auth_token (user_id,hash,selection,calendar) ".
"VALUES ( ".
$ilDB->quote($this->getUserId(),'integer').', '.
$ilDB->quote($this->getToken(),'text').', '.
$ilDB->quote($this->getSelectionType(),'integer').', '.
$ilDB->quote($this->getCalendar(),'integer').' '.
')';
$ilDB->manipulate($query);
return $this->getToken();
}

+ Here is the call graph for this function:

ilCalendarAuthenticationToken::createToken ( )
protected

Create a new token.

Returns

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

References getSelectionType(), and getUserId().

Referenced by add().

{
$this->token = md5($this->getUserId().$this->getSelectionType().rand());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCalendarAuthenticationToken::getCalendar ( )

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

References $calendar.

Referenced by add().

{
}

+ Here is the caller graph for this function:

ilCalendarAuthenticationToken::getIcal ( )

get stored ical

Returns

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

References $ical.

Referenced by storeIcal().

{
return $this->ical;
}

+ Here is the caller graph for this function:

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:

ilCalendarAuthenticationToken::getToken ( )

get token

Returns

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

References $token.

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

{
return $this->token;
}

+ Here is the caller graph for this function:

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().

{
return $this->user;
}

+ Here is the caller graph for this function:

ilCalendarAuthenticationToken::isIcalExpired ( )

Check if cache is disabled or expired.

Returns

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

References ilCalendarSettings\_getInstance().

{
return true;
include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
if(!ilCalendarSettings::_getInstance()->isSynchronisationCacheEnabled())
{
return true;
}
if(!ilCalendarSettings::_getInstance()->getSynchronisationCacheMinutes())
{
return true;
}
return time() > ($this->ical_ctime + 60 * ilCalendarSettings::_getInstance()->getSynchronisationCacheMinutes());
}

+ Here is the call graph for this function:

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 DB_FETCHMODE_OBJECT.

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

{
global $ilDB;
$query = "SELECT * FROM cal_auth_token ".
"WHERE user_id = ".$ilDB->quote($a_user_id,'integer').' '.
"AND selection = ".$ilDB->quote($a_selection,'integer').' '.
"AND calendar = ".$ilDB->quote($a_calendar,'integer');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return $row->hash;
}
return false;
}

+ Here is the caller graph for this function:

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 DB_FETCHMODE_OBJECT.

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

{
global $ilDB;
$query = "SELECT * FROM cal_auth_token ".
"WHERE hash = ".$ilDB->quote($a_token,'text');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return $row->user_id;
}
return 0;
}

+ Here is the caller graph for this function:

ilCalendarAuthenticationToken::read ( )
protected

Read key.

Returns

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

References $ilDB, $query, $res, $row, DB_FETCHMODE_OBJECT, getToken(), and getUserId().

Referenced by __construct().

{
global $ilDB;
if(!$this->getToken())
{
$query = "SELECT * FROM cal_auth_token ".
"WHERE user_id = ".$ilDB->quote($this->getUserId(),'integer');
}
else
{
$query = 'SELECT * FROM cal_auth_token '.
'WHERE user_id = '.$ilDB->quote($this->getUserId(),'integer').' '.
'AND hash = '.$ilDB->quote($this->getToken(),'text');
}
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->token = $row->hash;
$this->selection_type = $row->selection;
$this->calendar = $row->calendar;
$this->ical = $row->ical;
$this->ical_ctime = $row->c_time;
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCalendarAuthenticationToken::setCalendar (   $a_cal)

set calendar id

Parameters
object$a_cal
Returns

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

{
$this->calendar = $a_cal;
}
ilCalendarAuthenticationToken::setIcal (   $ical)

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

References $ical.

{
$this->ical = $ical;
}
ilCalendarAuthenticationToken::setSelectionType (   $a_type)

set selection type

Parameters
int$a_type
Returns

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

Referenced by ilCalendarBlockGUI\showCalendarSubscription().

{
$this->selection_type = $a_type;
}

+ Here is the caller graph for this function:

ilCalendarAuthenticationToken::storeIcal ( )

store ical

Returns

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

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

{
global $ilDB;
$ilDB->update(
'cal_auth_token',
array(
'ical' => array('clob',$this->getIcal()),
'c_time' => array('integer',time())
),
array(
'user_id' => array('integer',$this->getUserId()),
'hash' => array('text',$this->getToken())
)
);
}

+ Here is the call graph for this function:

Field Documentation

ilCalendarAuthenticationToken::$calendar = 0
private

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

Referenced by getCalendar().

ilCalendarAuthenticationToken::$ical = null
private

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

Referenced by getIcal(), and setIcal().

ilCalendarAuthenticationToken::$ical_ctime = null
private

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

ilCalendarAuthenticationToken::$selection_type = 0
private

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

Referenced by getSelectionType().

ilCalendarAuthenticationToken::$token = ''
private

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

Referenced by getToken().

ilCalendarAuthenticationToken::$user = null
private

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

Referenced by getUserId().

const ilCalendarAuthenticationToken::SELECTION_CALENDAR = 3
const ilCalendarAuthenticationToken::SELECTION_CATEGORY = 2
const ilCalendarAuthenticationToken::SELECTION_NONE = 0

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

const ilCalendarAuthenticationToken::SELECTION_PD = 1

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