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->course_ref_id = $a_course_ref_id;
66 $this->user_id = $user_id;
83 global $ilObjDataCache,
$ilLog;
85 $ilLog->write(__METHOD__.
': Begin course items...');
87 $target_obj_id = $ilObjDataCache->lookupObjId($a_target_id);
89 include_once(
'Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
91 $mappings = $cp_options->getMappings();
93 $query =
"SELECT * FROM crs_items WHERE ".
94 "parent_id = ".$this->ilDB->quote($this->
getParentId(),
'integer').
" ";
99 $ilLog->write(__METHOD__.
': No course items found.');
106 $ilLog->write(__METHOD__.
': Cannot create target object.');
109 $new_items =
new ilCourseItems($this->course_ref_id,$a_target_id);
112 if(!isset($mappings[
$row->parent_id]) or !$mappings[
$row->parent_id])
114 $ilLog->write(__METHOD__.
': No mapping for parent nr. '.
$row->parent_id);
117 if(!isset($mappings[
$row->obj_id]) or !$mappings[
$row->obj_id])
119 $ilLog->write(__METHOD__.
': No mapping for item nr. '.
$row->obj_id);
122 $new_item_id = $mappings[
$row->obj_id];
123 $new_parent = $mappings[
$row->parent_id];
125 $new_items->setItemId($new_item_id);
126 $new_items->setParentId($new_parent);
127 $new_items->setTimingType(
$row->timing_type);
128 $new_items->setTimingStart(
$row->timing_start);
129 $new_items->setTimingEnd(
$row->timing_end);
130 $new_items->setSuggestionStart(
$row->suggestion_start);
131 $new_items->setSuggestionEnd(
$row->suggestion_end);
132 $new_items->toggleChangeable(
$row->changeable);
133 $new_items->setEarliestStart(
$row->earliest_start);
134 $new_items->setLatestEnd(
$row->latest_end);
135 $new_items->toggleVisible(
$row->visible);
136 $new_items->update($new_item_id);
137 $ilLog->write(__METHOD__.
': Added new entry for item nr. '.
$row->obj_id);
139 $ilLog->write(__METHOD__.
': Finished course items.');
144 $this->item_id = $a_item_id;
149 return $this->item_id;
155 return $this->user_id ? $this->user_id : $ilUser->getId();
163 include_once
'Services/Tracking/classes/class.ilLPObjSettings.php';
165 $obj_id = $ilObjDataCache->lookupObjId($a_ref_id);
170 include_once
'Services/Tracking/classes/class.ilLPCollectionCache.php';
174 $ids = array($a_ref_id);
182 $query =
"SELECT * FROM crs_items ".
184 "AND ".$ilDB->in(
'obj_id',$ids,
false,
'integer');
187 return $res->numRows() ?
true :
false;
201 $subtree = $tree->getSubTree($tree->getNodeData($a_ref_id));
203 foreach($subtree as $node)
205 $ref_ids[] = $node[
'ref_id'];
208 $query =
"SELECT * FROM crs_items ".
210 "AND ".$ilDB->in(
'obj_id',$ref_ids,
false,
'integer').
" ".
211 "AND ".$ilDB->in(
'parent_id',$ref_ids,
false,
'integer').
" ";
214 return $res->numRows() ?
true :
false;
221 $subtree = $tree->getSubTree($tree->getNodeData($a_ref_id));
223 foreach($subtree as $node)
225 $ref_ids[] = $node[
'ref_id'];
228 $query =
"SELECT * FROM crs_items ".
230 "AND changeable = ".$ilDB->quote(1,
'integer').
" ".
231 "AND ".$ilDB->in(
'obj_id',$ref_ids,
false,
'integer').
" ".
232 "AND ".$ilDB->in(
'parent_id',$ref_ids,
false,
'integer').
" ";
235 return $res->numRows() ?
true :
false;
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))
368 $node = $this->tree->getNodeData($item);
369 if($node[
"ref_id"] == $item)
379 include_once(
'./Modules/Course/classes/class.ilCourseObjectiveMaterials.php');
383 if($this->tree->isDeleted($ref_id))
388 $node = $this->tree->getNodeData($ref_id);
389 if($node[
"ref_id"] == $ref_id)
402 foreach($this->items as $item)
404 if($item[
"type"] !=
"rolf" and
405 ($item[
"timing_type"] or
406 ($item[
"timing_start"] <= time() and $item[
"timing_end"] >= time())))
408 if($rbacsystem->checkAccess(
'visible',$item[
'ref_id']))
414 return $filtered ? $filtered : array();
418 foreach($this->items as $item)
420 if($item[
"child"] == $a_item_id)
432 $ilErr->setMessage(
'');
438 $ilErr->appendMessage($this->lng->txt(
"crs_activation_start_invalid"));
445 $ilErr->appendMessage($this->lng->txt(
'crs_latest_end_not_valid'));
449 #if($this->getTimingType() == IL_CRS_TIMINGS_PRESETTING and
450 # $this->enabledChangeable())
452 # if($this->getSuggestionStart() < $this->getEarliestStart() or
453 # $this->getSuggestionEnd() > $this->getLatestEnd() or
454 # $this->getSuggestionStart() > $this->getLatestEnd() or
455 # $this->getSuggestionEnd() < $this->getEarliestStart())
457 # $ilErr->appendMessage($this->lng->txt("crs_suggestion_not_within_activation"));
461 if($ilErr->getMessage())
478 $query =
"INSERT INTO crs_items (timing_type,timing_start,timing_end,".
479 "suggestion_start,suggestion_end, ".
480 "changeable,earliest_start,latest_end,visible,parent_id,obj_id) ".
492 $ilDB->quote($this->
getItemId(),
'integer').
" ".
502 $query =
"UPDATE crs_items SET ".
503 "timing_type = ".$ilDB->quote($this->
getTimingType(),
'integer').
", ".
504 "timing_start = ".$ilDB->quote($this->
getTimingStart(),
'integer').
", ".
505 "timing_end = ".$ilDB->quote($this->
getTimingEnd(),
'integer').
", ".
510 "latest_end = ".$ilDB->quote($this->
getLatestEnd(),
'integer').
", ".
512 "WHERE parent_id = ".$ilDB->quote($this->
getParentId(),
'integer').
" ".
513 "AND obj_id = ".$ilDB->quote($a_item_id,
'integer').
"";
538 $all_items = $this->tree->getChilds($this->parent);
540 foreach($all_items as $item)
542 $query =
"DELETE FROM crs_items ".
543 "WHERE parent_id = ".$ilDB->quote($item[
"child"],
'integer').
"";
546 $query =
"DELETE FROM crs_items ".
547 "WHERE parent_id = ".$ilDB->quote($this->course_ref_id,
'integer').
" ";
558 $this->items = array();
560 $ilBench->start(
"Course",
"ilCouseItems_read - getChilds");
561 $all_items = $this->tree->getChilds($this->parent);
562 $ilBench->stop(
"Course",
"ilCouseItems_read - getChilds");
564 foreach($all_items as $item)
566 if($item[
"type"] !=
'rolf')
568 $this->items[] = $item;
571 $ilBench->start(
"Course",
"ilCouseItems_read - getItemData");
572 for($i = 0;$i < count($this->items); ++$i)
574 if($this->items[$i][
"type"] ==
'rolf')
576 unset($this->items[$i]);
581 $ilBench->stop(
"Course",
"ilCouseItems_read - getItemData");
583 $ilBench->start(
"Course",
"ilCouseItems_read - purge and sort");
586 $ilBench->stop(
"Course",
"ilCouseItems_read - purge and sort");
589 $this->items_per_child = array();
590 foreach($this->items as $item)
592 $this->items_per_child[$item[
"child"]] = $item;
604 $query =
"SELECT obj_id FROM crs_items ".
605 "WHERE parent_id = ".$ilDB->quote($this->
getParentId(),
'integer').
" ";
622 $query =
"DELETE FROM crs_items ".
623 "WHERE parent_id = ".$ilDB->quote($this->
getParentId(),
'integer').
" ".
624 "AND obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ";
634 $ilBench->start(
"Course",
"ilCourseItems_getItemData - 1");
635 $query =
"SELECT * FROM crs_items ".
636 "WHERE obj_id = ".$ilDB->quote($a_item[
'child'],
'integer').
" ".
637 "AND parent_id = ".$ilDB->quote($a_item[
'parent'],
'integer').
" ";
639 $ilBench->stop(
"Course",
"ilCourseItems_getItemData - 1");
642 $ilBench->start(
"Course",
"ilCourseItems_getItemData - 2");
643 $a_item[
"timing_type"] =
$row->timing_type;
644 $a_item[
"timing_start"] =
$row->timing_start;
645 $a_item[
"timing_end"] =
$row->timing_end;
646 $a_item[
"suggestion_start"] =
$row->suggestion_start ?
$row->suggestion_start :
647 mktime(0,0,1,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
648 $a_item[
"suggestion_end"] =
$row->suggestion_end ?
$row->suggestion_end :
649 mktime(23,55,00,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
650 $a_item[
'changeable'] =
$row->changeable;
651 $a_item[
'earliest_start'] =
$row->earliest_start ?
$row->earliest_start :
652 mktime(0,0,1,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
653 $a_item[
'latest_end'] =
$row->latest_end ?
$row->latest_end :
654 mktime(23,55,00,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
655 $a_item[
'visible'] =
$row->visible;
657 include_once
'Modules/Course/classes/Timings/class.ilTimingPlaned.php';
659 $ilBench->stop(
"Course",
"ilCourseItems_getItemData - 2");
661 $ilBench->start(
"Course",
"ilCourseItems_getItemData - 3");
664 $obj_id = ($a_item[
'obj_id'] > 0)
666 : $ilObjDataCache->lookupObjId(
$row->obj_id);
667 $obj_type = ($a_item[
'type'] !=
"")
669 : $ilObjDataCache->lookupType($obj_id);
672 $ilBench->stop(
"Course",
"ilCourseItems_getItemData - 3");
677 $ilBench->start(
"Course",
"ilCourseItems_getItemData - 4");
678 if($a_item[
'changeable'] and
681 if(
$data[
'planed_start'])
683 $a_item[
'start'] =
$data[
'planed_start'];
684 $a_item[
'end'] =
$data[
'planed_end'];
685 $a_item[
'activation_info'] =
'crs_timings_planed_info';
689 $a_item[
'start'] =
$row->suggestion_start;
690 $a_item[
'end'] =
$row->suggestion_end;
691 $a_item[
'activation_info'] =
'crs_timings_suggested_info';
696 $a_item[
'start'] =
$row->suggestion_start;
697 $a_item[
'end'] =
$row->suggestion_end;
698 $a_item[
'activation_info'] =
'crs_timings_suggested_info';
702 $a_item[
'start'] =
$row->timing_start;
703 $a_item[
'end'] =
$row->timing_end;
704 $a_item[
'activation_info'] =
'activation';
706 elseif($obj_type ==
'sess')
708 include_once(
'./Modules/Session/classes/class.ilSessionAppointment.php');
710 $ilBench->start(
"Course",
"ilCourseItems_getItemData - lookupAppointment");
712 $ilBench->stop(
"Course",
"ilCourseItems_getItemData - lookupAppointment");
715 $a_item[
'start'] = $info[
'start'];
716 $a_item[
'end'] = $info[
'end'];
717 $a_item[
'fullday'] = $info[
'fullday'];
718 $a_item[
'activation_info'] =
'crs_timings_suggested_info';
722 $a_item[
'start'] = 999999999;
724 $ilBench->stop(
"Course",
"ilCourseItems_getItemData - 4");
727 $ilBench->start(
"Course",
"ilCourseItems_getItemData - 5");
728 if(!isset($a_item[
"timing_start"]))
732 $ilBench->stop(
"Course",
"ilCourseItems_getItemData - 5");
739 global
$ilDB, $objDefinition;
742 $a_item[
"timing_start"] = time();
743 $a_item[
"timing_end"] = time();
744 $a_item[
"suggestion_start"] = time();
745 $a_item[
"suggestion_end"] = time();
746 $a_item[
'visible'] = 0;
747 $a_item[
'changeable'] = 0;
748 $a_item[
'earliest_start'] = time();
749 $a_item[
'latest_end'] = mktime(23,55,00,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
750 $a_item[
'visible'] = 0;
751 $a_item[
'changeable'] = 0;
754 $query =
"INSERT INTO crs_items (parent_id,obj_id,timing_type,timing_start,timing_end," .
755 "suggestion_start,suggestion_end, ".
756 "changeable,earliest_start,latest_end,visible,position) ".
758 $ilDB->quote($a_item[
'parent'],
'integer').
",".
759 $ilDB->quote($a_item[
"child"],
'integer').
",".
760 $ilDB->quote($a_item[
"timing_type"],
'integer').
",".
761 $ilDB->quote($a_item[
"timing_start"],
'integer').
",".
762 $ilDB->quote($a_item[
"timing_end"],
'integer').
",".
763 $ilDB->quote($a_item[
"suggestion_start"],
'integer').
",".
764 $ilDB->quote($a_item[
"suggestion_end"],
'integer').
",".
765 $ilDB->quote($a_item[
"changeable"],
'integer').
",".
766 $ilDB->quote($a_item[
'earliest_start'],
'integer').
", ".
767 $ilDB->quote($a_item[
'latest_end'],
'integer').
", ".
768 $ilDB->quote($a_item[
"visible"],
'integer').
", ".
769 $ilDB->quote(0,
'integer').
")";
780 $query =
"SELECT MAX(position) last_position FROM crs_items ".
781 "WHERE parent_id = ".$ilDB->quote($this->
getParentId(),
'integer').
" ";
786 $max =
$row->last_position;
788 return $max ? $max : 0;
795 include_once
'Modules/Session/classes/class.ilEventItems.php';
797 global $ilObjDataCache;
799 if($ilObjDataCache->lookupType($ilObjDataCache->lookupObjId($a_ref_id)) !=
'crs')
814 if(!$node_b[
"obj_id"])
819 $query =
"UPDATE crs_items SET ".
820 "position = ".$ilDB->quote($node_a[
"position"],
'integer').
" ".
821 "WHERE obj_id = ".$ilDB->quote($node_b[
"obj_id"],
'integer').
" ".
822 "AND parent_id = ".$ilDB->quote($this->
getParentId(),
'integer').
"";
825 $query =
"UPDATE crs_items SET ".
826 "position = ".$ilDB->quote($node_b[
"position"],
'integer').
" ".
827 "WHERE obj_id = ".$ilDB->quote($node_a[
"obj_id"],
'integer').
" ".
828 "AND parent_id = ".$ilDB->quote($this->
getParentId(),
'integer').
"";
842 public static function _sort($a_sort_mode,$a_items)
849 $inactive = $active = array();
850 foreach($a_items as $item)
864 return array_merge($sorted_active,$sorted_inactive);
877 include_once
'./Services/Container/classes/class.ilContainerSortingSettings.php';
889 $this->items = array_merge($sorted_active,$sorted_inactive);
900 $inactive = $active = array();
901 foreach($this->items as $item)
912 return array($active,$inactive);
921 include_once
'Modules/Course/classes/class.ilObjCourse.php';
923 global
$ilDB,$ilUser;
925 $query =
"SELECT * FROM crs_items ".
926 "WHERE obj_id = ".$ilDB->quote($a_item_id,
'integer');
934 $data[
'timing_type'] =
$row->timing_type;
935 $data[
'timing_start'] =
$row->timing_start;
937 $data[
"suggestion_start"] =
$row->suggestion_start ?
$row->suggestion_start :
938 mktime(0,0,1,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
939 $data[
"suggestion_end"] =
$row->suggestion_end ?
$row->suggestion_end :
940 mktime(23,55,00,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
942 $data[
'earliest_start'] =
$row->earliest_start ?
$row->earliest_start :
943 mktime(0,0,1,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
945 mktime(23,55,00,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
948 include_once
'Modules/Course/classes/Timings/class.ilTimingPlaned.php';
954 include_once(
'./Modules/Session/classes/class.ilSessionAppointment.php');
957 $data[
'start'] = $info[
'start'];
958 $data[
'end'] = $info[
'end'];
959 $data[
'activation_info'] =
'crs_timings_suggested_info';
962 else if(
$data[
'changeable'] and
965 if($user_data[
'planed_start'])
967 $data[
'start'] = $user_data[
'planed_start'];
968 $data[
'end'] = $user_data[
'planed_end'];
969 $data[
'activation_info'] =
'crs_timings_planed_info';
975 $data[
'activation_info'] =
'crs_timings_suggested_info';
982 $data[
'activation_info'] =
'crs_timings_suggested_info';
988 $data[
'activation_info'] =
'activation';
992 $data[
'start'] = 999999999;
1002 $query =
"SELECT * FROM crs_items ".
1003 "WHERE obj_id = ".$ilDB->quote($a_item_id,
'integer').
" ";
1008 if(
$row->activation_unlimited)
1012 if(time() >
$row->activation_start and time() <
$row->activation_end)
1031 if(!is_array($a_ref_ids) or !$a_ref_ids)
1036 $query =
"SELECT obj_id,timing_type,timing_start,timing_end,visible FROM crs_items ".
1037 "WHERE ".$ilDB->in(
'obj_id',$a_ref_ids,
false,
'integer');
1042 $ac_times[(string)
$row->obj_id][
'obj_id'] =
$row->obj_id;
1043 $ac_times[(
string)
$row->obj_id][
'timing_type'] =
$row->timing_type;
1044 $ac_times[(string)
$row->obj_id][
'timing_start'] =
$row->timing_start;
1045 $ac_times[(
string)
$row->obj_id][
'timing_end'] =
$row->timing_end;
1046 $ac_times[(string)
$row->obj_id][
'visible'] =
$row->visible;
1049 return $ac_times ? $ac_times : array();
1057 if (is_array($this->items_per_child[$a_item[
"child"]]))
1059 $a_item = array_merge($a_item, $this->items_per_child[$a_item[
"child"]]);