ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

public

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

References $ilDB, and read().

79  {
80  global $ilDB;
81 
82  $this->db = $ilDB;
83  $this->cat_id = $a_cat_id;
84 
85  $this->read();
86  }
global $ilDB
+ 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
object

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

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

Referenced by ilCalendarAppEventListener\createCategory(), ilCalendarSubscriptionGUI\show(), and ilCalendarAppEventListener\updateCategory().

96  {
97  global $ilDB;
98 
99  $query = "SELECT cat_id FROM cal_categories " .
100  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
101  "AND type = " . $ilDB->quote(self::TYPE_OBJ, 'integer');
102  $res = $ilDB->query($query);
103  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
104  return new ilCalendarCategory($row->cat_id);
105  }
106  return null;
107  }
Stores calendar categories.
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ add()

ilCalendarCategory::add ( )

add new category

public

Returns

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

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

328  {
329  global $ilDB;
330 
331  $next_id = $ilDB->nextId('cal_categories');
332 
333  $query = "INSERT INTO cal_categories (cat_id,obj_id,color,type,title,loc_type,remote_url,remote_user,remote_pass,remote_sync) " .
334  "VALUES ( " .
335  $ilDB->quote($next_id, 'integer') . ", " .
336  $this->db->quote($this->getObjId(), 'integer') . ", " .
337  $this->db->quote($this->getColor(), 'text') . ", " .
338  $this->db->quote($this->getType(), 'integer') . ", " .
339  $this->db->quote($this->getTitle(), 'text') . ", " .
340  $this->db->quote($this->getLocationType(), 'integer') . ', ' .
341  $this->db->quote($this->getRemoteUrl(), 'text') . ', ' .
342  $this->db->quote($this->getRemoteUser(), 'text') . ', ' .
343  $this->db->quote($this->getRemotePass(), 'text') . ', ' .
344  $this->db->quote($this->getRemoteSyncLastExecution()->get(IL_CAL_DATETIME, '', ilTimeZone::UTC), 'timestamp') . ' ' .
345  ")";
346 
347  $ilDB->manipulate($query);
348 
349  $this->cat_id = $next_id;
350  return $this->cat_id;
351  }
const IL_CAL_DATETIME
getRemoteSyncLastExecution()
Get last execution date of remote sync.
$query
global $ilDB
+ Here is the call graph for this function:

◆ delete()

ilCalendarCategory::delete ( )

delete

public

Returns

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

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

385  {
386  global $ilDB;
387 
388  $query = "DELETE FROM cal_categories " .
389  "WHERE cat_id = " . $this->db->quote($this->cat_id, 'integer') . " ";
390  $res = $ilDB->manipulate($query);
391 
392  include_once('./Services/Calendar/classes/class.ilCalendarVisibility.php');
394 
395  include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
396  foreach (ilCalendarCategoryAssignments::_getAssignedAppointments(array($this->cat_id)) as $app_id) {
397  include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
398  ilCalendarEntry::_delete($app_id);
399  }
401  }
static _deleteCategories($a_cat_id)
delete by category
static _delete($a_entry_id)
delete entry
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
static _deleteByCategoryId($a_cat_id)
Delete assignments by category id.
static _getAssignedAppointments($a_cat_id)
Get assigned apointments.
global $ilDB
+ Here is the call graph for this function:

◆ getCategoryID()

ilCalendarCategory::getCategoryID ( )

get category id

public

Returns
int category id

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

References $cat_id.

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

155  {
156  return $this->cat_id;
157  }
+ Here is the caller graph for this function:

◆ getColor()

ilCalendarCategory::getColor ( )

get color

public

Returns

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

References $color.

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

201  {
202  return $this->color;
203  }
+ Here is the caller graph for this function:

◆ getInstanceByCategoryId()

static ilCalendarCategory::getInstanceByCategoryId (   $a_cat_id)
static

◆ getLocationType()

ilCalendarCategory::getLocationType ( )

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

References $location.

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

260  {
261  return $this->location;
262  }
+ Here is the caller graph for this function:

◆ getObjId()

ilCalendarCategory::getObjId ( )

get obj_id

public

Returns

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

References $obj_id.

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

245  {
246  return $this->obj_id;
247  }
+ Here is the caller graph for this function:

◆ getObjType()

ilCalendarCategory::getObjType ( )

get type

public

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

References $obj_type.

255  {
256  return $this->obj_type;
257  }

◆ getRemotePass()

ilCalendarCategory::getRemotePass ( )

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

References $remote_pass.

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

295  {
296  return $this->remote_pass;
297  }
+ Here is the caller graph for this function:

◆ getRemoteSyncLastExecution()

ilCalendarCategory::getRemoteSyncLastExecution ( )

Get last execution date of remote sync.

Returns

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

References $remote_sync.

Referenced by add(), and update().

313  {
314  if ($this->remote_sync instanceof ilDateTime) {
315  return $this->remote_sync;
316  }
317  return new ilDateTime();
318  }
Date and time handling
+ Here is the caller graph for this function:

◆ getRemoteUrl()

ilCalendarCategory::getRemoteUrl ( )

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

References $remote_url.

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

275  {
276  return $this->remote_url;
277  }
+ Here is the caller graph for this function:

◆ getRemoteUser()

ilCalendarCategory::getRemoteUser ( )

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

References $remote_user.

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

285  {
286  return $this->remote_user;
287  }
+ Here is the caller graph for this function:

◆ getTitle()

ilCalendarCategory::getTitle ( )

get title

public

Returns
string title

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

References $title.

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

178  {
179  return $this->title;
180  }
+ Here is the caller graph for this function:

◆ getType()

ilCalendarCategory::getType ( )

get type

public

Returns

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

References $type.

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

223  {
224  return $this->type;
225  }
+ 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 134 of file class.ilCalendarCategory.php.

References $ilDB, $query, $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

135  {
136  global $ilDB;
137 
138  $query = "SELECT * FROM cal_cat_assignments " .
139  'WHERE cat_id = ' . $ilDB->quote($a_category_id, 'integer');
140  $res = $ilDB->query($query);
141  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
142  $apps[] = $row->cal_id;
143  }
144  return $apps ? $apps : array();
145  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB

◆ lookupCategorySortIndex()

static ilCalendarCategory::lookupCategorySortIndex (   $a_type_id)
static

Lookup sort index of calendar type.

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

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

126  {
127  return array_search($a_type_id, self::$SORTED_TYPES);
128  }
+ Here is the caller graph for this function:

◆ read()

ilCalendarCategory::read ( )
private

read

protected

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

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

Referenced by __construct().

426  {
427  global $ilDB;
428 
429  if (!$this->cat_id) {
430  return true;
431  }
432 
433  $query = "SELECT * FROM cal_categories " .
434  "WHERE cat_id = " . $this->db->quote($this->getCategoryID(), 'integer') . " ";
435  $res = $this->db->query($query);
436  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
437  $this->cat_id = $row->cat_id;
438  $this->obj_id = $row->obj_id;
439  $this->type = $row->type;
440  $this->color = $row->color;
441  $this->title = $row->title;
442  $this->location = $row->loc_type;
443  $this->remote_url = $row->remote_url;
444  $this->remote_user = $row->remote_user;
445  $this->remote_pass = $row->remote_pass;
446 
447  if ($row->remote_sync) {
448  $this->remote_sync = new ilDateTime($row->remote_sync, IL_CAL_DATETIME, 'UTC');
449  } else {
450  $this->remote_sync = new ilDateTime();
451  }
452  }
453  if ($this->getType() == self::TYPE_OBJ) {
454  $this->title = ilObject::_lookupTitle($this->getObjId());
455  $this->obj_type = ilObject::_lookupType($this->getObjId());
456  }
457  }
const IL_CAL_DATETIME
static _lookupTitle($a_id)
lookup object title
Set the worksheet tab color
foreach($_POST as $key=> $value) $res
Date and time handling
$query
static _lookupType($a_id, $a_reference=false)
lookup object type
global $ilDB
getCategoryID()
get category id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setColor()

ilCalendarCategory::setColor (   $a_color)

set color

public

Parameters
stringcolor

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

References color.

190  {
191  $this->color = $a_color;
192  }
Set the worksheet tab color

◆ setLocationType()

ilCalendarCategory::setLocationType (   $a_type)

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

References $a_type.

265  {
266  $this->location = $a_type;
267  }
$a_type
Definition: workflow.php:92

◆ setObjId()

ilCalendarCategory::setObjId (   $a_obj_id)

set obj id

public

Parameters
intobj_id

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

234  {
235  $this->obj_id = $a_obj_id;
236  }

◆ setRemotePass()

ilCalendarCategory::setRemotePass (   $a_pass)

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

290  {
291  $this->remote_pass = $a_pass;
292  }

◆ setRemoteSyncLastExecution()

ilCalendarCategory::setRemoteSyncLastExecution ( ilDateTime  $dt = null)

Set remote sync last execution.

Parameters
ilDateTime$dt

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

304  {
305  $this->remote_sync = $dt;
306  }

◆ setRemoteUrl()

ilCalendarCategory::setRemoteUrl (   $a_url)

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

270  {
271  $this->remote_url = $a_url;
272  }

◆ setRemoteUser()

ilCalendarCategory::setRemoteUser (   $a_user)

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

280  {
281  $this->remote_user = $a_user;
282  }

◆ setTitle()

ilCalendarCategory::setTitle (   $a_title)

set title

public

Parameters
stringtitle
Returns

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

167  {
168  $this->title = $a_title;
169  }

◆ setType()

ilCalendarCategory::setType (   $a_type)

set type

public

Parameters
inttype

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

References $a_type.

212  {
213  $this->type = $a_type;
214  }
$a_type
Definition: workflow.php:92

◆ update()

ilCalendarCategory::update ( )

update

public

Returns

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

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

360  {
361  global $ilDB;
362 
363  $query = "UPDATE cal_categories " .
364  "SET obj_id = " . $this->db->quote($this->getObjId(), 'integer') . ", " .
365  "color = " . $this->db->quote($this->getColor(), 'text') . ", " .
366  "type = " . $this->db->quote($this->getType(), 'integer') . ", " .
367  "title = " . $this->db->quote($this->getTitle(), 'text') . ", " .
368  "loc_type = " . $this->db->quote($this->getLocationType(), 'integer') . ', ' .
369  "remote_url = " . $this->db->quote($this->getRemoteUrl(), 'text') . ', ' .
370  "remote_user = " . $this->db->quote($this->getRemoteUser(), 'text') . ', ' .
371  "remote_pass = " . $this->db->quote($this->getRemotePass(), 'text') . ', ' .
372  'remote_sync = ' . $this->db->quote($this->getRemoteSyncLastExecution()->get(IL_CAL_DATETIME, '', ilTimeZone::UTC), 'timestamp') . ' ' .
373  "WHERE cat_id = " . $this->db->quote($this->cat_id, 'integer') . " ";
374  $res = $ilDB->manipulate($query);
375  return true;
376  }
const IL_CAL_DATETIME
getRemoteSyncLastExecution()
Get last execution date of remote sync.
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:

◆ validate()

ilCalendarCategory::validate ( )

validate

public

Returns
bool

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

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

410  {
411  if ($this->getLocationType() == ilCalendarCategory::LTYPE_REMOTE and !$this->getRemoteUrl()) {
412  return false;
413  }
414  if (strlen($this->getTitle()) and strlen($this->getColor()) and $this->getType()) {
415  return true;
416  }
417  return false;
418  }
+ 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:
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: