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;
   150             "timing_end" => [
"integer", $this->
getTimingEnd() ?? 0],
   151             "suggestion_start" => [
"integer", $this->suggestion_start ?? 0],
   152             "suggestion_end" => [
"integer", $this->suggestion_end ?? 0],
   154             "suggestion_start_rel" => [
"integer", $this->suggestion_start_rel ?? 0],
   155             "suggestion_end_rel" => [
"integer", $this->suggestion_end_rel ?? 0],
   159         if (!is_null($parent_id)) {
   160             $values[
"parent_id"] = [
"integer", $parent_id];
   164             "obj_id" => [
"integer", 
$ref_id]
   167         $this->db->update(
"crs_items", $values, $where);
   169         unset(self::$preloaded_data[$ref_id]);
   180         $db = $DIC->database();
   183             "SELECT parent_id, obj_id, timing_type, timing_start, timing_end, suggestion_start," . PHP_EOL
   184             . 
"suggestion_end, changeable, visible, position, suggestion_start_rel, suggestion_end_rel" . PHP_EOL
   185             . 
"FROM crs_items" . PHP_EOL
   186             . 
"WHERE " . $db->
in(
"obj_id", $ref_ids, 
false, 
"integer") . PHP_EOL
   188         $set = $db->
query($sql);
   190             self::$preloaded_data[$row[
"obj_id"]] = $row;
   198         $db = $DIC->database();
   200         if (isset(self::$preloaded_data[$ref_id])) {
   201             return self::$preloaded_data[
$ref_id];
   205             "SELECT parent_id, obj_id, timing_type, timing_start, timing_end, suggestion_start," . PHP_EOL
   206             . 
"suggestion_end, changeable, visible, position, suggestion_start_rel, suggestion_end_rel" . PHP_EOL
   207             . 
"FROM crs_items" . PHP_EOL
   208             . 
"WHERE obj_id = " . $db->
quote($ref_id, 
"integer") . PHP_EOL
   210         $set = $db->
query($sql);
   213         if (!isset($row[
"obj_id"])) {
   214             $row = self::createDefaultEntry($ref_id);
   216             self::$preloaded_data[$row[
"obj_id"]] = $row;
   227         $ilUser = $DIC->user();
   229         $item_array = self::getItem((
int) $item[
'ref_id']);
   231         $item[
'obj_id'] = ($item[
'obj_id'] > 0)
   234         $item[
'type'] = ($item[
'type'] != 
'')
   238         $item[
'timing_type'] = $item_array[
'timing_type'] ?? 0;
   240         if ($item_array[
'timing_type'] == self::TIMINGS_PRESETTING &&
   242                 ($item_array[
'changeable'] ?? 
false) ||
   247             $user_data = 
new ilTimingUser((
int) $item[
'ref_id'], $ilUser->getId());
   248             if ($user_data->isScheduled()) {
   250                 $item[
'end'] = $user_data->getEnd()->get(
IL_CAL_UNIX);
   251                 $item[
'activation_info'] = 
'crs_timings_planed_info';
   253                 $item[
'start'] = $item_array[
'suggestion_start'] ?? 
"";
   254                 $item[
'end'] = $item_array[
'suggestion_end'] ?? 
"";
   255                 $item[
'activation_info'] = 
'crs_timings_suggested_info';
   258         } elseif (($item_array[
'timing_type'] ?? 0) == self::TIMINGS_PRESETTING) {
   259             $item[
'start'] = $item_array[
'suggestion_start'] ?? 
"";
   260             $item[
'end'] = $item_array[
'suggestion_end'] ?? 
"";
   261             $item[
'activation_info'] = 
'crs_timings_suggested_info';
   262         } elseif (($item_array[
'timing_type'] ?? 0) == self::TIMINGS_ACTIVATION) {
   263             $item[
'start'] = $item_array[
'timing_start'] ?? 
"";
   264             $item[
'end'] = $item_array[
'timing_end'] ?? 
"";
   265             $item[
'activation_info'] = 
'obj_activation_list_gui';
   269         if ($item[
'type'] == 
'sess') {
   272             $item[
'masked_start'] = $item[
'start'] ?? 
'';
   273             $item[
'masked_end'] = $item[
'end'] ?? 
'';
   274             $item[
'start'] = $info[
'start'] ?? 
'';
   275             $item[
'end'] = $info[
'end'] ?? 
'';
   284         self::addAdditionalSubItemInformation($item);
   285         if (isset($item[
'timing_type'])) {
   286             if (!isset($item[
'masked_start'])) {
   287                 $start = $item[
'start'] ?? 0;
   288                 $end = $item[
'end'] ?? 0;
   290                 $start = $item[
'masked_start'];
   291                 $end = $item[
'masked_end'];
   294             switch ($item[
'timing_type']) {
   309             if ($activation != 
"") {
   312                 $lng = $DIC->language();
   316                     $lng->
txt($item[
'activation_info']),
   332         $db = $DIC->database();
   333         $tree = $DIC->repositoryTree();
   335         $parent_id = $tree->getParentId($ref_id);
   341         $ilAtomQuery->addTableLock(
"crs_items");
   343         $ilAtomQuery->addQueryCallable(
function (
ilDBInterface $db) use ($ref_id, $parent_id, &$item): 
void {
   345                 "SELECT parent_id, obj_id, timing_type, timing_start, timing_end, suggestion_start," . PHP_EOL
   346                 . 
"suggestion_end, changeable, visible, position, suggestion_start_rel, suggestion_end_rel" . PHP_EOL
   347                 . 
"FROM crs_items" . PHP_EOL
   348                 . 
"WHERE obj_id = " . $db->
quote($ref_id, 
"integer") . PHP_EOL
   350             $set = $db->
query($sql);
   355                 $item[
"timing_type"] = self::TIMINGS_DEACTIVATED;
   356                 $item[
"timing_start"] = $now;
   357                 $item[
"timing_end"] = $now;
   358                 $item[
"suggestion_start"] = $now;
   359                 $item[
"suggestion_end"] = $now;
   360                 $item[
'visible'] = 0;
   361                 $item[
'changeable'] = 0;
   364                     "parent_id" => [
"integer", $parent_id],
   365                     "obj_id" => [
"integer", 
$ref_id],
   366                     "timing_type" => [
"integer", $item[
"timing_type"]],
   367                     "timing_start" => [
"integer", $item[
"timing_start"]],
   368                     "timing_end" => [
"integer", $item[
"timing_end"]],
   369                     "suggestion_start" => [
"integer", $item[
"suggestion_start"]],
   370                     "suggestion_end" => [
"integer", $item[
"suggestion_end"]],
   371                     "changeable" => [
"integer", $item[
"changeable"]],
   372                     "visible" => [
"integer", $item[
"visible"]],
   373                     "suggestion_start_rel" => [
"integer", $item[
"suggestion_start_rel"] ?? 0],
   374                     "suggestion_end_rel" => [
"integer", $item[
"suggestion_end_rel"] ?? 0],
   375                     "position" => [
"integer", 0]
   377                 $db->
insert(
"crs_items", $values);
   385         $item[
"parent_id"] = $parent_id;
   397         $db = $DIC->database();
   404             "DELETE FROM crs_items " . PHP_EOL
   405             . 
"WHERE obj_id = " . $db->
quote($ref_id, 
'integer') . PHP_EOL
   410             "DELETE FROM crs_items " . PHP_EOL
   411             . 
"WHERE parent_id = " . $db->
quote($ref_id, 
'integer') . PHP_EOL
   422         $ilLog = $DIC[
"ilLog"];
   424         $ilLog->write(__METHOD__ . 
': Begin course items...' . $ref_id);
   426         $items = self::getItems($ref_id, 
false);
   428             $ilLog->write(__METHOD__ . 
': No course items found.');
   434             $ilLog->write(__METHOD__ . 
': Cannot create target object.');
   439         $mappings = $cp_options->getMappings();
   441         foreach ($items as $item) {
   442             if (!isset($mappings[$item[
'parent_id']]) or !$mappings[$item[
'parent_id']]) {
   443                 $ilLog->write(__METHOD__ . 
': No mapping for parent nr. ' . $item[
'parent_id']);
   446             if (!isset($mappings[$item[
'obj_id']]) or !$mappings[$item[
'obj_id']]) {
   447                 $ilLog->write(__METHOD__ . 
': No mapping for item nr. ' . $item[
'obj_id']);
   450             $new_item_id = $mappings[$item[
'obj_id']];
   451             $new_parent = $mappings[$item[
'parent_id']];
   453             $new_item = 
new self();
   454             $new_item->setTimingType((
int) $item[
'timing_type']);
   455             $new_item->setTimingStart((
int) $item[
'timing_start']);
   456             $new_item->setTimingEnd((
int) $item[
'timing_end']);
   457             $new_item->setSuggestionStart((
int) $item[
'suggestion_start']);
   458             $new_item->setSuggestionEnd((
int) $item[
'suggestion_end']);
   459             $new_item->toggleChangeable((
bool) $item[
'changeable']);
   460             $new_item->toggleVisible((
bool) $item[
'visible']);
   461             $new_item->update($new_item_id, $new_parent);
   462             $new_item->setSuggestionStartRelative((
int) ($item[
'suggestion_start_rel'] ?? 0));
   463             $new_item->setSuggestionEndRelative((
int) ($item[
'suggestion_end_rel'] ?? 0));
   464             $new_item->createDefaultEntry($new_item_id);
   465             $new_item->update($new_item_id);
   481         $tree = $DIC->repositoryTree();
   482         $db = $DIC->database();
   484         $subtree = $tree->getSubTree($tree->getNodeData($ref_id));
   486         foreach ($subtree as $node) {
   487             $ref_ids[] = $node[
'ref_id'];
   491             "SELECT parent_id" . PHP_EOL
   492             . 
"FROM crs_items" . PHP_EOL
   493             . 
"WHERE timing_type = " . $db->
quote(self::TIMINGS_PRESETTING, 
'integer') . PHP_EOL
   494             . 
"AND " . $db->
in(
'obj_id', $ref_ids, 
false, 
'integer') . PHP_EOL
   497         return (
bool) 
$res->numRows();
   507         $tree = $DIC->repositoryTree();
   508         $db = $DIC->database();
   510         $subtree = $tree->getSubTree($tree->getNodeData($ref_id));
   512         foreach ($subtree as $node) {
   513             $ref_ids[] = $node[
'ref_id'];
   517             "SELECT parent_id" . PHP_EOL
   518             . 
"FROM crs_items" . PHP_EOL
   519             . 
"WHERE timing_type = " . $db->
quote(self::TIMINGS_PRESETTING, 
'integer') . PHP_EOL
   520             . 
"AND changeable = " . $db->
quote(1, 
'integer') . PHP_EOL
   521             . 
"AND " . $db->
in(
'obj_id', $ref_ids, 
false, 
'integer') . PHP_EOL
   524         return (
bool) 
$res->numRows();
   534         $tree = $DIC->repositoryTree();
   538         foreach (
array_map(
'intval', $ref_ids) as $item_ref_id) {
   539             if ($tree->isDeleted($item_ref_id)) {
   543             $node = $tree->getNodeData($item_ref_id);
   544             if (!isset($node[
"ref_id"]) || (
int) $node[
"ref_id"] !== $item_ref_id) {
   547             $res[$item_ref_id] = $node;
   551             self::preloadData(array_keys(
$res));
   552             foreach (
$res as $idx => $item) {
   553                 self::addAdditionalSubItemInformation($item);
   558         return array_values(
$res);
   567         return self::processListItems($event_items->getItems());
   576         $items = $ig_items->getValidItems();
   577         return self::processListItems($items);
   586         return self::processListItems($item_ids);
   592     public static function getItems(
int $parent_id, 
bool $with_list_data = 
true): array
   596         $tree = $DIC->repositoryTree();
   601         foreach ($tree->getChilds($parent_id) as $item) {
   602             if ($item[
'type'] !== 
'rolf') {
   604                 $ref_ids[] = (
int) $item[
'ref_id'];
   609             self::preloadData($ref_ids);
   611             foreach ($items as $idx => $item) {
   612                 if (!$with_list_data) {
   613                     $items[$idx] = array_merge($item, self::getItem((
int) $item[
'ref_id']));
   615                     self::addAdditionalSubItemInformation($item);
   616                     $items[$idx] = $item;
   628         $items = self::getItems($parent_id, 
false);
   629         $active = $availability = $inactive = [];
   630         foreach ($items as $item) {
   631             if ($item[
'timing_type'] == self::TIMINGS_DEACTIVATED) {
   633             } elseif ($item[
'timing_type'] == self::TIMINGS_ACTIVATION) {
   634                 $availability[] = $item;
   643         $items = array_merge($active, $availability, $inactive);
   654         $objDefinition = $DIC[
"objDefinition"];
   659         foreach (self::getTimingsAdministrationItems($container_ref_id) as $item) {
   660             if (!in_array($item[
'ref_id'], $event_items) &&
   661                 !$objDefinition->isSideBlock($item[
'type'])) {
   672         $db = $DIC->database();
   675             "SELECT parent_id, obj_id, timing_type, timing_start, timing_end, suggestion_start," . PHP_EOL
   676             . 
"suggestion_end, changeable, visible, position, suggestion_start_rel, suggestion_end_rel" . PHP_EOL
   677             . 
"FROM crs_items" . PHP_EOL
   678             . 
"WHERE obj_id = " . $db->
quote($ref_id, 
'integer') . PHP_EOL
   682             $sql .= 
"AND parent_id = " . $db->
quote($parent_id, 
"integer") . PHP_EOL;
 static lookupTimingMode(int $a_obj_id)
 
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
 
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)
 
const IL_CRS_VIEW_TIMING_RELATIVE
 
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)
 
static getItemsByObjective(int $objective_id)
Get objective items. 
 
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 formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false, ilObjUser $user=null)
Format a period of two dates Shows: 14. 
 
setSuggestionEnd(int $end)
 
static _getInstance(int $a_copy_id)
 
manipulate(string $query)
Run a (write) Query on the database. 
 
static _lookupType(int $id, bool $reference=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...
 
addCustomProperty(string $property='', string $value='', bool $alert=false, bool $newline=false)
 
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)