90 $this->logger =
$GLOBALS[
'DIC']->logger()->cal();
92 $this->user_id = $a_usr_id;
93 if (!$this->user_id) {
94 $this->user_id =
$ilUser->getId();
111 if (self::$instance) {
131 $query =
"SELECT cat_id FROM cal_categories " .
132 "WHERE obj_id = " .
$ilDB->quote($a_obj_id,
'integer') .
" " .
152 public static function _isOwner($a_usr_id, $a_cal_id)
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') .
" " .
163 return $res->numRows() ?
true :
false;
175 self::MODE_PERSONAL_DESKTOP_ITEMS,
189 self::MODE_REPOSITORY,
203 'categories' => $this->categories,
204 'categories_info' => $this->categories_info,
205 'subitem_categories' => $this->subitem_categories
217 $info = unserialize($a_ser);
219 $this->categories = $info[
'categories'];
220 $this->categories_info = $info[
'categories_info'];
221 $this->subitem_categories = $info[
'subitem_categories'];
230 $this->ch_user_id = $a_user_id;
245 $this->mode = $a_mode;
255 $this->target_ref_id = $a_ref_id;
270 $this->root_ref_id = $a_val;
291 public function initialize($a_mode, $a_source_ref_id = 0, $a_use_cache =
false, $a_cat_id = 0)
294 include_once(
"./Services/Calendar/exceptions/class.ilCalCategoriesInitializedMultipleException.php");
301 if ($a_use_cache && $this->
getMode() != self::MODE_REPOSITORY_CONTAINER_ONLY) {
304 if ($this->
getMode() != self::MODE_REPOSITORY &&
305 $this->
getMode() != self::MODE_CONSULTATION &&
306 $this->
getMode() != self::MODE_PORTFOLIO_CONSULTATION) {
315 include_once(
'./Services/Calendar/classes/class.ilCalendarUserSettings.php');
336 $this->root_ref_id = $a_source_ref_id;
342 $this->root_ref_id = $a_source_ref_id;
353 #$this->readPrivateCalendars();
370 $this->user_id .
':' . $a_mode .
':categories:' . (
int) $a_source_ref_id,
388 if (isset($this->categories_info[$a_cat_id])) {
389 return $this->categories_info[$a_cat_id];
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];
411 return $this->categories_info ? $this->categories_info : array();
422 if ($a_include_subitem_calendars) {
423 return array_merge((array) $this->categories, (array) $this->subitem_categories);
426 return $this->categories ? $this->categories : array();
437 if (!isset($this->categories_info[$a_cat_id][
'subitem_ids'])) {
438 return array($a_cat_id);
440 return array_merge((array) $this->categories_info[$a_cat_id][
'subitem_ids'], array($a_cat_id));
457 $has_personal_calendar =
false;
458 foreach ($this->categories_info as $info) {
459 if ($info[
'obj_type'] ==
'sess' || $info[
'obj_type'] ==
'exc') {
468 $has_personal_calendar =
true;
471 if ($info[
'editable']) {
472 $cats[$info[
'cat_id']] = $info[
'title'];
476 if (!$has_personal_calendar) {
477 $cats[0] =
$lng->txt(
'cal_default_calendar');
479 return $cats ? $cats : array();
490 foreach ($this->categories_info as $info) {
493 $not[] = $info[
'cat_id'];
509 return isset($this->categories_info[$a_cat_id][
'editable']) and $this->categories_info[$a_cat_id][
'editable'];
521 return in_array($a_cat_id, $this->categories) or
522 in_array($a_cat_id, (array) $this->subitem_categories);
539 $rbacsystem =
$DIC[
'rbacsystem'];
547 include_once(
'./Services/Membership/classes/class.ilParticipants.php');
560 include_once
'./Services/Calendar/classes/class.ilCalendarCategory.php';
566 $this->categories[] = $a_cal_id;
581 $ilAccess =
$DIC[
'ilAccess'];
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']) {
598 $courses[] = $item[
'obj_id'];
602 $sessions[] = $item[
'obj_id'];
606 $groups[] = $item[
'obj_id'];
610 $exercises[] = $item[
'obj_id'];
634 $ilAccess =
$DIC[
'ilAccess'];
635 $tree =
$DIC[
'tree'];
640 if (!$a_container_only) {
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')." ".
659 $subtree_query =
$GLOBALS[
'DIC'][
'tree']->getSubTreeQuery(
661 array(
'object_reference.ref_id',
'object_data.obj_id'),
662 array(
'crs',
'grp',
'sess',
'exc')
668 if ($tree->isDeleted($row->ref_id)) {
673 if ($obj_type ==
'crs' or $obj_type ==
'grp') {
682 if ($ilAccess->checkAccess(
'read',
'', $row->ref_id)) {
683 $obj_ids[] = $row->obj_id;
694 if (!$a_container_only) {
702 include_once
'./Services/Calendar/classes/class.ilCalendarCategory.php';
704 switch ($cat->getType()) {
737 $rbacsystem =
$DIC[
'rbacsystem'];
738 $ilAccess =
$DIC[
'ilAccess'];
741 if (is_array($cat_ids)) {
742 $in =
" AND " . $this->db->in(
'cat_id', $cat_ids,
false,
'integer') .
" ";
746 $query =
"SELECT * FROM cal_categories " .
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;
760 $this->categories_info[$row->cat_id][
'accepted'] =
false;
783 if (is_array($only_cat_ids)) {
784 $in =
" AND " . $this->db->in(
'cat_id', $only_cat_ids,
false,
'integer') .
" ";
788 $query =
"SELECT cat_id FROM cal_categories " .
790 "AND obj_id = " . $this->db->quote(
$ilUser->getId(),
'integer') .
" " .
$in;
793 $cat_ids[] = $row->cat_id;
797 include_once(
'./Services/Calendar/classes/class.ilCalendarSharedStatus.php');
799 if (!$cat_ids = array_merge((array) $cat_ids, $accepted_ids)) {
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);
810 $query =
"SELECT * FROM cal_categories " .
812 "AND " .
$ilDB->in(
'cat_id', $cat_ids,
false,
'integer') .
" " .
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;
824 include_once
'./Services/Calendar/classes/class.ilCalendarShared.php';
825 if (in_array($row->cat_id, $accepted_ids)) {
827 if ($shared->isEditableForUser(
$ilUser->getId())) {
828 $this->categories_info[$row->cat_id][
'editable'] =
true;
830 $this->categories_info[$row->cat_id][
'editable'] =
false;
833 $this->categories_info[$row->cat_id][
'editable'] =
true;
835 if (
$ilUser->getId() == $row->obj_id) {
836 $this->categories_info[$row->cat_id][
'settings'] =
true;
838 $this->categories_info[$row->cat_id][
'settings'] =
false;
841 $this->categories_info[$row->cat_id][
'accepted'] = in_array($row->cat_id, $accepted_ids);
852 include_once
"Modules/Course/classes/class.ilCourseParticipants.php";
855 $users = array_unique(array_merge($participants->getTutors(), $participants->getAdmins()));
856 include_once
'Services/Booking/classes/class.ilBookingEntry.php';
859 foreach ($users as $user) {
882 if ($a_target_ref_id) {
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') .
' ) ';
893 if ($a_cat_id == 0) {
901 if ($a_cat_id == 0 || $row->cat_id == $a_cat_id) {
907 $query =
'SELECT * FROM cal_categories ' .
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;
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;
924 $filter = ($a_cat_id > 0)
925 ?
" AND cat_id = " .
$ilDB->quote($a_cat_id,
"integer")
928 $query =
"SELECT * FROM cal_categories cc " .
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;
962 $query =
"SELECT * FROM cal_categories " .
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;
990 $ilAccess =
$DIC[
'ilAccess'];
991 $tree =
$DIC[
'tree'];
996 if (!count($a_obj_ids)) {
1000 $query =
"SELECT * FROM cal_categories " .
1002 "AND " .
$ilDB->in(
'obj_id', $a_obj_ids,
false,
'integer') .
" " .
1009 if ($obj_type ==
'crs' or $obj_type ==
'grp') {
1019 if ($ilAccess->checkAccess(
'edit_event',
'', $ref_id)) {
1022 if ($ilAccess->checkAccess(
'edit_event',
'', $ref_id)) {
1026 } elseif ($ilAccess->checkAccess(
'read',
'', $ref_id)) {
1033 $this->categories_info[$row->cat_id][
'editable'] = $editable;
1034 $this->categories_info[$row->cat_id][
'settings'] = $settings;
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;
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;
1060 $access =
$DIC->access();
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'];
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";
1082 $course_sessions = array();
1085 !$access->checkAccessOfUser($this->user_id,
'read',
'', $row->sess_ref_id) ||
1086 !$access->checkAccessOfUser($this->user_id,
'visible',
'', $row->sess_ref_id)
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;
1095 foreach ($this->categories as $cat_id) {
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;
1107 $this->categories_info[$cat_id][
'subitem_ids'] = array();
1108 $this->categories_info[$cat_id][
'subitem_obj_ids'] = array();
1126 $set =
$ilDB->query(
"SELECT * FROM cal_categories " .
1128 "AND obj_id = " .
$ilDB->quote($a_user_id,
'integer'));
1130 while ($rec =
$ilDB->fetchAssoc($set)) {
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
if(php_sapi_name() !='cli') $in
An exception for terminatinating execution or to throw for unit testing.
return true
Flag indicating whether or not HTTP headers will be sent when outputting captcha image/audio.
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 _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
foreach($_POST as $key=> $value) $res