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';
71 $this->user_id = $a_usr_id;
74 $this->user_id = $ilUser->getId();
108 $query =
"SELECT cat_id FROM cal_categories ".
109 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ".
130 public static function _isOwner($a_usr_id,$a_cal_id)
134 $query =
"SELECT * FROM cal_categories ".
135 "WHERE cat_id = ".$ilDB->quote($a_cal_id ,
'integer').
" ".
136 "AND obj_id = ".$ilDB->quote($a_usr_id ,
'integer').
" ".
139 return $res->numRows() ?
true :
false;
151 self::MODE_PERSONAL_DESKTOP_ITEMS,
165 self::MODE_REPOSITORY,
180 'categories' => $this->categories,
181 'categories_info' => $this->categories_info,
182 'subitem_categories'=> $this->subitem_categories
194 $info = unserialize($a_ser);
196 $this->categories = $info[
'categories'];
197 $this->categories_info = $info[
'categories_info'];
198 $this->subitem_categories = $info[
'subitem_categories'];
209 public function initialize($a_mode,$a_source_ref_id = 0,$a_use_cache =
false)
224 case self::MODE_REMOTE_ACCESS:
225 include_once(
'./Services/Calendar/classes/class.ilCalendarUserSettings.php');
236 case self::MODE_PERSONAL_DESKTOP_MEMBERSHIP:
240 case self::MODE_PERSONAL_DESKTOP_ITEMS:
244 case self::MODE_REPOSITORY:
245 $this->root_ref_id = $a_source_ref_id;
250 case self::MODE_MANAGE:
255 case self::MODE_CONSULTATION:
265 $this->user_id.
':'.$a_mode.
':categories:'.(
int) $a_source_ref_id,
283 if(isset($this->categories_info[$a_cat_id]))
285 return $this->categories_info[$a_cat_id];
288 if(in_array($a_cat_id,(array) $this->subitem_categories))
290 foreach($this->categories as $cat_id)
292 if(in_array($a_cat_id,$this->categories_info[$cat_id][
'subitem_ids']))
294 return $this->categories_info[$cat_id];
310 return $this->categories_info ? $this->categories_info : array();
321 if($a_include_subitem_calendars)
323 return array_merge((array) $this->categories, (array) $this->subitem_categories);
326 return $this->categories ? $this->categories : array();
337 if(!isset($this->categories_info[$a_cat_id][
'subitem_ids']))
339 return array($a_cat_id);
341 return array_merge((array) $this->categories_info[$a_cat_id][
'subitem_ids'],array($a_cat_id));
356 $has_personal_calendar =
false;
357 foreach($this->categories_info as $info)
359 if($info[
'obj_type'] ==
'sess')
365 $has_personal_calendar =
true;
368 if($info[
'editable'])
370 $cats[$info[
'cat_id']] = $info[
'title'];
374 if(!$has_personal_calendar)
376 $cats[0] = $lng->txt(
'cal_default_calendar');
378 return $cats ? $cats : array();
389 foreach($this->categories_info as $info)
395 $not[] = $info[
'cat_id'];
411 return isset($this->categories_info[$a_cat_id][
'editable']) and $this->categories_info[$a_cat_id][
'editable'];
423 return in_array($a_cat_id,$this->categories) or
424 in_array($a_cat_id,(array) $this->subitem_categories);
447 include_once(
'./Services/Membership/classes/class.ilParticipants.php');
476 if($ilAccess->checkAccess(
'read',
'',$item[
'ref_id']))
478 switch($item[
'type'])
481 $courses[] = $item[
'obj_id'];
485 $sessions[] = $item[
'obj_id'];
489 $groups[] = $item[
'obj_id'];
512 global $ilAccess,$tree;
519 $query =
"SELECT ref_id,obd.obj_id obj_id FROM tree t1 ".
520 "JOIN object_reference obr ON t1.child = obr.ref_id ".
521 "JOIN object_data obd ON obd.obj_id = obr.obj_id ".
522 "WHERE t1.lft >= (SELECT lft FROM tree WHERE child = ".$this->db->quote($this->root_ref_id,
'integer').
" ) ".
523 "AND t1.lft <= (SELECT rgt FROM tree WHERE child = ".$this->db->quote($this->root_ref_id,
'integer').
" ) ".
524 "AND ".$ilDB->in(
'type',array(
'crs',
'grp',
'sess'),
false,
'text').
" ".
531 if($tree->isDeleted(
$row->ref_id))
537 if($obj_type ==
'crs' or $obj_type ==
'grp')
545 if($ilAccess->checkAccess(
'read',
'',
$row->ref_id))
547 $obj_ids[] =
$row->obj_id;
561 global $rbacsystem,$ilAccess;
564 $query =
"SELECT * FROM cal_categories ".
571 $this->categories[] =
$row->cat_id;
572 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
573 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
574 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
575 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
576 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
578 $this->categories_info[
$row->cat_id][
'accepted'] =
false;
597 $query =
"SELECT cat_id FROM cal_categories ".
599 "AND obj_id = ".$this->db->quote($ilUser->getId(),
'integer').
" ";
603 $cat_ids[] =
$row->cat_id;
607 include_once(
'./Services/Calendar/classes/class.ilCalendarSharedStatus.php');
609 if(!$cat_ids = array_merge((array) $cat_ids, $accepted_ids))
616 $query =
"SELECT * FROM cal_categories ".
618 "AND ".$ilDB->in(
'cat_id',$cat_ids,
false,
'integer').
" ".
624 $this->categories[] =
$row->cat_id;
625 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
626 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
627 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
628 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
629 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
630 $this->categories_info[
$row->cat_id][
'editable'] =
$row->obj_id == $ilUser->getId();
631 $this->categories_info[
$row->cat_id][
'accepted'] = in_array(
$row->cat_id, $accepted_ids);
650 $query =
"SELECT * FROM cal_categories ".
652 "AND obj_id = ".$ilDB->quote(
$user_id,
'integer');
656 $this->categories[] =
$row->cat_id;
657 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
658 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
659 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
660 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
661 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
662 $this->categories_info[
$row->cat_id][
'editable'] =
false;
663 $this->categories_info[
$row->cat_id][
'accepted'] =
false;
664 $this->categories_info[
$row->cat_id][
'remote'] =
false;
682 $query =
"SELECT * FROM cal_categories ".
684 "AND obj_id = ".$ilDB->quote(
$user_id,
'integer');
688 $this->categories[] =
$row->cat_id;
689 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
690 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
691 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
692 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
693 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
694 $this->categories_info[
$row->cat_id][
'editable'] =
false;
695 $this->categories_info[
$row->cat_id][
'accepted'] =
false;
696 $this->categories_info[
$row->cat_id][
'remote'] =
false;
708 global $ilAccess,$tree;
711 if(!count($a_obj_ids))
716 $query =
"SELECT * FROM cal_categories ".
718 "AND ".$ilDB->in(
'obj_id',$a_obj_ids,
false,
'integer').
" ".
726 if($obj_type ==
'crs' or $obj_type ==
'grp')
738 if($ilAccess->checkAccess(
'edit_event',
'',$ref_id))
744 elseif($ilAccess->checkAccess(
'read',
'',$ref_id))
753 $this->categories_info[
$row->cat_id][
'editable'] = $editable;
755 $this->categories[] =
$row->cat_id;
756 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
757 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
758 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
759 #$this->categories_info[$row->cat_id]['title'] = ilObject::_lookupTitle($row->obj_id);
760 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
762 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
763 $this->categories_info[
$row->cat_id][
'remote'] =
false;
778 $course_ids = array();
779 foreach($this->categories as $cat_id)
781 if($this->categories_info[$cat_id][
'obj_type'] ==
'crs' or $this->categories_info[$cat_id][
'obj_type'] ==
'grp')
783 $course_ids[] = $this->categories_info[$cat_id][
'obj_id'];
787 $query =
"SELECT od2.obj_id sess_id, od1.obj_id crs_id,cat_id FROM object_data od1 ".
788 "JOIN object_reference or1 ON od1.obj_id = or1.obj_id ".
789 "JOIN tree t ON or1.ref_id = t.parent ".
790 "JOIN object_reference or2 ON t.child = or2.ref_id ".
791 "JOIN object_data od2 ON or2.obj_id = od2.obj_id ".
792 "JOIN cal_categories cc ON od2.obj_id = cc.obj_id ".
793 "WHERE od2.type = 'sess' ".
794 "AND (od1.type = 'crs' OR od1.type = 'grp') ".
795 "AND ".$ilDB->in(
'od1.obj_id',$course_ids,
false,
'integer').
' '.
796 "AND or2.deleted IS NULL";
800 $course_sessions = array();
803 $cat_ids[] =
$row->cat_id;
804 $course_sessions[
$row->crs_id][
$row->sess_id] =
$row->cat_id;
805 $this->subitem_categories[] =
$row->cat_id;
808 foreach($this->categories as $cat_id)
811 ($this->categories_info[$cat_id][
'obj_type'] ==
'crs' ||
812 $this->categories_info[$cat_id][
'obj_type'] ==
'grp' ) &&
813 isset($this->categories_info[$cat_id][
'obj_id']) &&
814 isset($course_sessions[$this->categories_info[$cat_id][
'obj_id']]) &&
815 is_array($course_sessions[$this->categories_info[$cat_id][
'obj_id']]))
817 foreach($course_sessions[$this->categories_info[$cat_id][
'obj_id']] as $sess_id => $sess_cat_id)
819 $this->categories_info[$cat_id][
'subitem_ids'][$sess_id] = $sess_cat_id;
820 $this->categories_info[$cat_id][
'subitem_obj_ids'][$sess_cat_id] = $sess_id;
825 $this->categories_info[$cat_id][
'subitem_ids'] = array();
826 $this->categories_info[$cat_id][
'subitem_obj_ids'] = array();
842 $set = $ilDB->query(
"SELECT * FROM cal_categories ".
844 "AND obj_id = ".$ilDB->quote($a_user_id,
'integer'));
846 while ($rec = $ilDB->fetchAssoc($set))