85 $this->logger =
$GLOBALS[
'DIC']->logger()->cal();
87 $this->user_id = $a_usr_id;
88 if (!$this->user_id) {
89 $this->user_id =
$ilUser->getId();
104 if (self::$instance) {
124 $query =
"SELECT cat_id FROM cal_categories " .
125 "WHERE obj_id = " .
$ilDB->quote($a_obj_id,
'integer') .
" " .
145 public static function _isOwner($a_usr_id, $a_cal_id)
151 $query =
"SELECT * FROM cal_categories " .
152 "WHERE cat_id = " .
$ilDB->quote($a_cal_id,
'integer') .
" " .
153 "AND obj_id = " .
$ilDB->quote($a_usr_id,
'integer') .
" " .
156 return $res->numRows() ? true :
false;
168 self::MODE_PERSONAL_DESKTOP_ITEMS,
182 self::MODE_REPOSITORY,
196 'categories' => $this->categories,
197 'categories_info' => $this->categories_info,
198 'subitem_categories' => $this->subitem_categories
210 $info = unserialize($a_ser);
212 $this->categories =
$info[
'categories'];
213 $this->categories_info =
$info[
'categories_info'];
214 $this->subitem_categories =
$info[
'subitem_categories'];
223 $this->ch_user_id = $a_user_id;
238 $this->mode = $a_mode;
248 $this->target_ref_id = $a_ref_id;
263 $this->root_ref_id = $a_val;
284 public function initialize($a_mode, $a_source_ref_id = 0, $a_use_cache =
false, $a_cat_id = 0)
287 include_once(
"./Services/Calendar/exceptions/class.ilCalCategoriesInitializedMultipleException.php");
294 if ($a_use_cache && $this->
getMode() != self::MODE_REPOSITORY_CONTAINER_ONLY) {
297 if ($this->
getMode() != self::MODE_REPOSITORY &&
298 $this->
getMode() != self::MODE_CONSULTATION &&
299 $this->
getMode() != self::MODE_PORTFOLIO_CONSULTATION) {
308 include_once(
'./Services/Calendar/classes/class.ilCalendarUserSettings.php');
329 $this->root_ref_id = $a_source_ref_id;
335 $this->root_ref_id = $a_source_ref_id;
346 #$this->readPrivateCalendars();
363 $this->user_id .
':' . $a_mode .
':categories:' . (
int) $a_source_ref_id,
381 if (isset($this->categories_info[$a_cat_id])) {
382 return $this->categories_info[$a_cat_id];
385 if (in_array($a_cat_id, (array) $this->subitem_categories)) {
386 foreach ($this->categories as $cat_id) {
387 if (in_array($a_cat_id, $this->categories_info[$cat_id][
'subitem_ids'])) {
388 return $this->categories_info[$cat_id];
404 return $this->categories_info ? $this->categories_info : array();
415 if ($a_include_subitem_calendars) {
416 return array_merge((array) $this->categories, (array) $this->subitem_categories);
419 return $this->categories ? $this->categories : array();
430 if (!isset($this->categories_info[$a_cat_id][
'subitem_ids'])) {
431 return array($a_cat_id);
433 return array_merge((array) $this->categories_info[$a_cat_id][
'subitem_ids'], array($a_cat_id));
450 $has_personal_calendar =
false;
451 foreach ($this->categories_info as
$info) {
452 if (
$info[
'obj_type'] ==
'sess' ||
$info[
'obj_type'] ==
'exc') {
456 $has_personal_calendar =
true;
459 if (
$info[
'editable']) {
464 if (!$has_personal_calendar) {
465 $cats[0] =
$lng->txt(
'cal_default_calendar');
467 return $cats ? $cats : array();
478 foreach ($this->categories_info as
$info) {
481 $not[] =
$info[
'cat_id'];
497 return isset($this->categories_info[$a_cat_id][
'editable']) and $this->categories_info[$a_cat_id][
'editable'];
509 return in_array($a_cat_id, $this->categories) or
510 in_array($a_cat_id, (array) $this->subitem_categories);
527 $rbacsystem =
$DIC[
'rbacsystem'];
535 include_once(
'./Services/Membership/classes/class.ilParticipants.php');
548 include_once
'./Services/Calendar/classes/class.ilCalendarCategory.php';
554 $this->categories[] = $a_cal_id;
569 $ilAccess =
$DIC[
'ilAccess'];
581 $exercises = array();
583 if ($ilAccess->checkAccess(
'read',
'', $item[
'ref_id'])) {
584 switch ($item[
'type']) {
586 $courses[] = $item[
'obj_id'];
590 $sessions[] = $item[
'obj_id'];
594 $groups[] = $item[
'obj_id'];
598 $exercises[] = $item[
'obj_id'];
622 $ilAccess =
$DIC[
'ilAccess'];
628 if (!$a_container_only) {
637 #$query = "SELECT ref_id,obd.obj_id obj_id FROM tree t1 ".
638 # "JOIN object_reference obr ON t1.child = obr.ref_id ".
639 # "JOIN object_data obd ON obd.obj_id = obr.obj_id ".
640 # "WHERE t1.lft >= (SELECT lft FROM tree WHERE child = ".$this->db->quote($this->root_ref_id,'integer')." ) ".
641 # "AND t1.lft <= (SELECT rgt FROM tree WHERE child = ".$this->db->quote($this->root_ref_id,'integer')." ) ".
642 # "AND ".$ilDB->in('type',array('crs','grp','sess'),false,'text')." ".
647 $subtree_query =
$GLOBALS[
'DIC'][
'tree']->getSubTreeQuery(
649 array(
'object_reference.ref_id',
'object_data.obj_id'),
650 array(
'crs',
'grp',
'sess',
'exc')
661 if ($obj_type ==
'crs' or $obj_type ==
'grp') {
670 if ($ilAccess->checkAccess(
'read',
'',
$row->ref_id)) {
671 $obj_ids[] =
$row->obj_id;
682 if (!$a_container_only) {
690 include_once
'./Services/Calendar/classes/class.ilCalendarCategory.php';
692 switch ($cat->getType()) {
725 $rbacsystem =
$DIC[
'rbacsystem'];
726 $ilAccess =
$DIC[
'ilAccess'];
729 if (is_array($cat_ids)) {
730 $in =
" AND " . $this->db->in(
'cat_id', $cat_ids,
false,
'integer') .
" ";
734 $query =
"SELECT * FROM cal_categories " .
740 $this->categories[] =
$row->cat_id;
741 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
742 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
743 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
744 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
745 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
748 $this->categories_info[
$row->cat_id][
'accepted'] =
false;
771 if (is_array($only_cat_ids)) {
772 $in =
" AND " . $this->db->in(
'cat_id', $only_cat_ids,
false,
'integer') .
" ";
776 $query =
"SELECT cat_id FROM cal_categories " .
778 "AND obj_id = " . $this->db->quote(
$ilUser->getId(),
'integer') .
" " .
$in;
781 $cat_ids[] =
$row->cat_id;
785 include_once(
'./Services/Calendar/classes/class.ilCalendarSharedStatus.php');
787 if (!$cat_ids = array_merge((array) $cat_ids, $accepted_ids)) {
791 if (is_array($only_cat_ids)) {
792 $cat_ids = array_filter($cat_ids,
function (
$id) use ($only_cat_ids) {
793 return in_array(
$id, $only_cat_ids);
798 $query =
"SELECT * FROM cal_categories " .
800 "AND " .
$ilDB->in(
'cat_id', $cat_ids,
false,
'integer') .
" " .
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;
812 include_once
'./Services/Calendar/classes/class.ilCalendarShared.php';
813 if (in_array(
$row->cat_id, $accepted_ids)) {
815 if ($shared->isEditableForUser(
$ilUser->getId())) {
816 $this->categories_info[
$row->cat_id][
'editable'] =
true;
818 $this->categories_info[
$row->cat_id][
'editable'] =
false;
821 $this->categories_info[
$row->cat_id][
'editable'] =
true;
824 $this->categories_info[
$row->cat_id][
'settings'] =
true;
826 $this->categories_info[
$row->cat_id][
'settings'] =
false;
829 $this->categories_info[
$row->cat_id][
'accepted'] = in_array(
$row->cat_id, $accepted_ids);
840 include_once
"Modules/Course/classes/class.ilCourseParticipants.php";
843 $users = array_unique(array_merge($participants->getTutors(), $participants->getAdmins()));
844 include_once
'Services/Booking/classes/class.ilBookingEntry.php';
870 if ($a_target_ref_id) {
873 $query =
'SELECT DISTINCT(cc.cat_id) FROM booking_entry be ' .
874 'LEFT JOIN booking_obj_assignment bo ON be.booking_id = bo.booking_id ' .
875 'JOIN cal_entries ce ON be.booking_id = ce.context_id ' .
876 'JOIN cal_cat_assignments ca ON ce.cal_id = ca.cal_id ' .
877 'JOIN cal_categories cc ON ca.cat_id = cc.cat_id ' .
878 'WHERE ((bo.target_obj_id IS NULL) OR bo.target_obj_id = ' .
$ilDB->quote($target_obj_id,
'integer') .
' ) ';
881 if ($a_cat_id == 0) {
889 if ($a_cat_id == 0 ||
$row->cat_id == $a_cat_id) {
895 $query =
'SELECT * FROM cal_categories ' .
899 $this->categories[] =
$row->cat_id;
900 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
901 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
903 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
904 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
905 $this->categories_info[
$row->cat_id][
'editable'] =
false;
906 $this->categories_info[
$row->cat_id][
'settings'] =
false;
907 $this->categories_info[
$row->cat_id][
'accepted'] =
false;
908 $this->categories_info[
$row->cat_id][
'remote'] =
false;
912 $filter = ($a_cat_id > 0)
913 ?
" AND cat_id = " .
$ilDB->quote($a_cat_id,
"integer")
916 $query =
"SELECT * FROM cal_categories cc " .
920 $this->categories[] =
$row->cat_id;
921 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
922 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
923 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
924 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
925 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
926 $this->categories_info[
$row->cat_id][
'editable'] =
false;
927 $this->categories_info[
$row->cat_id][
'settings'] =
false;
928 $this->categories_info[
$row->cat_id][
'accepted'] =
false;
929 $this->categories_info[
$row->cat_id][
'remote'] =
false;
950 $query =
"SELECT * FROM cal_categories " .
955 $this->categories[] =
$row->cat_id;
956 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
957 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
958 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
959 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
960 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
961 $this->categories_info[
$row->cat_id][
'editable'] =
false;
962 $this->categories_info[
$row->cat_id][
'settings'] =
false;
963 $this->categories_info[
$row->cat_id][
'accepted'] =
false;
964 $this->categories_info[
$row->cat_id][
'remote'] =
false;
978 $ilAccess =
$DIC[
'ilAccess'];
984 if (!count($a_obj_ids)) {
988 $query =
"SELECT * FROM cal_categories " .
990 "AND " .
$ilDB->in(
'obj_id', $a_obj_ids,
false,
'integer') .
" " .
997 if ($obj_type ==
'crs' or $obj_type ==
'grp') {
1007 if ($ilAccess->checkAccess(
'edit_event',
'', $ref_id)) {
1010 if ($ilAccess->checkAccess(
'edit_event',
'', $ref_id)) {
1014 } elseif ($ilAccess->checkAccess(
'read',
'', $ref_id)) {
1021 $this->categories_info[
$row->cat_id][
'editable'] = $editable;
1022 $this->categories_info[
$row->cat_id][
'settings'] = $settings;
1024 $this->categories[] =
$row->cat_id;
1025 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
1026 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
1027 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
1028 #$this->categories_info[$row->cat_id]['title'] = ilObject::_lookupTitle($row->obj_id);
1029 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
1031 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
1032 $this->categories_info[
$row->cat_id][
'remote'] =
false;
1033 $this->categories_info[
$row->cat_id][
'source_ref_id'] = $a_source_ref_id;
1048 $access =
$DIC->access();
1050 $course_ids = array();
1051 foreach ($this->categories as $cat_id) {
1052 if ($this->categories_info[$cat_id][
'obj_type'] ==
'crs' or $this->categories_info[$cat_id][
'obj_type'] ==
'grp') {
1053 $course_ids[] = $this->categories_info[$cat_id][
'obj_id'];
1057 $query =
"SELECT od2.obj_id sess_id, od1.obj_id crs_id,cat_id, or2.ref_id sess_ref_id FROM object_data od1 " .
1058 "JOIN object_reference or1 ON od1.obj_id = or1.obj_id " .
1059 "JOIN tree t ON or1.ref_id = t.parent " .
1060 "JOIN object_reference or2 ON t.child = or2.ref_id " .
1061 "JOIN object_data od2 ON or2.obj_id = od2.obj_id " .
1062 "JOIN cal_categories cc ON od2.obj_id = cc.obj_id " .
1063 "WHERE " .
$ilDB->in(
'od2.type', array(
'sess',
'exc'),
false,
'text') .
1064 "AND (od1.type = 'crs' OR od1.type = 'grp') " .
1065 "AND " .
$ilDB->in(
'od1.obj_id', $course_ids,
false,
'integer') .
' ' .
1066 "AND or2.deleted IS NULL";
1070 $course_sessions = array();
1073 !$access->checkAccessOfUser($this->user_id,
'read',
'',
$row->sess_ref_id) ||
1074 !$access->checkAccessOfUser($this->user_id,
'visible',
'',
$row->sess_ref_id)
1078 $cat_ids[] =
$row->cat_id;
1079 $course_sessions[
$row->crs_id][
$row->sess_id] =
$row->cat_id;
1080 $this->subitem_categories[] =
$row->cat_id;
1083 foreach ($this->categories as $cat_id) {
1085 ($this->categories_info[$cat_id][
'obj_type'] ==
'crs' ||
1086 $this->categories_info[$cat_id][
'obj_type'] ==
'grp') &&
1087 isset($this->categories_info[$cat_id][
'obj_id']) &&
1088 isset($course_sessions[$this->categories_info[$cat_id][
'obj_id']]) &&
1089 is_array($course_sessions[$this->categories_info[$cat_id][
'obj_id']])) {
1090 foreach ($course_sessions[$this->categories_info[$cat_id][
'obj_id']] as $sess_id => $sess_cat_id) {
1091 $this->categories_info[$cat_id][
'subitem_ids'][$sess_id] = $sess_cat_id;
1092 $this->categories_info[$cat_id][
'subitem_obj_ids'][$sess_cat_id] = $sess_id;
1095 $this->categories_info[$cat_id][
'subitem_ids'] = array();
1096 $this->categories_info[$cat_id][
'subitem_obj_ids'] = array();
1114 $set =
$ilDB->query(
"SELECT * FROM cal_categories " .
1116 "AND obj_id = " .
$ilDB->quote($a_user_id,
'integer'));
1118 while ($rec =
$ilDB->fetchAssoc($set)) {
if(php_sapi_name() !='cli') $in
An exception for terminatinating execution or to throw for unit testing.
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...
Exception being thrown calendar categories is initiliazed multiple times for the same user.
static getInstance()
get singleton instance
class for calendar categories
static deletePDItemsCache($a_usr_id)
Delete cache (add remove desktop item)
readPDCalendars()
Read categories of user.
readAllConsultationHoursCalendarOfContainer($a_container_ref_id)
Read personal consultation hours calendar of all tutors for a container.
getNotificationCalendars()
Get all calendars that allow send of notifications (Editable and course group calendars)
readSelectedItemCalendars()
Read categories of selected items.
const MODE_PERSONAL_DESKTOP_MEMBERSHIP
const MODE_PERSONAL_DESKTOP_ITEMS
setCHUserId($a_user_id)
Set ch user id.
static _lookupCategoryIdByObjId($a_obj_id)
lookup category by obj_id
readSingleCalendar($a_cat_id)
const MODE_PORTFOLIO_CONSULTATION
addSubitemCalendars()
Add subitem calendars E.g.
getSubitemCategories($a_cat_id)
get subitem categories for a specific category
readSelectedCategories($a_obj_ids, $a_source_ref_id=0)
read selected categories
readConsultationHoursCalendar($a_target_ref_id=null, $a_cat_id=0)
Read personal consultation hours calendar.
readPrivateCalendars($only_cat_ids=null)
Read private calendars.
readSelectedCalendar($a_cal_id)
Read info about selected calendar.
isVisible($a_cat_id)
check if category is visible
wakeup($a_ser)
Load from serialize string.
sleep()
Serialize categories.
readBookingCalendar($user_id=null)
Read booking manager calendar.
const MODE_SINGLE_CALENDAR
getCHUserId()
Get ch user id.
__construct($a_usr_id=0)
Singleton instance.
getCategoriesInfo()
get categories
static lookupPrivateCategories($a_user_id)
Lookup private categories of user.
const MODE_REPOSITORY_CONTAINER_ONLY
setTargetRefId($a_ref_id)
readReposCalendars($a_container_only=false)
Read available repository calendars.
setSourceRefId($a_val)
Set source ref id.
getCategoryInfo($a_cat_id)
@access public
static _isOwner($a_usr_id, $a_cal_id)
check if user is owner of a category
readPublicCalendars($cat_ids=null)
Read public calendars.
static deleteRepositoryCache($a_usr_id)
Delete cache.
isEditable($a_cat_id)
check if category is editable
prepareCategoriesOfUserForSelection()
prepare categories of users for selection
getCategories($a_include_subitem_calendars=false)
get categories
static _getInstance($a_usr_id=0)
get singleton instance
getSourceRefId()
Get source ref id.
const MODE_REMOTE_SELECTED
initialize($a_mode, $a_source_ref_id=0, $a_use_cache=false, $a_cat_id=0)
initialize visible categories
Stores calendar categories.
static _getInstance()
get singleton instance
static getAcceptedCalendars($a_usr_id)
get accepted shared calendars
Handles shared calendars.
static _getInstance()
get instance for logged in user
const CAL_SELECTION_MEMBERSHIP
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _lookupDesktopItems($user_id, $a_types="")
get all desktop items of user and specified type
static _lookupFullname($a_user_id)
Lookup Full Name.
static _lookupObjId($a_id)
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
if(!array_key_exists('StateId', $_REQUEST)) $id
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
foreach($_POST as $key=> $value) $res