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');
462 global $ilUser,$ilAccess;
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').
" ".
530 if($tree->isDeleted(
$row->ref_id))
535 if($ilAccess->checkAccess(
'read',
'',
$row->ref_id))
537 $obj_ids[] =
$row->obj_id;
551 global $rbacsystem,$ilAccess;
554 $query =
"SELECT * FROM cal_categories ".
561 $this->categories[] =
$row->cat_id;
562 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
563 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
564 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
565 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
566 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
568 $this->categories_info[
$row->cat_id][
'accepted'] =
false;
586 $query =
"SELECT cat_id FROM cal_categories ".
588 "AND obj_id = ".$this->db->quote($ilUser->getId(),
'integer').
" ";
592 $cat_ids[] =
$row->cat_id;
596 include_once(
'./Services/Calendar/classes/class.ilCalendarSharedStatus.php');
598 if(!$cat_ids = array_merge((array) $cat_ids, $accepted_ids))
605 $query =
"SELECT * FROM cal_categories ".
607 "AND ".$ilDB->in(
'cat_id',$cat_ids,
false,
'integer').
" ".
613 $this->categories[] =
$row->cat_id;
614 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
615 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
616 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
617 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
618 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
619 $this->categories_info[
$row->cat_id][
'editable'] =
$row->obj_id == $ilUser->getId();
620 $this->categories_info[
$row->cat_id][
'accepted'] = in_array(
$row->cat_id, $accepted_ids);
638 $query =
"SELECT * FROM cal_categories ".
640 "AND obj_id = ".$ilDB->quote(
$user_id,
'integer');
644 $this->categories[] =
$row->cat_id;
645 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
646 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
647 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
648 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
649 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
650 $this->categories_info[
$row->cat_id][
'editable'] =
false;
651 $this->categories_info[
$row->cat_id][
'accepted'] =
false;
669 $query =
"SELECT * FROM cal_categories ".
671 "AND obj_id = ".$ilDB->quote(
$user_id,
'integer');
675 $this->categories[] =
$row->cat_id;
676 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
677 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
678 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
679 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
680 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
681 $this->categories_info[
$row->cat_id][
'editable'] =
false;
682 $this->categories_info[
$row->cat_id][
'accepted'] =
false;
694 global $ilAccess,$tree;
697 if(!count($a_obj_ids))
702 $query =
"SELECT * FROM cal_categories ".
704 "AND ".$ilDB->in(
'obj_id',$a_obj_ids,
false,
'integer').
" ".
714 if($ilAccess->checkAccess(
'edit_event',
'',
$ref_id))
720 elseif($ilAccess->checkAccess(
'read',
'',
$ref_id))
729 $this->categories_info[
$row->cat_id][
'editable'] = $editable;
731 $this->categories[] =
$row->cat_id;
732 $this->categories_info[
$row->cat_id][
'obj_id'] =
$row->obj_id;
733 $this->categories_info[
$row->cat_id][
'cat_id'] =
$row->cat_id;
734 $this->categories_info[
$row->cat_id][
'color'] =
$row->color;
735 #$this->categories_info[$row->cat_id]['title'] = ilObject::_lookupTitle($row->obj_id);
736 $this->categories_info[
$row->cat_id][
'title'] =
$row->title;
738 $this->categories_info[
$row->cat_id][
'type'] =
$row->type;
752 $course_ids = array();
753 foreach($this->categories as $cat_id)
755 if($this->categories_info[$cat_id][
'obj_type'] ==
'crs')
757 $course_ids[] = $this->categories_info[$cat_id][
'obj_id'];
761 $query =
"SELECT od2.obj_id sess_id, od1.obj_id crs_id,cat_id FROM object_data od1 ".
762 "JOIN object_reference or1 ON od1.obj_id = or1.obj_id ".
763 "JOIN tree t ON or1.ref_id = t.parent ".
764 "JOIN object_reference or2 ON t.child = or2.ref_id ".
765 "JOIN object_data od2 ON or2.obj_id = od2.obj_id ".
766 "JOIN cal_categories cc ON od2.obj_id = cc.obj_id ".
767 "WHERE od2.type = 'sess' ".
768 "AND od1.type = 'crs' ".
769 "AND ".$ilDB->in(
'od1.obj_id',$course_ids,
false,
'integer').
' '.
770 "AND or2.deleted IS NULL";
774 $course_sessions = array();
777 $cat_ids[] =
$row->cat_id;
778 $course_sessions[
$row->crs_id][
$row->sess_id] =
$row->cat_id;
779 $this->subitem_categories[] =
$row->cat_id;
782 foreach($this->categories as $cat_id)
784 if($this->categories_info[$cat_id][
'obj_type'] ==
'crs' &&
785 isset($this->categories_info[$cat_id][
'obj_id']) &&
786 isset($course_sessions[$this->categories_info[$cat_id][
'obj_id']]) &&
787 is_array($course_sessions[$this->categories_info[$cat_id][
'obj_id']]))
789 foreach($course_sessions[$this->categories_info[$cat_id][
'obj_id']] as $sess_id => $sess_cat_id)
791 $this->categories_info[$cat_id][
'subitem_ids'][$sess_id] = $sess_cat_id;
792 $this->categories_info[$cat_id][
'subitem_obj_ids'][$sess_cat_id] = $sess_id;
797 $this->categories_info[$cat_id][
'subitem_ids'] = array();
798 $this->categories_info[$cat_id][
'subitem_obj_ids'] = array();