24 include_once(
'./Services/Calendar/classes/class.ilCalendarCategory.php');
25 include_once(
'./Services/Calendar/classes/class.ilCalendarSettings.php');
26 include_once
'./Services/Calendar/classes/class.ilCalendarCache.php';
78 $this->user_id = $a_usr_id;
81 $this->user_id = $ilUser->getId();
98 return self::$instance;
115 $query =
"SELECT cat_id FROM cal_categories ".
116 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ".
137 public static function _isOwner($a_usr_id,$a_cal_id)
141 $query =
"SELECT * FROM cal_categories ".
142 "WHERE cat_id = ".$ilDB->quote($a_cal_id ,
'integer').
" ".
143 "AND obj_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
146 return $res->numRows() ? true :
false;
158 self::MODE_PERSONAL_DESKTOP_ITEMS,
172 self::MODE_REPOSITORY,
187 'categories' => $this->categories,
188 'categories_info' => $this->categories_info,
189 'subitem_categories'=> $this->subitem_categories
201 $info = unserialize($a_ser);
203 $this->categories = $info[
'categories'];
204 $this->categories_info = $info[
'categories_info'];
205 $this->subitem_categories = $info[
'subitem_categories'];
214 $this->ch_user_id = $a_user_id;
229 $this->mode = $a_mode;
239 $this->target_ref_id = $a_ref_id;
255 public function initialize($a_mode,$a_source_ref_id = 0,$a_use_cache =
false)
263 if($this->
getMode() != self::MODE_CONSULTATION &&
264 $this->
getMode() != self::MODE_PORTFOLIO_CONSULTATION)
275 case self::MODE_REMOTE_ACCESS:
276 include_once(
'./Services/Calendar/classes/class.ilCalendarUserSettings.php');
287 case self::MODE_REMOTE_SELECTED:
291 case self::MODE_PERSONAL_DESKTOP_MEMBERSHIP:
295 case self::MODE_PERSONAL_DESKTOP_ITEMS:
299 case self::MODE_REPOSITORY:
300 $this->root_ref_id = $a_source_ref_id;
305 case self::MODE_MANAGE:
310 case self::MODE_CONSULTATION:
311 #$this->readPrivateCalendars(); 316 case self::MODE_PORTFOLIO_CONSULTATION:
325 $this->user_id.
':'.$a_mode.
':categories:'.(
int) $a_source_ref_id,
343 if(isset($this->categories_info[$a_cat_id]))
345 return $this->categories_info[$a_cat_id];
348 if(in_array($a_cat_id,(array) $this->subitem_categories))
350 foreach($this->categories as $cat_id)
352 if(in_array($a_cat_id,$this->categories_info[$cat_id][
'subitem_ids']))
354 return $this->categories_info[$cat_id];
370 return $this->categories_info ? $this->categories_info : array();
381 if($a_include_subitem_calendars)
383 return array_merge((array) $this->categories, (array) $this->subitem_categories);
386 return $this->categories ? $this->categories : array();
397 if(!isset($this->categories_info[$a_cat_id][
'subitem_ids']))
399 return array($a_cat_id);
401 return array_merge((array) $this->categories_info[$a_cat_id][
'subitem_ids'],array($a_cat_id));
416 $has_personal_calendar =
false;
417 foreach($this->categories_info as $info)
419 if($info[
'obj_type'] ==
'sess' || $info[
'obj_type'] ==
'exc')
425 $has_personal_calendar =
true;
428 if($info[
'editable'])
430 $cats[$info[
'cat_id']] = $info[
'title'];
434 if(!$has_personal_calendar)
436 $cats[0] = $lng->txt(
'cal_default_calendar');
438 return $cats ? $cats : array();
449 foreach($this->categories_info as $info)
455 $not[] = $info[
'cat_id'];
471 return isset($this->categories_info[$a_cat_id][
'editable']) and $this->categories_info[$a_cat_id][
'editable'];
483 return in_array($a_cat_id,$this->categories) or
484 in_array($a_cat_id,(array) $this->subitem_categories);
507 include_once(
'./Services/Membership/classes/class.ilParticipants.php');
520 include_once
'./Services/Calendar/classes/class.ilCalendarCategory.php';
529 $this->categories[] = $a_cal_id;
553 $exercises = array();
556 if($ilAccess->checkAccess(
'read',
'',$item[
'ref_id']))
558 switch($item[
'type'])
561 $courses[] = $item[
'obj_id'];
565 $sessions[] = $item[
'obj_id'];
569 $groups[] = $item[
'obj_id'];
573 $exercises[] = $item[
'obj_id'];
596 global $ilAccess,$tree;
603 #$query = "SELECT ref_id,obd.obj_id obj_id FROM tree t1 ". 604 # "JOIN object_reference obr ON t1.child = obr.ref_id ". 605 # "JOIN object_data obd ON obd.obj_id = obr.obj_id ". 606 # "WHERE t1.lft >= (SELECT lft FROM tree WHERE child = ".$this->db->quote($this->root_ref_id,'integer')." ) ". 607 # "AND t1.lft <= (SELECT rgt FROM tree WHERE child = ".$this->db->quote($this->root_ref_id,'integer')." ) ". 608 # "AND ".$ilDB->in('type',array('crs','grp','sess'),false,'text')." ". 611 $subtree_query =
$GLOBALS[
'tree']->getSubTreeQuery(
613 array(
'object_reference.ref_id',
'object_data.obj_id'),
614 array(
'crs',
'grp',
'sess',
'exc')
617 $res = $ilDB->query($subtree_query);
621 if($tree->isDeleted(
$row->ref_id))
627 if($obj_type ==
'crs' or $obj_type ==
'grp')
635 if($ilAccess->checkAccess(
'read',
'',
$row->ref_id))
637 $obj_ids[] =
$row->obj_id;
651 global $rbacsystem,$ilAccess;
654 $query =
"SELECT * FROM cal_categories ".
661 $this->categories[] =
$row->cat_id;
662 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
663 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
664 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
665 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
666 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
668 $this->categories_info[
$row->cat_id][
'accepted'] =
false;
687 $query =
"SELECT cat_id FROM cal_categories ".
689 "AND obj_id = ".$this->db->quote($ilUser->getId(),
'integer').
" ";
693 $cat_ids[] =
$row->cat_id;
697 include_once(
'./Services/Calendar/classes/class.ilCalendarSharedStatus.php');
699 if(!$cat_ids = array_merge((array) $cat_ids, $accepted_ids))
706 $query =
"SELECT * FROM cal_categories ".
708 "AND ".$ilDB->in(
'cat_id',$cat_ids,
false,
'integer').
" ".
714 $this->categories[] =
$row->cat_id;
715 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
716 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
717 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
718 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
719 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
721 include_once
'./Services/Calendar/classes/class.ilCalendarShared.php';
722 if(in_array(
$row->cat_id, $accepted_ids))
725 if($shared->isEditableForUser($ilUser->getId()))
727 $this->categories_info[
$row->cat_id][
'editable'] =
true;
731 $this->categories_info[
$row->cat_id][
'editable'] =
false;
736 $this->categories_info[
$row->cat_id][
'editable'] =
true;
739 $this->categories_info[
$row->cat_id][
'accepted'] = in_array(
$row->cat_id, $accepted_ids);
762 $query =
'SELECT DISTINCT(cc.cat_id) FROM booking_entry be '.
763 'LEFT JOIN booking_obj_assignment bo ON be.booking_id = bo.booking_id '.
764 'JOIN cal_entries ce ON be.booking_id = ce.context_id '.
765 'JOIN cal_cat_assignments ca ON ce.cal_id = ca.cal_id '.
766 'JOIN cal_categories cc ON ca.cat_id = cc.cat_id '.
767 'WHERE ((bo.target_obj_id IS NULL) OR bo.target_obj_id = '.$ilDB->quote($target_obj_id,
'integer').
' ) '.
768 'AND cc.obj_id = '.$ilDB->quote($this->
getCHUserId(),
'integer');
780 $query =
'SELECT * FROM cal_categories '.
781 'WHERE '.$ilDB->in(
'cat_id',
$categories,
false,
'integer');
785 $this->categories[] =
$row->cat_id;
786 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
787 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
788 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
789 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
790 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
791 $this->categories_info[
$row->cat_id][
'editable'] =
false;
792 $this->categories_info[
$row->cat_id][
'accepted'] =
false;
793 $this->categories_info[
$row->cat_id][
'remote'] =
false;
799 $query =
"SELECT * FROM cal_categories cc ".
801 "AND obj_id = ".$ilDB->quote($this->
getCHUserId(),
'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;
811 $this->categories_info[
$row->cat_id][
'editable'] =
false;
812 $this->categories_info[
$row->cat_id][
'accepted'] =
false;
813 $this->categories_info[
$row->cat_id][
'remote'] =
false;
833 $query =
"SELECT * FROM cal_categories ".
835 "AND obj_id = ".$ilDB->quote(
$user_id,
'integer');
839 $this->categories[] =
$row->cat_id;
840 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
841 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
842 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
843 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
844 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
845 $this->categories_info[
$row->cat_id][
'editable'] =
false;
846 $this->categories_info[
$row->cat_id][
'accepted'] =
false;
847 $this->categories_info[
$row->cat_id][
'remote'] =
false;
859 global $ilAccess,$tree;
862 if(!count($a_obj_ids))
867 $query =
"SELECT * FROM cal_categories ".
869 "AND ".$ilDB->in(
'obj_id',$a_obj_ids,
false,
'integer').
" ".
877 if($obj_type ==
'crs' or $obj_type ==
'grp')
889 if($ilAccess->checkAccess(
'edit_event',
'',$ref_id))
895 elseif($ilAccess->checkAccess(
'read',
'',$ref_id))
904 $this->categories_info[
$row->cat_id][
'editable'] = $editable;
906 $this->categories[] =
$row->cat_id;
907 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
908 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
909 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
910 #$this->categories_info[$row->cat_id]['title'] = ilObject::_lookupTitle($row->obj_id); 911 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
913 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
914 $this->categories_info[
$row->cat_id][
'remote'] =
false;
929 $course_ids = array();
930 foreach($this->categories as $cat_id)
932 if($this->categories_info[$cat_id][
'obj_type'] ==
'crs' or $this->categories_info[$cat_id][
'obj_type'] ==
'grp')
934 $course_ids[] = $this->categories_info[$cat_id][
'obj_id'];
938 $query =
"SELECT od2.obj_id sess_id, od1.obj_id crs_id,cat_id FROM object_data od1 ".
939 "JOIN object_reference or1 ON od1.obj_id = or1.obj_id ".
940 "JOIN tree t ON or1.ref_id = t.parent ".
941 "JOIN object_reference or2 ON t.child = or2.ref_id ".
942 "JOIN object_data od2 ON or2.obj_id = od2.obj_id ".
943 "JOIN cal_categories cc ON od2.obj_id = cc.obj_id ".
944 "WHERE ".$ilDB->in(
'od2.type',array(
'sess',
'exc'),
false,
'text').
945 "AND (od1.type = 'crs' OR od1.type = 'grp') ".
946 "AND ".$ilDB->in(
'od1.obj_id',$course_ids,
false,
'integer').
' '.
947 "AND or2.deleted IS NULL";
951 $course_sessions = array();
954 $cat_ids[] =
$row->cat_id;
955 $course_sessions[
$row->crs_id][
$row->sess_id] =
$row->cat_id;
956 $this->subitem_categories[] =
$row->cat_id;
959 foreach($this->categories as $cat_id)
962 ($this->categories_info[$cat_id][
'obj_type'] ==
'crs' ||
963 $this->categories_info[$cat_id][
'obj_type'] ==
'grp' ) &&
964 isset($this->categories_info[$cat_id][
'obj_id']) &&
965 isset($course_sessions[$this->categories_info[$cat_id][
'obj_id']]) &&
966 is_array($course_sessions[$this->categories_info[$cat_id][
'obj_id']]))
968 foreach($course_sessions[$this->categories_info[$cat_id][
'obj_id']] as $sess_id => $sess_cat_id)
970 $this->categories_info[$cat_id][
'subitem_ids'][$sess_id] = $sess_cat_id;
971 $this->categories_info[$cat_id][
'subitem_obj_ids'][$sess_cat_id] = $sess_id;
976 $this->categories_info[$cat_id][
'subitem_ids'] = array();
977 $this->categories_info[$cat_id][
'subitem_obj_ids'] = array();
993 $set = $ilDB->query(
"SELECT * FROM cal_categories ".
995 "AND obj_id = ".$ilDB->quote($a_user_id,
'integer'));
997 while ($rec = $ilDB->fetchAssoc($set))
class for calendar categories
static getInstance()
get singleton instance
readSelectedItemCalendars()
Read categories of selected items.
addSubitemCalendars()
Add subitem calendars E.g.
static _getInstance()
get singleton instance
static _isOwner($a_usr_id, $a_cal_id)
check if user is owner of a category
wakeup($a_ser)
Load from serialize string.
getCategoryInfo($a_cat_id)
public
const MODE_PERSONAL_DESKTOP_MEMBERSHIP
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
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
sleep()
Serialize categories.
isVisible($a_cat_id)
check if category is visible
Stores calendar categories.
static deletePDItemsCache($a_usr_id)
Delete cache (add remove desktop item)
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
Handles shared calendars.
getAcceptedCalendars($a_usr_id)
get accepted shared calendars
static _getAllReferences($a_id)
get all reference ids of object
const DB_FETCHMODE_OBJECT
isEditable($a_cat_id)
check if category is editable
static deleteRepositoryCache($a_usr_id)
Delete cache.
readPublicCalendars()
Read public calendars.
getCHUserId()
Get ch user id.
static _getInstance()
get instance for logged in user
static _lookupObjId($a_id)
getSubitemCategories($a_cat_id)
get subitem categories for a specific category
readSelectedCategories($a_obj_ids)
read selected categories
readSelectedCalendar($a_cal_id)
Read info about selected calendar.
readBookingCalendar($user_id=NULL)
Read booking manager 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)
static _lookupType($a_id, $a_reference=false)
lookup object type
readReposCalendars()
Read available repository calendars.
static _lookupDesktopItems($user_id, $a_types="")
get all desktop items of user and specified type
getCategories($a_include_subitem_calendars=false)
get categories
__construct($a_usr_id=0)
Singleton instance.
getNotificationCalendars()
Get all calendars that allow send of notifications (Editable and course group calendars) ...
readPrivateCalendars()
Read private calendars.
static lookupPrivateCategories($a_user_id)
Lookup private categories of user.
readPDCalendars()
Read categories of user.
getCategoriesInfo()
get categories
const MODE_PERSONAL_DESKTOP_ITEMS