ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCalendarShared Class Reference

Handles shared calendars. More...

+ Collaboration diagram for ilCalendarShared:

Public Member Functions

 __construct ($a_calendar_id)
 constructor
 getCalendarId ()
 get calendar id
 getShared ()
 get shared
 getUsers ()
 get users
 getRoles ()
 get roles
 isShared ($a_obj_id)
 Check if calendar is already shared with specific user or role.
 share ($a_obj_id, $a_type)
 share calendar
 stopSharing ($a_obj_id)
 stop sharing

Static Public Member Functions

static deleteByCalendar ($a_cal_id)
 Delete all entries for a specific calendar id.
static deleteByUser ($a_user_id)
 Delete all entries for a specific user.
static isSharedWithUser ($a_usr_id, $a_calendar_id)
 is shared with user
static getSharedCalendarsForUser ($a_usr_id=0)
 get shared calendars of user

Data Fields

const TYPE_USR = 1
const TYPE_ROLE = 2

Protected Member Functions

 read ()
 read shared calendars

Protected Attributes

 $db

Private Attributes

 $calendar_id
 $shared = array()
 $shared_users = array()
 $shared_roles = array()

Detailed Description

Handles shared 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 33 of file class.ilCalendarShared.php.

Constructor & Destructor Documentation

ilCalendarShared::__construct (   $a_calendar_id)

constructor

public

Parameters
intcalendar id

Definition at line 53 of file class.ilCalendarShared.php.

References $ilDB, and read().

{
global $ilDB;
$this->calendar_id = $a_calendar_id;
$this->db = $ilDB;
$this->read();
}

+ Here is the call graph for this function:

Member Function Documentation

static ilCalendarShared::deleteByCalendar (   $a_cal_id)
static

Delete all entries for a specific calendar id.

public

Parameters
@return

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

References $ilDB, $query, and $res.

{
global $ilDB;
$query = "DELETE FROM cal_shared WHERE cal_id = ".$ilDB->quote($a_cal_id ,'integer')." ";
$res = $ilDB->manipulate($query);
return true;
}
static ilCalendarShared::deleteByUser (   $a_user_id)
static

Delete all entries for a specific user.

public

Parameters
intusr_id
Returns

Definition at line 87 of file class.ilCalendarShared.php.

References $ilDB, $query, and $res.

{
global $ilDB;
$query = "DELETE FROM cal_shared WHERE obj_id = ".$ilDB->quote($a_user_id ,'integer')." ";
$res = $ilDB->manipulate($query);
return true;
// TODO: delete also cal_shared_user_status
}
ilCalendarShared::getCalendarId ( )

get calendar id

public

Returns
int calendar id

Definition at line 208 of file class.ilCalendarShared.php.

References $calendar_id.

Referenced by read(), share(), and stopSharing().

{
}

+ Here is the caller graph for this function:

ilCalendarShared::getRoles ( )

get roles

public

Returns
array

Definition at line 241 of file class.ilCalendarShared.php.

{
return $this->shared_roles ? $this->shared_roles : array();
}
ilCalendarShared::getShared ( )

get shared

public

Returns
array

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

{
return $this->shared ? $this->shared : array();
}
static ilCalendarShared::getSharedCalendarsForUser (   $a_usr_id = 0)
static

get shared calendars of user

public

Parameters
intuser id
Returns
array shared calendar info

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

References $ilDB, $query, $res, $row, $shared, ilCalendarCategories\_isOwner(), and DB_FETCHMODE_OBJECT.

Referenced by ilCalendarInboxGUI\inbox(), and ilCalendarCategoryGUI\readPermissions().

{
global $ilDB,$ilUser,$rbacreview;
if(!$a_usr_id)
{
$a_usr_id = $ilUser->getId();
}
$query = "SELECT * FROM cal_shared ".
"WHERE obj_type = ".$ilDB->quote(self::TYPE_USR ,'integer')." ".
"AND obj_id = ".$ilDB->quote($a_usr_id ,'integer')." ".
"ORDER BY create_date";
$res = $ilDB->query($query);
$calendars = array();
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$calendars[] = $row->cal_id;
$shared[$row->cal_id]['cal_id'] = $row->cal_id;
$shared[$row->cal_id]['create_date'] = $row->create_date;
$shared[$row->cal_id]['obj_type'] = $row->obj_type;
}
$assigned_roles = $rbacreview->assignedRoles($ilUser->getId());
$query = "SELECT * FROM cal_shared ".
"WHERE obj_type = ".$ilDB->quote(self::TYPE_ROLE ,'integer')." ".
"AND ".$ilDB->in('obj_id',$assigned_roles,false ,'integer');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
if(in_array($row->cal_id,$calendars))
{
continue;
}
if(ilCalendarCategories::_isOwner($ilUser->getId(),$row->cal_id))
{
continue;
}
$shared[$row->cal_id]['cal_id'] = $row->cal_id;
$shared[$row->cal_id]['create_date'] = $row->create_date;
$shared[$row->cal_id]['obj_type'] = $row->obj_type;
}
return $shared ? $shared : array();
// TODO: return also role calendars
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCalendarShared::getUsers ( )

get users

public

Returns
array

Definition at line 230 of file class.ilCalendarShared.php.

{
return $this->shared_users ? $this->shared_users : array();
}
ilCalendarShared::isShared (   $a_obj_id)

Check if calendar is already shared with specific user or role.

public

Parameters
intobj_id
Returns
bool

Definition at line 253 of file class.ilCalendarShared.php.

Referenced by share(), and stopSharing().

{
return isset($this->shared[$a_obj_id]);
}

+ Here is the caller graph for this function:

static ilCalendarShared::isSharedWithUser (   $a_usr_id,
  $a_calendar_id 
)
static

is shared with user

public

Parameters
intusr_id
intcalendar id
Returns
bool

Definition at line 107 of file class.ilCalendarShared.php.

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

Referenced by ilCalendarInboxGUI\acceptShared(), ilCalendarInboxGUI\declineShared(), and ilCalendarCategoryGUI\unshare().

{
global $ilDB,$rbacreview;
$query = 'SELECT * FROM cal_shared '.
"WHERE cal_id = ".$ilDB->quote($a_calendar_id ,'integer')." ";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$obj_ids[$row->obj_id] = $row->obj_type;
}
$assigned_roles = $rbacreview->assignedRoles($a_usr_id);
foreach($obj_ids as $id => $type)
{
switch($type)
{
case self::TYPE_USR:
if($a_usr_id == $id)
{
return true;
}
break;
case self::TYPE_ROLE:
if(in_array($id,$assigned_roles))
{
return true;
}
break;
}
}
return false;
}

+ Here is the caller graph for this function:

ilCalendarShared::read ( )
protected

read shared calendars

protected

Returns

Definition at line 320 of file class.ilCalendarShared.php.

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

Referenced by __construct(), share(), and stopSharing().

{
global $ilDB;
$this->shared = $this->shared_users = $this->shared_roles = array();
$query = "SELECT * FROM cal_shared WHERE cal_id = ".$this->db->quote($this->getCalendarId() ,'integer');
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
switch($row->obj_type)
{
case self::TYPE_USR:
$this->shared_users[$row->obj_id]['obj_id'] = $row->obj_id;
$this->shared_users[$row->obj_id]['obj_type'] = $row->obj_type;
$this->shared_users[$row->obj_id]['create_date'] = $row->create_date;
break;
case self::TYPE_ROLE:
$this->shared_roles[$row->obj_id]['obj_id'] = $row->obj_id;
$this->shared_roles[$row->obj_id]['obj_type'] = $row->obj_type;
$this->shared_roles[$row->obj_id]['create_date'] = $row->create_date;
break;
}
$this->shared[$row->obj_id]['obj_id'] = $row->obj_id;
$this->shared[$row->obj_id]['obj_type'] = $row->obj_type;
$this->shared[$row->obj_id]['create_date'] = $row->create_date;
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCalendarShared::share (   $a_obj_id,
  $a_type 
)

share calendar

public

Parameters
intobj_id
inttype
Returns
bool

Definition at line 266 of file class.ilCalendarShared.php.

References $ilDB, $query, $res, getCalendarId(), isShared(), and read().

{
global $ilDB;
if($this->isShared($a_obj_id))
{
return false;
}
$query = "INSERT INTO cal_shared (cal_id,obj_id,obj_type,create_date) ".
"VALUES ( ".
$this->db->quote($this->getCalendarId() ,'integer').", ".
$this->db->quote($a_obj_id ,'integer').", ".
$this->db->quote($a_type ,'integer').", ".
$ilDB->now()." ".
")";
$res = $ilDB->manipulate($query);
$this->read();
return true;
}

+ Here is the call graph for this function:

ilCalendarShared::stopSharing (   $a_obj_id)

stop sharing

public

Parameters
intobj_id
Returns
bool

Definition at line 294 of file class.ilCalendarShared.php.

References $ilDB, $query, $res, ilCalendarSharedStatus\deleteStatus(), getCalendarId(), isShared(), and read().

{
global $ilDB;
if(!$this->isShared($a_obj_id))
{
return false;
}
$query = "DELETE FROM cal_shared WHERE cal_id = ".$this->db->quote($this->getCalendarId() ,'integer')." ".
"AND obj_id = ".$this->db->quote($a_obj_id ,'integer')." ";
$res = $ilDB->manipulate($query);
include_once('./Services/Calendar/classes/class.ilCalendarSharedStatus.php');
$this->read();
return true;
}

+ Here is the call graph for this function:

Field Documentation

ilCalendarShared::$calendar_id
private

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

Referenced by getCalendarId().

ilCalendarShared::$db
protected

Definition at line 44 of file class.ilCalendarShared.php.

ilCalendarShared::$shared = array()
private

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

Referenced by getSharedCalendarsForUser().

ilCalendarShared::$shared_roles = array()
private

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

ilCalendarShared::$shared_users = array()
private

Definition at line 41 of file class.ilCalendarShared.php.

const ilCalendarShared::TYPE_ROLE = 2
const ilCalendarShared::TYPE_USR = 1

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