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

class for calendar categories More...

+ Collaboration diagram for ilCalendarCategories:

Public Member Functions

 __construct ($a_usr_id=0)
 Singleton instance. More...
 
 setCHUserId ($a_user_id)
 Set ch user id. More...
 
 getCHUserId ()
 Get ch user id. More...
 
 getMode ()
 
 getTargetRefId ()
 
 setSourceRefId ($a_val)
 Set source ref id. More...
 
 getSourceRefId ()
 Get source ref id. More...
 
 initialize ($a_mode, $a_source_ref_id=0, $a_use_cache=false, $a_cat_id=0)
 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...
 
 readSingleCalendar ($a_cat_id)
 
 readAllConsultationHoursCalendarOfContainer ($a_container_ref_id)
 Read personal consultation hours calendar of all tutors for a container. More...
 
 readConsultationHoursCalendar ($a_target_ref_id=null, $a_cat_id=0)
 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
 
const MODE_REPOSITORY_CONTAINER_ONLY = 10
 
const MODE_SINGLE_CALENDAR = 11
 

Protected Member Functions

 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 ($a_container_only=false)
 Read available repository calendars. More...
 
 readPublicCalendars ($cat_ids=null)
 Read public calendars. More...
 
 readPrivateCalendars ($only_cat_ids=null)
 Read private calendars. More...
 
 readSelectedCategories ($a_obj_ids, $a_source_ref_id=0)
 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
 
 $logger = null
 ilLogger More...
 
 $fav_rep
 

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

Constructor & Destructor Documentation

◆ __construct()

ilCalendarCategories::__construct (   $a_usr_id = 0)

Singleton instance.

protected

Parameters
int$a_usr_iduser id
Returns

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

References $DIC, $GLOBALS, $ilDB, and $ilUser.

84  {
85  global $DIC;
86 
87  $ilUser = $DIC['ilUser'];
88  $ilDB = $DIC['ilDB'];
89 
90  $this->logger = $GLOBALS['DIC']->logger()->cal();
91 
92  $this->user_id = $a_usr_id;
93  if (!$this->user_id) {
94  $this->user_id = $ilUser->getId();
95  }
96  $this->db = $ilDB;
97 
98  $this->fav_rep = new ilFavouritesDBRepository();
99  }
global $DIC
Definition: goto.php:24
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
global $ilDB
$ilUser
Definition: imgupload.php:18

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

Referenced by ilCalendarScheduleFilterHidden\__construct(), ilCalendarScheduleFilterBookings\__construct(), ilCalendarScheduleFilterConsultationHourInRepository\__construct(), ilCalendarScheduleFilterBookingPool\__construct(), ilCalendarActions\__construct(), ilCalendarAppointmentsTableGUI\__construct(), ilCalendarChangedAppointmentsTableGUI\__construct(), ilCalendarSchedule\__construct(), ilCalendarAppointmentColors\__construct(), ilCalendarPresentationGUI\__construct(), ilCalendarMonthGUI\addScheduleFilter(), ilAppointmentPresentationConsultationHoursGUI\collectPropertiesAndActions(), ilCalendarAppointmentGUI\distributeNotifications(), ilCalendarAppointmentGUI\edit(), ilCalendarAppointmentGUI\editResponsibleUsers(), ilPortfolioPageGUI\executeCommand(), ilCalendarScheduleFilterHidden\filterCategories(), ilAppointmentPresentationGUI\getCatInfo(), ilCalendarSchedule\getChangedEvents(), ilCalendarSchedule\getEvents(), ilCalendarAppointmentPanelGUI\getHTML(), ilCalendarAgendaListGUI\getHTML(), ilCalendarRemoteAccessHandler\handleRequest(), ilPDCalendarBlockGUI\initCategories(), ilCalendarBlockGUI\initCategories(), ilCalendarAppointmentGUI\initForm(), ilCalendarCategoryGUI\initFormCategory(), ilCalendarCategoryTableGUI\parse(), ilCalendarManageTableGUI\parse(), ilPortfolioPageGUI\renderConsultationHours(), ilCalendarAppointmentGUI\save(), ilCalendarCategoryGUI\saveSelection(), ilCalendarCategoryGUI\showAssignedAppointments(), ilCalendarAppointmentGUI\showInfoScreen(), and ilCalendarPresentationGUI\synchroniseExternalCalendars().

110  {
111  if (self::$instance) {
112  return self::$instance;
113  }
114  return self::$instance = new ilCalendarCategories($a_usr_id);
115  }
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 152 of file class.ilCalendarCategories.php.

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

Referenced by ilCalendarShared\getSharedCalendarsForUser().

153  {
154  global $DIC;
155 
156  $ilDB = $DIC['ilDB'];
157 
158  $query = "SELECT * FROM cal_categories " .
159  "WHERE cat_id = " . $ilDB->quote($a_cal_id, 'integer') . " " .
160  "AND obj_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
161  "AND type = " . $ilDB->quote(ilCalendarCategory::TYPE_USR, 'integer') . " ";
162  $res = $ilDB->query($query);
163  return $res->numRows() ? true : false;
164  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
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 125 of file class.ilCalendarCategories.php.

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

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

126  {
127  global $DIC;
128 
129  $ilDB = $DIC['ilDB'];
130 
131  $query = "SELECT cat_id FROM cal_categories " .
132  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
133  "AND type = " . $ilDB->quote(ilCalendarCategory::TYPE_OBJ, 'integer') . " ";
134 
135  $res = $ilDB->query($query);
136  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
137  return $row->cat_id;
138  }
139  return 0;
140  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
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 1055 of file class.ilCalendarCategories.php.

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

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

1056  {
1057  global $DIC;
1058 
1059  $ilDB = $DIC->database();
1060  $access = $DIC->access();
1061 
1062  $course_ids = array();
1063  foreach ($this->categories as $cat_id) {
1064  if ($this->categories_info[$cat_id]['obj_type'] == 'crs' or $this->categories_info[$cat_id]['obj_type'] == 'grp') {
1065  $course_ids[] = $this->categories_info[$cat_id]['obj_id'];
1066  }
1067  }
1068 
1069  $query = "SELECT od2.obj_id sess_id, od1.obj_id crs_id,cat_id, or2.ref_id sess_ref_id FROM object_data od1 " .
1070  "JOIN object_reference or1 ON od1.obj_id = or1.obj_id " .
1071  "JOIN tree t ON or1.ref_id = t.parent " .
1072  "JOIN object_reference or2 ON t.child = or2.ref_id " .
1073  "JOIN object_data od2 ON or2.obj_id = od2.obj_id " .
1074  "JOIN cal_categories cc ON od2.obj_id = cc.obj_id " .
1075  "WHERE " . $ilDB->in('od2.type', array('sess','exc'), false, 'text') .
1076  "AND (od1.type = 'crs' OR od1.type = 'grp') " .
1077  "AND " . $ilDB->in('od1.obj_id', $course_ids, false, 'integer') . ' ' .
1078  "AND or2.deleted IS NULL";
1079 
1080  $res = $ilDB->query($query);
1081  $cat_ids = array();
1082  $course_sessions = array();
1083  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1084  if (
1085  !$access->checkAccessOfUser($this->user_id, 'read', '', $row->sess_ref_id) ||
1086  !$access->checkAccessOfUser($this->user_id, 'visible', '', $row->sess_ref_id)
1087  ) {
1088  continue;
1089  }
1090  $cat_ids[] = $row->cat_id;
1091  $course_sessions[$row->crs_id][$row->sess_id] = $row->cat_id;
1092  $this->subitem_categories[] = $row->cat_id;
1093  }
1094 
1095  foreach ($this->categories as $cat_id) {
1096  if (
1097  ($this->categories_info[$cat_id]['obj_type'] == 'crs' ||
1098  $this->categories_info[$cat_id]['obj_type'] == 'grp') &&
1099  isset($this->categories_info[$cat_id]['obj_id']) &&
1100  isset($course_sessions[$this->categories_info[$cat_id]['obj_id']]) &&
1101  is_array($course_sessions[$this->categories_info[$cat_id]['obj_id']])) {
1102  foreach ($course_sessions[$this->categories_info[$cat_id]['obj_id']] as $sess_id => $sess_cat_id) {
1103  $this->categories_info[$cat_id]['subitem_ids'][$sess_id] = $sess_cat_id;
1104  $this->categories_info[$cat_id]['subitem_obj_ids'][$sess_cat_id] = $sess_id;
1105  }
1106  } else {
1107  $this->categories_info[$cat_id]['subitem_ids'] = array();
1108  $this->categories_info[$cat_id]['subitem_obj_ids'] = array();
1109  }
1110  }
1111  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
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
int$a_usr_id
Returns

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

References ilCalendarCache\getInstance().

Referenced by ilFavouritesManager\add(), ilCalendarAppEventListener\handleEvent(), and ilFavouritesManager\remove().

172  {
173  ilCalendarCache::getInstance()->deleteByAdditionalKeys(
174  $a_usr_id,
175  self::MODE_PERSONAL_DESKTOP_ITEMS,
176  'categories'
177  );
178  }
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 185 of file class.ilCalendarCategories.php.

References ilCalendarCache\getInstance().

Referenced by ilCalendarAppEventListener\handleEvent().

186  {
187  ilCalendarCache::getInstance()->deleteByAdditionalKeys(
188  $a_usr_id,
189  self::MODE_REPOSITORY,
190  'categories'
191  );
192  }
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 420 of file class.ilCalendarCategories.php.

421  {
422  if ($a_include_subitem_calendars) {
423  return array_merge((array) $this->categories, (array) $this->subitem_categories);
424  }
425 
426  return $this->categories ? $this->categories : array();
427  }

◆ getCategoriesInfo()

ilCalendarCategories::getCategoriesInfo ( )

get categories

public

Parameters

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

410  {
411  return $this->categories_info ? $this->categories_info : array();
412  }

◆ getCategoryInfo()

ilCalendarCategories::getCategoryInfo (   $a_cat_id)

public

Parameters

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

387  {
388  if (isset($this->categories_info[$a_cat_id])) {
389  return $this->categories_info[$a_cat_id];
390  }
391 
392  if (in_array($a_cat_id, (array) $this->subitem_categories)) {
393  foreach ($this->categories as $cat_id) {
394  if (in_array($a_cat_id, $this->categories_info[$cat_id]['subitem_ids'])) {
395  return $this->categories_info[$cat_id];
396  }
397  }
398  }
399  }

◆ getCHUserId()

ilCalendarCategories::getCHUserId ( )

Get ch user id.

Returns
type

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

References $ch_user_id.

Referenced by readAllConsultationHoursCalendarOfContainer(), and readConsultationHoursCalendar().

239  {
240  return $this->ch_user_id;
241  }
+ Here is the caller graph for this function:

◆ getMode()

ilCalendarCategories::getMode ( )

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

References $mode.

Referenced by initialize().

249  {
250  return $this->mode;
251  }
+ 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 487 of file class.ilCalendarCategories.php.

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

488  {
489  $not = array();
490  foreach ($this->categories_info as $info) {
491  if ($info['type'] == ilCalendarCategory::TYPE_OBJ and $info['editable'] == true) {
492  if (ilObject::_lookupType($info['obj_id']) == 'crs' or ilObject::_lookupType($info['obj_id']) == 'grp') {
493  $not[] = $info['cat_id'];
494  }
495  }
496  }
497  return $not;
498  }
static _lookupType($a_id, $a_reference=false)
lookup object type
+ Here is the call graph for this function:

◆ getSourceRefId()

ilCalendarCategories::getSourceRefId ( )

Get source ref id.

Returns
int ref id of current context/source

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

References $root_ref_id.

279  {
280  return $this->root_ref_id;
281  }

◆ 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 435 of file class.ilCalendarCategories.php.

436  {
437  if (!isset($this->categories_info[$a_cat_id]['subitem_ids'])) {
438  return array($a_cat_id);
439  }
440  return array_merge((array) $this->categories_info[$a_cat_id]['subitem_ids'], array($a_cat_id));
441  }

◆ getTargetRefId()

ilCalendarCategories::getTargetRefId ( )

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

References $target_ref_id.

◆ initialize()

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

initialize visible categories

public

Parameters
intmode
intref_id of root node
Returns

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

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

Referenced by ilCalendarSelectionBlockGUI\getCalendars().

292  {
293  if ($this->getMode() != 0) {
294  include_once("./Services/Calendar/exceptions/class.ilCalCategoriesInitializedMultipleException.php");
295  throw new ilCalCategoriesInitializedMultipleException("ilCalendarCategories is initialized multiple times for user " . $this->user_id . ".");
296  }
297 
298  $this->setMode($a_mode);
299 
300  // see comments in https://mantis.ilias.de/view.php?id=25254
301  if ($a_use_cache && $this->getMode() != self::MODE_REPOSITORY_CONTAINER_ONLY) {
302  // Read categories from cache
303  if ($cats = ilCalendarCache::getInstance()->getEntry($this->user_id . ':' . $a_mode . ':categories:' . (int) $a_source_ref_id)) {
304  if ($this->getMode() != self::MODE_REPOSITORY &&
305  $this->getMode() != self::MODE_CONSULTATION &&
306  $this->getMode() != self::MODE_PORTFOLIO_CONSULTATION) {
307  $this->wakeup($cats);
308  return;
309  }
310  }
311  }
312 
313  switch ($this->getMode()) {
314  case self::MODE_REMOTE_ACCESS:
315  include_once('./Services/Calendar/classes/class.ilCalendarUserSettings.php');
317  $this->readPDCalendars();
318  } else {
319  $this->readSelectedItemCalendars();
320  }
321  break;
322 
323  case self::MODE_REMOTE_SELECTED:
324  $this->readSelectedCalendar($a_source_ref_id);
325  break;
326 
327  case self::MODE_PERSONAL_DESKTOP_MEMBERSHIP:
328  $this->readPDCalendars();
329  break;
330 
331  case self::MODE_PERSONAL_DESKTOP_ITEMS:
332  $this->readSelectedItemCalendars();
333  break;
334 
335  case self::MODE_REPOSITORY:
336  $this->root_ref_id = $a_source_ref_id;
337  $this->root_obj_id = ilObject::_lookupObjId($this->root_ref_id);
338  $this->readReposCalendars();
339  break;
340 
341  case self::MODE_REPOSITORY_CONTAINER_ONLY:
342  $this->root_ref_id = $a_source_ref_id;
343  $this->root_obj_id = ilObject::_lookupObjId($this->root_ref_id);
344  $this->readReposCalendars(true);
345  break;
346 
347  case self::MODE_MANAGE:
348  $this->readPDCalendars();
349  $this->readSelectedItemCalendars();
350  break;
351 
352  case self::MODE_CONSULTATION:
353  #$this->readPrivateCalendars();
354  $this->setTargetRefId($a_source_ref_id);
355  $this->readConsultationHoursCalendar($a_source_ref_id);
356  break;
357 
358  case self::MODE_PORTFOLIO_CONSULTATION:
360  break;
361 
362  case self::MODE_SINGLE_CALENDAR:
363  $this->readSingleCalendar($a_cat_id);
364  break;
365  }
366 
367  if ($a_use_cache) {
368  // Store in cache
369  ilCalendarCache::getInstance()->storeEntry(
370  $this->user_id . ':' . $a_mode . ':categories:' . (int) $a_source_ref_id,
371  $this->sleep(),
372  $this->user_id,
373  $a_mode,
374  'categories'
375  );
376  }
377  }
static getInstance()
get singleton instance
readSelectedItemCalendars()
Read categories of selected items.
Exception being thrown calendar categories is initiliazed multiple times for the same user...
wakeup($a_ser)
Load from serialize string.
readReposCalendars($a_container_only=false)
Read available repository calendars.
sleep()
Serialize categories.
static _getInstance()
get instance for logged in user
static _lookupObjId($a_id)
readSelectedCalendar($a_cal_id)
Read info about selected calendar.
readConsultationHoursCalendar($a_target_ref_id=null, $a_cat_id=0)
Read personal consultation hours calendar.
readPDCalendars()
Read categories of user.
+ Here is the call graph for this function:
+ Here is the caller 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 507 of file class.ilCalendarCategories.php.

508  {
509  return isset($this->categories_info[$a_cat_id]['editable']) and $this->categories_info[$a_cat_id]['editable'];
510  }

◆ isVisible()

ilCalendarCategories::isVisible (   $a_cat_id)

check if category is visible

public

Parameters
int$a_cat_idcategory id
Returns

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

520  {
521  return in_array($a_cat_id, $this->categories) or
522  in_array($a_cat_id, (array) $this->subitem_categories);
523  }

◆ lookupPrivateCategories()

static ilCalendarCategories::lookupPrivateCategories (   $a_user_id)
static

Lookup private categories of user.

Parameters

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

References $DIC, $ilDB, and ilCalendarCategory\TYPE_USR.

Referenced by ilUserExporter\getXmlExportTailDependencies().

1120  {
1121  global $DIC;
1122 
1123  $ilDB = $DIC['ilDB'];
1124 
1125  // First read private calendars of user
1126  $set = $ilDB->query("SELECT * FROM cal_categories " .
1127  "WHERE type = " . $ilDB->quote(ilCalendarCategory::TYPE_USR, 'integer') . " " .
1128  "AND obj_id = " . $ilDB->quote($a_user_id, 'integer'));
1129  $cats = array();
1130  while ($rec = $ilDB->fetchAssoc($set)) {
1131  $cats[] = $rec;
1132  }
1133  return $cats;
1134  }
global $DIC
Definition: goto.php:24
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 451 of file class.ilCalendarCategories.php.

References $DIC, $lng, ilCalendarCategory\LTYPE_REMOTE, and ilCalendarCategory\TYPE_USR.

452  {
453  global $DIC;
454 
455  $lng = $DIC['lng'];
456 
457  $has_personal_calendar = false;
458  foreach ($this->categories_info as $info) {
459  if ($info['obj_type'] == 'sess' || $info['obj_type'] == 'exc') {
460  continue;
461  }
462 
463  if ($info['remote'] == ilCalendarCategory::LTYPE_REMOTE) {
464  continue;
465  }
466 
467  if ($info['type'] == ilCalendarCategory::TYPE_USR and $info['editable']) {
468  $has_personal_calendar = true;
469  }
470 
471  if ($info['editable']) {
472  $cats[$info['cat_id']] = $info['title'];
473  }
474  }
475  // If there
476  if (!$has_personal_calendar) {
477  $cats[0] = $lng->txt('cal_default_calendar');
478  }
479  return $cats ? $cats : array();
480  }
$lng
global $DIC
Definition: goto.php:24

◆ readAllConsultationHoursCalendarOfContainer()

ilCalendarCategories::readAllConsultationHoursCalendarOfContainer (   $a_container_ref_id)

Read personal consultation hours calendar of all tutors for a container.

Parameters
int$a_container_ref_idcontainer ref id

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

References ilCourseParticipants\_getInstanceByObjId(), ilObject\_lookupObjId(), getCHUserId(), ilBookingEntry\lookupBookableUsersForObject(), readConsultationHoursCalendar(), and setCHUserId().

Referenced by readReposCalendars().

851  {
852  include_once "Modules/Course/classes/class.ilCourseParticipants.php";
853  $obj_id = ilObject::_lookupObjId($a_container_ref_id);
854  $participants = ilCourseParticipants::_getInstanceByObjId($obj_id);
855  $users = array_unique(array_merge($participants->getTutors(), $participants->getAdmins()));
856  include_once 'Services/Booking/classes/class.ilBookingEntry.php';
857  $users = ilBookingEntry::lookupBookableUsersForObject($obj_id, $users);
858  $old_ch = $this->getCHUserId();
859  foreach ($users as $user) {
860  $this->setCHUserId($user);
861  $this->readConsultationHoursCalendar($a_container_ref_id);
862  }
863  $this->setCHUserId($old_ch);
864  }
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
setCHUserId($a_user_id)
Set ch user id.
static lookupBookableUsersForObject($a_obj_id, $a_user_ids)
Consultation hours are offered if 1) consultation hour owner is admin or tutor and no object assignme...
static _lookupObjId($a_id)
readConsultationHoursCalendar($a_target_ref_id=null, $a_cat_id=0)
Read personal consultation hours calendar.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readBookingCalendar()

ilCalendarCategories::readBookingCalendar (   $user_id = null)

Read booking manager calendar.

Parameters
int$user_id
Returns

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

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

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

953  {
954  global $DIC;
955 
956  $ilDB = $DIC['ilDB'];
957 
958  if (!$user_id) {
960  }
961 
962  $query = "SELECT * FROM cal_categories " .
963  "WHERE type = " . $ilDB->quote(ilCalendarCategory::TYPE_BOOK, 'integer') . ' ' .
964  "AND obj_id = " . $ilDB->quote($user_id, 'integer');
965  $res = $ilDB->query($query);
966  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
967  $this->categories[] = $row->cat_id;
968  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
969  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
970  $this->categories_info[$row->cat_id]['title'] = $row->title;
971  $this->categories_info[$row->cat_id]['color'] = $row->color;
972  $this->categories_info[$row->cat_id]['type'] = $row->type;
973  $this->categories_info[$row->cat_id]['editable'] = false;
974  $this->categories_info[$row->cat_id]['settings'] = false;
975  $this->categories_info[$row->cat_id]['accepted'] = false;
976  $this->categories_info[$row->cat_id]['remote'] = false;
977  }
978  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
global $ilDB
+ Here is the caller graph for this function:

◆ readConsultationHoursCalendar()

ilCalendarCategories::readConsultationHoursCalendar (   $a_target_ref_id = null,
  $a_cat_id = 0 
)

Read personal consultation hours calendar.

Parameters
int$user_id
Returns

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

References $categories, $DIC, $ilDB, $lng, $query, $res, ilObjUser\_lookupFullname(), ilObject\_lookupObjId(), ilDBConstants\FETCHMODE_OBJECT, getCHUserId(), setCHUserId(), and ilCalendarCategory\TYPE_CH.

Referenced by initialize(), readAllConsultationHoursCalendarOfContainer(), readPDCalendars(), readSelectedItemCalendars(), and readSingleCalendar().

872  {
873  global $DIC;
874 
875  $ilDB = $DIC['ilDB'];
876  $lng = $DIC['lng'];
877 
878  if (!$this->getCHUserId()) {
879  $this->setCHUserId($this->user_id);
880  }
881 
882  if ($a_target_ref_id) {
883  $target_obj_id = ilObject::_lookupObjId($a_target_ref_id);
884 
885  $query = 'SELECT DISTINCT(cc.cat_id) FROM booking_entry be ' .
886  'LEFT JOIN booking_obj_assignment bo ON be.booking_id = bo.booking_id ' .
887  'JOIN cal_entries ce ON be.booking_id = ce.context_id ' .
888  'JOIN cal_cat_assignments ca ON ce.cal_id = ca.cal_id ' .
889  'JOIN cal_categories cc ON ca.cat_id = cc.cat_id ' .
890  'WHERE ((bo.target_obj_id IS NULL) OR bo.target_obj_id = ' . $ilDB->quote($target_obj_id, 'integer') . ' ) ';
891 
892  // limit only to user if no cat id is given
893  if ($a_cat_id == 0) {
894  $query .= 'AND cc.obj_id = ' . $ilDB->quote($this->getCHUserId(), 'integer');
895  }
896 
897 
898  $res = $ilDB->query($query);
899  $categories = array();
900  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
901  if ($a_cat_id == 0 || $row->cat_id == $a_cat_id) {
902  $categories[] = $row->cat_id;
903  }
904  }
905 
906  if ($categories) {
907  $query = 'SELECT * FROM cal_categories ' .
908  'WHERE ' . $ilDB->in('cat_id', $categories, false, 'integer');
909  $res = $ilDB->query($query);
910  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
911  $this->categories[] = $row->cat_id;
912  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
913  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
914  $this->categories_info[$row->cat_id]['title'] = ilObjUser::_lookupFullname($row->obj_id);
915  $this->categories_info[$row->cat_id]['color'] = $row->color;
916  $this->categories_info[$row->cat_id]['type'] = $row->type;
917  $this->categories_info[$row->cat_id]['editable'] = false;
918  $this->categories_info[$row->cat_id]['settings'] = false;
919  $this->categories_info[$row->cat_id]['accepted'] = false;
920  $this->categories_info[$row->cat_id]['remote'] = false;
921  }
922  }
923  } else { // no category given
924  $filter = ($a_cat_id > 0)
925  ? " AND cat_id = " . $ilDB->quote($a_cat_id, "integer")
926  : " AND obj_id = " . $ilDB->quote($this->getCHUserId(), 'integer');
927 
928  $query = "SELECT * FROM cal_categories cc " .
929  "WHERE type = " . $ilDB->quote(ilCalendarCategory::TYPE_CH, 'integer') . ' ' . $filter;
930  $res = $ilDB->query($query);
931  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
932  $this->categories[] = $row->cat_id;
933  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
934  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
935  $this->categories_info[$row->cat_id]['title'] = $row->title;
936  $this->categories_info[$row->cat_id]['color'] = $row->color;
937  $this->categories_info[$row->cat_id]['type'] = $row->type;
938  $this->categories_info[$row->cat_id]['editable'] = false;
939  $this->categories_info[$row->cat_id]['settings'] = false;
940  $this->categories_info[$row->cat_id]['accepted'] = false;
941  $this->categories_info[$row->cat_id]['remote'] = false;
942  }
943  }
944  return true;
945  }
static _lookupFullname($a_user_id)
Lookup Full Name.
setCHUserId($a_user_id)
Set ch user id.
foreach($_POST as $key=> $value) $res
$lng
static _lookupObjId($a_id)
global $DIC
Definition: goto.php:24
$query
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 535 of file class.ilCalendarCategories.php.

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

Referenced by initialize().

536  {
537  global $DIC;
538 
539  $rbacsystem = $DIC['rbacsystem'];
540 
541 
542  $this->readPublicCalendars();
543  $this->readPrivateCalendars();
545  $this->readBookingCalendar();
546 
547  include_once('./Services/Membership/classes/class.ilParticipants.php');
548  $this->readSelectedCategories(ilParticipants::_getMembershipByType($this->user_id, 'crs'));
549  $this->readSelectedCategories(ilParticipants::_getMembershipByType($this->user_id, 'grp'));
550 
551  $this->addSubitemCalendars();
552  }
addSubitemCalendars()
Add subitem calendars E.g.
readSelectedCategories($a_obj_ids, $a_source_ref_id=0)
read selected categories
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
readBookingCalendar($user_id=null)
Read booking manager calendar.
readPrivateCalendars($only_cat_ids=null)
Read private calendars.
global $DIC
Definition: goto.php:24
readConsultationHoursCalendar($a_target_ref_id=null, $a_cat_id=0)
Read personal consultation hours calendar.
readPublicCalendars($cat_ids=null)
Read public calendars.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readPrivateCalendars()

ilCalendarCategories::readPrivateCalendars (   $only_cat_ids = null)
protected

Read private calendars.

protected

Returns

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

References $DIC, $ilDB, $ilUser, $in, $query, $res, ilDBConstants\FETCHMODE_OBJECT, ilCalendarSharedStatus\getAcceptedCalendars(), ilCalendarCategory\LTYPE_REMOTE, and ilCalendarCategory\TYPE_USR.

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

774  {
775  global $DIC;
776 
777  $ilUser = $DIC['ilUser'];
778  global $DIC;
779 
780  $ilDB = $DIC['ilDB'];
781 
782  $in = "";
783  if (is_array($only_cat_ids)) {
784  $in = " AND " . $this->db->in('cat_id', $only_cat_ids, false, 'integer') . " ";
785  }
786 
787  // First read private calendars of user
788  $query = "SELECT cat_id FROM cal_categories " .
789  "WHERE type = " . $this->db->quote(ilCalendarCategory::TYPE_USR, 'integer') . " " .
790  "AND obj_id = " . $this->db->quote($ilUser->getId(), 'integer') . " " . $in;
791  $res = $this->db->query($query);
792  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
793  $cat_ids[] = $row->cat_id;
794  }
795 
796  // Read shared calendars
797  include_once('./Services/Calendar/classes/class.ilCalendarSharedStatus.php');
798  $accepted_ids = ilCalendarSharedStatus::getAcceptedCalendars($ilUser->getId());
799  if (!$cat_ids = array_merge((array) $cat_ids, $accepted_ids)) {
800  return true;
801  }
802 
803  if (is_array($only_cat_ids)) {
804  $cat_ids = array_filter($cat_ids, function ($id) use ($only_cat_ids) {
805  return in_array($id, $only_cat_ids);
806  });
807  }
808 
809  // user categories
810  $query = "SELECT * FROM cal_categories " .
811  "WHERE type = " . $this->db->quote(ilCalendarCategory::TYPE_USR, 'integer') . " " .
812  "AND " . $ilDB->in('cat_id', $cat_ids, false, 'integer') . " " .
813  "ORDER BY title ";
814 
815  $res = $this->db->query($query);
816  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
817  $this->categories[] = $row->cat_id;
818  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
819  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
820  $this->categories_info[$row->cat_id]['title'] = $row->title;
821  $this->categories_info[$row->cat_id]['color'] = $row->color;
822  $this->categories_info[$row->cat_id]['type'] = $row->type;
823 
824  include_once './Services/Calendar/classes/class.ilCalendarShared.php';
825  if (in_array($row->cat_id, $accepted_ids)) {
826  $shared = new ilCalendarShared($row->cat_id);
827  if ($shared->isEditableForUser($ilUser->getId())) {
828  $this->categories_info[$row->cat_id]['editable'] = true;
829  } else {
830  $this->categories_info[$row->cat_id]['editable'] = false;
831  }
832  } else {
833  $this->categories_info[$row->cat_id]['editable'] = true;
834  }
835  if ($ilUser->getId() == $row->obj_id) {
836  $this->categories_info[$row->cat_id]['settings'] = true;
837  } else {
838  $this->categories_info[$row->cat_id]['settings'] = false;
839  }
840 
841  $this->categories_info[$row->cat_id]['accepted'] = in_array($row->cat_id, $accepted_ids);
842  $this->categories_info[$row->cat_id]['remote'] = ($row->loc_type == ilCalendarCategory::LTYPE_REMOTE);
843  }
844  }
static getAcceptedCalendars($a_usr_id)
get accepted shared calendars
Handles shared calendars.
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
global $ilDB
$ilUser
Definition: imgupload.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readPublicCalendars()

ilCalendarCategories::readPublicCalendars (   $cat_ids = null)
protected

Read public calendars.

protected

Returns

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

References $DIC, $in, $query, $res, ilCalendarSettings\_getInstance(), ilDBConstants\FETCHMODE_OBJECT, ilCalendarCategory\LTYPE_REMOTE, and ilCalendarCategory\TYPE_GLOBAL.

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

734  {
735  global $DIC;
736 
737  $rbacsystem = $DIC['rbacsystem'];
738  $ilAccess = $DIC['ilAccess'];
739 
740  $in = "";
741  if (is_array($cat_ids)) {
742  $in = " AND " . $this->db->in('cat_id', $cat_ids, false, 'integer') . " ";
743  }
744 
745  // global categories
746  $query = "SELECT * FROM cal_categories " .
747  "WHERE type = " . $this->db->quote(ilCalendarCategory::TYPE_GLOBAL, 'integer') . " " . $in .
748  "ORDER BY title ";
749 
750  $res = $this->db->query($query);
751  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
752  $this->categories[] = $row->cat_id;
753  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
754  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
755  $this->categories_info[$row->cat_id]['title'] = $row->title;
756  $this->categories_info[$row->cat_id]['color'] = $row->color;
757  $this->categories_info[$row->cat_id]['type'] = $row->type;
758  $this->categories_info[$row->cat_id]['editable'] = $rbacsystem->checkAccess('edit_event', ilCalendarSettings::_getInstance()->getCalendarSettingsId());
759  $this->categories_info[$row->cat_id]['settings'] = $rbacsystem->checkAccess('write', ilCalendarSettings::_getInstance()->getCalendarSettingsId());
760  $this->categories_info[$row->cat_id]['accepted'] = false;
761  $this->categories_info[$row->cat_id]['remote'] = ($row->loc_type == ilCalendarCategory::LTYPE_REMOTE);
762  }
763 
764  return true;
765  }
static _getInstance()
get singleton instance
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readReposCalendars()

ilCalendarCategories::readReposCalendars (   $a_container_only = false)
protected

Read available repository calendars.

protected

Parameters

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

References $DIC, $GLOBALS, $ilDB, $res, ilCalendarSettings\_getInstance(), ilParticipants\_getMembershipByType(), ilObject\_lookupType(), addSubitemCalendars(), ilDBConstants\FETCHMODE_OBJECT, readAllConsultationHoursCalendarOfContainer(), readBookingCalendar(), readPrivateCalendars(), readPublicCalendars(), and readSelectedCategories().

Referenced by initialize().

631  {
632  global $DIC;
633 
634  $ilAccess = $DIC['ilAccess'];
635  $tree = $DIC['tree'];
636  global $DIC;
637 
638  $ilDB = $DIC['ilDB'];
639 
640  if (!$a_container_only) {
641  $this->readPublicCalendars();
642  $this->readPrivateCalendars();
643  //$this->readConsultationHoursCalendar($this->root_ref_id);
644  $this->readAllConsultationHoursCalendarOfContainer($this->root_ref_id);
645  }
646 
647 
648 
649  #$query = "SELECT ref_id,obd.obj_id obj_id FROM tree t1 ".
650  # "JOIN object_reference obr ON t1.child = obr.ref_id ".
651  # "JOIN object_data obd ON obd.obj_id = obr.obj_id ".
652  # "WHERE t1.lft >= (SELECT lft FROM tree WHERE child = ".$this->db->quote($this->root_ref_id,'integer')." ) ".
653  # "AND t1.lft <= (SELECT rgt FROM tree WHERE child = ".$this->db->quote($this->root_ref_id,'integer')." ) ".
654  # "AND ".$ilDB->in('type',array('crs','grp','sess'),false,'text')." ".
655  # "AND tree = 1";
656 
657  // alternative 1: do not aggregate items of current course
658  if (!true) { //
659  $subtree_query = $GLOBALS['DIC']['tree']->getSubTreeQuery(
660  $this->root_ref_id,
661  array('object_reference.ref_id', 'object_data.obj_id'),
662  array('crs', 'grp', 'sess', 'exc')
663  );
664 
665  $res = $ilDB->query($subtree_query);
666  $obj_ids = array();
667  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
668  if ($tree->isDeleted($row->ref_id)) {
669  continue;
670  }
671 
672  $obj_type = ilObject::_lookupType($row->obj_id);
673  if ($obj_type == 'crs' or $obj_type == 'grp') {
674  //Added for calendar revision --> https://goo.gl/CXGTRF
675  //In 5.2-trunk, the booking pools did not appear in the marginal calendar.
676  $this->readBookingCalendar();
677  // Check for global/local activation
678  if (!ilCalendarSettings::_getInstance()->lookupCalendarActivated($row->obj_id)) {
679  continue;
680  }
681  }
682  if ($ilAccess->checkAccess('read', '', $row->ref_id)) {
683  $obj_ids[] = $row->obj_id;
684  }
685  }
686  $this->readSelectedCategories($obj_ids, $this->root_ref_id);
687  } else { // alternative 2: aggregate items of current course (discussion with timon 3.8.3017: this is the current preference)
688  $this->readSelectedCategories(array($this->root_obj_id), $this->root_ref_id);
689  }
690 
691  $this->addSubitemCalendars();
692 
693 
694  if (!$a_container_only) {
695  $this->readSelectedCategories(ilParticipants::_getMembershipByType($this->user_id, 'crs'));
696  $this->readSelectedCategories(ilParticipants::_getMembershipByType($this->user_id, 'grp'));
697  }
698  }
readAllConsultationHoursCalendarOfContainer($a_container_ref_id)
Read personal consultation hours calendar of all tutors for a container.
addSubitemCalendars()
Add subitem calendars E.g.
readSelectedCategories($a_obj_ids, $a_source_ref_id=0)
read selected categories
static _getInstance()
get singleton instance
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
readBookingCalendar($user_id=null)
Read booking manager calendar.
readPrivateCalendars($only_cat_ids=null)
Read private calendars.
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
static _lookupType($a_id, $a_reference=false)
lookup object type
global $ilDB
readPublicCalendars($cat_ids=null)
Read public 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 558 of file class.ilCalendarCategories.php.

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

Referenced by initialize(), and readSingleCalendar().

559  {
560  include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
561  $cat = new ilCalendarCategory($a_cal_id);
562  if ($cat->getType() == ilCalendarCategory::TYPE_OBJ) {
563  $this->readSelectedCategories(array($cat->getObjId()));
564  $this->addSubitemCalendars();
565  } else {
566  $this->categories[] = $a_cal_id;
567  }
568  }
addSubitemCalendars()
Add subitem calendars E.g.
readSelectedCategories($a_obj_ids, $a_source_ref_id=0)
read selected categories
Stores calendar categories.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readSelectedCategories()

ilCalendarCategories::readSelectedCategories (   $a_obj_ids,
  $a_source_ref_id = 0 
)
protected

read selected categories

protected

Returns

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

References $DIC, $ilDB, $query, $res, ilObject\_getAllReferences(), ilCalendarSettings\_getInstance(), ilObject\_lookupType(), ilDBConstants\FETCHMODE_OBJECT, and ilCalendarCategory\TYPE_OBJ.

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

987  {
988  global $DIC;
989 
990  $ilAccess = $DIC['ilAccess'];
991  $tree = $DIC['tree'];
992  global $DIC;
993 
994  $ilDB = $DIC['ilDB'];
995 
996  if (!count($a_obj_ids)) {
997  return true;
998  }
999 
1000  $query = "SELECT * FROM cal_categories " .
1001  "WHERE type = " . $this->db->quote(ilCalendarCategory::TYPE_OBJ, 'integer') . " " .
1002  "AND " . $ilDB->in('obj_id', $a_obj_ids, false, 'integer') . " " .
1003  "ORDER BY title ";
1004 
1005  $res = $this->db->query($query);
1006  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1007  // check activation/deactivation
1008  $obj_type = ilObject::_lookupType($row->obj_id);
1009  if ($obj_type == 'crs' or $obj_type == 'grp') {
1010  if (!ilCalendarSettings::_getInstance()->lookupCalendarActivated($row->obj_id)) {
1011  continue;
1012  }
1013  }
1014 
1015  $editable = false;
1016  $exists = false;
1017  $settings = false;
1018  foreach (ilObject::_getAllReferences($row->obj_id) as $ref_id) {
1019  if ($ilAccess->checkAccess('edit_event', '', $ref_id)) {
1020  $settings = true;
1021  }
1022  if ($ilAccess->checkAccess('edit_event', '', $ref_id)) {
1023  $exists = true;
1024  $editable = true;
1025  break;
1026  } elseif ($ilAccess->checkAccess('read', '', $ref_id)) {
1027  $exists = true;
1028  }
1029  }
1030  if (!$exists) {
1031  continue;
1032  }
1033  $this->categories_info[$row->cat_id]['editable'] = $editable;
1034  $this->categories_info[$row->cat_id]['settings'] = $settings;
1035 
1036  $this->categories[] = $row->cat_id;
1037  $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
1038  $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
1039  $this->categories_info[$row->cat_id]['color'] = $row->color;
1040  #$this->categories_info[$row->cat_id]['title'] = ilObject::_lookupTitle($row->obj_id);
1041  $this->categories_info[$row->cat_id]['title'] = $row->title;
1042  $this->categories_info[$row->cat_id]['obj_type'] = ilObject::_lookupType($row->obj_id);
1043  $this->categories_info[$row->cat_id]['type'] = $row->type;
1044  $this->categories_info[$row->cat_id]['remote'] = false;
1045  $this->categories_info[$row->cat_id]['source_ref_id'] = $a_source_ref_id;
1046  }
1047  }
static _getInstance()
get singleton instance
static _getAllReferences($a_id)
get all reference ids of object
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
static _lookupType($a_id, $a_reference=false)
lookup object type
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 576 of file class.ilCalendarCategories.php.

References $DIC, $ilUser, addSubitemCalendars(), readBookingCalendar(), readConsultationHoursCalendar(), readPrivateCalendars(), readPublicCalendars(), and readSelectedCategories().

Referenced by initialize().

577  {
578  global $DIC;
579 
580  $ilUser = $DIC['ilUser'];
581  $ilAccess = $DIC['ilAccess'];
582 
583  $this->readPublicCalendars();
584  $this->readPrivateCalendars();
586  $this->readBookingCalendar();
587 
588  $obj_ids = array();
589 
590  $courses = array();
591  $groups = array();
592  $sessions = array();
593  $exercises = array();
594  foreach ($this->fav_rep->getFavouritesOfUser($ilUser->getId(), array('crs','grp','sess','exc')) as $item) {
595  if ($ilAccess->checkAccess('read', '', $item['ref_id'])) {
596  switch ($item['type']) {
597  case 'crs':
598  $courses[] = $item['obj_id'];
599  break;
600 
601  case 'sess':
602  $sessions[] = $item['obj_id'];
603  break;
604 
605  case 'grp':
606  $groups[] = $item['obj_id'];
607  break;
608 
609  case 'exc':
610  $exercises[] = $item['obj_id'];
611  break;
612  }
613  }
614  }
615  $this->readSelectedCategories($courses);
616  $this->readSelectedCategories($sessions);
617  $this->readSelectedCategories($groups);
618  $this->readSelectedCategories($exercises);
619 
620  $this->addSubitemCalendars();
621  }
addSubitemCalendars()
Add subitem calendars E.g.
readSelectedCategories($a_obj_ids, $a_source_ref_id=0)
read selected categories
readBookingCalendar($user_id=null)
Read booking manager calendar.
readPrivateCalendars($only_cat_ids=null)
Read private calendars.
global $DIC
Definition: goto.php:24
readConsultationHoursCalendar($a_target_ref_id=null, $a_cat_id=0)
Read personal consultation hours calendar.
$ilUser
Definition: imgupload.php:18
readPublicCalendars($cat_ids=null)
Read public calendars.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readSingleCalendar()

ilCalendarCategories::readSingleCalendar (   $a_cat_id)

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

References readBookingCalendar(), readConsultationHoursCalendar(), readPrivateCalendars(), readPublicCalendars(), readSelectedCalendar(), ilCalendarCategory\TYPE_BOOK, ilCalendarCategory\TYPE_CH, ilCalendarCategory\TYPE_GLOBAL, ilCalendarCategory\TYPE_OBJ, and ilCalendarCategory\TYPE_USR.

Referenced by initialize().

701  {
702  include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
703  $cat = new ilCalendarCategory($a_cat_id);
704  switch ($cat->getType()) {
706  $this->readSelectedCalendar($a_cat_id);
707  break;
708 
710  $this->readPublicCalendars(array($a_cat_id));
711  break;
712 
714  $this->readPrivateCalendars(array($a_cat_id));
715  break;
716 
718  $this->readConsultationHoursCalendar($this->root_ref_id, $a_cat_id);
719  break;
720 
722  $this->readBookingCalendar();
723  break;
724  }
725  }
readBookingCalendar($user_id=null)
Read booking manager calendar.
Stores calendar categories.
readPrivateCalendars($only_cat_ids=null)
Read private calendars.
readSelectedCalendar($a_cal_id)
Read info about selected calendar.
readConsultationHoursCalendar($a_target_ref_id=null, $a_cat_id=0)
Read personal consultation hours calendar.
readPublicCalendars($cat_ids=null)
Read public 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 228 of file class.ilCalendarCategories.php.

Referenced by readAllConsultationHoursCalendarOfContainer(), and readConsultationHoursCalendar().

229  {
230  $this->ch_user_id = $a_user_id;
231  }
+ Here is the caller graph for this function:

◆ setMode()

ilCalendarCategories::setMode (   $a_mode)
protected

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

Referenced by initialize().

244  {
245  $this->mode = $a_mode;
246  }
+ Here is the caller graph for this function:

◆ setSourceRefId()

ilCalendarCategories::setSourceRefId (   $a_val)

Set source ref id.

Parameters
int$a_valref id of current context/source

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

269  {
270  $this->root_ref_id = $a_val;
271  }

◆ setTargetRefId()

ilCalendarCategories::setTargetRefId (   $a_ref_id)
protected

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

Referenced by initialize().

254  {
255  $this->target_ref_id = $a_ref_id;
256  }
+ Here is the caller graph for this function:

◆ sleep()

ilCalendarCategories::sleep ( )
protected

Serialize categories.

Returns

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

Referenced by initialize().

200  {
201  return serialize(
202  array(
203  'categories' => $this->categories,
204  'categories_info' => $this->categories_info,
205  'subitem_categories' => $this->subitem_categories
206  )
207  );
208  }
+ Here is the caller graph for this function:

◆ wakeup()

ilCalendarCategories::wakeup (   $a_ser)
protected

Load from serialize string.

Parameters
stringserialize categories
Returns

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

Referenced by initialize().

216  {
217  $info = unserialize($a_ser);
218 
219  $this->categories = $info['categories'];
220  $this->categories_info = $info['categories_info'];
221  $this->subitem_categories = $info['subitem_categories'];
222  }
+ Here is the caller graph for this function:

Field Documentation

◆ $categories

ilCalendarCategories::$categories = array()
protected

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

Referenced by readConsultationHoursCalendar().

◆ $categories_info

ilCalendarCategories::$categories_info = array()
protected

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

◆ $ch_user_id

ilCalendarCategories::$ch_user_id = 0
protected

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

Referenced by getCHUserId().

◆ $db

ilCalendarCategories::$db
protected

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

◆ $fav_rep

ilCalendarCategories::$fav_rep
protected

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

◆ $instance

ilCalendarCategories::$instance = null
staticprotected

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

◆ $logger

ilCalendarCategories::$logger = null
protected

ilLogger

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

◆ $mode

ilCalendarCategories::$mode = 0
protected

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

Referenced by getMode().

◆ $root_obj_id

ilCalendarCategories::$root_obj_id = 0
protected

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

◆ $root_ref_id

ilCalendarCategories::$root_ref_id = 0
protected

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

Referenced by getSourceRefId().

◆ $subitem_categories

ilCalendarCategories::$subitem_categories = array()
protected

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

◆ $target_ref_id

ilCalendarCategories::$target_ref_id = 0
protected

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

Referenced by getTargetRefId().

◆ $user_id

ilCalendarCategories::$user_id
protected

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

Referenced by readBookingCalendar().

◆ MODE_CONSULTATION

const ilCalendarCategories::MODE_CONSULTATION = 7

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

Referenced by ilCalendarSchedule\__construct().

◆ MODE_MANAGE

const ilCalendarCategories::MODE_MANAGE = 6

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

◆ MODE_PERSONAL_DESKTOP_ITEMS

const ilCalendarCategories::MODE_PERSONAL_DESKTOP_ITEMS = 5

◆ 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

◆ MODE_REPOSITORY_CONTAINER_ONLY

const ilCalendarCategories::MODE_REPOSITORY_CONTAINER_ONLY = 10

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

Referenced by ilCalendarBlockGUI\initCategories().

◆ MODE_SINGLE_CALENDAR

const ilCalendarCategories::MODE_SINGLE_CALENDAR = 11

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