ILIAS  Release_4_0_x_branch Revision 61816
 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 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

Protected Attributes

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

Private Member Functions

 read ()
 read

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 56 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 73 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 226 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 272 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 114 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 160 of file class.ilCalendarCategory.php.

References $color.

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

{
return $this->color;
}

+ Here is the caller graph for this function:

ilCalendarCategory::getObjId ( )

get obj_id

public

Returns

Definition at line 204 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 214 of file class.ilCalendarCategory.php.

References $obj_type.

{
}
ilCalendarCategory::getTitle ( )

get title

public

Returns
string title

Definition at line 137 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 182 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 93 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 308 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 149 of file class.ilCalendarCategory.php.

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

set obj id

public

Parameters
intobj_id

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

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

set title

public

Parameters
stringtitle
Returns

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

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

set type

public

Parameters
inttype

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

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

update

public

Returns

Definition at line 252 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 298 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 41 of file class.ilCalendarCategory.php.

Referenced by add(), and getCategoryID().

ilCalendarCategory::$color
protected

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

Referenced by getColor().

ilCalendarCategory::$db
protected

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

ilCalendarCategory::$obj_id
protected

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

Referenced by getObjId().

ilCalendarCategory::$obj_type = null
protected

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

Referenced by getObjType().

ilCalendarCategory::$title
protected

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

Referenced by getTitle().

ilCalendarCategory::$type = self::TYPE_USR
protected

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

Referenced by getType().

const ilCalendarCategory::DEFAULT_COLOR = '#04427e'

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