44 $this->timing_type = $a_type;
65 $this->timing_start = $a_start;
85 $this->timing_end = $a_end;
105 $this->suggestion_start = $a_start;
115 return $this->suggestion_start ? $this->suggestion_start : mktime(0,0,1,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
125 $this->suggestion_end = $a_end;
135 return $this->suggestion_end ? $this->suggestion_end : mktime(23,55,00,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
145 $this->earliest_start = $a_start;
155 return $this->earliest_start ? $this->earliest_start : mktime(0,0,1,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
165 $this->latest_end = $a_end;
175 return $this->latest_end ? $this->latest_end : mktime(23,55,00,date(
'n',time()),date(
'j',time()),date(
'Y',time()));
185 $this->visible = (int) $a_status;
205 $this->changeable = (int) $a_status;
227 $ilErr->setMessage(
'');
233 $ilErr->appendMessage($lng->txt(
"crs_activation_start_invalid"));
240 $ilErr->appendMessage($lng->txt(
'crs_latest_end_not_valid'));
244 if($ilErr->getMessage())
257 function update($a_ref_id, $a_parent_id = null)
262 $query =
"UPDATE crs_items SET ".
263 "timing_type = ".$ilDB->quote($this->
getTimingType(),
'integer').
", ".
264 "timing_start = ".$ilDB->quote((
int)$this->
getTimingStart(),
'integer').
", ".
265 "timing_end = ".$ilDB->quote((
int)$this->
getTimingEnd(),
'integer').
", ".
270 "latest_end = ".$ilDB->quote($this->
getLatestEnd(),
'integer').
", ";
274 $query .=
"parent_id = ".$ilDB->quote($a_parent_id,
'integer').
", ";
278 "WHERE obj_id = ".$ilDB->quote($a_ref_id,
'integer');
279 $ilDB->manipulate(
$query);
281 unset(self::$preloaded_data[$a_ref_id]);
295 $sql =
"SELECT * FROM crs_items".
296 " WHERE ".$ilDB->in(
"obj_id", $a_ref_ids,
"",
"integer");
297 $set = $ilDB->query($sql);
298 while(
$row = $ilDB->fetchAssoc($set))
300 self::$preloaded_data[
$row[
"obj_id"]] =
$row;
314 if(isset(self::$preloaded_data[$a_ref_id]))
316 return self::$preloaded_data[$a_ref_id];
319 $sql =
"SELECT * FROM crs_items".
320 " WHERE obj_id = ".$ilDB->quote($a_ref_id,
"integer");
321 $set = $ilDB->query($sql);
322 $row = $ilDB->fetchAssoc($set);
324 if(!isset(
$row[
"obj_id"]))
330 self::$preloaded_data[
$row[
"obj_id"]] =
$row;
346 $a_item[
'obj_id'] = ($a_item[
'obj_id'] > 0)
349 $a_item[
'type'] = ($a_item[
'type'] !=
'')
353 $a_item[
'timing_type'] = $item[
'timing_type'];
355 if($item[
'changeable'] &&
356 $item[
'timing_type'] == self::TIMINGS_PRESETTING)
358 include_once
'Modules/Course/classes/Timings/class.ilTimingPlaned.php';
360 if($user_data[
'planed_start'])
362 $a_item[
'start'] = $user_data[
'planed_start'];
363 $a_item[
'end'] = $user_data[
'planed_end'];
364 $a_item[
'activation_info'] =
'crs_timings_planed_info';
368 $a_item[
'start'] = $item[
'suggestion_start'];
369 $a_item[
'end'] = $item[
'suggestion_end'];
370 $a_item[
'activation_info'] =
'crs_timings_suggested_info';
373 elseif($item[
'timing_type'] == self::TIMINGS_PRESETTING)
375 $a_item[
'start'] = $item[
'suggestion_start'];
376 $a_item[
'end'] = $item[
'suggestion_end'];
377 $a_item[
'activation_info'] =
'crs_timings_suggested_info';
379 elseif($item[
'timing_type'] == self::TIMINGS_ACTIVATION)
381 $a_item[
'start'] = $item[
'timing_start'];
382 $a_item[
'end'] = $item[
'timing_end'];
383 $a_item[
'activation_info'] =
'activation';
387 $a_item[
'start'] =
'abc';
391 if($a_item[
'type'] ==
'sess')
393 include_once(
'./Modules/Session/classes/class.ilSessionAppointment.php');
397 $a_item[
'masked_start'] = $a_item[
'start'];
398 $a_item[
'masked_end'] = $a_item[
'end'];
399 $a_item[
'start'] = $info[
'start'];
400 $a_item[
'end'] = $info[
'end'];
416 if(isset($a_item[
'timing_type']))
418 if(!isset($a_item[
'masked_start']))
420 $start = $a_item[
'start'];
421 $end = $a_item[
'end'];
425 $start = $a_item[
'masked_start'];
426 $end = $a_item[
'masked_end'];
429 switch($a_item[
'timing_type'])
443 if ($activation !=
"")
446 $lng->loadLanguageModule(
'crs');
449 $activation,
false,
true);
464 $parent_id = $tree->getParentId($a_ref_id);
471 $ilDB->lockTables(array(
472 array(
"name" =>
"crs_items",
477 $sql =
"SELECT * FROM crs_items".
478 " WHERE obj_id = ".$ilDB->quote($a_ref_id,
"integer");
479 $set = $ilDB->query($sql);
480 if(!$ilDB->numRows($set))
483 $now_parts = getdate($now);
487 $a_item[
"timing_start"] = $now;
488 $a_item[
"timing_end"] = $now;
489 $a_item[
"suggestion_start"] = $now;
490 $a_item[
"suggestion_end"] = $now;
491 $a_item[
'visible'] = 0;
492 $a_item[
'changeable'] = 0;
493 $a_item[
'earliest_start'] = $now;
494 $a_item[
'latest_end'] = mktime(23,55,00,$now_parts[
"mon"],$now_parts[
"mday"],$now_parts[
"year"]);
495 $a_item[
'visible'] = 0;
496 $a_item[
'changeable'] = 0;
498 $query =
"INSERT INTO crs_items (parent_id,obj_id,timing_type,timing_start,timing_end," .
499 "suggestion_start,suggestion_end, ".
500 "changeable,earliest_start,latest_end,visible,position) ".
502 $ilDB->quote($parent_id,
'integer').
",".
503 $ilDB->quote($a_ref_id,
'integer').
",".
504 $ilDB->quote($a_item[
"timing_type"],
'integer').
",".
505 $ilDB->quote($a_item[
"timing_start"],
'integer').
",".
506 $ilDB->quote($a_item[
"timing_end"],
'integer').
",".
507 $ilDB->quote($a_item[
"suggestion_start"],
'integer').
",".
508 $ilDB->quote($a_item[
"suggestion_end"],
'integer').
",".
509 $ilDB->quote($a_item[
"changeable"],
'integer').
",".
510 $ilDB->quote($a_item[
'earliest_start'],
'integer').
", ".
511 $ilDB->quote($a_item[
'latest_end'],
'integer').
", ".
512 $ilDB->quote($a_item[
"visible"],
'integer').
", ".
513 $ilDB->quote(0,
'integer').
")";
514 $ilDB->manipulate(
$query);
517 $ilDB->unlockTables();
520 $a_item[
"obj_id"] = $a_ref_id;
521 $a_item[
"parent_id"] = $parent_id;
540 $query =
"DELETE FROM crs_items ".
541 "WHERE obj_id = ".$ilDB->quote($a_ref_id,
'integer');
542 $ilDB->manipulate(
$query);
544 $query =
"DELETE FROM crs_items ".
545 "WHERE parent_id = ".$ilDB->quote($a_ref_id,
'integer');
546 $ilDB->manipulate(
$query);
562 $ilLog->write(__METHOD__.
': Begin course items...');
567 $ilLog->write(__METHOD__.
': No course items found.');
574 $ilLog->write(__METHOD__.
': Cannot create target object.');
578 include_once(
'Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
580 $mappings = $cp_options->getMappings();
582 foreach($items as $item)
584 if(!isset($mappings[$item[
'parent_id']]) or !$mappings[$item[
'parent_id']])
586 $ilLog->write(__METHOD__.
': No mapping for parent nr. '.$item[
'parent_id']);
589 if(!isset($mappings[$item[
'obj_id']]) or !$mappings[$item[
'obj_id']])
591 $ilLog->write(__METHOD__.
': No mapping for item nr. '.$item[
'obj_id']);
594 $new_item_id = $mappings[$item[
'obj_id']];
595 $new_parent = $mappings[$item[
'parent_id']];
597 $new_item =
new self();
598 $new_item->setTimingType($item[
'timing_type']);
599 $new_item->setTimingStart($item[
'timing_start']);
600 $new_item->setTimingEnd($item[
'timing_end']);
601 $new_item->setSuggestionStart($item[
'suggestion_start']);
602 $new_item->setSuggestionEnd($item[
'suggestion_end']);
603 $new_item->toggleChangeable($item[
'changeable']);
604 $new_item->setEarliestStart($item[
'earliest_start']);
605 $new_item->setLatestEnd($item[
'latest_end']);
606 $new_item->toggleVisible($item[
'visible']);
607 $new_item->update($new_item_id, $new_parent);
609 $ilLog->write(__METHOD__.
': Added new entry for item nr. '.$item[
'obj_id']);
611 $ilLog->write(__METHOD__.
': Finished course items.');
629 $subtree = $tree->getSubTree($tree->getNodeData($a_ref_id));
631 foreach($subtree as $node)
633 $ref_ids[] = $node[
'ref_id'];
636 $query =
"SELECT * FROM crs_items ".
637 "WHERE timing_type = ".$ilDB->quote(self::TIMINGS_PRESETTING,
'integer').
" ".
638 "AND ".$ilDB->in(
'obj_id',$ref_ids,
false,
'integer');
640 return $res->numRows() ?
true :
false;
653 $subtree = $tree->getSubTree($tree->getNodeData($a_ref_id));
655 foreach($subtree as $node)
657 $ref_ids[] = $node[
'ref_id'];
660 $query =
"SELECT * FROM crs_items ".
661 "WHERE timing_type = ".$ilDB->quote(self::TIMINGS_PRESETTING,
'integer').
" ".
662 "AND changeable = ".$ilDB->quote(1,
'integer').
" ".
663 "AND ".$ilDB->in(
'obj_id',$ref_ids,
false,
'integer');
665 return $res->numRows() ?
true :
false;
680 foreach($a_ref_ids as $item_ref_id)
682 if($tree->isDeleted($item_ref_id))
687 $node = $tree->getNodeData($item_ref_id);
688 if($node[
"ref_id"] != $item_ref_id)
692 $res[$item_ref_id] = $node;
698 foreach(
$res as $idx => $item)
705 return array_values(
$res);
716 include_once
'Modules/Session/classes/class.ilEventItems.php';
729 include_once
'Modules/ItemGroup/classes/class.ilItemGroupItems.php';
731 $items = $ig_items->getValidItems();
743 include_once(
'./Modules/Course/classes/class.ilCourseObjectiveMaterials.php');
755 public static function getItems($a_parent_id, $a_with_list_data =
true)
762 foreach($tree->getChilds($a_parent_id) as $item)
764 if($item[
'type'] !=
'rolf')
767 $ref_ids[] = $item[
'ref_id'];
775 foreach($items as $idx => $item)
777 if(!$a_with_list_data)
779 $items[$idx] = array_merge($item, self::getItem($item[
'ref_id']));
784 $items[$idx] = $item;
804 $active = $inactive = array();
805 foreach($items as $item)
808 if($item[
'timing_type'] == self::TIMINGS_DEACTIVATED)
820 $items = array_merge($active,$inactive);
834 global $objDefinition;
838 include_once
'Modules/Session/classes/class.ilEventItems.php';
840 foreach(self::getTimingsAdministrationItems($a_container_ref_id) as $item)
842 if(!in_array($item[
'ref_id'],$event_items) &&
843 !$objDefinition->isSideBlock($item[
'type']))