82 $this->logger =
$GLOBALS[
'DIC']->logger()->cal();
84 $this->user_id = $a_usr_id;
85 if (!$this->user_id) {
86 $this->user_id = $ilUser->getId();
101 if (self::$instance) {
102 return self::$instance;
119 $query =
"SELECT cat_id FROM cal_categories " .
120 "WHERE obj_id = " . $ilDB->quote($a_obj_id,
'integer') .
" " .
140 public static function _isOwner($a_usr_id, $a_cal_id)
144 $query =
"SELECT * FROM cal_categories " .
145 "WHERE cat_id = " . $ilDB->quote($a_cal_id,
'integer') .
" " .
146 "AND obj_id = " . $ilDB->quote($a_usr_id,
'integer') .
" " .
149 return $res->numRows() ? true :
false;
161 self::MODE_PERSONAL_DESKTOP_ITEMS,
175 self::MODE_REPOSITORY,
189 'categories' => $this->categories,
190 'categories_info' => $this->categories_info,
191 'subitem_categories'=> $this->subitem_categories
203 $info = unserialize($a_ser);
205 $this->categories =
$info[
'categories'];
206 $this->categories_info =
$info[
'categories_info'];
207 $this->subitem_categories =
$info[
'subitem_categories'];
216 $this->ch_user_id = $a_user_id;
231 $this->mode = $a_mode;
241 $this->target_ref_id = $a_ref_id;
256 $this->root_ref_id = $a_val;
277 public function initialize($a_mode, $a_source_ref_id = 0, $a_use_cache =
false, $a_cat_id = 0)
280 include_once(
"./Services/Calendar/exceptions/class.ilCalCategoriesInitializedMultipleException.php");
287 if ($a_use_cache && $this->
getMode() != self::MODE_REPOSITORY_CONTAINER_ONLY) {
290 if ($this->
getMode() != self::MODE_REPOSITORY &&
291 $this->
getMode() != self::MODE_CONSULTATION &&
292 $this->
getMode() != self::MODE_PORTFOLIO_CONSULTATION) {
300 case self::MODE_REMOTE_ACCESS:
301 include_once(
'./Services/Calendar/classes/class.ilCalendarUserSettings.php');
309 case self::MODE_REMOTE_SELECTED:
313 case self::MODE_PERSONAL_DESKTOP_MEMBERSHIP:
317 case self::MODE_PERSONAL_DESKTOP_ITEMS:
321 case self::MODE_REPOSITORY:
322 $this->root_ref_id = $a_source_ref_id;
327 case self::MODE_REPOSITORY_CONTAINER_ONLY:
328 $this->root_ref_id = $a_source_ref_id;
333 case self::MODE_MANAGE:
338 case self::MODE_CONSULTATION:
339 #$this->readPrivateCalendars(); 344 case self::MODE_PORTFOLIO_CONSULTATION:
348 case self::MODE_SINGLE_CALENDAR:
356 $this->user_id .
':' . $a_mode .
':categories:' . (
int) $a_source_ref_id,
374 if (isset($this->categories_info[$a_cat_id])) {
375 return $this->categories_info[$a_cat_id];
378 if (in_array($a_cat_id, (
array) $this->subitem_categories)) {
379 foreach ($this->categories as $cat_id) {
380 if (in_array($a_cat_id, $this->categories_info[$cat_id][
'subitem_ids'])) {
381 return $this->categories_info[$cat_id];
397 return $this->categories_info ? $this->categories_info :
array();
408 if ($a_include_subitem_calendars) {
409 return array_merge((
array) $this->categories, (
array) $this->subitem_categories);
412 return $this->categories ? $this->categories :
array();
423 if (!isset($this->categories_info[$a_cat_id][
'subitem_ids'])) {
424 return array($a_cat_id);
426 return array_merge((
array) $this->categories_info[$a_cat_id][
'subitem_ids'],
array($a_cat_id));
441 $has_personal_calendar =
false;
442 foreach ($this->categories_info as
$info) {
443 if ($info[
'obj_type'] ==
'sess' || $info[
'obj_type'] ==
'exc') {
447 $has_personal_calendar =
true;
450 if ($info[
'editable']) {
451 $cats[$info[
'cat_id']] = $info[
'title'];
455 if (!$has_personal_calendar) {
456 $cats[0] = $lng->txt(
'cal_default_calendar');
458 return $cats ? $cats :
array();
469 foreach ($this->categories_info as
$info) {
472 $not[] = $info[
'cat_id'];
488 return isset($this->categories_info[$a_cat_id][
'editable']) and $this->categories_info[$a_cat_id][
'editable'];
500 return in_array($a_cat_id, $this->categories) or
501 in_array($a_cat_id, (
array) $this->subitem_categories);
524 include_once(
'./Services/Membership/classes/class.ilParticipants.php');
537 include_once
'./Services/Calendar/classes/class.ilCalendarCategory.php';
543 $this->categories[] = $a_cal_id;
567 $exercises =
array();
569 if ($ilAccess->checkAccess(
'read',
'', $item[
'ref_id'])) {
570 switch ($item[
'type']) {
572 $courses[] = $item[
'obj_id'];
576 $sessions[] = $item[
'obj_id'];
580 $groups[] = $item[
'obj_id'];
584 $exercises[] = $item[
'obj_id'];
606 global $ilAccess,$tree;
609 if (!$a_container_only) {
618 #$query = "SELECT ref_id,obd.obj_id obj_id FROM tree t1 ". 619 # "JOIN object_reference obr ON t1.child = obr.ref_id ". 620 # "JOIN object_data obd ON obd.obj_id = obr.obj_id ". 621 # "WHERE t1.lft >= (SELECT lft FROM tree WHERE child = ".$this->db->quote($this->root_ref_id,'integer')." ) ". 622 # "AND t1.lft <= (SELECT rgt FROM tree WHERE child = ".$this->db->quote($this->root_ref_id,'integer')." ) ". 623 # "AND ".$ilDB->in('type',array('crs','grp','sess'),false,'text')." ". 628 $subtree_query =
$GLOBALS[
'tree']->getSubTreeQuery(
630 array(
'object_reference.ref_id',
'object_data.obj_id'),
631 array(
'crs',
'grp',
'sess',
'exc')
634 $res = $ilDB->query($subtree_query);
637 if ($tree->isDeleted(
$row->ref_id)) {
642 if ($obj_type ==
'crs' or $obj_type ==
'grp') {
651 if ($ilAccess->checkAccess(
'read',
'',
$row->ref_id)) {
652 $obj_ids[] =
$row->obj_id;
663 if (!$a_container_only) {
671 include_once
'./Services/Calendar/classes/class.ilCalendarCategory.php';
673 switch ($cat->getType()) {
704 global $rbacsystem,$ilAccess;
707 if (is_array($cat_ids)) {
708 $in =
" AND " . $this->db->in(
'cat_id', $cat_ids,
false,
'integer') .
" ";
712 $query =
"SELECT * FROM cal_categories " .
718 $this->categories[] =
$row->cat_id;
719 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
720 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
721 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
722 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
723 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
726 $this->categories_info[
$row->cat_id][
'accepted'] =
false;
745 if (is_array($only_cat_ids)) {
746 $in =
" AND " . $this->db->in(
'cat_id', $only_cat_ids,
false,
'integer') .
" ";
750 $query =
"SELECT cat_id FROM cal_categories " .
752 "AND obj_id = " . $this->db->quote($ilUser->getId(),
'integer') .
" " .
$in;
755 $cat_ids[] =
$row->cat_id;
759 include_once(
'./Services/Calendar/classes/class.ilCalendarSharedStatus.php');
761 if (!$cat_ids = array_merge((
array) $cat_ids, $accepted_ids)) {
765 if (is_array($only_cat_ids)) {
766 $cat_ids = array_filter($cat_ids,
function (
$id) use ($only_cat_ids) {
767 return in_array(
$id, $only_cat_ids);
772 $query =
"SELECT * FROM cal_categories " .
774 "AND " . $ilDB->in(
'cat_id', $cat_ids,
false,
'integer') .
" " .
777 $res = $this->db->query($query);
779 $this->categories[] =
$row->cat_id;
780 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
781 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
782 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
783 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
784 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
786 include_once
'./Services/Calendar/classes/class.ilCalendarShared.php';
787 if (in_array(
$row->cat_id, $accepted_ids)) {
789 if ($shared->isEditableForUser($ilUser->getId())) {
790 $this->categories_info[
$row->cat_id][
'editable'] =
true;
792 $this->categories_info[
$row->cat_id][
'editable'] =
false;
795 $this->categories_info[
$row->cat_id][
'editable'] =
true;
797 if ($ilUser->getId() ==
$row->obj_id) {
798 $this->categories_info[
$row->cat_id][
'settings'] =
true;
800 $this->categories_info[
$row->cat_id][
'settings'] =
false;
803 $this->categories_info[
$row->cat_id][
'accepted'] = in_array(
$row->cat_id, $accepted_ids);
814 include_once
"Modules/Course/classes/class.ilCourseParticipants.php";
817 $users = array_unique(array_merge($participants->getTutors(), $participants->getAdmins()));
818 include_once
'Services/Booking/classes/class.ilBookingEntry.php';
821 foreach (
$users as $user) {
841 if ($a_target_ref_id) {
844 $query =
'SELECT DISTINCT(cc.cat_id) FROM booking_entry be ' .
845 'LEFT JOIN booking_obj_assignment bo ON be.booking_id = bo.booking_id ' .
846 'JOIN cal_entries ce ON be.booking_id = ce.context_id ' .
847 'JOIN cal_cat_assignments ca ON ce.cal_id = ca.cal_id ' .
848 'JOIN cal_categories cc ON ca.cat_id = cc.cat_id ' .
849 'WHERE ((bo.target_obj_id IS NULL) OR bo.target_obj_id = ' . $ilDB->quote($target_obj_id,
'integer') .
' ) ';
852 if ($a_cat_id == 0) {
860 if ($a_cat_id == 0 ||
$row->cat_id == $a_cat_id) {
866 $query =
'SELECT * FROM cal_categories ' .
867 'WHERE ' . $ilDB->in(
'cat_id',
$categories,
false,
'integer');
870 $this->categories[] =
$row->cat_id;
871 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
872 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
874 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
875 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
876 $this->categories_info[
$row->cat_id][
'editable'] =
false;
877 $this->categories_info[
$row->cat_id][
'settings'] =
false;
878 $this->categories_info[
$row->cat_id][
'accepted'] =
false;
879 $this->categories_info[
$row->cat_id][
'remote'] =
false;
883 $filter = ($a_cat_id > 0)
884 ?
" AND cat_id = " . $ilDB->quote($a_cat_id,
"integer")
885 :
" AND obj_id = " . $ilDB->quote($this->
getCHUserId(),
'integer');
887 $query =
"SELECT * FROM cal_categories cc " .
891 $this->categories[] =
$row->cat_id;
892 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
893 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
894 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
895 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
896 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
897 $this->categories_info[
$row->cat_id][
'editable'] =
false;
898 $this->categories_info[
$row->cat_id][
'settings'] =
false;
899 $this->categories_info[
$row->cat_id][
'accepted'] =
false;
900 $this->categories_info[
$row->cat_id][
'remote'] =
false;
919 $query =
"SELECT * FROM cal_categories " .
921 "AND obj_id = " . $ilDB->quote(
$user_id,
'integer');
924 $this->categories[] =
$row->cat_id;
925 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
926 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
927 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
928 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
929 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
930 $this->categories_info[
$row->cat_id][
'editable'] =
false;
931 $this->categories_info[
$row->cat_id][
'settings'] =
false;
932 $this->categories_info[
$row->cat_id][
'accepted'] =
false;
933 $this->categories_info[
$row->cat_id][
'remote'] =
false;
945 global $ilAccess,$tree;
948 if (!count($a_obj_ids)) {
952 $query =
"SELECT * FROM cal_categories " .
954 "AND " . $ilDB->in(
'obj_id', $a_obj_ids,
false,
'integer') .
" " .
961 if ($obj_type ==
'crs' or $obj_type ==
'grp') {
971 if ($ilAccess->checkAccess(
'edit_event',
'', $ref_id)) {
974 if ($ilAccess->checkAccess(
'edit_event',
'', $ref_id)) {
978 } elseif ($ilAccess->checkAccess(
'read',
'', $ref_id)) {
985 $this->categories_info[
$row->cat_id][
'editable'] = $editable;
986 $this->categories_info[
$row->cat_id][
'settings'] = $settings;
988 $this->categories[] =
$row->cat_id;
989 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
990 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
991 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
992 #$this->categories_info[$row->cat_id]['title'] = ilObject::_lookupTitle($row->obj_id); 993 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
995 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
996 $this->categories_info[
$row->cat_id][
'remote'] =
false;
997 $this->categories_info[
$row->cat_id][
'source_ref_id'] = $a_source_ref_id;
1011 $course_ids =
array();
1012 foreach ($this->categories as $cat_id) {
1013 if ($this->categories_info[$cat_id][
'obj_type'] ==
'crs' or $this->categories_info[$cat_id][
'obj_type'] ==
'grp') {
1014 $course_ids[] = $this->categories_info[$cat_id][
'obj_id'];
1018 $query =
"SELECT od2.obj_id sess_id, od1.obj_id crs_id,cat_id FROM object_data od1 " .
1019 "JOIN object_reference or1 ON od1.obj_id = or1.obj_id " .
1020 "JOIN tree t ON or1.ref_id = t.parent " .
1021 "JOIN object_reference or2 ON t.child = or2.ref_id " .
1022 "JOIN object_data od2 ON or2.obj_id = od2.obj_id " .
1023 "JOIN cal_categories cc ON od2.obj_id = cc.obj_id " .
1024 "WHERE " . $ilDB->in(
'od2.type',
array(
'sess',
'exc'),
false,
'text') .
1025 "AND (od1.type = 'crs' OR od1.type = 'grp') " .
1026 "AND " . $ilDB->in(
'od1.obj_id', $course_ids,
false,
'integer') .
' ' .
1027 "AND or2.deleted IS NULL";
1031 $course_sessions =
array();
1033 $cat_ids[] =
$row->cat_id;
1034 $course_sessions[
$row->crs_id][
$row->sess_id] =
$row->cat_id;
1035 $this->subitem_categories[] =
$row->cat_id;
1038 foreach ($this->categories as $cat_id) {
1040 ($this->categories_info[$cat_id][
'obj_type'] ==
'crs' ||
1041 $this->categories_info[$cat_id][
'obj_type'] ==
'grp') &&
1042 isset($this->categories_info[$cat_id][
'obj_id']) &&
1043 isset($course_sessions[$this->categories_info[$cat_id][
'obj_id']]) &&
1044 is_array($course_sessions[$this->categories_info[$cat_id][
'obj_id']])) {
1045 foreach ($course_sessions[$this->categories_info[$cat_id][
'obj_id']] as $sess_id => $sess_cat_id) {
1046 $this->categories_info[$cat_id][
'subitem_ids'][$sess_id] = $sess_cat_id;
1047 $this->categories_info[$cat_id][
'subitem_obj_ids'][$sess_cat_id] = $sess_id;
1050 $this->categories_info[$cat_id][
'subitem_ids'] =
array();
1051 $this->categories_info[$cat_id][
'subitem_obj_ids'] =
array();
1067 $set = $ilDB->query(
"SELECT * FROM cal_categories " .
1069 "AND obj_id = " . $ilDB->quote($a_user_id,
'integer'));
1071 while ($rec = $ilDB->fetchAssoc($set)) {
class for calendar categories
static getInstance()
get singleton instance
readAllConsultationHoursCalendarOfContainer($a_container_ref_id)
Read personal consultation hours calendar of all tutors for a container.
readSelectedItemCalendars()
Read categories of selected items.
addSubitemCalendars()
Add subitem calendars E.g.
readSelectedCategories($a_obj_ids, $a_source_ref_id=0)
read selected categories
static _getInstance()
get singleton instance
Exception being thrown calendar categories is initiliazed multiple times for the same user...
static _isOwner($a_usr_id, $a_cal_id)
check if user is owner of a category
wakeup($a_ser)
Load from serialize string.
static getAcceptedCalendars($a_usr_id)
get accepted shared calendars
getCategoryInfo($a_cat_id)
public
const MODE_PERSONAL_DESKTOP_MEMBERSHIP
static _lookupFullname($a_user_id)
Lookup Full Name.
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
readReposCalendars($a_container_only=false)
Read available repository calendars.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
if(!array_key_exists('StateId', $_REQUEST)) $id
setCHUserId($a_user_id)
Set ch user id.
const CAL_SELECTION_MEMBERSHIP
static _lookupCategoryIdByObjId($a_obj_id)
lookup category by obj_id
const MODE_REMOTE_SELECTED
readBookingCalendar($user_id=null)
Read booking manager calendar.
sleep()
Serialize categories.
isVisible($a_cat_id)
check if category is visible
const MODE_REPOSITORY_CONTAINER_ONLY
Stores calendar categories.
const MODE_SINGLE_CALENDAR
static deletePDItemsCache($a_usr_id)
Delete cache (add remove desktop item)
Handles shared calendars.
readPrivateCalendars($only_cat_ids=null)
Read private calendars.
static _getAllReferences($a_id)
get all reference ids of object
setSourceRefId($a_val)
Set source ref 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...
isEditable($a_cat_id)
check if category is editable
static deleteRepositoryCache($a_usr_id)
Delete cache.
foreach($_POST as $key=> $value) $res
getCHUserId()
Get ch user id.
getSourceRefId()
Get source ref id.
static _getInstance()
get instance for logged in user
static _lookupObjId($a_id)
initialize($a_mode, $a_source_ref_id=0, $a_use_cache=false, $a_cat_id=0)
initialize visible categories
getSubitemCategories($a_cat_id)
get subitem categories for a specific category
readSelectedCalendar($a_cal_id)
Read info about selected calendar.
const MODE_PORTFOLIO_CONSULTATION
prepareCategoriesOfUserForSelection()
prepare categories of users for selection
static _getInstance($a_usr_id=0)
get singleton instance
setTargetRefId($a_ref_id)
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
if(php_sapi_name() !='cli') $in
static _lookupDesktopItems($user_id, $a_types="")
get all desktop items of user and specified type
readConsultationHoursCalendar($a_target_ref_id=null, $a_cat_id=0)
Read personal consultation hours calendar.
getCategories($a_include_subitem_calendars=false)
get categories
__construct($a_usr_id=0)
Singleton instance.
readSingleCalendar($a_cat_id)
getNotificationCalendars()
Get all calendars that allow send of notifications (Editable and course group calendars) ...
static lookupPrivateCategories($a_user_id)
Lookup private categories of user.
readPublicCalendars($cat_ids=null)
Read public calendars.
readPDCalendars()
Read categories of user.
getCategoriesInfo()
get categories
const MODE_PERSONAL_DESKTOP_ITEMS