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

Stores calendar categories. More...

+ Collaboration diagram for ilCalendarCategory:

Public Member Functions

 __construct ($a_cat_id=0)
 Constructor.
 getCategoryID ()
 get category id
 setTitle ($a_title)
 set title
 getTitle ()
 get title
 setColor ($a_color)
 set color
 getColor ()
 get color
 setType ($a_type)
 set type
 getType ()
 get type
 setObjId ($a_obj_id)
 set obj id
 getObjId ()
 get obj_id
 getObjType ()
 get type
 add ()
 add new category
 update ()
 update
 delete ()
 delete
 validate ()
 validate

Static Public Member Functions

static _getInstanceByObjId ($a_obj_id)
 get instance by obj_id
static getInstanceByCategoryId ($a_cat_id)
 Get instance by category id.
static lookupAppointments ($a_category_id)
 get all assigned appointment ids

Data Fields

const DEFAULT_COLOR = '#04427e'
const TYPE_USR = 1
const TYPE_OBJ = 2
const TYPE_GLOBAL = 3
const TYPE_CH = 4
const TYPE_BOOK = 5

Protected Attributes

 $cat_id
 $color
 $type = self::TYPE_USR
 $obj_id
 $obj_type = null
 $title
 $db

Private Member Functions

 read ()
 read

Static Private Attributes

static $instances = null

Detailed Description

Stores calendar categories.

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.ilCalendarCategory.php.

Constructor & Destructor Documentation

ilCalendarCategory::__construct (   $a_cat_id = 0)

Constructor.

public

Definition at line 60 of file class.ilCalendarCategory.php.

References $ilDB, and read().

{
global $ilDB;
$this->db = $ilDB;
$this->cat_id = $a_cat_id;
$this->read();
}

+ Here is the call graph for this function:

Member Function Documentation

static ilCalendarCategory::_getInstanceByObjId (   $a_obj_id)
static

get instance by obj_id

Parameters
intobj_id
Returns
object

Definition at line 77 of file class.ilCalendarCategory.php.

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

Referenced by ilCalendarAppEventListener\updateCategory().

{
global $ilDB;
$query = "SELECT cat_id FROM cal_categories ".
"WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ".
"AND type = ".$ilDB->quote(self::TYPE_OBJ ,'integer');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return new ilCalendarCategory($row->cat_id);
}
return null;
}

+ Here is the caller graph for this function:

ilCalendarCategory::add ( )

add new category

public

Returns

Definition at line 245 of file class.ilCalendarCategory.php.

References $cat_id, $ilDB, $query, $res, getColor(), getObjId(), getTitle(), and getType().

{
global $ilDB;
$next_id = $ilDB->nextId('cal_categories');
$query = "INSERT INTO cal_categories (cat_id,obj_id,color,type,title) ".
"VALUES ( ".
$ilDB->quote($next_id,'integer').", ".
$this->db->quote($this->getObjId() ,'integer').", ".
$this->db->quote($this->getColor() ,'text').", ".
$this->db->quote($this->getType() ,'integer').", ".
$this->db->quote($this->getTitle() ,'text')." ".
")";
$res = $ilDB->manipulate($query);
$this->cat_id = $next_id;
return $this->cat_id;
}

+ Here is the call graph for this function:

ilCalendarCategory::delete ( )

delete

public

Returns

Definition at line 291 of file class.ilCalendarCategory.php.

References $ilDB, $query, $res, ilCalendarEntry\_delete(), ilCalendarCategoryAssignments\_deleteByCategoryId(), ilCalendarHidden\_deleteCategories(), and ilCalendarCategoryAssignments\_getAssignedAppointments().

{
global $ilDB;
$query = "DELETE FROM cal_categories ".
"WHERE cat_id = ".$this->db->quote($this->cat_id ,'integer')." ";
$res = $ilDB->manipulate($query);
include_once('./Services/Calendar/classes/class.ilCalendarHidden.php');
include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
foreach(ilCalendarCategoryAssignments::_getAssignedAppointments(array($this->cat_id)) as $app_id)
{
include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
}
}

+ Here is the call graph for this function:

ilCalendarCategory::getCategoryID ( )

get category id

public

Returns
int category id

Definition at line 133 of file class.ilCalendarCategory.php.

References $cat_id.

Referenced by read().

{
return $this->cat_id;
}

+ Here is the caller graph for this function:

ilCalendarCategory::getColor ( )

get color

public

Returns

Definition at line 179 of file class.ilCalendarCategory.php.

References $color.

Referenced by add(), update(), and validate().

{
return $this->color;
}

+ Here is the caller graph for this function:

static ilCalendarCategory::getInstanceByCategoryId (   $a_cat_id)
static

Get instance by category id.

Parameters
int$a_cat_id
Returns
ilCalendarCategory

Definition at line 97 of file class.ilCalendarCategory.php.

Referenced by ilCalendarExport\buildAppointmentUrl().

{
if(!self::$instances[$a_cat_id])
{
return self::$instances[$a_cat_id] = new ilCalendarCategory($a_cat_id);
}
return self::$instances[$a_cat_id];
}

+ Here is the caller graph for this function:

ilCalendarCategory::getObjId ( )

get obj_id

public

Returns

Definition at line 223 of file class.ilCalendarCategory.php.

References $obj_id.

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

{
return $this->obj_id;
}

+ Here is the caller graph for this function:

ilCalendarCategory::getObjType ( )

get type

public

Definition at line 233 of file class.ilCalendarCategory.php.

References $obj_type.

{
}
ilCalendarCategory::getTitle ( )

get title

public

Returns
string title

Definition at line 156 of file class.ilCalendarCategory.php.

References $title.

Referenced by add(), update(), and validate().

{
return $this->title;
}

+ Here is the caller graph for this function:

ilCalendarCategory::getType ( )

get type

public

Returns

Definition at line 201 of file class.ilCalendarCategory.php.

References $type.

Referenced by add(), read(), update(), and validate().

{
return $this->type;
}

+ Here is the caller graph for this function:

static ilCalendarCategory::lookupAppointments (   $a_category_id)
static

get all assigned appointment ids

Returns
Parameters
object$a_category_id

Definition at line 112 of file class.ilCalendarCategory.php.

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

{
global $ilDB;
$query = "SELECT * FROM cal_cat_assignments ".
'WHERE cat_id = '.$ilDB->quote($a_category_id,'integer');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$apps[] = $row->cal_id;
}
return $apps ? $apps : array();
}
ilCalendarCategory::read ( )
private

read

protected

Definition at line 327 of file class.ilCalendarCategory.php.

References $ilDB, $query, $res, $row, ilObject\_lookupTitle(), ilObject\_lookupType(), DB_FETCHMODE_OBJECT, getCategoryID(), getObjId(), getType(), and TYPE_OBJ.

Referenced by __construct().

{
global $ilDB;
if(!$this->cat_id)
{
return true;
}
$query = "SELECT * FROM cal_categories ".
"WHERE cat_id = ".$this->db->quote($this->getCategoryID() ,'integer')." ";
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->cat_id = $row->cat_id;
$this->obj_id = $row->obj_id;
$this->type = $row->type;
$this->color = $row->color;
$this->title = $row->title;
}
if($this->getType() == self::TYPE_OBJ)
{
$this->title = ilObject::_lookupTitle($this->getObjId());
$this->obj_type = ilObject::_lookupType($this->getObjId());
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCalendarCategory::setColor (   $a_color)

set color

public

Parameters
stringcolor

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

{
$this->color = $a_color;
}
ilCalendarCategory::setObjId (   $a_obj_id)

set obj id

public

Parameters
intobj_id

Definition at line 212 of file class.ilCalendarCategory.php.

{
$this->obj_id = $a_obj_id;
}
ilCalendarCategory::setTitle (   $a_title)

set title

public

Parameters
stringtitle
Returns

Definition at line 145 of file class.ilCalendarCategory.php.

{
$this->title = $a_title;
}
ilCalendarCategory::setType (   $a_type)

set type

public

Parameters
inttype

Definition at line 190 of file class.ilCalendarCategory.php.

{
$this->type = $a_type;
}
ilCalendarCategory::update ( )

update

public

Returns

Definition at line 271 of file class.ilCalendarCategory.php.

References $ilDB, $query, $res, getColor(), getObjId(), getTitle(), and getType().

{
global $ilDB;
$query = "UPDATE cal_categories ".
"SET obj_id = ".$this->db->quote($this->getObjId() ,'integer').", ".
"color = ".$this->db->quote($this->getColor() ,'text').", ".
"type = ".$this->db->quote($this->getType() ,'integer').", ".
"title = ".$this->db->quote($this->getTitle() ,'text')." ".
"WHERE cat_id = ".$this->db->quote($this->cat_id ,'integer')." ";
$res = $ilDB->manipulate($query);
return true;
}

+ Here is the call graph for this function:

ilCalendarCategory::validate ( )

validate

public

Returns
bool

Definition at line 317 of file class.ilCalendarCategory.php.

References getColor(), getTitle(), and getType().

{
return strlen($this->getTitle()) and strlen($this->getColor()) and $this->getType();
}

+ Here is the call graph for this function:

Field Documentation

ilCalendarCategory::$cat_id
protected

Definition at line 45 of file class.ilCalendarCategory.php.

Referenced by add(), and getCategoryID().

ilCalendarCategory::$color
protected

Definition at line 46 of file class.ilCalendarCategory.php.

Referenced by getColor().

ilCalendarCategory::$db
protected

Definition at line 52 of file class.ilCalendarCategory.php.

ilCalendarCategory::$instances = null
staticprivate

Definition at line 35 of file class.ilCalendarCategory.php.

ilCalendarCategory::$obj_id
protected

Definition at line 48 of file class.ilCalendarCategory.php.

Referenced by getObjId().

ilCalendarCategory::$obj_type = null
protected

Definition at line 49 of file class.ilCalendarCategory.php.

Referenced by getObjType().

ilCalendarCategory::$title
protected

Definition at line 50 of file class.ilCalendarCategory.php.

Referenced by getTitle().

ilCalendarCategory::$type = self::TYPE_USR
protected

Definition at line 47 of file class.ilCalendarCategory.php.

Referenced by getType().

const ilCalendarCategory::DEFAULT_COLOR = '#04427e'

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