ILIAS  release_7 Revision v7.30-3-g800a261c036
ilCalendarCategory Class Reference

Stores calendar categories. More...

+ Collaboration diagram for ilCalendarCategory:

Public Member Functions

 __construct ($a_cat_id=0)
 Constructor. More...
 
 getCategoryID ()
 get category id More...
 
 setTitle ($a_title)
 set title More...
 
 getTitle ()
 get title More...
 
 setColor ($a_color)
 set color More...
 
 getColor ()
 get color More...
 
 setType ($a_type)
 set type More...
 
 getType ()
 get type More...
 
 setObjId ($a_obj_id)
 set obj id More...
 
 getObjId ()
 get obj_id More...
 
 getObjType ()
 get type More...
 
 getLocationType ()
 
 setLocationType ($a_type)
 
 setRemoteUrl ($a_url)
 
 getRemoteUrl ()
 
 setRemoteUser ($a_user)
 
 getRemoteUser ()
 
 setRemotePass ($a_pass)
 
 getRemotePass ()
 
 setRemoteSyncLastExecution (ilDateTime $dt=null)
 Set remote sync last execution. More...
 
 getRemoteSyncLastExecution ()
 Get last execution date of remote sync. More...
 
 add ()
 add new category More...
 
 update ()
 update More...
 
 delete ()
 delete More...
 
 validate ()
 validate More...
 

Static Public Member Functions

static _getInstanceByObjId ($a_obj_id)
 get instance by obj_id More...
 
static getInstanceByCategoryId ($a_cat_id)
 Get instance by category id. More...
 
static lookupCategorySortIndex ($a_type_id)
 Lookup sort index of calendar type. More...
 
static lookupAppointments ($a_category_id)
 get all assigned appointment ids More...
 

Data Fields

const LTYPE_LOCAL = 1
 
const LTYPE_REMOTE = 2
 
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
 
 $location = self::LTYPE_LOCAL
 
 $remote_url
 
 $remote_user
 
 $remote_pass
 
 $remote_sync = null
 
 $db
 

Static Protected Attributes

static $SORTED_TYPES
 

Private Member Functions

 read ()
 read More...
 

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

◆ __construct()

ilCalendarCategory::__construct (   $a_cat_id = 0)

Constructor.

@access public

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

79 {
80 global $DIC;
81
82 $ilDB = $DIC['ilDB'];
83
84 $this->db = $ilDB;
85 $this->cat_id = $a_cat_id;
86
87 $this->read();
88 }
global $DIC
Definition: goto.php:24
global $ilDB

References $DIC, $ilDB, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ _getInstanceByObjId()

static ilCalendarCategory::_getInstanceByObjId (   $a_obj_id)
static

get instance by obj_id

Parameters
intobj_id
Returns
\ilCalendarCategory

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

98 {
99 global $DIC;
100
101 $ilDB = $DIC['ilDB'];
102
103 $query = "SELECT cat_id FROM cal_categories " .
104 "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
105 "AND type = " . $ilDB->quote(self::TYPE_OBJ, 'integer');
106 $res = $ilDB->query($query);
107 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
108 return new ilCalendarCategory($row->cat_id);
109 }
110 return null;
111 }
Stores calendar categories.
$query
foreach($_POST as $key=> $value) $res

References $DIC, $ilDB, $query, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilCalendarPresentationGUI\__construct(), ilCalendarPresentationGUI\addStandardTabs(), ilCalendarAppEventListener\createCategory(), ilCalendarSubscriptionGUI\getModalForSubscription(), ilCalendarSubscriptionGUI\show(), and ilCalendarAppEventListener\updateCategory().

+ Here is the caller graph for this function:

◆ add()

ilCalendarCategory::add ( )

add new category

@access public

Returns

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

334 {
335 global $DIC;
336
337 $ilDB = $DIC['ilDB'];
338
339 $next_id = $ilDB->nextId('cal_categories');
340
341 $query = "INSERT INTO cal_categories (cat_id,obj_id,color,type,title,loc_type,remote_url,remote_user,remote_pass,remote_sync) " .
342 "VALUES ( " .
343 $ilDB->quote($next_id, 'integer') . ", " .
344 $this->db->quote($this->getObjId(), 'integer') . ", " .
345 $this->db->quote($this->getColor(), 'text') . ", " .
346 $this->db->quote($this->getType(), 'integer') . ", " .
347 $this->db->quote($this->getTitle(), 'text') . ", " .
348 $this->db->quote($this->getLocationType(), 'integer') . ', ' .
349 $this->db->quote($this->getRemoteUrl(), 'text') . ', ' .
350 $this->db->quote($this->getRemoteUser(), 'text') . ', ' .
351 $this->db->quote($this->getRemotePass(), 'text') . ', ' .
352 $this->db->quote($this->getRemoteSyncLastExecution()->get(IL_CAL_DATETIME, '', ilTimeZone::UTC), 'timestamp') . ' ' .
353 ")";
354
355 $ilDB->manipulate($query);
356
357 $this->cat_id = $next_id;
358 return $this->cat_id;
359 }
const IL_CAL_DATETIME
getRemoteSyncLastExecution()
Get last execution date of remote sync.

References $cat_id, $DIC, $ilDB, $query, getColor(), getLocationType(), getObjId(), getRemotePass(), getRemoteSyncLastExecution(), getRemoteUrl(), getRemoteUser(), getTitle(), getType(), IL_CAL_DATETIME, and ilTimeZone\UTC.

+ Here is the call graph for this function:

◆ delete()

ilCalendarCategory::delete ( )

delete

@access public

Returns

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

395 {
396 global $DIC;
397
398 $ilDB = $DIC['ilDB'];
399
400 $query = "DELETE FROM cal_categories " .
401 "WHERE cat_id = " . $this->db->quote($this->cat_id, 'integer') . " ";
402 $res = $ilDB->manipulate($query);
403
404 include_once('./Services/Calendar/classes/class.ilCalendarVisibility.php');
406
407 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
408 foreach (ilCalendarCategoryAssignments::_getAssignedAppointments(array($this->cat_id)) as $app_id) {
409 include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
411 }
413 }
static _getAssignedAppointments($a_cat_id)
Get assigned apointments.
static _deleteByCategoryId($a_cat_id)
Delete assignments by category id.
static _delete($a_entry_id)
delete entry
static _deleteCategories($a_cat_id)
delete by category

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

+ Here is the call graph for this function:

◆ getCategoryID()

ilCalendarCategory::getCategoryID ( )

get category id

@access public

Returns
int category id

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

161 {
162 return $this->cat_id;
163 }

References $cat_id.

Referenced by ilCalendarRemoteReader\importIcal(), and read().

+ Here is the caller graph for this function:

◆ getColor()

ilCalendarCategory::getColor ( )

get color

@access public

Returns

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

References $color.

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

+ Here is the caller graph for this function:

◆ getInstanceByCategoryId()

static ilCalendarCategory::getInstanceByCategoryId (   $a_cat_id)
static

◆ getLocationType()

ilCalendarCategory::getLocationType ( )

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

References $location.

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

+ Here is the caller graph for this function:

◆ getObjId()

ilCalendarCategory::getObjId ( )

get obj_id

@access public

Returns

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

References $obj_id.

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

+ Here is the caller graph for this function:

◆ getObjType()

ilCalendarCategory::getObjType ( )

get type

@access public

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

References $obj_type.

◆ getRemotePass()

ilCalendarCategory::getRemotePass ( )

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

References $remote_pass.

Referenced by add(), ilCalendarCategoryGUI\doSynchronisation(), and update().

+ Here is the caller graph for this function:

◆ getRemoteSyncLastExecution()

ilCalendarCategory::getRemoteSyncLastExecution ( )

Get last execution date of remote sync.

Returns
\ilDateTime

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

319 {
320 if ($this->remote_sync instanceof ilDateTime) {
321 return $this->remote_sync;
322 }
323 return new ilDateTime();
324 }
@classDescription Date and time handling

References $remote_sync.

Referenced by add(), and update().

+ Here is the caller graph for this function:

◆ getRemoteUrl()

ilCalendarCategory::getRemoteUrl ( )

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

References $remote_url.

Referenced by add(), ilCalendarCategoryGUI\doSynchronisation(), update(), and validate().

+ Here is the caller graph for this function:

◆ getRemoteUser()

ilCalendarCategory::getRemoteUser ( )

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

References $remote_user.

Referenced by add(), ilCalendarCategoryGUI\doSynchronisation(), and update().

+ Here is the caller graph for this function:

◆ getTitle()

ilCalendarCategory::getTitle ( )

get title

@access public

Returns
string title

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

References $title.

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

+ Here is the caller graph for this function:

◆ getType()

ilCalendarCategory::getType ( )

get type

@access public

Returns

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

229 {
230 return $this->type;
231 }

References $type.

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

+ Here is the caller graph for this function:

◆ lookupAppointments()

static ilCalendarCategory::lookupAppointments (   $a_category_id)
static

get all assigned appointment ids

Returns
Parameters
object$a_category_id

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

139 {
140 global $DIC;
141
142 $ilDB = $DIC['ilDB'];
143
144 $query = "SELECT * FROM cal_cat_assignments " .
145 'WHERE cat_id = ' . $ilDB->quote($a_category_id, 'integer');
146 $res = $ilDB->query($query);
147 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
148 $apps[] = $row->cal_id;
149 }
150 return $apps ? $apps : array();
151 }

References $DIC, $ilDB, $query, $res, and ilDBConstants\FETCHMODE_OBJECT.

◆ lookupCategorySortIndex()

static ilCalendarCategory::lookupCategorySortIndex (   $a_type_id)
static

Lookup sort index of calendar type.

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

130 {
131 return array_search($a_type_id, self::$SORTED_TYPES);
132 }

Referenced by ilCalendarSelectionBlockGUI\getCalendars(), ilCalendarCategoryTableGUI\parse(), and ilCalendarManageTableGUI\parse().

+ Here is the caller graph for this function:

◆ read()

ilCalendarCategory::read ( )
private

read

@access protected

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

438 {
439 global $DIC;
440
441 $ilDB = $DIC['ilDB'];
442
443 if (!$this->cat_id) {
444 return true;
445 }
446
447 $query = "SELECT * FROM cal_categories " .
448 "WHERE cat_id = " . $this->db->quote($this->getCategoryID(), 'integer') . " ";
449 $res = $this->db->query($query);
450 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
451 $this->cat_id = $row->cat_id;
452 $this->obj_id = $row->obj_id;
453 $this->type = $row->type;
454 $this->color = $row->color;
455 $this->title = $row->title;
456 $this->location = $row->loc_type;
457 $this->remote_url = $row->remote_url;
458 $this->remote_user = $row->remote_user;
459 $this->remote_pass = $row->remote_pass;
460
461 if ($row->remote_sync) {
462 $this->remote_sync = new ilDateTime($row->remote_sync, IL_CAL_DATETIME, 'UTC');
463 } else {
464 $this->remote_sync = new ilDateTime();
465 }
466 }
467 if ($this->getType() == self::TYPE_OBJ) {
468 $this->title = ilObject::_lookupTitle($this->getObjId());
469 $this->obj_type = ilObject::_lookupType($this->getObjId());
470 }
471 }
static _lookupTitle($a_id)
lookup object title
static _lookupType($a_id, $a_reference=false)
lookup object type

References $DIC, $ilDB, $query, $res, ilObject\_lookupTitle(), ilObject\_lookupType(), ilDBConstants\FETCHMODE_OBJECT, getCategoryID(), getObjId(), getType(), and IL_CAL_DATETIME.

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setColor()

ilCalendarCategory::setColor (   $a_color)

set color

@access public

Parameters
stringcolor

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

196 {
197 $this->color = $a_color;
198 }

◆ setLocationType()

ilCalendarCategory::setLocationType (   $a_type)

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

271 {
272 $this->location = $a_type;
273 }

◆ setObjId()

ilCalendarCategory::setObjId (   $a_obj_id)

set obj id

@access public

Parameters
intobj_id

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

240 {
241 $this->obj_id = $a_obj_id;
242 }

◆ setRemotePass()

ilCalendarCategory::setRemotePass (   $a_pass)

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

296 {
297 $this->remote_pass = $a_pass;
298 }

◆ setRemoteSyncLastExecution()

ilCalendarCategory::setRemoteSyncLastExecution ( ilDateTime  $dt = null)

Set remote sync last execution.

Parameters
ilDateTime$dt

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

310 {
311 $this->remote_sync = $dt;
312 }

◆ setRemoteUrl()

ilCalendarCategory::setRemoteUrl (   $a_url)

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

276 {
277 $this->remote_url = $a_url;
278 }

◆ setRemoteUser()

ilCalendarCategory::setRemoteUser (   $a_user)

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

286 {
287 $this->remote_user = $a_user;
288 }

◆ setTitle()

ilCalendarCategory::setTitle (   $a_title)

set title

@access public

Parameters
stringtitle
Returns

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

173 {
174 $this->title = $a_title;
175 }

◆ setType()

ilCalendarCategory::setType (   $a_type)

set type

@access public

Parameters
inttype

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

218 {
219 $this->type = $a_type;
220 }

◆ update()

ilCalendarCategory::update ( )

update

@access public

Returns

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

368 {
369 global $DIC;
370
371 $ilDB = $DIC['ilDB'];
372
373 $query = "UPDATE cal_categories " .
374 "SET obj_id = " . $this->db->quote($this->getObjId(), 'integer') . ", " .
375 "color = " . $this->db->quote($this->getColor(), 'text') . ", " .
376 "type = " . $this->db->quote($this->getType(), 'integer') . ", " .
377 "title = " . $this->db->quote($this->getTitle(), 'text') . ", " .
378 "loc_type = " . $this->db->quote($this->getLocationType(), 'integer') . ', ' .
379 "remote_url = " . $this->db->quote($this->getRemoteUrl(), 'text') . ', ' .
380 "remote_user = " . $this->db->quote($this->getRemoteUser(), 'text') . ', ' .
381 "remote_pass = " . $this->db->quote($this->getRemotePass(), 'text') . ', ' .
382 'remote_sync = ' . $this->db->quote($this->getRemoteSyncLastExecution()->get(IL_CAL_DATETIME, '', ilTimeZone::UTC), 'timestamp') . ' ' .
383 "WHERE cat_id = " . $this->db->quote($this->cat_id, 'integer') . " ";
384 $res = $ilDB->manipulate($query);
385 return true;
386 }

References $DIC, $ilDB, $query, $res, getColor(), getLocationType(), getObjId(), getRemotePass(), getRemoteSyncLastExecution(), getRemoteUrl(), getRemoteUser(), getTitle(), getType(), IL_CAL_DATETIME, and ilTimeZone\UTC.

+ Here is the call graph for this function:

◆ validate()

ilCalendarCategory::validate ( )

validate

@access public

Returns
bool

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

422 {
423 if ($this->getLocationType() == ilCalendarCategory::LTYPE_REMOTE and !$this->getRemoteUrl()) {
424 return false;
425 }
426 if (strlen($this->getTitle()) and strlen($this->getColor()) and $this->getType()) {
427 return true;
428 }
429 return false;
430 }

References getColor(), getLocationType(), getRemoteUrl(), getTitle(), getType(), and LTYPE_REMOTE.

+ Here is the call graph for this function:

Field Documentation

◆ $cat_id

ilCalendarCategory::$cat_id
protected

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

Referenced by add(), and getCategoryID().

◆ $color

ilCalendarCategory::$color
protected

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

Referenced by getColor().

◆ $db

ilCalendarCategory::$db
protected

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

◆ $instances

ilCalendarCategory::$instances = null
staticprivate

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

◆ $location

ilCalendarCategory::$location = self::LTYPE_LOCAL
protected

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

Referenced by getLocationType().

◆ $obj_id

ilCalendarCategory::$obj_id
protected

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

Referenced by getObjId().

◆ $obj_type

ilCalendarCategory::$obj_type = null
protected

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

Referenced by getObjType().

◆ $remote_pass

ilCalendarCategory::$remote_pass
protected

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

Referenced by getRemotePass().

◆ $remote_sync

ilCalendarCategory::$remote_sync = null
protected

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

Referenced by getRemoteSyncLastExecution().

◆ $remote_url

ilCalendarCategory::$remote_url
protected

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

Referenced by getRemoteUrl().

◆ $remote_user

ilCalendarCategory::$remote_user
protected

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

Referenced by getRemoteUser().

◆ $SORTED_TYPES

ilCalendarCategory::$SORTED_TYPES
staticprotected
Initial value:
= array(
0 => self::TYPE_GLOBAL,
1 => self::TYPE_USR,
2 => self::TYPE_CH,
3 => self::TYPE_BOOK,
4 => self::TYPE_OBJ
)

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

◆ $title

ilCalendarCategory::$title
protected

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

Referenced by getTitle().

◆ $type

ilCalendarCategory::$type = self::TYPE_USR
protected

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

Referenced by getType().

◆ DEFAULT_COLOR

const ilCalendarCategory::DEFAULT_COLOR = '#04427e'

◆ LTYPE_LOCAL

const ilCalendarCategory::LTYPE_LOCAL = 1

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

Referenced by ilCalendarCategoryGUI\initFormCategory().

◆ LTYPE_REMOTE

◆ TYPE_BOOK

◆ TYPE_CH

◆ TYPE_GLOBAL

◆ TYPE_OBJ

◆ TYPE_USR


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