24include_once(
'./Services/Calendar/classes/class.ilCalendarCategory.php');
25include_once(
'./Services/Calendar/classes/class.ilCalendarSettings.php');
26include_once
'./Services/Calendar/classes/class.ilCalendarCache.php';
83 $this->logger =
$GLOBALS[
'DIC']->logger()->cal();
85 $this->user_id = $a_usr_id;
88 $this->user_id =
$ilUser->getId();
122 $query =
"SELECT cat_id FROM cal_categories ".
123 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ".
144 public static function _isOwner($a_usr_id,$a_cal_id)
148 $query =
"SELECT * FROM cal_categories ".
149 "WHERE cat_id = ".$ilDB->quote($a_cal_id ,
'integer').
" ".
150 "AND obj_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
153 return $res->numRows() ? true :
false;
165 self::MODE_PERSONAL_DESKTOP_ITEMS,
179 self::MODE_REPOSITORY,
194 'categories' => $this->categories,
195 'categories_info' => $this->categories_info,
196 'subitem_categories'=> $this->subitem_categories
208 $info = unserialize($a_ser);
210 $this->categories =
$info[
'categories'];
211 $this->categories_info =
$info[
'categories_info'];
212 $this->subitem_categories =
$info[
'subitem_categories'];
221 $this->ch_user_id = $a_user_id;
236 $this->mode = $a_mode;
246 $this->target_ref_id = $a_ref_id;
262 public function initialize($a_mode,$a_source_ref_id = 0,$a_use_cache =
false)
270 if($this->
getMode() != self::MODE_CONSULTATION &&
271 $this->
getMode() != self::MODE_PORTFOLIO_CONSULTATION)
283 include_once(
'./Services/Calendar/classes/class.ilCalendarUserSettings.php');
307 $this->root_ref_id = $a_source_ref_id;
318 #$this->readPrivateCalendars();
332 $this->user_id.
':'.$a_mode.
':categories:'.(
int) $a_source_ref_id,
350 if(isset($this->categories_info[$a_cat_id]))
352 return $this->categories_info[$a_cat_id];
355 if(in_array($a_cat_id,(array) $this->subitem_categories))
357 foreach($this->categories as $cat_id)
359 if(in_array($a_cat_id,$this->categories_info[$cat_id][
'subitem_ids']))
361 return $this->categories_info[$cat_id];
377 return $this->categories_info ? $this->categories_info : array();
388 if($a_include_subitem_calendars)
390 return array_merge((array) $this->categories, (array) $this->subitem_categories);
393 return $this->categories ? $this->categories : array();
404 if(!isset($this->categories_info[$a_cat_id][
'subitem_ids']))
406 return array($a_cat_id);
408 return array_merge((array) $this->categories_info[$a_cat_id][
'subitem_ids'],array($a_cat_id));
423 $has_personal_calendar =
false;
424 foreach($this->categories_info as
$info)
426 if(
$info[
'obj_type'] ==
'sess' ||
$info[
'obj_type'] ==
'exc')
432 $has_personal_calendar =
true;
435 if(
$info[
'editable'])
441 if(!$has_personal_calendar)
443 $cats[0] =
$lng->txt(
'cal_default_calendar');
445 return $cats ? $cats : array();
456 foreach($this->categories_info as
$info)
462 $not[] =
$info[
'cat_id'];
478 return isset($this->categories_info[$a_cat_id][
'editable']) and $this->categories_info[$a_cat_id][
'editable'];
490 return in_array($a_cat_id,$this->categories) or
491 in_array($a_cat_id,(array) $this->subitem_categories);
514 include_once(
'./Services/Membership/classes/class.ilParticipants.php');
527 include_once
'./Services/Calendar/classes/class.ilCalendarCategory.php';
536 $this->categories[] = $a_cal_id;
560 $exercises = array();
563 if($ilAccess->checkAccess(
'read',
'',$item[
'ref_id']))
565 switch($item[
'type'])
568 $courses[] = $item[
'obj_id'];
572 $sessions[] = $item[
'obj_id'];
576 $groups[] = $item[
'obj_id'];
580 $exercises[] = $item[
'obj_id'];
603 global $ilAccess,$tree;
610 #$query = "SELECT ref_id,obd.obj_id obj_id FROM tree t1 ".
611 # "JOIN object_reference obr ON t1.child = obr.ref_id ".
612 # "JOIN object_data obd ON obd.obj_id = obr.obj_id ".
613 # "WHERE t1.lft >= (SELECT lft FROM tree WHERE child = ".$this->db->quote($this->root_ref_id,'integer')." ) ".
614 # "AND t1.lft <= (SELECT rgt FROM tree WHERE child = ".$this->db->quote($this->root_ref_id,'integer')." ) ".
615 # "AND ".$ilDB->in('type',array('crs','grp','sess'),false,'text')." ".
618 $subtree_query =
$GLOBALS[
'tree']->getSubTreeQuery(
620 array(
'object_reference.ref_id',
'object_data.obj_id'),
621 array(
'crs',
'grp',
'sess',
'exc')
628 if($tree->isDeleted(
$row->ref_id))
634 if($obj_type ==
'crs' or $obj_type ==
'grp')
642 if($ilAccess->checkAccess(
'read',
'',
$row->ref_id))
644 $obj_ids[] =
$row->obj_id;
658 global $rbacsystem,$ilAccess;
661 $query =
"SELECT * FROM cal_categories ".
668 $this->categories[] =
$row->cat_id;
669 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
670 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
671 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
672 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
673 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
675 $this->categories_info[
$row->cat_id][
'accepted'] =
false;
694 $query =
"SELECT cat_id FROM cal_categories ".
696 "AND obj_id = ".$this->db->quote(
$ilUser->getId(),
'integer').
" ";
700 $cat_ids[] =
$row->cat_id;
704 include_once(
'./Services/Calendar/classes/class.ilCalendarSharedStatus.php');
706 if(!$cat_ids = array_merge((array) $cat_ids, $accepted_ids))
713 $query =
"SELECT * FROM cal_categories ".
715 "AND ".$ilDB->in(
'cat_id',$cat_ids,
false,
'integer').
" ".
721 $this->categories[] =
$row->cat_id;
722 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
723 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
724 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
725 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
726 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
728 include_once
'./Services/Calendar/classes/class.ilCalendarShared.php';
729 if(in_array(
$row->cat_id, $accepted_ids))
732 if($shared->isEditableForUser(
$ilUser->getId()))
734 $this->categories_info[
$row->cat_id][
'editable'] =
true;
738 $this->categories_info[
$row->cat_id][
'editable'] =
false;
743 $this->categories_info[
$row->cat_id][
'editable'] =
true;
746 $this->categories_info[
$row->cat_id][
'accepted'] = in_array(
$row->cat_id, $accepted_ids);
769 $query =
'SELECT DISTINCT(cc.cat_id) FROM booking_entry be '.
770 'LEFT JOIN booking_obj_assignment bo ON be.booking_id = bo.booking_id '.
771 'JOIN cal_entries ce ON be.booking_id = ce.context_id '.
772 'JOIN cal_cat_assignments ca ON ce.cal_id = ca.cal_id '.
773 'JOIN cal_categories cc ON ca.cat_id = cc.cat_id '.
774 'WHERE ((bo.target_obj_id IS NULL) OR bo.target_obj_id = '.$ilDB->quote($target_obj_id,
'integer').
' ) '.
775 'AND cc.obj_id = '.$ilDB->quote($this->
getCHUserId(),
'integer');
787 $query =
'SELECT * FROM cal_categories '.
788 'WHERE '.$ilDB->in(
'cat_id',
$categories,
false,
'integer');
792 $this->categories[] =
$row->cat_id;
793 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
794 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
795 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
796 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
797 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
798 $this->categories_info[
$row->cat_id][
'editable'] =
false;
799 $this->categories_info[
$row->cat_id][
'accepted'] =
false;
800 $this->categories_info[
$row->cat_id][
'remote'] =
false;
806 $query =
"SELECT * FROM cal_categories cc ".
808 "AND obj_id = ".$ilDB->quote($this->
getCHUserId(),
'integer');
812 $this->categories[] =
$row->cat_id;
813 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
814 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
815 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
816 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
817 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
818 $this->categories_info[
$row->cat_id][
'editable'] =
false;
819 $this->categories_info[
$row->cat_id][
'accepted'] =
false;
820 $this->categories_info[
$row->cat_id][
'remote'] =
false;
840 $query =
"SELECT * FROM cal_categories ".
842 "AND obj_id = ".$ilDB->quote(
$user_id,
'integer');
846 $this->categories[] =
$row->cat_id;
847 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
848 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
849 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
850 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
851 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
852 $this->categories_info[
$row->cat_id][
'editable'] =
false;
853 $this->categories_info[
$row->cat_id][
'accepted'] =
false;
854 $this->categories_info[
$row->cat_id][
'remote'] =
false;
866 global $ilAccess,$tree;
869 if(!count($a_obj_ids))
874 $query =
"SELECT * FROM cal_categories ".
876 "AND ".$ilDB->in(
'obj_id',$a_obj_ids,
false,
'integer').
" ".
884 if($obj_type ==
'crs' or $obj_type ==
'grp')
896 if($ilAccess->checkAccess(
'edit_event',
'',
$ref_id))
902 elseif($ilAccess->checkAccess(
'read',
'',
$ref_id))
911 $this->categories_info[
$row->cat_id][
'editable'] = $editable;
913 $this->categories[] =
$row->cat_id;
914 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
915 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
916 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
917 #$this->categories_info[$row->cat_id]['title'] = ilObject::_lookupTitle($row->obj_id);
918 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
920 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
921 $this->categories_info[
$row->cat_id][
'remote'] =
false;
936 $course_ids = array();
937 foreach($this->categories as $cat_id)
939 if($this->categories_info[$cat_id][
'obj_type'] ==
'crs' or $this->categories_info[$cat_id][
'obj_type'] ==
'grp')
941 $course_ids[] = $this->categories_info[$cat_id][
'obj_id'];
945 $query =
"SELECT od2.obj_id sess_id, od1.obj_id crs_id,cat_id FROM object_data od1 ".
946 "JOIN object_reference or1 ON od1.obj_id = or1.obj_id ".
947 "JOIN tree t ON or1.ref_id = t.parent ".
948 "JOIN object_reference or2 ON t.child = or2.ref_id ".
949 "JOIN object_data od2 ON or2.obj_id = od2.obj_id ".
950 "JOIN cal_categories cc ON od2.obj_id = cc.obj_id ".
951 "WHERE ".$ilDB->in(
'od2.type',array(
'sess',
'exc'),
false,
'text').
952 "AND (od1.type = 'crs' OR od1.type = 'grp') ".
953 "AND ".$ilDB->in(
'od1.obj_id',$course_ids,
false,
'integer').
' '.
954 "AND or2.deleted IS NULL";
958 $course_sessions = array();
961 $cat_ids[] =
$row->cat_id;
962 $course_sessions[
$row->crs_id][
$row->sess_id] =
$row->cat_id;
963 $this->subitem_categories[] =
$row->cat_id;
966 foreach($this->categories as $cat_id)
969 ($this->categories_info[$cat_id][
'obj_type'] ==
'crs' ||
970 $this->categories_info[$cat_id][
'obj_type'] ==
'grp' ) &&
971 isset($this->categories_info[$cat_id][
'obj_id']) &&
972 isset($course_sessions[$this->categories_info[$cat_id][
'obj_id']]) &&
973 is_array($course_sessions[$this->categories_info[$cat_id][
'obj_id']]))
975 foreach($course_sessions[$this->categories_info[$cat_id][
'obj_id']] as $sess_id => $sess_cat_id)
977 $this->categories_info[$cat_id][
'subitem_ids'][$sess_id] = $sess_cat_id;
978 $this->categories_info[$cat_id][
'subitem_obj_ids'][$sess_cat_id] = $sess_id;
983 $this->categories_info[$cat_id][
'subitem_ids'] = array();
984 $this->categories_info[$cat_id][
'subitem_obj_ids'] = array();
1000 $set =
$ilDB->query(
"SELECT * FROM cal_categories ".
1002 "AND obj_id = ".$ilDB->quote($a_user_id,
'integer'));
1004 while ($rec =
$ilDB->fetchAssoc($set))
An exception for terminatinating execution or to throw for unit testing.
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.
getNotificationCalendars()
Get all calendars that allow send of notifications (Editable and course group calendars)
readPrivateCalendars()
Read private 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
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)
read selected categories
readPublicCalendars()
Read public 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.
getCHUserId()
Get ch user id.
__construct($a_usr_id=0)
Singleton instance.
getCategoriesInfo()
get categories
readBookingCalendar($user_id=NULL)
Read booking manager calendar.
static lookupPrivateCategories($a_user_id)
Lookup private categories of user.
setTargetRefId($a_ref_id)
getCategoryInfo($a_cat_id)
@access public
static _isOwner($a_usr_id, $a_cal_id)
check if user is owner of a category
readReposCalendars()
Read available repository calendars.
readConsultationHoursCalendar($a_target_ref_id=NULL)
Read personal consultation hours calendar.
initialize($a_mode, $a_source_ref_id=0, $a_use_cache=false)
initialize visible categories
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
const MODE_REMOTE_SELECTED
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 _lookupDesktopItems($user_id, $a_types="")
get all desktop items of user and specified type
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
$GLOBALS['loaded']
Global hash that tracks already loaded includes.