ILIAS  Release_4_2_x_branch Revision 61807
 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

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 33 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 188 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 210 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 115 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 129 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 80 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 139 of file class.ilCalendarAuthenticationToken.php.

References $token.

Referenced by add(), and storeIcal().

{
return $this->token;
}

+ Here is the caller graph for this function:

ilCalendarAuthenticationToken::getUserId ( )

Get current user.

Returns
int user

Definition at line 90 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 169 of file class.ilCalendarAuthenticationToken.php.

References ilCalendarSettings\_getInstance().

{
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 41 of file class.ilCalendarAuthenticationToken.php.

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by 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 62 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 219 of file class.ilCalendarAuthenticationToken.php.

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

Referenced by __construct().

{
global $ilDB;
$query = "SELECT * FROM cal_auth_token ".
"WHERE user_id = ".$ilDB->quote($this->getUserId(),'integer');
$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 110 of file class.ilCalendarAuthenticationToken.php.

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

Definition at line 120 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 100 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 148 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 22 of file class.ilCalendarAuthenticationToken.php.

Referenced by getCalendar().

ilCalendarAuthenticationToken::$ical = null
private

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

Referenced by getIcal(), and setIcal().

ilCalendarAuthenticationToken::$ical_ctime = null
private

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

ilCalendarAuthenticationToken::$selection_type = 0
private

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

Referenced by getSelectionType().

ilCalendarAuthenticationToken::$token = ''
private

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

Referenced by getToken().

ilCalendarAuthenticationToken::$user = null
private

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

Referenced by getUserId().

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: