ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
ilCalendarCategories Class Reference

class for calendar categories More...

+ Collaboration diagram for ilCalendarCategories:

Public Member Functions

 setCHUserId ($a_user_id)
 Set ch user id. More...
 
 getCHUserId ()
 Get ch user id. More...
 
 getMode ()
 
 getTargetRefId ()
 
 initialize ($a_mode, $a_source_ref_id=0, $a_use_cache=false)
 initialize visible categories More...
 
 getCategoryInfo ($a_cat_id)
 public More...
 
 getCategoriesInfo ()
 get categories More...
 
 getCategories ($a_include_subitem_calendars=false)
 get categories More...
 
 getSubitemCategories ($a_cat_id)
 get subitem categories for a specific category More...
 
 prepareCategoriesOfUserForSelection ()
 prepare categories of users for selection More...
 
 getNotificationCalendars ()
 Get all calendars that allow send of notifications (Editable and course group calendars) More...
 
 isEditable ($a_cat_id)
 check if category is editable More...
 
 isVisible ($a_cat_id)
 check if category is visible More...
 
 readConsultationHoursCalendar ($a_target_ref_id=NULL)
 Read personal consultation hours calendar. More...
 
 readBookingCalendar ($user_id=NULL)
 Read booking manager calendar. More...
 

Static Public Member Functions

static _getInstance ($a_usr_id=0)
 get singleton instance More...
 
static _lookupCategoryIdByObjId ($a_obj_id)
 lookup category by obj_id More...
 
static _isOwner ($a_usr_id, $a_cal_id)
 check if user is owner of a category More...
 
static deletePDItemsCache ($a_usr_id)
 Delete cache (add remove desktop item) More...
 
static deleteRepositoryCache ($a_usr_id)
 Delete cache. More...
 
static lookupPrivateCategories ($a_user_id)
 Lookup private categories of user. More...
 

Data Fields

const MODE_REPOSITORY = 2
 
const MODE_REMOTE_ACCESS = 3
 
const MODE_PERSONAL_DESKTOP_MEMBERSHIP = 4
 
const MODE_PERSONAL_DESKTOP_ITEMS = 5
 
const MODE_MANAGE = 6
 
const MODE_CONSULTATION = 7
 
const MODE_PORTFOLIO_CONSULTATION = 8
 
const MODE_REMOTE_SELECTED = 9
 

Protected Member Functions

 __construct ($a_usr_id=0)
 Singleton instance. More...
 
 sleep ()
 Serialize categories. More...
 
 wakeup ($a_ser)
 Load from serialize string. More...
 
 setMode ($a_mode)
 
 setTargetRefId ($a_ref_id)
 
 readPDCalendars ()
 Read categories of user. More...
 
 readSelectedCalendar ($a_cal_id)
 Read info about selected calendar. More...
 
 readSelectedItemCalendars ()
 Read categories of selected items. More...
 
 readReposCalendars ()
 Read available repository calendars. More...
 
 readPublicCalendars ()
 Read public calendars. More...
 
 readPrivateCalendars ()
 Read private calendars. More...
 
 readSelectedCategories ($a_obj_ids)
 read selected categories More...
 
 addSubitemCalendars ()
 Add subitem calendars E.g. More...
 

Protected Attributes

 $db
 
 $user_id
 
 $mode = 0
 
 $categories = array()
 
 $categories_info = array()
 
 $subitem_categories = array()
 
 $root_ref_id = 0
 
 $root_obj_id = 0
 
 $ch_user_id = 0
 
 $target_ref_id = 0
 

Static Protected Attributes

static $instance = null
 

Detailed Description

class for 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 37 of file class.ilCalendarCategories.php.

Constructor & Destructor Documentation

◆ __construct()

ilCalendarCategories::__construct (   $a_usr_id = 0)
protected

Singleton instance.

protected

Parameters
int$a_usr_iduser id
Returns

Definition at line 74 of file class.ilCalendarCategories.php.

References $ilDB, and $ilUser.

75  {
76  global $ilUser,$ilDB;
77 
78  $this->user_id = $a_usr_id;
79  if(!$this->user_id)
80  {
81  $this->user_id = $ilUser->getId();
82  }
83  $this->db = $ilDB;
84  }
global $ilUser
Definition: imgupload.php:15
global $ilDB

Member Function Documentation

◆ _getInstance()

static ilCalendarCategories::_getInstance (   $a_usr_id = 0)
static

get singleton instance

public

Parameters
int$a_usr_iduser id
Returns
ilCalendarCategories

Definition at line 94 of file class.ilCalendarCategories.php.

Referenced by ilCalendarScheduleFilterBookings\__construct(), ilCalendarAppointmentsTableGUI\__construct(), ilCalendarChangedAppointmentsTableGUI\__construct(), ilCalendarPresentationGUI\__construct(), ilCalendarSchedule\__construct(), ilCalendarAppointmentColors\__construct(), ilCalendarAppointmentGUI\distributeNotifications(), ilCalendarAppointmentGUI\edit(), ilCalendarAppointmentGUI\editResponsibleUsers(), ilCalendarScheduleFilterHidden\filterCategories(), ilCalendarSelectionBlockGUI\getCalendars(), ilCalendarSchedule\getChangedEvents(), ilCalendarSchedule\getEvents(), ilCalendarAppointmentPanelGUI\getHTML(), ilCalendarRemoteAccessHandler\handleRequest(), ilPDCalendarBlockGUI\initCategories(), ilCalendarBlockGUI\initCategories(), ilCalendarAppointmentGUI\initForm(), ilCalendarCategoryGUI\initFormCategory(), ilCalendarCategoryTableGUI\parse(), ilCalendarManageTableGUI\parse(), ilPortfolioPageGUI\renderConsultationHours(), ilCalendarAppointmentGUI\save(), ilCalendarCategoryGUI\saveSelection(), ilCalendarMonthGUI\show(), ilCalendarCategoryGUI\showAssignedAppointments(), ilCalendarAppointmentGUI\showInfoScreen(), and ilCalendarPresentationGUI\synchroniseExternalCalendars().

95  {
96  if(self::$instance)
97  {
98  return self::$instance;
99  }
100  return self::$instance = new ilCalendarCategories($a_usr_id);
101  }
class for calendar categories
+ Here is the caller graph for this function:

◆ _isOwner()

static ilCalendarCategories::_isOwner (   $a_usr_id,
  $a_cal_id 
)
static

check if user is owner of a category

public

Parameters
intusr_id
intcal_id
Returns
bool

Definition at line 137 of file class.ilCalendarCategories.php.

References $ilDB, $query, $res, and ilCalendarCategory\TYPE_USR.

Referenced by ilCalendarShared\getSharedCalendarsForUser().

138  {
139  global $ilDB;
140 
141  $query = "SELECT * FROM cal_categories ".
142  "WHERE cat_id = ".$ilDB->quote($a_cal_id ,'integer')." ".
143  "AND obj_id = ".$ilDB->quote($a_usr_id ,'integer')." ".
144  "AND type = ".$ilDB->quote(ilCalendarCategory::TYPE_USR ,'integer')." ";
145  $res = $ilDB->query($query);
146  return $res->numRows() ? true : false;
147  }
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupCategoryIdByObjId()

static ilCalendarCategories::_lookupCategoryIdByObjId (   $a_obj_id)
static

lookup category by obj_id

public

Parameters
intobj_id
Returns
int cat_id

Definition at line 111 of file class.ilCalendarCategories.php.

References $ilDB, $query, $res, $row, DB_FETCHMODE_OBJECT, and ilCalendarCategory\TYPE_OBJ.

Referenced by ilCalendarAppEventListener\createAppointments(), ilCalendarAppEventListener\deleteCategory(), ilDataLoader\generateCalendarEntries(), and ilCalendarAppointmentGUI\initForm().

112  {
113  global $ilDB;
114 
115  $query = "SELECT cat_id FROM cal_categories ".
116  "WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ".
117  "AND type = ".$ilDB->quote(ilCalendarCategory::TYPE_OBJ,'integer')." ";
118 
119  $res = $ilDB->query($query);
120  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
121  {
122  return $row->cat_id;
123  }
124  return 0;
125  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB
+ Here is the caller graph for this function:

◆ addSubitemCalendars()

ilCalendarCategories::addSubitemCalendars ( )
protected

Add subitem calendars E.g.

session calendars in courses, groups

Parameters

Definition at line 925 of file class.ilCalendarCategories.php.

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

Referenced by readPDCalendars(), readSelectedCalendar(), and readSelectedItemCalendars().

926  {
927  global $ilDB;
928 
929  $course_ids = array();
930  foreach($this->categories as $cat_id)
931  {
932  if($this->categories_info[$cat_id]['obj_type'] == 'crs' or $this->categories_info[$cat_id]['obj_type'] == 'grp')
933  {
934  $course_ids[] = $this->categories_info[$cat_id]['obj_id'];
935  }
936  }
937 
938  $query = "SELECT od2.obj_id sess_id, od1.obj_id crs_id,cat_id FROM object_data od1 ".
939  "JOIN object_reference or1 ON od1.obj_id = or1.obj_id ".
940  "JOIN tree t ON or1.ref_id = t.parent ".
941  "JOIN object_reference or2 ON t.child = or2.ref_id ".
942  "JOIN object_data od2 ON or2.obj_id = od2.obj_id ".
943  "JOIN cal_categories cc ON od2.obj_id = cc.obj_id ".
944  "WHERE ".$ilDB->in('od2.type',array('sess','exc'),false,'text').
945  "AND (od1.type = 'crs' OR od1.type = 'grp') ".
946  "AND ".$ilDB->in('od1.obj_id',$course_ids,false,'integer').' '.
947  "AND or2.deleted IS NULL";
948 
949  $res = $ilDB->query($query);
950  $cat_ids = array();
951  $course_sessions = array();
952  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
953  {
954  $cat_ids[] = $row->cat_id;
955  $course_sessions[$row->crs_id][$row->sess_id] = $row->cat_id;
956  $this->subitem_categories[] = $row->cat_id;
957  }
958 
959  foreach($this->categories as $cat_id)
960  {
961  if(
962  ($this->categories_info[$cat_id]['obj_type'] == 'crs' ||
963  $this->categories_info[$cat_id]['obj_type'] == 'grp' ) &&
964  isset($this->categories_info[$cat_id]['obj_id']) &&
965  isset($course_sessions[$this->categories_info[$cat_id]['obj_id']]) &&
966  is_array($course_sessions[$this->categories_info[$cat_id]['obj_id']]))
967  {
968  foreach($course_sessions[$this->categories_info[$cat_id]['obj_id']] as $sess_id => $sess_cat_id)
969  {
970  $this->categories_info[$cat_id]['subitem_ids'][$sess_id] = $sess_cat_id;
971  $this->categories_info[$cat_id]['subitem_obj_ids'][$sess_cat_id] = $sess_id;
972  }
973  }
974  else
975  {
976  $this->categories_info[$cat_id]['subitem_ids'] = array();
977  $this->categories_info[$cat_id]['subitem_obj_ids'] = array();
978  }
979  }
980  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB
+ Here is the caller graph for this function:

◆ deletePDItemsCache()

static ilCalendarCategories::deletePDItemsCache (   $a_usr_id)
static

Delete cache (add remove desktop item)

Parameters
object$a_usr_id
Returns

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

References ilCalendarCache\getInstance().

Referenced by ilObjUser\_addDesktopItem(), ilObjUser\_dropDesktopItem(), and ilCalendarAppEventListener\handleEvent().

155  {
156  ilCalendarCache::getInstance()->deleteByAdditionalKeys(
157  $a_usr_id,
158  self::MODE_PERSONAL_DESKTOP_ITEMS,
159  'categories'
160  );
161  }
static getInstance()
get singleton instance
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteRepositoryCache()

static ilCalendarCategories::deleteRepositoryCache (   $a_usr_id)
static

Delete cache.

Parameters
object$a_usr_id
Returns

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

References ilCalendarCache\getInstance().

Referenced by ilCalendarAppEventListener\handleEvent().

169  {
170  ilCalendarCache::getInstance()->deleteByAdditionalKeys(
171  $a_usr_id,
172  self::MODE_REPOSITORY,
173  'categories'
174  );
175 
176  }
static getInstance()
get singleton instance
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCategories()

ilCalendarCategories::getCategories (   $a_include_subitem_calendars = false)

get categories

Parameters
$a_include_subitemsinclude subitem calendars public
Returns

Definition at line 379 of file class.ilCalendarCategories.php.

380  {
381  if($a_include_subitem_calendars)
382  {
383  return array_merge((array) $this->categories, (array) $this->subitem_categories);
384  }
385 
386  return $this->categories ? $this->categories : array();
387  }

◆ getCategoriesInfo()

ilCalendarCategories::getCategoriesInfo ( )

get categories

public

Parameters

Definition at line 368 of file class.ilCalendarCategories.php.

369  {
370  return $this->categories_info ? $this->categories_info : array();
371  }

◆ getCategoryInfo()

ilCalendarCategories::getCategoryInfo (   $a_cat_id)

public

Parameters

Definition at line 341 of file class.ilCalendarCategories.php.

342  {
343  if(isset($this->categories_info[$a_cat_id]))
344  {
345  return $this->categories_info[$a_cat_id];
346  }
347 
348  if(in_array($a_cat_id,(array) $this->subitem_categories))
349  {
350  foreach($this->categories as $cat_id)
351  {
352  if(in_array($a_cat_id,$this->categories_info[$cat_id]['subitem_ids']))
353  {
354  return $this->categories_info[$cat_id];
355  }
356  }
357  }
358  }

◆ getCHUserId()

ilCalendarCategories::getCHUserId ( )

Get ch user id.

Returns
type

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

References $ch_user_id.

Referenced by readConsultationHoursCalendar().

223  {
224  return $this->ch_user_id;
225  }
+ Here is the caller graph for this function:

◆ getMode()

ilCalendarCategories::getMode ( )

Definition at line 232 of file class.ilCalendarCategories.php.

References $mode.

Referenced by initialize().

233  {
234  return $this->mode;
235  }
+ Here is the caller graph for this function:

◆ getNotificationCalendars()

ilCalendarCategories::getNotificationCalendars ( )

Get all calendars that allow send of notifications (Editable and course group calendars)

Returns

Definition at line 446 of file class.ilCalendarCategories.php.

References ilObject\_lookupType(), and ilCalendarCategory\TYPE_OBJ.

447  {
448  $not = array();
449  foreach($this->categories_info as $info)
450  {
451  if($info['type'] == ilCalendarCategory::TYPE_OBJ and $info['editable'] == true)
452  {
453  if(ilObject::_lookupType($info['obj_id']) == 'crs' or ilObject::_lookupType($info['obj_id']) == 'grp')
454  {
455  $not[] = $info['cat_id'];
456  }
457  }
458  }
459  return $not;
460  }
static _lookupType($a_id, $a_reference=false)
lookup object type
+ Here is the call graph for this function:

◆ getSubitemCategories()

ilCalendarCategories::getSubitemCategories (   $a_cat_id)

get subitem categories for a specific category

Parameters
int$a_category_idId of category in question
Returns
array Array of category ids

Definition at line 395 of file class.ilCalendarCategories.php.

396  {
397  if(!isset($this->categories_info[$a_cat_id]['subitem_ids']))
398  {
399  return array($a_cat_id);
400  }
401  return array_merge((array) $this->categories_info[$a_cat_id]['subitem_ids'],array($a_cat_id));
402  }

◆ getTargetRefId()

ilCalendarCategories::getTargetRefId ( )

Definition at line 242 of file class.ilCalendarCategories.php.

References $target_ref_id.

◆ initialize()

ilCalendarCategories::initialize (   $a_mode,
  $a_source_ref_id = 0,
  $a_use_cache = false 
)

initialize visible categories

public

Parameters
intmode
intref_id of root node
Returns

Definition at line 255 of file class.ilCalendarCategories.php.

References $user_id, ilCalendarUserSettings\_getInstance(), ilObject\_lookupObjId(), ilCalendarUserSettings\CAL_SELECTION_MEMBERSHIP, ilCalendarCache\getInstance(), getMode(), readConsultationHoursCalendar(), readPDCalendars(), readReposCalendars(), readSelectedCalendar(), readSelectedItemCalendars(), setMode(), setTargetRefId(), and wakeup().

256  {
257  $this->setMode($a_mode);
258  if($a_use_cache)
259  {
260  // Read categories from cache
261  if($cats = ilCalendarCache::getInstance()->getEntry($this->user_id.':'.$a_mode.':categories:'.(int) $a_source_ref_id))
262  {
263  if($this->getMode() != self::MODE_CONSULTATION &&
264  $this->getMode() != self::MODE_PORTFOLIO_CONSULTATION)
265  {
266  $this->wakeup($cats);
267  return;
268  }
269  }
270  }
271 
272 
273  switch($this->getMode())
274  {
275  case self::MODE_REMOTE_ACCESS:
276  include_once('./Services/Calendar/classes/class.ilCalendarUserSettings.php');
278  {
279  $this->readPDCalendars();
280  }
281  else
282  {
283  $this->readSelectedItemCalendars();
284  }
285  break;
286 
287  case self::MODE_REMOTE_SELECTED:
288  $this->readSelectedCalendar($a_source_ref_id);
289  break;
290 
291  case self::MODE_PERSONAL_DESKTOP_MEMBERSHIP:
292  $this->readPDCalendars();
293  break;
294 
295  case self::MODE_PERSONAL_DESKTOP_ITEMS:
296  $this->readSelectedItemCalendars();
297  break;
298 
299  case self::MODE_REPOSITORY:
300  $this->root_ref_id = $a_source_ref_id;
301  $this->root_obj_id = ilObject::_lookupObjId($this->root_ref_id);
302  $this->readReposCalendars();
303  break;
304 
305  case self::MODE_MANAGE:
306  $this->readPDCalendars();
307  $this->readSelectedItemCalendars();
308  break;
309 
310  case self::MODE_CONSULTATION:
311  #$this->readPrivateCalendars();
312  $this->setTargetRefId($a_source_ref_id);
313  $this->readConsultationHoursCalendar($a_source_ref_id);
314  break;
315 
316  case self::MODE_PORTFOLIO_CONSULTATION:
318  break;
319  }
320 
321  if($a_use_cache)
322  {
323  // Store in cache
324  ilCalendarCache::getInstance()->storeEntry(
325  $this->user_id.':'.$a_mode.':categories:'.(int) $a_source_ref_id,
326  $this->sleep(),
328  $a_mode,
329  'categories'
330  );
331  }
332  }
static getInstance()
get singleton instance
readSelectedItemCalendars()
Read categories of selected items.
wakeup($a_ser)
Load from serialize string.
readConsultationHoursCalendar($a_target_ref_id=NULL)
Read personal consultation hours calendar.
static _getInstance()
get instance for logged in user
static _lookupObjId($a_id)
readSelectedCalendar($a_cal_id)
Read info about selected calendar.
readReposCalendars()
Read available repository calendars.
readPDCalendars()
Read categories of user.
+ Here is the call graph for this function:

◆ isEditable()

ilCalendarCategories::isEditable (   $a_cat_id)

check if category is editable

public

Parameters
int$a_cat_idcategory id
Returns

Definition at line 469 of file class.ilCalendarCategories.php.

470  {
471  return isset($this->categories_info[$a_cat_id]['editable']) and $this->categories_info[$a_cat_id]['editable'];
472  }

◆ isVisible()

ilCalendarCategories::isVisible (   $a_cat_id)

check if category is visible

public

Parameters
int$a_cat_idcategory id
Returns

Definition at line 481 of file class.ilCalendarCategories.php.

482  {
483  return in_array($a_cat_id,$this->categories) or
484  in_array($a_cat_id,(array) $this->subitem_categories);
485  }

◆ lookupPrivateCategories()

static ilCalendarCategories::lookupPrivateCategories (   $a_user_id)
static

Lookup private categories of user.

Parameters

Definition at line 988 of file class.ilCalendarCategories.php.

References $ilDB, and ilCalendarCategory\TYPE_USR.

Referenced by ilUserExporter\getXmlExportTailDependencies().

989  {
990  global $ilDB;
991 
992  // First read private calendars of user
993  $set = $ilDB->query("SELECT * FROM cal_categories ".
994  "WHERE type = ".$ilDB->quote(ilCalendarCategory::TYPE_USR ,'integer')." ".
995  "AND obj_id = ".$ilDB->quote($a_user_id,'integer'));
996  $cats = array();
997  while ($rec = $ilDB->fetchAssoc($set))
998  {
999  $cats[] = $rec;
1000  }
1001  return $cats;
1002  }
global $ilDB
+ Here is the caller graph for this function:

◆ prepareCategoriesOfUserForSelection()

ilCalendarCategories::prepareCategoriesOfUserForSelection ( )

prepare categories of users for selection

public

Parameters
intuser id
Returns

Definition at line 412 of file class.ilCalendarCategories.php.

References $lng, and ilCalendarCategory\TYPE_USR.

413  {
414  global $lng;
415 
416  $has_personal_calendar = false;
417  foreach($this->categories_info as $info)
418  {
419  if($info['obj_type'] == 'sess' || $info['obj_type'] == 'exc')
420  {
421  continue;
422  }
423  if($info['type'] == ilCalendarCategory::TYPE_USR and $info['editable'])
424  {
425  $has_personal_calendar = true;
426  }
427 
428  if($info['editable'])
429  {
430  $cats[$info['cat_id']] = $info['title'];
431  }
432  }
433  // If there
434  if(!$has_personal_calendar)
435  {
436  $cats[0] = $lng->txt('cal_default_calendar');
437  }
438  return $cats ? $cats : array();
439  }
global $lng
Definition: privfeed.php:40

◆ readBookingCalendar()

ilCalendarCategories::readBookingCalendar (   $user_id = NULL)

Read booking manager calendar.

Parameters
int$user_id
Returns

Definition at line 824 of file class.ilCalendarCategories.php.

References $ilDB, $query, $res, $row, $user_id, DB_FETCHMODE_OBJECT, and ilCalendarCategory\TYPE_BOOK.

Referenced by readPDCalendars(), and readSelectedItemCalendars().

825  {
826  global $ilDB;
827 
828  if(!$user_id)
829  {
831  }
832 
833  $query = "SELECT * FROM cal_categories ".
834  "WHERE type = ".$ilDB->quote(ilCalendarCategory::TYPE_BOOK,'integer').' '.
835  "AND obj_id = ".$ilDB->quote($user_id,'integer');
836  $res = $ilDB->query($query);
837  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
838  {
839  $this->categories[] = $row->cat_id;
840  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
841  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
842  $this->categories_info[$row->cat_id]['title'] = $row->title;
843  $this->categories_info[$row->cat_id]['color'] = $row->color;
844  $this->categories_info[$row->cat_id]['type'] = $row->type;
845  $this->categories_info[$row->cat_id]['editable'] = false;
846  $this->categories_info[$row->cat_id]['accepted'] = false;
847  $this->categories_info[$row->cat_id]['remote'] = false;
848  }
849  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB
+ Here is the caller graph for this function:

◆ readConsultationHoursCalendar()

ilCalendarCategories::readConsultationHoursCalendar (   $a_target_ref_id = NULL)

Read personal consultation hours calendar.

Parameters
int$user_id
Returns

Definition at line 749 of file class.ilCalendarCategories.php.

References $categories, $ilDB, $query, $res, $row, ilObject\_lookupObjId(), DB_FETCHMODE_OBJECT, getCHUserId(), setCHUserId(), and ilCalendarCategory\TYPE_CH.

Referenced by initialize(), readPDCalendars(), readReposCalendars(), and readSelectedItemCalendars().

750  {
751  global $ilDB;
752 
753  if(!$this->getCHUserId())
754  {
755  $this->setCHUserId($this->user_id);
756  }
757 
758  if($a_target_ref_id)
759  {
760  $target_obj_id = ilObject::_lookupObjId($a_target_ref_id);
761 
762  $query = 'SELECT DISTINCT(cc.cat_id) FROM booking_entry be '.
763  'LEFT JOIN booking_obj_assignment bo ON be.booking_id = bo.booking_id '.
764  'JOIN cal_entries ce ON be.booking_id = ce.context_id '.
765  'JOIN cal_cat_assignments ca ON ce.cal_id = ca.cal_id '.
766  'JOIN cal_categories cc ON ca.cat_id = cc.cat_id '.
767  'WHERE ((bo.target_obj_id IS NULL) OR bo.target_obj_id = '.$ilDB->quote($target_obj_id,'integer').' ) '.
768  'AND cc.obj_id = '.$ilDB->quote($this->getCHUserId(),'integer');
769 
770 
771  $res = $ilDB->query($query);
772  $categories = array();
773  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
774  {
775  $categories[] = $row->cat_id;
776  }
777 
778  if($categories)
779  {
780  $query = 'SELECT * FROM cal_categories '.
781  'WHERE '.$ilDB->in('cat_id',$categories,false,'integer');
782  $res = $ilDB->query($query);
783  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
784  {
785  $this->categories[] = $row->cat_id;
786  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
787  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
788  $this->categories_info[$row->cat_id]['title'] = $row->title;
789  $this->categories_info[$row->cat_id]['color'] = $row->color;
790  $this->categories_info[$row->cat_id]['type'] = $row->type;
791  $this->categories_info[$row->cat_id]['editable'] = false;
792  $this->categories_info[$row->cat_id]['accepted'] = false;
793  $this->categories_info[$row->cat_id]['remote'] = false;
794  }
795  }
796  }
797  else // no category given
798  {
799  $query = "SELECT * FROM cal_categories cc ".
800  "WHERE type = ".$ilDB->quote(ilCalendarCategory::TYPE_CH,'integer').' '.
801  "AND obj_id = ".$ilDB->quote($this->getCHUserId(),'integer');
802  $res = $ilDB->query($query);
803  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
804  {
805  $this->categories[] = $row->cat_id;
806  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
807  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
808  $this->categories_info[$row->cat_id]['title'] = $row->title;
809  $this->categories_info[$row->cat_id]['color'] = $row->color;
810  $this->categories_info[$row->cat_id]['type'] = $row->type;
811  $this->categories_info[$row->cat_id]['editable'] = false;
812  $this->categories_info[$row->cat_id]['accepted'] = false;
813  $this->categories_info[$row->cat_id]['remote'] = false;
814  }
815  }
816  return true;
817  }
setCHUserId($a_user_id)
Set ch user id.
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
static _lookupObjId($a_id)
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readPDCalendars()

ilCalendarCategories::readPDCalendars ( )
protected

Read categories of user.

protected

Parameters

Definition at line 497 of file class.ilCalendarCategories.php.

References ilParticipants\_getMembershipByType(), addSubitemCalendars(), readBookingCalendar(), readConsultationHoursCalendar(), readPrivateCalendars(), readPublicCalendars(), and readSelectedCategories().

Referenced by initialize().

498  {
499  global $rbacsystem;
500 
501 
502  $this->readPublicCalendars();
503  $this->readPrivateCalendars();
505  $this->readBookingCalendar();
506 
507  include_once('./Services/Membership/classes/class.ilParticipants.php');
508  $this->readSelectedCategories(ilParticipants::_getMembershipByType($this->user_id,'crs'));
509  $this->readSelectedCategories(ilParticipants::_getMembershipByType($this->user_id,'grp'));
510 
511  $this->addSubitemCalendars();
512  }
addSubitemCalendars()
Add subitem calendars E.g.
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
readConsultationHoursCalendar($a_target_ref_id=NULL)
Read personal consultation hours calendar.
readPublicCalendars()
Read public calendars.
readSelectedCategories($a_obj_ids)
read selected categories
readBookingCalendar($user_id=NULL)
Read booking manager calendar.
readPrivateCalendars()
Read private calendars.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readPrivateCalendars()

ilCalendarCategories::readPrivateCalendars ( )
protected

Read private calendars.

protected

Returns

Definition at line 681 of file class.ilCalendarCategories.php.

References $ilDB, $ilUser, $query, $res, $row, DB_FETCHMODE_OBJECT, ilCalendarSharedStatus\getAcceptedCalendars(), ilCalendarCategory\LTYPE_REMOTE, and ilCalendarCategory\TYPE_USR.

Referenced by readPDCalendars(), readReposCalendars(), and readSelectedItemCalendars().

682  {
683  global $ilUser;
684  global $ilDB;
685 
686  // First read private calendars of user
687  $query = "SELECT cat_id FROM cal_categories ".
688  "WHERE type = ".$this->db->quote(ilCalendarCategory::TYPE_USR ,'integer')." ".
689  "AND obj_id = ".$this->db->quote($ilUser->getId(),'integer')." ";
690  $res = $this->db->query($query);
691  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
692  {
693  $cat_ids[] = $row->cat_id;
694  }
695 
696  // Read shared calendars
697  include_once('./Services/Calendar/classes/class.ilCalendarSharedStatus.php');
698  $accepted_ids = ilCalendarSharedStatus::getAcceptedCalendars($ilUser->getId());
699  if(!$cat_ids = array_merge((array) $cat_ids, $accepted_ids))
700  {
701  return true;
702  }
703 
704 
705  // user categories
706  $query = "SELECT * FROM cal_categories ".
707  "WHERE type = ".$this->db->quote(ilCalendarCategory::TYPE_USR ,'integer')." ".
708  "AND ".$ilDB->in('cat_id',$cat_ids,false,'integer')." ".
709  "ORDER BY title ";
710 
711  $res = $this->db->query($query);
712  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
713  {
714  $this->categories[] = $row->cat_id;
715  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
716  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
717  $this->categories_info[$row->cat_id]['title'] = $row->title;
718  $this->categories_info[$row->cat_id]['color'] = $row->color;
719  $this->categories_info[$row->cat_id]['type'] = $row->type;
720 
721  include_once './Services/Calendar/classes/class.ilCalendarShared.php';
722  if(in_array($row->cat_id, $accepted_ids))
723  {
724  $shared = new ilCalendarShared($row->cat_id);
725  if($shared->isEditableForUser($ilUser->getId()))
726  {
727  $this->categories_info[$row->cat_id]['editable'] = true;
728  }
729  else
730  {
731  $this->categories_info[$row->cat_id]['editable'] = false;
732  }
733  }
734  else
735  {
736  $this->categories_info[$row->cat_id]['editable'] = true;
737  }
738 
739  $this->categories_info[$row->cat_id]['accepted'] = in_array($row->cat_id, $accepted_ids);
740  $this->categories_info[$row->cat_id]['remote'] = ($row->loc_type == ilCalendarCategory::LTYPE_REMOTE);
741  }
742  }
Handles shared calendars.
getAcceptedCalendars($a_usr_id)
get accepted shared calendars
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilUser
Definition: imgupload.php:15
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readPublicCalendars()

ilCalendarCategories::readPublicCalendars ( )
protected

Read public calendars.

protected

Returns

Definition at line 649 of file class.ilCalendarCategories.php.

References $query, $res, $row, ilCalendarSettings\_getInstance(), DB_FETCHMODE_OBJECT, ilCalendarCategory\LTYPE_REMOTE, and ilCalendarCategory\TYPE_GLOBAL.

Referenced by readPDCalendars(), readReposCalendars(), and readSelectedItemCalendars().

650  {
651  global $rbacsystem,$ilAccess;
652 
653  // global categories
654  $query = "SELECT * FROM cal_categories ".
655  "WHERE type = ".$this->db->quote(ilCalendarCategory::TYPE_GLOBAL ,'integer')." ".
656  "ORDER BY title ";
657 
658  $res = $this->db->query($query);
659  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
660  {
661  $this->categories[] = $row->cat_id;
662  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
663  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
664  $this->categories_info[$row->cat_id]['title'] = $row->title;
665  $this->categories_info[$row->cat_id]['color'] = $row->color;
666  $this->categories_info[$row->cat_id]['type'] = $row->type;
667  $this->categories_info[$row->cat_id]['editable'] = $rbacsystem->checkAccess('edit_event',ilCalendarSettings::_getInstance()->getCalendarSettingsId());
668  $this->categories_info[$row->cat_id]['accepted'] = false;
669  $this->categories_info[$row->cat_id]['remote'] = ($row->loc_type == ilCalendarCategory::LTYPE_REMOTE);
670  }
671 
672  return true;
673  }
static _getInstance()
get singleton instance
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readReposCalendars()

ilCalendarCategories::readReposCalendars ( )
protected

Read available repository calendars.

protected

Parameters

Definition at line 594 of file class.ilCalendarCategories.php.

References $GLOBALS, $ilDB, $res, $row, ilCalendarSettings\_getInstance(), ilObject\_lookupType(), DB_FETCHMODE_OBJECT, readConsultationHoursCalendar(), readPrivateCalendars(), readPublicCalendars(), and readSelectedCategories().

Referenced by initialize().

595  {
596  global $ilAccess,$tree;
597  global $ilDB;
598 
599  $this->readPublicCalendars();
600  $this->readPrivateCalendars();
602 
603  #$query = "SELECT ref_id,obd.obj_id obj_id FROM tree t1 ".
604  # "JOIN object_reference obr ON t1.child = obr.ref_id ".
605  # "JOIN object_data obd ON obd.obj_id = obr.obj_id ".
606  # "WHERE t1.lft >= (SELECT lft FROM tree WHERE child = ".$this->db->quote($this->root_ref_id,'integer')." ) ".
607  # "AND t1.lft <= (SELECT rgt FROM tree WHERE child = ".$this->db->quote($this->root_ref_id,'integer')." ) ".
608  # "AND ".$ilDB->in('type',array('crs','grp','sess'),false,'text')." ".
609  # "AND tree = 1";
610 
611  $subtree_query = $GLOBALS['tree']->getSubTreeQuery(
612  $this->root_ref_id,
613  array('object_reference.ref_id','object_data.obj_id'),
614  array('crs','grp','sess','exc')
615  );
616 
617  $res = $ilDB->query($subtree_query);
618  $obj_ids = array();
619  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
620  {
621  if($tree->isDeleted($row->ref_id))
622  {
623  continue;
624  }
625 
626  $obj_type = ilObject::_lookupType($row->obj_id);
627  if($obj_type == 'crs' or $obj_type == 'grp')
628  {
629  // Check for global/local activation
630  if(!ilCalendarSettings::_getInstance()->lookupCalendarActivated($row->obj_id))
631  {
632  continue;
633  }
634  }
635  if($ilAccess->checkAccess('read','',$row->ref_id))
636  {
637  $obj_ids[] = $row->obj_id;
638  }
639  }
640  $this->readSelectedCategories($obj_ids);
641  }
static _getInstance()
get singleton instance
readConsultationHoursCalendar($a_target_ref_id=NULL)
Read personal consultation hours calendar.
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
readPublicCalendars()
Read public calendars.
$GLOBALS['ct_recipient']
readSelectedCategories($a_obj_ids)
read selected categories
static _lookupType($a_id, $a_reference=false)
lookup object type
global $ilDB
readPrivateCalendars()
Read private calendars.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readSelectedCalendar()

ilCalendarCategories::readSelectedCalendar (   $a_cal_id)
protected

Read info about selected calendar.

Parameters
type$a_cal_id

Definition at line 518 of file class.ilCalendarCategories.php.

References addSubitemCalendars(), readSelectedCategories(), and ilCalendarCategory\TYPE_OBJ.

Referenced by initialize().

519  {
520  include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
521  $cat = new ilCalendarCategory($a_cal_id);
522  if($cat->getType() == ilCalendarCategory::TYPE_OBJ)
523  {
524  $this->readSelectedCategories(array($cat->getObjId()));
525  $this->addSubitemCalendars();
526  }
527  else
528  {
529  $this->categories[] = $a_cal_id;
530  }
531  }
addSubitemCalendars()
Add subitem calendars E.g.
Stores calendar categories.
readSelectedCategories($a_obj_ids)
read selected categories
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readSelectedCategories()

ilCalendarCategories::readSelectedCategories (   $a_obj_ids)
protected

read selected categories

protected

Returns

Definition at line 857 of file class.ilCalendarCategories.php.

References $ilDB, $query, $ref_id, $res, $row, ilObject\_getAllReferences(), ilCalendarSettings\_getInstance(), ilObject\_lookupType(), DB_FETCHMODE_OBJECT, and ilCalendarCategory\TYPE_OBJ.

Referenced by readPDCalendars(), readReposCalendars(), readSelectedCalendar(), and readSelectedItemCalendars().

858  {
859  global $ilAccess,$tree;
860  global $ilDB;
861 
862  if(!count($a_obj_ids))
863  {
864  return true;
865  }
866 
867  $query = "SELECT * FROM cal_categories ".
868  "WHERE type = ".$this->db->quote(ilCalendarCategory::TYPE_OBJ ,'integer')." ".
869  "AND ".$ilDB->in('obj_id',$a_obj_ids,false,'integer')." ".
870  "ORDER BY title ";
871 
872  $res = $this->db->query($query);
873  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
874  {
875  // check activation/deactivation
876  $obj_type = ilObject::_lookupType($row->obj_id);
877  if($obj_type == 'crs' or $obj_type == 'grp')
878  {
879  if(!ilCalendarSettings::_getInstance()->lookupCalendarActivated($row->obj_id))
880  {
881  continue;
882  }
883  }
884 
885  $editable = false;
886  $exists = false;
887  foreach(ilObject::_getAllReferences($row->obj_id) as $ref_id)
888  {
889  if($ilAccess->checkAccess('edit_event','',$ref_id))
890  {
891  $exists = true;
892  $editable = true;
893  break;
894  }
895  elseif($ilAccess->checkAccess('read','',$ref_id))
896  {
897  $exists = true;
898  }
899  }
900  if(!$exists)
901  {
902  continue;
903  }
904  $this->categories_info[$row->cat_id]['editable'] = $editable;
905 
906  $this->categories[] = $row->cat_id;
907  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
908  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
909  $this->categories_info[$row->cat_id]['color'] = $row->color;
910  #$this->categories_info[$row->cat_id]['title'] = ilObject::_lookupTitle($row->obj_id);
911  $this->categories_info[$row->cat_id]['title'] = $row->title;
912  $this->categories_info[$row->cat_id]['obj_type'] = ilObject::_lookupType($row->obj_id);
913  $this->categories_info[$row->cat_id]['type'] = $row->type;
914  $this->categories_info[$row->cat_id]['remote'] = false;
915 
916  }
917  }
static _getInstance()
get singleton instance
static _getAllReferences($a_id)
get all reference ids of object
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
static _lookupType($a_id, $a_reference=false)
lookup object type
$ref_id
Definition: sahs_server.php:39
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readSelectedItemCalendars()

ilCalendarCategories::readSelectedItemCalendars ( )
protected

Read categories of selected items.

Parameters

Definition at line 539 of file class.ilCalendarCategories.php.

References $ilUser, ilObjUser\_lookupDesktopItems(), addSubitemCalendars(), readBookingCalendar(), readConsultationHoursCalendar(), readPrivateCalendars(), readPublicCalendars(), and readSelectedCategories().

Referenced by initialize().

540  {
541  global $ilUser,$ilAccess;
542 
543  $this->readPublicCalendars();
544  $this->readPrivateCalendars();
546  $this->readBookingCalendar();
547 
548  $obj_ids = array();
549 
550  $courses = array();
551  $groups = array();
552  $sessions = array();
553  $exercises = array();
554  foreach(ilObjUser::_lookupDesktopItems($ilUser->getId(),array('crs','grp','sess','exc')) as $item)
555  {
556  if($ilAccess->checkAccess('read','',$item['ref_id']))
557  {
558  switch($item['type'])
559  {
560  case 'crs':
561  $courses[] = $item['obj_id'];
562  break;
563 
564  case 'sess':
565  $sessions[] = $item['obj_id'];
566  break;
567 
568  case 'grp':
569  $groups[] = $item['obj_id'];
570  break;
571 
572  case 'exc':
573  $exercises[] = $item['obj_id'];
574  break;
575  }
576  }
577  }
578  $this->readSelectedCategories($courses);
579  $this->readSelectedCategories($sessions);
580  $this->readSelectedCategories($groups);
581  $this->readSelectedCategories($exercises);
582 
583  $this->addSubitemCalendars();
584 
585  }
addSubitemCalendars()
Add subitem calendars E.g.
readConsultationHoursCalendar($a_target_ref_id=NULL)
Read personal consultation hours calendar.
readPublicCalendars()
Read public calendars.
readSelectedCategories($a_obj_ids)
read selected categories
readBookingCalendar($user_id=NULL)
Read booking manager calendar.
static _lookupDesktopItems($user_id, $a_types="")
get all desktop items of user and specified type
global $ilUser
Definition: imgupload.php:15
readPrivateCalendars()
Read private calendars.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCHUserId()

ilCalendarCategories::setCHUserId (   $a_user_id)

Set ch user id.

Parameters
int$a_user_id

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

Referenced by readConsultationHoursCalendar().

213  {
214  $this->ch_user_id = $a_user_id;
215  }
+ Here is the caller graph for this function:

◆ setMode()

ilCalendarCategories::setMode (   $a_mode)
protected

Definition at line 227 of file class.ilCalendarCategories.php.

Referenced by initialize().

228  {
229  $this->mode = $a_mode;
230  }
+ Here is the caller graph for this function:

◆ setTargetRefId()

ilCalendarCategories::setTargetRefId (   $a_ref_id)
protected

Definition at line 237 of file class.ilCalendarCategories.php.

Referenced by initialize().

238  {
239  $this->target_ref_id = $a_ref_id;
240  }
+ Here is the caller graph for this function:

◆ sleep()

ilCalendarCategories::sleep ( )
protected

Serialize categories.

Returns

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

184  {
185  return serialize(
186  array(
187  'categories' => $this->categories,
188  'categories_info' => $this->categories_info,
189  'subitem_categories'=> $this->subitem_categories
190  )
191  );
192  }

◆ wakeup()

ilCalendarCategories::wakeup (   $a_ser)
protected

Load from serialize string.

Parameters
stringserialize categories
Returns

Definition at line 199 of file class.ilCalendarCategories.php.

Referenced by initialize().

200  {
201  $info = unserialize($a_ser);
202 
203  $this->categories = $info['categories'];
204  $this->categories_info = $info['categories_info'];
205  $this->subitem_categories = $info['subitem_categories'];
206  }
+ Here is the caller graph for this function:

Field Documentation

◆ $categories

ilCalendarCategories::$categories = array()
protected

Definition at line 56 of file class.ilCalendarCategories.php.

Referenced by readConsultationHoursCalendar().

◆ $categories_info

ilCalendarCategories::$categories_info = array()
protected

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

◆ $ch_user_id

ilCalendarCategories::$ch_user_id = 0
protected

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

Referenced by getCHUserId().

◆ $db

ilCalendarCategories::$db
protected

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

◆ $instance

ilCalendarCategories::$instance = null
staticprotected

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

◆ $mode

ilCalendarCategories::$mode = 0
protected

Definition at line 54 of file class.ilCalendarCategories.php.

Referenced by getMode().

◆ $root_obj_id

ilCalendarCategories::$root_obj_id = 0
protected

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

◆ $root_ref_id

ilCalendarCategories::$root_ref_id = 0
protected

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

◆ $subitem_categories

ilCalendarCategories::$subitem_categories = array()
protected

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

◆ $target_ref_id

ilCalendarCategories::$target_ref_id = 0
protected

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

Referenced by getTargetRefId().

◆ $user_id

ilCalendarCategories::$user_id
protected

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

Referenced by initialize(), and readBookingCalendar().

◆ MODE_CONSULTATION

const ilCalendarCategories::MODE_CONSULTATION = 7

◆ MODE_MANAGE

const ilCalendarCategories::MODE_MANAGE = 6

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

Referenced by ilCalendarManageTableGUI\parse().

◆ MODE_PERSONAL_DESKTOP_ITEMS

◆ MODE_PERSONAL_DESKTOP_MEMBERSHIP

const ilCalendarCategories::MODE_PERSONAL_DESKTOP_MEMBERSHIP = 4

◆ MODE_PORTFOLIO_CONSULTATION

◆ MODE_REMOTE_ACCESS

const ilCalendarCategories::MODE_REMOTE_ACCESS = 3

◆ MODE_REMOTE_SELECTED

const ilCalendarCategories::MODE_REMOTE_SELECTED = 9

◆ MODE_REPOSITORY

const ilCalendarCategories::MODE_REPOSITORY = 2

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