34 define(
'IL_CRS_TIMINGS_ACTIVATION',0);
35 define(
'IL_CRS_TIMINGS_DEACTIVATED',1);
36 define(
'IL_CRS_TIMINGS_PRESETTING',2);
37 define(
'IL_CRS_TIMINGS_FIXED',3);
65 $this->user_id = $user_id;
82 global $ilObjDataCache,
$ilLog;
84 $ilLog->write(__METHOD__.
': Begin course items...');
86 $target_obj_id = $ilObjDataCache->lookupObjId($a_target_id);
88 include_once(
'Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
90 $mappings = $cp_options->getMappings();
92 $query =
"SELECT * FROM crs_items WHERE ".
93 "parent_id = ".$this->ilDB->quote($this->
getParentId(),
'integer').
" ";
98 $ilLog->write(__METHOD__.
': No course items found.');
105 $ilLog->write(__METHOD__.
': Cannot create target object.');
108 $new_items =
new ilCourseItems($this->course_obj,$a_target_id);
111 if(!isset($mappings[
$row->parent_id]) or !$mappings[
$row->parent_id])
113 $ilLog->write(__METHOD__.
': No mapping for parent nr. '.
$row->parent_id);
116 if(!isset($mappings[
$row->obj_id]) or !$mappings[
$row->obj_id])
118 $ilLog->write(__METHOD__.
': No mapping for item nr. '.
$row->obj_id);
121 $new_item_id = $mappings[
$row->obj_id];
122 $new_parent = $mappings[
$row->parent_id];
124 $new_items->setItemId($new_item_id);
125 $new_items->setParentId($new_parent);
126 $new_items->setTimingType(
$row->timing_type);
127 $new_items->setTimingStart(
$row->timing_start);
128 $new_items->setTimingEnd(
$row->timing_end);
129 $new_items->setSuggestionStart(
$row->suggestion_start);
130 $new_items->setSuggestionEnd(
$row->suggestion_end);
131 $new_items->toggleChangeable(
$row->changeable);
132 $new_items->setEarliestStart(
$row->earliest_start);
133 $new_items->setLatestEnd(
$row->latest_end);
134 $new_items->toggleVisible(
$row->visible);
135 $new_items->update($new_item_id);
136 $ilLog->write(__METHOD__.
': Added new entry for item nr. '.
$row->obj_id);
138 $ilLog->write(__METHOD__.
': Finished course items.');
143 $this->item_id = $a_item_id;
148 return $this->item_id;
154 return $this->user_id ? $this->user_id : $ilUser->getId();
162 include_once
'Services/Tracking/classes/class.ilLPObjSettings.php';
164 $obj_id = $ilObjDataCache->lookupObjId($a_ref_id);
169 include_once
'Services/Tracking/classes/class.ilLPCollectionCache.php';
173 $ids = array($a_ref_id);
181 $query =
"SELECT * FROM crs_items ".
183 "AND ".$ilDB->in(
'obj_id',$ids,
false,
'integer');
186 return $res->numRows() ?
true :
false;
200 $subtree = $tree->getSubTree($tree->getNodeData($a_ref_id));
202 foreach($subtree as $node)
204 $ref_ids[] = $node[
'ref_id'];
207 $query =
"SELECT * FROM crs_items ".
209 "AND ".$ilDB->in(
'obj_id',$ref_ids,
false,
'integer').
" ".
210 "AND ".$ilDB->in(
'parent_id',$ref_ids,
false,
'integer').
" ";
213 return $res->numRows() ?
true :
false;
220 $subtree = $tree->getSubTree($tree->getNodeData($a_ref_id));
222 foreach($subtree as $node)
224 $ref_ids[] = $node[
'ref_id'];
227 $query =
"SELECT * FROM crs_items ".
229 "AND changeable = ".$ilDB->quote(1,
'integer').
" ".
230 "AND ".$ilDB->in(
'obj_id',$ref_ids,
false,
'integer').
" ".
231 "AND ".$ilDB->in(
'parent_id',$ref_ids,
false,
'integer').
" ";
234 return $res->numRows() ?
true :
false;
239 $this->parent = $a_parent ? $a_parent : $this->course_obj->getRefId();
252 $this->timing_type = $a_type;
261 $this->timing_start = $a_start;
269 $this->timing_end = $a_end;
277 $this->suggestion_start = $a_start;
281 return $this->suggestion_start ? $this->suggestion_start : mktime(0,0,1,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
285 $this->suggestion_end = $a_end;
289 return $this->suggestion_end ? $this->suggestion_end : mktime(23,55,00,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
293 $this->earliest_start = $a_start;
297 return $this->earliest_start ? $this->earliest_start : mktime(0,0,1,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
301 $this->latest_end = $a_end;
305 return $this->latest_end ? $this->latest_end : mktime(23,55,00,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
309 $this->visible = (int) $a_status;
313 return (
bool) $this->visible;
317 $this->changeable = (int) $a_status;
321 return (
bool) $this->changeable;
326 $this->position = $a_pos;
331 return $this->items ? $this->items : array();
339 global $objDefinition;
341 include_once
'Modules/Session/classes/class.ilEventItems.php';
344 foreach($this->items as $item)
346 if(!in_array($item[
'ref_id'],$event_items) &&
347 !$objDefinition->isSideBlock($item[
'type']))
352 return $filtered ? $filtered : array();
357 include_once
'Modules/Session/classes/class.ilEventItems.php';
360 $event_items = $event_items_obj->getItems();
361 foreach($event_items as $item)
363 if($this->tree->isDeleted($item))
367 $node = $this->tree->getNodeData($item);
375 include_once(
'./Modules/Course/classes/class.ilCourseObjectiveMaterials.php');
379 if($this->tree->isDeleted($ref_id))
383 $node = $this->tree->getNodeData($ref_id);
394 foreach($this->items as $item)
396 if($item[
"type"] !=
"rolf" and
397 ($item[
"timing_type"] or
398 ($item[
"timing_start"] <= time() and $item[
"timing_end"] >= time())))
400 if($rbacsystem->checkAccess(
'visible',$item[
'ref_id']))
406 return $filtered ? $filtered : array();
410 foreach($this->items as $item)
412 if($item[
"child"] == $a_item_id)
424 $ilErr->setMessage(
'');
430 $ilErr->appendMessage($this->lng->txt(
"crs_activation_start_invalid"));
437 $ilErr->appendMessage($this->lng->txt(
'crs_latest_end_not_valid'));
441 #if($this->getTimingType() == IL_CRS_TIMINGS_PRESETTING and
442 # $this->enabledChangeable())
444 # if($this->getSuggestionStart() < $this->getEarliestStart() or
445 # $this->getSuggestionEnd() > $this->getLatestEnd() or
446 # $this->getSuggestionStart() > $this->getLatestEnd() or
447 # $this->getSuggestionEnd() < $this->getEarliestStart())
449 # $ilErr->appendMessage($this->lng->txt("crs_suggestion_not_within_activation"));
453 if($ilErr->getMessage())
470 $query =
"INSERT INTO crs_items (timing_type,timing_start,timing_end,".
471 "suggestion_start,suggestion_end, ".
472 "changeable,earliest_start,latest_end,visible,parent_id,obj_id) ".
484 $ilDB->quote($this->
getItemId(),
'integer').
" ".
494 $query =
"UPDATE crs_items SET ".
495 "timing_type = ".$ilDB->quote($this->
getTimingType(),
'integer').
", ".
496 "timing_start = ".$ilDB->quote($this->
getTimingStart(),
'integer').
", ".
497 "timing_end = ".$ilDB->quote($this->
getTimingEnd(),
'integer').
", ".
502 "latest_end = ".$ilDB->quote($this->
getLatestEnd(),
'integer').
", ".
504 "WHERE parent_id = ".$ilDB->quote($this->
getParentId(),
'integer').
" ".
505 "AND obj_id = ".$ilDB->quote($a_item_id,
'integer').
"";
530 $all_items = $this->tree->getChilds($this->parent);
532 foreach($all_items as $item)
534 $query =
"DELETE FROM crs_items ".
535 "WHERE parent_id = ".$ilDB->quote($item[
"child"],
'integer').
"";
538 $query =
"DELETE FROM crs_items ".
539 "WHERE parent_id = ".$ilDB->quote($this->course_obj->getRefId(),
'integer').
" ";
550 $this->items = array();
552 $ilBench->start(
"Course",
"ilCouseItems_read - getChilds");
553 $all_items = $this->tree->getChilds($this->parent);
554 $ilBench->stop(
"Course",
"ilCouseItems_read - getChilds");
556 foreach($all_items as $item)
558 if($item[
"type"] !=
'rolf')
560 $this->items[] = $item;
563 $ilBench->start(
"Course",
"ilCouseItems_read - getItemData");
564 for($i = 0;$i < count($this->items); ++$i)
566 if($this->items[$i][
"type"] ==
'rolf')
568 unset($this->items[$i]);
573 $ilBench->stop(
"Course",
"ilCouseItems_read - getItemData");
575 $ilBench->start(
"Course",
"ilCouseItems_read - purge and sort");
578 $ilBench->stop(
"Course",
"ilCouseItems_read - purge and sort");
581 $this->items_per_child = array();
582 foreach($this->items as $item)
584 $this->items_per_child[$item[
"child"]] = $item;
596 $query =
"SELECT obj_id FROM crs_items ".
597 "WHERE parent_id = ".$ilDB->quote($this->
getParentId(),
'integer').
" ";
614 $query =
"DELETE FROM crs_items ".
615 "WHERE parent_id = ".$ilDB->quote($this->
getParentId(),
'integer').
" ".
616 "AND obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ";
626 $ilBench->start(
"Course",
"ilCourseItems_getItemData - 1");
627 $query =
"SELECT * FROM crs_items ".
628 "WHERE obj_id = ".$ilDB->quote($a_item[
'child'],
'integer').
" ".
629 "AND parent_id = ".$ilDB->quote($a_item[
'parent'],
'integer').
" ";
631 $ilBench->stop(
"Course",
"ilCourseItems_getItemData - 1");
634 $ilBench->start(
"Course",
"ilCourseItems_getItemData - 2");
635 $a_item[
"timing_type"] =
$row->timing_type;
636 $a_item[
"timing_start"] =
$row->timing_start;
637 $a_item[
"timing_end"] =
$row->timing_end;
638 $a_item[
"suggestion_start"] =
$row->suggestion_start ?
$row->suggestion_start :
639 mktime(0,0,1,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
640 $a_item[
"suggestion_end"] =
$row->suggestion_end ?
$row->suggestion_end :
641 mktime(23,55,00,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
642 $a_item[
'changeable'] =
$row->changeable;
643 $a_item[
'earliest_start'] =
$row->earliest_start ?
$row->earliest_start :
644 mktime(0,0,1,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
645 $a_item[
'latest_end'] =
$row->latest_end ?
$row->latest_end :
646 mktime(23,55,00,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
647 $a_item[
'visible'] =
$row->visible;
649 include_once
'Modules/Course/classes/Timings/class.ilTimingPlaned.php';
651 $ilBench->stop(
"Course",
"ilCourseItems_getItemData - 2");
653 $ilBench->start(
"Course",
"ilCourseItems_getItemData - 3");
656 $obj_id = ($a_item[
'obj_id'] > 0)
658 : $ilObjDataCache->lookupObjId(
$row->obj_id);
659 $obj_type = ($a_item[
'type'] !=
"")
661 : $ilObjDataCache->lookupType($obj_id);
664 $ilBench->stop(
"Course",
"ilCourseItems_getItemData - 3");
669 $ilBench->start(
"Course",
"ilCourseItems_getItemData - 4");
670 if($a_item[
'changeable'] and
673 if(
$data[
'planed_start'])
675 $a_item[
'start'] =
$data[
'planed_start'];
676 $a_item[
'end'] =
$data[
'planed_end'];
677 $a_item[
'activation_info'] =
'crs_timings_planed_info';
681 $a_item[
'start'] =
$row->suggestion_start;
682 $a_item[
'end'] =
$row->suggestion_end;
683 $a_item[
'activation_info'] =
'crs_timings_suggested_info';
688 $a_item[
'start'] =
$row->suggestion_start;
689 $a_item[
'end'] =
$row->suggestion_end;
690 $a_item[
'activation_info'] =
'crs_timings_suggested_info';
694 $a_item[
'start'] =
$row->timing_start;
695 $a_item[
'end'] =
$row->timing_end;
696 $a_item[
'activation_info'] =
'activation';
698 elseif($obj_type ==
'sess')
700 include_once(
'./Modules/Session/classes/class.ilSessionAppointment.php');
702 $ilBench->start(
"Course",
"ilCourseItems_getItemData - lookupAppointment");
704 $ilBench->stop(
"Course",
"ilCourseItems_getItemData - lookupAppointment");
707 $a_item[
'start'] = $info[
'start'];
708 $a_item[
'end'] = $info[
'end'];
709 $a_item[
'fullday'] = $info[
'fullday'];
710 $a_item[
'activation_info'] =
'crs_timings_suggested_info';
714 $a_item[
'start'] = 999999999;
716 $ilBench->stop(
"Course",
"ilCourseItems_getItemData - 4");
719 $ilBench->start(
"Course",
"ilCourseItems_getItemData - 5");
720 if(!isset($a_item[
"timing_start"]))
724 $ilBench->stop(
"Course",
"ilCourseItems_getItemData - 5");
731 global
$ilDB, $objDefinition;
734 $a_item[
"timing_start"] = time();
735 $a_item[
"timing_end"] = time();
736 $a_item[
"suggestion_start"] = time();
737 $a_item[
"suggestion_end"] = time();
738 $a_item[
'visible'] = 0;
739 $a_item[
'changeable'] = 0;
740 $a_item[
'earliest_start'] = time();
741 $a_item[
'latest_end'] = mktime(23,55,00,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
742 $a_item[
'visible'] = 0;
743 $a_item[
'changeable'] = 0;
746 $query =
"INSERT INTO crs_items (parent_id,obj_id,timing_type,timing_start,timing_end," .
747 "suggestion_start,suggestion_end, ".
748 "changeable,earliest_start,latest_end,visible,position) ".
750 $ilDB->quote($a_item[
'parent'],
'integer').
",".
751 $ilDB->quote($a_item[
"child"],
'integer').
",".
752 $ilDB->quote($a_item[
"timing_type"],
'integer').
",".
753 $ilDB->quote($a_item[
"timing_start"],
'integer').
",".
754 $ilDB->quote($a_item[
"timing_end"],
'integer').
",".
755 $ilDB->quote($a_item[
"suggestion_start"],
'integer').
",".
756 $ilDB->quote($a_item[
"suggestion_end"],
'integer').
",".
757 $ilDB->quote($a_item[
"changeable"],
'integer').
",".
758 $ilDB->quote($a_item[
'earliest_start'],
'integer').
", ".
759 $ilDB->quote($a_item[
'latest_end'],
'integer').
", ".
760 $ilDB->quote($a_item[
"visible"],
'integer').
", ".
761 $ilDB->quote(0,
'integer').
")";
772 $query =
"SELECT MAX(position) last_position FROM crs_items ".
773 "WHERE parent_id = ".$ilDB->quote($this->
getParentId(),
'integer').
" ";
778 $max =
$row->last_position;
780 return $max ? $max : 0;
787 include_once
'Modules/Session/classes/class.ilEventItems.php';
789 global $ilObjDataCache;
791 if($ilObjDataCache->lookupType($ilObjDataCache->lookupObjId($a_ref_id)) !=
'crs')
806 if(!$node_b[
"obj_id"])
811 $query =
"UPDATE crs_items SET ".
812 "position = ".$ilDB->quote($node_a[
"position"],
'integer').
" ".
813 "WHERE obj_id = ".$ilDB->quote($node_b[
"obj_id"],
'integer').
" ".
814 "AND parent_id = ".$ilDB->quote($this->
getParentId(),
'integer').
"";
817 $query =
"UPDATE crs_items SET ".
818 "position = ".$ilDB->quote($node_b[
"position"],
'integer').
" ".
819 "WHERE obj_id = ".$ilDB->quote($node_a[
"obj_id"],
'integer').
" ".
820 "AND parent_id = ".$ilDB->quote($this->
getParentId(),
'integer').
"";
834 public static function _sort($a_sort_mode,$a_items)
841 $inactive = $active = array();
842 foreach($a_items as $item)
856 return array_merge($sorted_active,$sorted_inactive);
869 switch($this->course_obj->getOrderType())
879 $this->items = array_merge($sorted_active,$sorted_inactive);
890 $inactive = $active = array();
891 foreach($this->items as $item)
902 return array($active,$inactive);
911 include_once
'Modules/Course/classes/class.ilObjCourse.php';
913 global
$ilDB,$ilUser;
915 $query =
"SELECT * FROM crs_items ".
916 "WHERE obj_id = ".$ilDB->quote($a_item_id,
'integer');
924 $data[
'timing_type'] =
$row->timing_type;
925 $data[
'timing_start'] =
$row->timing_start;
927 $data[
"suggestion_start"] =
$row->suggestion_start ?
$row->suggestion_start :
928 mktime(0,0,1,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
929 $data[
"suggestion_end"] =
$row->suggestion_end ?
$row->suggestion_end :
930 mktime(23,55,00,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
932 $data[
'earliest_start'] =
$row->earliest_start ?
$row->earliest_start :
933 mktime(0,0,1,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
935 mktime(23,55,00,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
939 include_once
'Modules/Course/classes/Timings/class.ilTimingPlaned.php';
943 if(
$data[
'changeable'] and
946 if($user_data[
'planed_start'])
948 $data[
'start'] = $user_data[
'planed_start'];
949 $data[
'end'] = $user_data[
'planed_end'];
950 $data[
'activation_info'] =
'crs_timings_planed_info';
956 $data[
'activation_info'] =
'crs_timings_suggested_info';
963 $data[
'activation_info'] =
'crs_timings_suggested_info';
969 $data[
'activation_info'] =
'activation';
973 $data[
'start'] = 999999999;
983 $query =
"SELECT * FROM crs_items ".
984 "WHERE obj_id = ".$ilDB->quote($a_item_id,
'integer').
" ";
989 if(
$row->activation_unlimited)
993 if(time() >
$row->activation_start and time() <
$row->activation_end)
1012 if(!is_array($a_ref_ids) or !$a_ref_ids)
1017 $query =
"SELECT obj_id,timing_type,timing_start,timing_end,visible FROM crs_items ".
1018 "WHERE ".$ilDB->in(
'obj_id',$a_ref_ids,
false,
'integer');
1023 $ac_times[(string)
$row->obj_id][
'obj_id'] =
$row->obj_id;
1024 $ac_times[(
string)
$row->obj_id][
'timing_type'] =
$row->timing_type;
1025 $ac_times[(string)
$row->obj_id][
'timing_start'] =
$row->timing_start;
1026 $ac_times[(
string)
$row->obj_id][
'timing_end'] =
$row->timing_end;
1027 $ac_times[(string)
$row->obj_id][
'visible'] =
$row->visible;
1030 return $ac_times ? $ac_times : array();
1038 if (is_array($this->items_per_child[$a_item[
"child"]]))
1040 $a_item = array_merge($a_item, $this->items_per_child[$a_item[
"child"]]);