19 declare(strict_types=1);
57 $this->error = $DIC[
"ilErr"];
58 $this->
lng = $DIC->language();
59 $this->db = $DIC->database();
64 $this->timing_type =
$type;
74 $this->timing_start = $start;
84 $this->timing_end = $end;
97 $this->suggestion_start = $start;
105 $this->suggestion_start_rel = $start;
113 $this->suggestion_end_rel = $end;
121 $this->suggestion_end = $end;
126 $this->visible = $status;
136 $this->changeable = (
int) $status;
149 "timing_end" => [
"integer", $this->
getTimingEnd() ?? 0],
150 "suggestion_start" => [
"integer", $this->suggestion_start ?? 0],
151 "suggestion_end" => [
"integer", $this->suggestion_end ?? 0],
153 "suggestion_start_rel" => [
"integer", $this->suggestion_start_rel ?? 0],
154 "suggestion_end_rel" => [
"integer", $this->suggestion_end_rel ?? 0],
158 if (!is_null($parent_id)) {
159 $values[
"parent_id"] = [
"integer", $parent_id];
163 "obj_id" => [
"integer",
$ref_id]
166 $this->db->update(
"crs_items", $values, $where);
168 unset(self::$preloaded_data[$ref_id]);
179 $db = $DIC->database();
182 "SELECT parent_id, obj_id, timing_type, timing_start, timing_end, suggestion_start," . PHP_EOL
183 .
"suggestion_end, changeable, visible, position, suggestion_start_rel, suggestion_end_rel" . PHP_EOL
184 .
"FROM crs_items" . PHP_EOL
185 .
"WHERE " . $db->
in(
"obj_id", $ref_ids,
false,
"integer") . PHP_EOL
187 $set = $db->
query($sql);
189 self::$preloaded_data[$row[
"obj_id"]] = $row;
196 $db = $DIC->database();
198 if (isset(self::$preloaded_data[$ref_id])) {
199 return self::$preloaded_data[
$ref_id];
203 "SELECT parent_id, obj_id, timing_type, timing_start, timing_end, suggestion_start," . PHP_EOL
204 .
"suggestion_end, changeable, visible, position, suggestion_start_rel, suggestion_end_rel" . PHP_EOL
205 .
"FROM crs_items" . PHP_EOL
206 .
"WHERE obj_id = " . $db->
quote($ref_id,
"integer") . PHP_EOL
208 $set = $db->
query($sql);
211 if (!isset($row[
"obj_id"])) {
212 $row = self::createDefaultEntry($ref_id);
214 self::$preloaded_data[$row[
"obj_id"]] = $row;
227 $item_array = self::getItem((
int) $item[
'ref_id']);
229 $item[
'obj_id'] = ($item[
'obj_id'] > 0)
232 $item[
'type'] = ($item[
'type'] !=
'')
236 $item[
'timing_type'] = $item_array[
'timing_type'] ?? 0;
238 if (($item_array[
'changeable'] ??
false) &&
239 $item_array[
'timing_type'] == self::TIMINGS_PRESETTING) {
242 if ($user_data->isScheduled()) {
244 $item[
'end'] = $user_data->getEnd()->get(
IL_CAL_UNIX);
245 $item[
'activation_info'] =
'crs_timings_planed_info';
247 $item[
'start'] = $item_array[
'suggestion_start'] ??
"";
248 $item[
'end'] = $item_array[
'suggestion_end'] ??
"";
249 $item[
'activation_info'] =
'crs_timings_suggested_info';
252 } elseif (($item_array[
'timing_type'] ?? 0) == self::TIMINGS_PRESETTING) {
253 $item[
'start'] = $item_array[
'suggestion_start'] ??
"";
254 $item[
'end'] = $item_array[
'suggestion_end'] ??
"";
255 $item[
'activation_info'] =
'crs_timings_suggested_info';
256 } elseif (($item_array[
'timing_type'] ?? 0) == self::TIMINGS_ACTIVATION) {
257 $item[
'start'] = $item_array[
'timing_start'] ??
"";
258 $item[
'end'] = $item_array[
'timing_end'] ??
"";
259 $item[
'activation_info'] =
'obj_activation_list_gui';
261 $item[
'start'] =
'abc';
265 if ($item[
'type'] ==
'sess') {
268 $item[
'masked_start'] = $item[
'start'];
269 $item[
'masked_end'] = $item[
'end'] ??
"";
270 $item[
'start'] = $info[
'start'] ??
'';
271 $item[
'end'] = $info[
'end'] ??
'';
280 self::addAdditionalSubItemInformation($item);
281 if (isset($item[
'timing_type'])) {
282 if (!isset($item[
'masked_start'])) {
283 $start = $item[
'start'] ?? 0;
284 $end = $item[
'end'] ?? 0;
286 $start = $item[
'masked_start'];
287 $end = $item[
'masked_end'];
290 switch ($item[
'timing_type']) {
305 if ($activation !=
"") {
308 $lng = $DIC->language();
312 $lng->
txt($item[
'activation_info']),
328 $db = $DIC->database();
329 $tree = $DIC->repositoryTree();
331 $parent_id = $tree->getParentId($ref_id);
337 $ilAtomQuery->addTableLock(
"crs_items");
339 $ilAtomQuery->addQueryCallable(
function (
ilDBInterface $db) use ($ref_id, $parent_id, &$item):
void {
341 "SELECT parent_id, obj_id, timing_type, timing_start, timing_end, suggestion_start," . PHP_EOL
342 .
"suggestion_end, changeable, visible, position, suggestion_start_rel, suggestion_end_rel" . PHP_EOL
343 .
"FROM crs_items" . PHP_EOL
344 .
"WHERE obj_id = " . $db->
quote($ref_id,
"integer") . PHP_EOL
346 $set = $db->
query($sql);
351 $item[
"timing_type"] = self::TIMINGS_DEACTIVATED;
352 $item[
"timing_start"] = $now;
353 $item[
"timing_end"] = $now;
354 $item[
"suggestion_start"] = $now;
355 $item[
"suggestion_end"] = $now;
356 $item[
'visible'] = 0;
357 $item[
'changeable'] = 0;
360 "parent_id" => [
"integer", $parent_id],
361 "obj_id" => [
"integer",
$ref_id],
362 "timing_type" => [
"integer", $item[
"timing_type"]],
363 "timing_start" => [
"integer", $item[
"timing_start"]],
364 "timing_end" => [
"integer", $item[
"timing_end"]],
365 "suggestion_start" => [
"integer", $item[
"suggestion_start"]],
366 "suggestion_end" => [
"integer", $item[
"suggestion_end"]],
367 "changeable" => [
"integer", $item[
"changeable"]],
368 "visible" => [
"integer", $item[
"visible"]],
369 "suggestion_start_rel" => [
"integer", $item[
"suggestion_start_rel"] ?? 0],
370 "suggestion_end_rel" => [
"integer", $item[
"suggestion_end_rel"] ?? 0],
371 "position" => [
"integer", 0]
373 $db->
insert(
"crs_items", $values);
381 $item[
"parent_id"] = $parent_id;
393 $db = $DIC->database();
400 "DELETE FROM crs_items " . PHP_EOL
401 .
"WHERE obj_id = " . $db->
quote($ref_id,
'integer') . PHP_EOL
406 "DELETE FROM crs_items " . PHP_EOL
407 .
"WHERE parent_id = " . $db->
quote($ref_id,
'integer') . PHP_EOL
418 $ilLog = $DIC[
"ilLog"];
420 $ilLog->write(__METHOD__ .
': Begin course items...' . $ref_id);
422 $items = self::getItems($ref_id,
false);
424 $ilLog->write(__METHOD__ .
': No course items found.');
430 $ilLog->write(__METHOD__ .
': Cannot create target object.');
435 $mappings = $cp_options->getMappings();
437 foreach ($items as $item) {
438 if (!isset($mappings[$item[
'parent_id']]) or !$mappings[$item[
'parent_id']]) {
439 $ilLog->write(__METHOD__ .
': No mapping for parent nr. ' . $item[
'parent_id']);
442 if (!isset($mappings[$item[
'obj_id']]) or !$mappings[$item[
'obj_id']]) {
443 $ilLog->write(__METHOD__ .
': No mapping for item nr. ' . $item[
'obj_id']);
446 $new_item_id = $mappings[$item[
'obj_id']];
447 $new_parent = $mappings[$item[
'parent_id']];
449 $new_item =
new self();
450 $new_item->setTimingType((
int) $item[
'timing_type']);
451 $new_item->setTimingStart((
int) $item[
'timing_start']);
452 $new_item->setTimingEnd((
int) $item[
'timing_end']);
453 $new_item->setSuggestionStart((
int) $item[
'suggestion_start']);
454 $new_item->setSuggestionEnd((
int) $item[
'suggestion_end']);
455 $new_item->toggleChangeable((
bool) $item[
'changeable']);
456 $new_item->toggleVisible((
bool) $item[
'visible']);
457 $new_item->update($new_item_id, $new_parent);
458 $new_item->setSuggestionStartRelative((
int) ($item[
'suggestion_start_rel'] ?? 0));
459 $new_item->setSuggestionEndRelative((
int) ($item[
'suggestion_end_rel'] ?? 0));
460 $new_item->createDefaultEntry($new_item_id);
461 $new_item->update($new_item_id);
477 $tree = $DIC->repositoryTree();
478 $db = $DIC->database();
480 $subtree = $tree->getSubTree($tree->getNodeData($ref_id));
482 foreach ($subtree as $node) {
483 $ref_ids[] = $node[
'ref_id'];
487 "SELECT parent_id" . PHP_EOL
488 .
"FROM crs_items" . PHP_EOL
489 .
"WHERE timing_type = " . $db->
quote(self::TIMINGS_PRESETTING,
'integer') . PHP_EOL
490 .
"AND " . $db->
in(
'obj_id', $ref_ids,
false,
'integer') . PHP_EOL
493 return (
bool)
$res->numRows();
503 $tree = $DIC->repositoryTree();
504 $db = $DIC->database();
506 $subtree = $tree->getSubTree($tree->getNodeData($ref_id));
508 foreach ($subtree as $node) {
509 $ref_ids[] = $node[
'ref_id'];
513 "SELECT parent_id" . PHP_EOL
514 .
"FROM crs_items" . PHP_EOL
515 .
"WHERE timing_type = " . $db->
quote(self::TIMINGS_PRESETTING,
'integer') . PHP_EOL
516 .
"AND changeable = " . $db->
quote(1,
'integer') . PHP_EOL
517 .
"AND " . $db->
in(
'obj_id', $ref_ids,
false,
'integer') . PHP_EOL
520 return (
bool)
$res->numRows();
530 $tree = $DIC->repositoryTree();
534 foreach (array_map(
'intval', $ref_ids) as $item_ref_id) {
535 if ($tree->isDeleted($item_ref_id)) {
539 $node = $tree->getNodeData($item_ref_id);
540 if (!isset($node[
"ref_id"]) || (
int) $node[
"ref_id"] !== $item_ref_id) {
543 $res[$item_ref_id] = $node;
547 self::preloadData(array_keys(
$res));
548 foreach (
$res as $idx => $item) {
549 self::addAdditionalSubItemInformation($item);
554 return array_values(
$res);
563 return self::processListItems($event_items->getItems());
572 $items = $ig_items->getValidItems();
573 return self::processListItems($items);
582 return self::processListItems($item_ids);
588 public static function getItems(
int $parent_id,
bool $with_list_data =
true): array
592 $tree = $DIC->repositoryTree();
597 foreach ($tree->getChilds($parent_id) as $item) {
598 if ($item[
'type'] !==
'rolf') {
600 $ref_ids[] = (
int) $item[
'ref_id'];
605 self::preloadData($ref_ids);
607 foreach ($items as $idx => $item) {
608 if (!$with_list_data) {
609 $items[$idx] = array_merge($item, self::getItem((
int) $item[
'ref_id']));
611 self::addAdditionalSubItemInformation($item);
612 $items[$idx] = $item;
624 $items = self::getItems($parent_id,
false);
625 $active = $availability = $inactive = [];
626 foreach ($items as $item) {
627 if ($item[
'timing_type'] == self::TIMINGS_DEACTIVATED) {
629 } elseif ($item[
'timing_type'] == self::TIMINGS_ACTIVATION) {
630 $availability[] = $item;
639 $items = array_merge($active, $availability, $inactive);
650 $objDefinition = $DIC[
"objDefinition"];
655 foreach (self::getTimingsAdministrationItems($container_ref_id) as $item) {
656 if (!in_array($item[
'ref_id'], $event_items) &&
657 !$objDefinition->isSideBlock($item[
'type'])) {
668 $db = $DIC->database();
671 "SELECT parent_id, obj_id, timing_type, timing_start, timing_end, suggestion_start," . PHP_EOL
672 .
"suggestion_end, changeable, visible, position, suggestion_start_rel, suggestion_end_rel" . PHP_EOL
673 .
"FROM crs_items" . PHP_EOL
674 .
"WHERE obj_id = " . $db->
quote($ref_id,
'integer') . PHP_EOL
678 $sql .=
"AND parent_id = " . $db->
quote($parent_id,
"integer") . PHP_EOL;
static deleteAllEntries(int $ref_id)
Delete all db entries for ref id.
static _getAssignedMaterials(int $a_objective_id)
int $suggestion_start_rel
numRows(ilDBStatement $statement)
insert(string $table_name, array $values)
static hasChangeableTimings(int $ref_id)
Check if there is any active changeable timing (in subtree)
getStart()
Use to set start date.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static getItemsByEvent(int $event_id)
Get session material / event items.
fetchAssoc(ilDBStatement $statement)
static processListItems(array $ref_ids)
Validate ref ids and add list data.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
toggleChangeable(bool $status)
const TIMINGS_DEACTIVATED
setSuggestionEnd(?int $end)
quote($value, string $type)
loadLanguageModule(string $a_module)
Load language module.
setTimingStart(?int $start)
static createDefaultEntry(int $ref_id)
Create db entry with default values.
static _getItemsOfContainer(int $a_ref_id)
static cloneDependencies(int $ref_id, int $target_id, int $copy_id)
static _lookupObjId(int $ref_id)
static getItems(int $parent_id, bool $with_list_data=true)
Get sub item data.
static array $preloaded_data
static getTimingsAdministrationItems(int $parent_id)
Get (sub) item data for timings administration view (active/inactive)
static _lookupAppointment(int $a_obj_id)
static preloadData(array $ref_ids)
Preload data to internal cache.
static getTimingsItems(int $container_ref_id)
Get (sub) item data for timings view (no session material, no side blocks)
read(int $ref_id, int $parent_id=0)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
setSuggestionStartRelative(?int $start)
static addListGUIActivationProperty(ilObjectListGUI $list_gui, array &$item)
Get timing details for list gui.
query(string $query)
Run a (read-only) Query on the database.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
toggleVisible(bool $status)
static getItemsByItemGroup(int $item_group_ref_id)
Get materials of item group.
setSuggestionEndRelative(int $end)
in(string $field, array $values, bool $negate=false, string $type="")
static getItem(int $ref_id)
Error Handling & global info handling uses PEAR error class.
static getItemsByObjective(int $objective_id)
Get objective items.
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false)
Format a period of two dates Shows: 14.
static addAdditionalSubItemInformation(array &$item)
Parse item data for list entries.
static hasTimings(int $ref_id)
Check if there is any active timing (in subtree)
static _getInstance(int $a_copy_id)
manipulate(string $query)
Run a (write) Query on the database.
static _lookupType(int $id, bool $reference=false)
addCustomProperty(string $property="", string $value="", bool $alert=false, bool $newline=false)
setSuggestionStart(?int $start)
update(int $ref_id, ?int $parent_id=null)
Class ilObjectActivation.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)