54 $this->error = $DIC[
"ilErr"];
55 $this->lng = $DIC->language();
56 $this->db = $DIC->database();
88 $this->timing_start = $a_start;
108 $this->timing_end = $a_end;
128 $this->suggestion_start = $a_start;
148 $this->suggestion_start_rel = $a_start;
158 $this->suggestion_end_rel = $a_end;
163 return $this->earliest_start_rel;
168 $this->earliest_start_rel = $a_start;
178 $this->suggestion_end = $a_end;
198 $this->earliest_start = $a_start;
208 return $this->earliest_start;
219 $this->visible = (int) $a_status;
239 $this->changeable = (int) $a_status;
266 $ilErr->appendMessage(
$lng->txt(
"crs_activation_start_invalid"));
268 } elseif ($this->
getTimingType() == self::TIMINGS_PRESETTING) {
270 $ilErr->appendMessage(
$lng->txt(
'crs_timing_err_sug_start_end'));
274 if (
$ilErr->getMessage()) {
288 $errors[] = self::ERR_SUG_START_END;
290 $errors[] = self::ERR_SUG_START_END;
301 public function update($a_ref_id, $a_parent_id = null)
306 $query =
"UPDATE crs_items SET " .
317 $query .=
"parent_id = " .
$ilDB->quote($a_parent_id,
'integer') .
", ";
321 "WHERE obj_id = " .
$ilDB->quote($a_ref_id,
'integer');
324 unset(self::$preloaded_data[$a_ref_id]);
338 $ilDB = $DIC->database();
340 $sql =
"SELECT * FROM crs_items" .
341 " WHERE " .
$ilDB->in(
"obj_id", $a_ref_ids,
"",
"integer");
342 $set =
$ilDB->query($sql);
344 self::$preloaded_data[
$row[
"obj_id"]] =
$row;
358 $ilDB = $DIC->database();
360 if (isset(self::$preloaded_data[$a_ref_id])) {
361 return self::$preloaded_data[$a_ref_id];
364 $sql =
"SELECT * FROM crs_items" .
365 " WHERE obj_id = " .
$ilDB->quote($a_ref_id,
"integer");
366 $set =
$ilDB->query($sql);
369 if (!isset(
$row[
"obj_id"])) {
370 $row = self::createDefaultEntry($a_ref_id);
372 if (
$row[
"obj_id"]) {
373 self::$preloaded_data[
$row[
"obj_id"]] =
$row;
389 $item = self::getItem($a_item[
'ref_id']);
391 $a_item[
'obj_id'] = ($a_item[
'obj_id'] > 0)
394 $a_item[
'type'] = ($a_item[
'type'] !=
'')
398 $a_item[
'timing_type'] = $item[
'timing_type'];
400 if ($item[
'changeable'] &&
401 $item[
'timing_type'] == self::TIMINGS_PRESETTING) {
403 include_once
'./Modules/Course/classes/Timings/class.ilTimingUser.php';
405 if ($user_data->isScheduled()) {
407 $a_item[
'end'] = $user_data->getEnd()->get(
IL_CAL_UNIX);
408 $a_item[
'activation_info'] =
'crs_timings_planed_info';
410 $a_item[
'start'] = $item[
'suggestion_start'];
411 $a_item[
'end'] = $item[
'suggestion_end'];
412 $a_item[
'activation_info'] =
'crs_timings_suggested_info';
415 } elseif ($item[
'timing_type'] == self::TIMINGS_PRESETTING) {
416 $a_item[
'start'] = $item[
'suggestion_start'];
417 $a_item[
'end'] = $item[
'suggestion_end'];
418 $a_item[
'activation_info'] =
'crs_timings_suggested_info';
419 } elseif ($item[
'timing_type'] == self::TIMINGS_ACTIVATION) {
420 $a_item[
'start'] = $item[
'timing_start'];
421 $a_item[
'end'] = $item[
'timing_end'];
422 $a_item[
'activation_info'] =
'obj_activation_list_gui';
424 $a_item[
'start'] =
'abc';
428 if ($a_item[
'type'] ==
'sess') {
429 include_once(
'./Modules/Session/classes/class.ilSessionAppointment.php');
433 $a_item[
'masked_start'] = $a_item[
'start'];
434 $a_item[
'masked_end'] = $a_item[
'end'];
435 $a_item[
'start'] =
$info[
'start'];
436 $a_item[
'end'] =
$info[
'end'];
451 $lng = $DIC->language();
453 self::addAdditionalSubItemInformation($a_item);
454 if (isset($a_item[
'timing_type'])) {
455 if (!isset($a_item[
'masked_start'])) {
456 $start = $a_item[
'start'];
457 $end = $a_item[
'end'];
459 $start = $a_item[
'masked_start'];
460 $end = $a_item[
'masked_end'];
463 switch ($a_item[
'timing_type']) {
478 if ($activation !=
"") {
481 $lng = $DIC->language();
482 $lng->loadLanguageModule(
'crs');
485 $lng->txt($a_item[
'activation_info']),
504 $ilDB = $DIC->database();
505 $tree = $DIC->repositoryTree();
507 $parent_id =
$tree->getParentId($a_ref_id);
513 $ilAtomQuery =
$ilDB->buildAtomQuery();
514 $ilAtomQuery->addTableLock(
"crs_items");
516 $ilAtomQuery->addQueryCallable(
function (
ilDBInterface $ilDB) use ($a_ref_id, $parent_id, &$a_item) {
517 $sql =
"SELECT * FROM crs_items" .
518 " WHERE obj_id = " . $ilDB->
quote($a_ref_id,
"integer");
519 $set = $ilDB->
query($sql);
522 $now_parts = getdate($now);
525 $a_item[
"timing_type"] = self::TIMINGS_DEACTIVATED;
526 $a_item[
"timing_start"] = $now;
527 $a_item[
"timing_end"] = $now;
528 $a_item[
"suggestion_start"] = $now;
529 $a_item[
"suggestion_end"] = $now;
530 $a_item[
'visible'] = 0;
531 $a_item[
'changeable'] = 0;
533 $query =
"INSERT INTO crs_items (parent_id,obj_id,timing_type,timing_start,timing_end," .
534 "suggestion_start,suggestion_end, " .
535 "changeable,visible,suggestion_start_rel, suggestion_end_rel, position) " .
537 $ilDB->
quote($parent_id,
'integer') .
"," .
538 $ilDB->
quote($a_ref_id,
'integer') .
"," .
539 $ilDB->
quote($a_item[
"timing_type"],
'integer') .
"," .
540 $ilDB->
quote($a_item[
"timing_start"],
'integer') .
"," .
541 $ilDB->
quote($a_item[
"timing_end"],
'integer') .
"," .
542 $ilDB->
quote($a_item[
"suggestion_start"],
'integer') .
"," .
543 $ilDB->
quote($a_item[
"suggestion_end"],
'integer') .
"," .
544 $ilDB->
quote($a_item[
"changeable"],
'integer') .
"," .
545 $ilDB->
quote($a_item[
"visible"],
'integer') .
", " .
546 $ilDB->
quote($a_item[
"suggestion_start_rel"],
'integer') .
"," .
547 $ilDB->
quote($a_item[
'suggestion_end_rel'],
'integer') .
", " .
548 $ilDB->
quote(0,
'integer') .
")";
556 $a_item[
"obj_id"] = $a_ref_id;
557 $a_item[
"parent_id"] = $parent_id;
571 $ilDB = $DIC->database();
577 $query =
"DELETE FROM crs_items " .
578 "WHERE obj_id = " .
$ilDB->quote($a_ref_id,
'integer');
581 $query =
"DELETE FROM crs_items " .
582 "WHERE parent_id = " .
$ilDB->quote($a_ref_id,
'integer');
601 $ilLog->write(__METHOD__ .
': Begin course items...' . $a_ref_id);
603 $items = self::getItems($a_ref_id,
false);
605 $ilLog->write(__METHOD__ .
': No course items found.');
611 $ilLog->write(__METHOD__ .
': Cannot create target object.');
615 include_once(
'Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
617 $mappings = $cp_options->getMappings();
619 foreach ($items as $item) {
620 if (!isset($mappings[$item[
'parent_id']])
or !$mappings[$item[
'parent_id']]) {
621 $ilLog->write(__METHOD__ .
': No mapping for parent nr. ' . $item[
'parent_id']);
624 if (!isset($mappings[$item[
'obj_id']])
or !$mappings[$item[
'obj_id']]) {
625 $ilLog->write(__METHOD__ .
': No mapping for item nr. ' . $item[
'obj_id']);
628 $new_item_id = $mappings[$item[
'obj_id']];
629 $new_parent = $mappings[$item[
'parent_id']];
631 $new_item =
new self();
632 $new_item->setTimingType($item[
'timing_type']);
633 $new_item->setTimingStart($item[
'timing_start']);
634 $new_item->setTimingEnd($item[
'timing_end']);
635 $new_item->setSuggestionStart($item[
'suggestion_start']);
636 $new_item->setSuggestionEnd($item[
'suggestion_end']);
637 $new_item->toggleChangeable($item[
'changeable']);
638 $new_item->toggleVisible($item[
'visible']);
639 $new_item->update($new_item_id, $new_parent);
640 $new_item->setSuggestionStartRelative($item[
'suggestion_start_rel']);
641 $new_item->setSuggestionEndRelative($item[
'suggestion_end_rel']);
642 $new_item->createDefaultEntry($new_item_id);
643 $new_item->update($new_item_id);
662 $tree = $DIC->repositoryTree();
663 $ilDB = $DIC->database();
665 $subtree =
$tree->getSubTree(
$tree->getNodeData($a_ref_id));
667 foreach ($subtree as $node) {
668 $ref_ids[] = $node[
'ref_id'];
671 $query =
"SELECT * FROM crs_items " .
672 "WHERE timing_type = " .
$ilDB->quote(self::TIMINGS_PRESETTING,
'integer') .
" " .
673 "AND " .
$ilDB->in(
'obj_id', $ref_ids,
false,
'integer');
675 return $res->numRows() ? true :
false;
688 $tree = $DIC->repositoryTree();
689 $ilDB = $DIC->database();
691 $subtree =
$tree->getSubTree(
$tree->getNodeData($a_ref_id));
693 foreach ($subtree as $node) {
694 $ref_ids[] = $node[
'ref_id'];
697 $query =
"SELECT * FROM crs_items " .
698 "WHERE timing_type = " .
$ilDB->quote(self::TIMINGS_PRESETTING,
'integer') .
" " .
699 "AND changeable = " .
$ilDB->quote(1,
'integer') .
" " .
700 "AND " .
$ilDB->in(
'obj_id', $ref_ids,
false,
'integer');
702 return $res->numRows() ? true :
false;
715 $tree = $DIC->repositoryTree();
719 foreach ($a_ref_ids as $item_ref_id) {
720 if (
$tree->isDeleted($item_ref_id)) {
724 $node =
$tree->getNodeData($item_ref_id);
725 if ($node[
"ref_id"] != $item_ref_id) {
728 $res[$item_ref_id] = $node;
732 self::preloadData(array_keys(
$res));
733 foreach (
$res as $idx => $item) {
734 self::addAdditionalSubItemInformation($item);
739 return array_values(
$res);
750 include_once
'Modules/Session/classes/class.ilEventItems.php';
752 return self::processListItems($event_items->getItems());
763 include_once
'Modules/ItemGroup/classes/class.ilItemGroupItems.php';
765 $items = $ig_items->getValidItems();
766 return self::processListItems($items);
777 include_once(
'./Modules/Course/classes/class.ilCourseObjectiveMaterials.php');
779 return self::processListItems($item_ids);
789 public static function getItems($a_parent_id, $a_with_list_data =
true)
793 $tree = $DIC->repositoryTree();
798 foreach (
$tree->getChilds($a_parent_id) as $item) {
799 if ($item[
'type'] !=
'rolf') {
801 $ref_ids[] = $item[
'ref_id'];
806 self::preloadData($ref_ids);
808 foreach ($items as $idx => $item) {
809 if (!$a_with_list_data) {
810 $items[$idx] = array_merge($item, self::getItem($item[
'ref_id']));
812 self::addAdditionalSubItemInformation($item);
813 $items[$idx] = $item;
828 $items = self::getItems($a_parent_id,
false);
831 $active = $inactive = array();
832 foreach ($items as $item) {
834 if ($item[
'timing_type'] == self::TIMINGS_DEACTIVATED) {
843 $items = array_merge($active, $inactive);
859 $objDefinition = $DIC[
"objDefinition"];
863 include_once
'Modules/Session/classes/class.ilEventItems.php';
865 foreach (self::getTimingsAdministrationItems($a_container_ref_id) as $item) {
866 if (!in_array($item[
'ref_id'], $event_items) &&
867 !$objDefinition->isSideBlock($item[
'type'])) {
880 public function read($a_ref_id, $a_parent_id = 0)
883 $ilDB = $DIC->database();
885 $query =
'SELECT * FROM crs_items ' .
886 'WHERE obj_id = ' .
$ilDB->quote($a_ref_id,
'integer') .
' ';
889 $query .= (
'AND parent_id = ' .
$ilDB->quote($a_parent_id,
'integer') .
' ');
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
getTimingEnd()
Get timing end.
validateActivation()
Validate current properties.
static createDefaultEntry($a_ref_id)
Create db entry with default values.
setTimingStart($a_start)
Set timing start.
static getItems($a_parent_id, $a_with_list_data=true)
Get sub item data.
setSuggestionStartRelative($a_start)
validateRelativePlaning()
static getItemsByEvent($a_event_id)
Get session material / event items.
getStart()
Use to set start date.
update($a_ref_id, $a_parent_id=null)
Update db entry.
static hasTimings($a_ref_id)
Check if there is any active timing (in subtree)
static _getItemsOfContainer($a_ref_id)
static getTimingsItems($a_container_ref_id)
Get (sub) item data for timings view (no session material, no side blocks)
TableGUI class for timings administration.
static getItem($a_ref_id)
Get item data.
const TIMINGS_DEACTIVATED
enabledVisible()
Get visible status.
getSuggestionEnd()
Get suggestion end.
addCustomProperty( $a_property="", $a_value="", $a_alert=false, $a_newline=false)
add custom property
getTimingStart()
Get timing start.
static addAdditionalSubItemInformation(array &$a_item)
Parse item data for list entries.
getSuggestionStartRelative()
toggleVisible($a_status)
Set visible status.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
setEarliestStart($a_start)
Set earliest start.
foreach($_POST as $key=> $value) $res
static getTimingsAdministrationItems($a_parent_id)
Get (sub) item data for timings administration view (active/inactive)
static hasChangeableTimings($a_ref_id)
Check if there is any active changeable timing (in subtree)
static _lookupObjId($a_id)
setTimingEnd($a_end)
Set timing end.
static processListItems(array $a_ref_ids)
Validate ref ids and add list data.
static preloadData(array $a_ref_ids)
Preload data to internal cache.
getEaliestStartRelative()
getTimingType()
get timing type
getSuggestionStart()
Get suggestion start.
static addListGUIActivationProperty(ilObjectListGUI $a_list_gui, array &$a_item)
Get timing details for list gui.
enabledChangeable()
Get changeable status.
static _lookupType($a_id, $a_reference=false)
lookup object type
static deleteAllEntries($a_ref_id)
Delete all db entries for ref id.
static _getAssignedMaterials($a_objective_id)
get assigned materials
setSuggestionStart($a_start)
Set suggestion start.
setTimingType($a_type)
Set timing type.
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
static getItemsByObjective($a_objective_id)
Get objective items.
toggleChangeable($a_status)
Set changeable status.
static cloneDependencies($a_ref_id, $a_target_id, $a_copy_id)
Clone dependencies.
static _lookupAppointment($a_obj_id)
lookup appointment
query($query)
Run a (read-only) Query on the database.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
getEarliestStart()
Get earliest start.
static getItemsByItemGroup($a_item_group_ref_id)
Get materials of item group.
getSuggestionEndRelative()
Class ilObjectActivation.
setSuggestionEnd($a_end)
Set suggestion end.
read($a_ref_id, $a_parent_id=0)
setSuggestionEndRelative($a_end)
manipulate($query)
Run a (write) Query on the database.
setEarliestStartRelative($a_start)