ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilObjectActivation Class Reference

Class ilObjectActivation. More...

+ Collaboration diagram for ilObjectActivation:

Public Member Functions

 __construct ()
 
 setTimingType (int $type)
 
 getTimingType ()
 
 setTimingStart (?int $start)
 
 getTimingStart ()
 
 setTimingEnd (?int $end)
 
 getTimingEnd ()
 
 setSuggestionStart (?int $start)
 
 setSuggestionStartRelative (?int $start)
 
 setSuggestionEndRelative (int $end)
 
 setSuggestionEnd (?int $end)
 
 toggleVisible (bool $status)
 
 enabledVisible ()
 
 toggleChangeable (bool $status)
 
 enabledChangeable ()
 
 update (int $ref_id, ?int $parent_id=null)
 
 read (int $ref_id, int $parent_id=0)
 

Static Public Member Functions

static preloadData (array $ref_ids)
 Preload data to internal cache. More...
 
static getItem (int $ref_id)
 
static addAdditionalSubItemInformation (array &$item)
 Parse item data for list entries. More...
 
static addListGUIActivationProperty (ilObjectListGUI $list_gui, array &$item)
 Get timing details for list gui. More...
 
static deleteAllEntries (int $ref_id)
 Delete all db entries for ref id. More...
 
static cloneDependencies (int $ref_id, int $target_id, int $copy_id)
 
static hasTimings (int $ref_id)
 Check if there is any active timing (in subtree) More...
 
static hasChangeableTimings (int $ref_id)
 Check if there is any active changeable timing (in subtree) More...
 
static getItemsByEvent (int $event_id)
 Get session material / event items. More...
 
static getItemsByItemGroup (int $item_group_ref_id)
 Get materials of item group. More...
 
static getItemsByObjective (int $objective_id)
 Get objective items. More...
 
static getItems (int $parent_id, bool $with_list_data=true)
 Get sub item data. More...
 
static getTimingsAdministrationItems (int $parent_id)
 Get (sub) item data for timings administration view (active/inactive) More...
 
static getTimingsItems (int $container_ref_id)
 Get (sub) item data for timings view (no session material, no side blocks) More...
 

Data Fields

const ERR_SUG_START_END = 1
 
const TIMINGS_ACTIVATION = 0
 
const TIMINGS_DEACTIVATED = 1
 
const TIMINGS_PRESETTING = 2
 
const TIMINGS_FIXED = 3
 

Static Protected Member Functions

static createDefaultEntry (int $ref_id)
 Create db entry with default values. More...
 
static processListItems (array $ref_ids)
 Validate ref ids and add list data. More...
 

Protected Attributes

ilErrorHandling $error
 
ilLanguage $lng
 
ilDBInterface $db
 
int $timing_type = 0
 
int $timing_start = null
 
int $timing_end = null
 
int $suggestion_start = null
 
int $suggestion_end = null
 
bool $visible = false
 
int $changeable = 0
 
int $suggestion_start_rel = null
 
int $suggestion_end_rel = null
 

Static Protected Attributes

static array $preloaded_data = []
 

Detailed Description

Class ilObjectActivation.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id
class.ilCourseItems.php 30321 2011-08-22 12:05:03Z jluetzen

Definition at line 27 of file class.ilObjectActivation.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjectActivation::__construct ( )

Definition at line 53 of file class.ilObjectActivation.php.

References $DIC, and ILIAS\Repository\lng().

54  {
55  global $DIC;
56 
57  $this->error = $DIC["ilErr"];
58  $this->lng = $DIC->language();
59  $this->db = $DIC->database();
60  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ addAdditionalSubItemInformation()

static ilObjectActivation::addAdditionalSubItemInformation ( array &  $item)
static

Parse item data for list entries.

Definition at line 222 of file class.ilObjectActivation.php.

References $DIC, ilSessionAppointment\_lookupAppointment(), ilObject\_lookupObjId(), ilObject\_lookupType(), ilTimingUser\getStart(), IL_CAL_UNIX, ilCourseConstants\IL_CRS_VIEW_TIMING_RELATIVE, and ilObjCourse\lookupTimingMode().

Referenced by ilObjRootFolder\addAdditionalSubItemInformation(), ilObjFolder\addAdditionalSubItemInformation(), ilObjCategory\addAdditionalSubItemInformation(), ilObjGroup\addAdditionalSubItemInformation(), ilObjCourse\addAdditionalSubItemInformation(), and ILIAS\Container\Content\ItemSetManager\addAdditionalSubItemInformationToObject().

222  : void
223  {
224  global $DIC;
225  $ilUser = $DIC->user();
226 
227  $item_array = self::getItem((int) $item['ref_id']);
228 
229  $item['obj_id'] = ($item['obj_id'] > 0)
230  ? $item['obj_id']
231  : ilObject::_lookupObjId((int) $item['ref_id']);
232  $item['type'] = ($item['type'] != '')
233  ? $item['type']
234  : ilObject::_lookupType((int) $item['obj_id']);
235 
236  $item['timing_type'] = $item_array['timing_type'] ?? 0;
237 
238  if ($item_array['timing_type'] == self::TIMINGS_PRESETTING &&
239  (
240  ($item_array['changeable'] ?? false) ||
242  )
243  ) {
244  // cognos-blu-patch: begin
245  $user_data = new ilTimingUser((int) $item['ref_id'], $ilUser->getId());
246  if ($user_data->isScheduled()) {
247  $item['start'] = $user_data->getStart()->get(IL_CAL_UNIX);
248  $item['end'] = $user_data->getEnd()->get(IL_CAL_UNIX);
249  $item['activation_info'] = 'crs_timings_planed_info';
250  } else {
251  $item['start'] = $item_array['suggestion_start'] ?? "";
252  $item['end'] = $item_array['suggestion_end'] ?? "";
253  $item['activation_info'] = 'crs_timings_suggested_info';
254  }
255  // cognos-blu-patch: end
256  } elseif (($item_array['timing_type'] ?? 0) == self::TIMINGS_PRESETTING) {
257  $item['start'] = $item_array['suggestion_start'] ?? "";
258  $item['end'] = $item_array['suggestion_end'] ?? "";
259  $item['activation_info'] = 'crs_timings_suggested_info';
260  } elseif (($item_array['timing_type'] ?? 0) == self::TIMINGS_ACTIVATION) {
261  $item['start'] = $item_array['timing_start'] ?? "";
262  $item['end'] = $item_array['timing_end'] ?? "";
263  $item['activation_info'] = 'obj_activation_list_gui';
264  }
265 
266  // #7359 - session sorting should always base on appointment date
267  if ($item['type'] == 'sess') {
268  $info = ilSessionAppointment::_lookupAppointment((int) $item['obj_id']);
269  // #11987
270  $item['masked_start'] = $item['start'] ?? '';
271  $item['masked_end'] = $item['end'] ?? '';
272  $item['start'] = $info['start'] ?? '';
273  $item['end'] = $info['end'] ?? '';
274  }
275  }
static lookupTimingMode(int $a_obj_id)
getStart()
Use to set start date.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_CAL_UNIX
static _lookupObjId(int $ref_id)
global $DIC
Definition: feed.php:28
static _lookupAppointment(int $a_obj_id)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addListGUIActivationProperty()

static ilObjectActivation::addListGUIActivationProperty ( ilObjectListGUI  $list_gui,
array &  $item 
)
static

Get timing details for list gui.

Definition at line 280 of file class.ilObjectActivation.php.

References $DIC, ilObjectListGUI\addCustomProperty(), ilDatePresentation\formatPeriod(), IL_CAL_UNIX, ilLanguage\loadLanguageModule(), TIMINGS_ACTIVATION, TIMINGS_PRESETTING, and ilLanguage\txt().

Referenced by ilSearchResultTableGUI\fillRow(), ilObjSessionGUI\modifyItemGUI(), ILIAS\Containter\Content\ItemRenderer\renderItem(), and ilContainerContentGUI\renderItem().

280  : void
281  {
282  self::addAdditionalSubItemInformation($item);
283  if (isset($item['timing_type'])) {
284  if (!isset($item['masked_start'])) {
285  $start = $item['start'] ?? 0;
286  $end = $item['end'] ?? 0;
287  } else {
288  $start = $item['masked_start'];
289  $end = $item['masked_end'];
290  }
291  $activation = '';
292  switch ($item['timing_type']) {
294  $activation = ilDatePresentation::formatPeriod(
295  new ilDateTime($start, IL_CAL_UNIX),
296  new ilDateTime($end, IL_CAL_UNIX)
297  );
298  break;
299 
301  $activation = ilDatePresentation::formatPeriod(
302  new ilDate($start, IL_CAL_UNIX),
303  new ilDate($end, IL_CAL_UNIX)
304  );
305  break;
306  }
307  if ($activation != "") {
308  global $DIC;
309 
310  $lng = $DIC->language();
311  $lng->loadLanguageModule('crs');
312 
313  $list_gui->addCustomProperty(
314  $lng->txt($item['activation_info']),
315  $activation,
316  false,
317  true
318  );
319  }
320  }
321  }
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...
loadLanguageModule(string $a_module)
Load language module.
const IL_CAL_UNIX
global $DIC
Definition: feed.php:28
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false)
Format a period of two dates Shows: 14.
addCustomProperty(string $property='', string $value='', bool $alert=false, bool $newline=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cloneDependencies()

static ilObjectActivation::cloneDependencies ( int  $ref_id,
int  $target_id,
int  $copy_id 
)
static

Definition at line 416 of file class.ilObjectActivation.php.

References $DIC, ilCopyWizardOptions\_getInstance(), and ilObjectFactory\getInstanceByRefId().

Referenced by ilObjFolder\cloneDependencies(), ilObjGroup\cloneDependencies(), and ilObjCourse\cloneDependencies().

416  : void
417  {
418  global $DIC;
419 
420  $ilLog = $DIC["ilLog"];
421 
422  $ilLog->write(__METHOD__ . ': Begin course items...' . $ref_id);
423 
424  $items = self::getItems($ref_id, false);
425  if (!$items) {
426  $ilLog->write(__METHOD__ . ': No course items found.');
427  return;
428  }
429 
430  // new course item object
431  if (!is_object(ilObjectFactory::getInstanceByRefId($target_id, false))) {
432  $ilLog->write(__METHOD__ . ': Cannot create target object.');
433  return;
434  }
435 
436  $cp_options = ilCopyWizardOptions::_getInstance($copy_id);
437  $mappings = $cp_options->getMappings();
438 
439  foreach ($items as $item) {
440  if (!isset($mappings[$item['parent_id']]) or !$mappings[$item['parent_id']]) {
441  $ilLog->write(__METHOD__ . ': No mapping for parent nr. ' . $item['parent_id']);
442  continue;
443  }
444  if (!isset($mappings[$item['obj_id']]) or !$mappings[$item['obj_id']]) {
445  $ilLog->write(__METHOD__ . ': No mapping for item nr. ' . $item['obj_id']);
446  continue;
447  }
448  $new_item_id = $mappings[$item['obj_id']];
449  $new_parent = $mappings[$item['parent_id']];
450 
451  $new_item = new self();
452  $new_item->setTimingType((int) $item['timing_type']);
453  $new_item->setTimingStart((int) $item['timing_start']);
454  $new_item->setTimingEnd((int) $item['timing_end']);
455  $new_item->setSuggestionStart((int) $item['suggestion_start']);
456  $new_item->setSuggestionEnd((int) $item['suggestion_end']);
457  $new_item->toggleChangeable((bool) $item['changeable']);
458  $new_item->toggleVisible((bool) $item['visible']);
459  $new_item->update($new_item_id, $new_parent);
460  $new_item->setSuggestionStartRelative((int) ($item['suggestion_start_rel'] ?? 0));
461  $new_item->setSuggestionEndRelative((int) ($item['suggestion_end_rel'] ?? 0));
462  $new_item->createDefaultEntry($new_item_id);
463  $new_item->update($new_item_id);
464  }
465  }
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
static _getInstance(int $a_copy_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createDefaultEntry()

static ilObjectActivation::createDefaultEntry ( int  $ref_id)
staticprotected

Create db entry with default values.

Definition at line 326 of file class.ilObjectActivation.php.

References $DIC, $ref_id, ilDBInterface\buildAtomQuery(), ilDBInterface\insert(), ilDBInterface\numRows(), ilDBInterface\query(), and ilDBInterface\quote().

326  : array
327  {
328  global $DIC;
329 
330  $db = $DIC->database();
331  $tree = $DIC->repositoryTree();
332 
333  $parent_id = $tree->getParentId($ref_id);
334  if (!$parent_id) {
335  return [];
336  }
337 
338  $ilAtomQuery = $db->buildAtomQuery();
339  $ilAtomQuery->addTableLock("crs_items");
340 
341  $ilAtomQuery->addQueryCallable(function (ilDBInterface $db) use ($ref_id, $parent_id, &$item): void {
342  $sql =
343  "SELECT parent_id, obj_id, timing_type, timing_start, timing_end, suggestion_start," . PHP_EOL
344  . "suggestion_end, changeable, visible, position, suggestion_start_rel, suggestion_end_rel" . PHP_EOL
345  . "FROM crs_items" . PHP_EOL
346  . "WHERE obj_id = " . $db->quote($ref_id, "integer") . PHP_EOL
347  ;
348  $set = $db->query($sql);
349  if (!$db->numRows($set)) {
350  $now = time();
351 
352  $item = [];
353  $item["timing_type"] = self::TIMINGS_DEACTIVATED;
354  $item["timing_start"] = $now;
355  $item["timing_end"] = $now;
356  $item["suggestion_start"] = $now;
357  $item["suggestion_end"] = $now;
358  $item['visible'] = 0;
359  $item['changeable'] = 0;
360 
361  $values = [
362  "parent_id" => ["integer", $parent_id],
363  "obj_id" => ["integer", $ref_id],
364  "timing_type" => ["integer", $item["timing_type"]],
365  "timing_start" => ["integer", $item["timing_start"]],
366  "timing_end" => ["integer", $item["timing_end"]],
367  "suggestion_start" => ["integer", $item["suggestion_start"]],
368  "suggestion_end" => ["integer", $item["suggestion_end"]],
369  "changeable" => ["integer", $item["changeable"]],
370  "visible" => ["integer", $item["visible"]],
371  "suggestion_start_rel" => ["integer", $item["suggestion_start_rel"] ?? 0],
372  "suggestion_end_rel" => ["integer", $item["suggestion_end_rel"] ?? 0],
373  "position" => ["integer", 0]
374  ];
375  $db->insert("crs_items", $values);
376  }
377  });
378 
379  $ilAtomQuery->run();
380 
381  // #9982 - to make getItem()-cache work
382  $item["obj_id"] = $ref_id;
383  $item["parent_id"] = $parent_id;
384 
385  return $item;
386  }
numRows(ilDBStatement $statement)
insert(string $table_name, array $values)
quote($value, string $type)
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
query(string $query)
Run a (read-only) Query on the database.
+ Here is the call graph for this function:

◆ deleteAllEntries()

static ilObjectActivation::deleteAllEntries ( int  $ref_id)
static

Delete all db entries for ref id.

Definition at line 391 of file class.ilObjectActivation.php.

References $DIC, ilDBInterface\manipulate(), and ilDBInterface\quote().

Referenced by ilObject\delete(), and ilObjPoll\doDelete().

391  : bool
392  {
393  global $DIC;
394 
395  $db = $DIC->database();
396 
397  if (!$ref_id) {
398  return false;
399  }
400 
401  $sql =
402  "DELETE FROM crs_items " . PHP_EOL
403  . "WHERE obj_id = " . $db->quote($ref_id, 'integer') . PHP_EOL
404  ;
405  $db->manipulate($sql);
406 
407  $sql =
408  "DELETE FROM crs_items " . PHP_EOL
409  . "WHERE parent_id = " . $db->quote($ref_id, 'integer') . PHP_EOL
410  ;
411  $db->manipulate($sql);
412 
413  return true;
414  }
quote($value, string $type)
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
manipulate(string $query)
Run a (write) Query on the database.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enabledChangeable()

ilObjectActivation::enabledChangeable ( )

Definition at line 139 of file class.ilObjectActivation.php.

References $changeable.

Referenced by update().

139  : bool
140  {
141  return (bool) $this->changeable;
142  }
+ Here is the caller graph for this function:

◆ enabledVisible()

ilObjectActivation::enabledVisible ( )

Definition at line 129 of file class.ilObjectActivation.php.

References $visible.

Referenced by update().

129  : bool
130  {
131  return $this->visible;
132  }
+ Here is the caller graph for this function:

◆ getItem()

static ilObjectActivation::getItem ( int  $ref_id)
static

Definition at line 193 of file class.ilObjectActivation.php.

References $DIC, $ref_id, ilDBInterface\fetchAssoc(), ilDBInterface\query(), and ilDBInterface\quote().

Referenced by ilObjCourse\__readSettings(), ilTimingCache\_getTimings(), ilObjCourseAccess\_isActivated(), ilObjectXMLWriter\appendTimeTargets(), ilObjSurvey\checkReminder(), ilAccess\doActivationCheck(), ilObjPortfolioTemplate\doRead(), ilObjPoll\doRead(), ilTimingsUser\handleNewMembership(), ilObjTest\loadFromDb(), ilObjSurvey\loadFromDb(), ilObjLTIConsumer\loadRepositoryActivationSettings(), ilObjCmiXapi\loadRepositoryActivationSettings(), ilCalendarScheduleFilterTimings\modifyEvent(), ilTimingCache\readObjectInformation(), ilObjLTIConsumer\saveRepositoryActivationSettings(), ilObjCmiXapi\saveRepositoryActivationSettings(), ilObjSurvey\saveToDb(), ilObjPortfolioTemplate\updateActivation(), ilSoapObjectAdministration\updateReferences(), ilObjCourse\updateSettings(), ilTimingPlaned\validate(), and ilContainerXmlWriter\writeCourseItemInformation().

193  : array
194  {
195  global $DIC;
196  $db = $DIC->database();
197 
198  if (isset(self::$preloaded_data[$ref_id])) {
199  return self::$preloaded_data[$ref_id];
200  }
201 
202  $sql =
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
207  ;
208  $set = $db->query($sql);
209  $row = $db->fetchAssoc($set);
210 
211  if (!isset($row["obj_id"])) {
212  $row = self::createDefaultEntry($ref_id);
213  } else {
214  self::$preloaded_data[$row["obj_id"]] = $row;
215  }
216  return $row;
217  }
fetchAssoc(ilDBStatement $statement)
quote($value, string $type)
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
query(string $query)
Run a (read-only) Query on the database.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getItems()

static ilObjectActivation::getItems ( int  $parent_id,
bool  $with_list_data = true 
)
static

Get sub item data.

Definition at line 590 of file class.ilObjectActivation.php.

References $DIC, and ILIAS\Repository\int().

Referenced by ilCourseStart\getPossibleStarters(), ilContainerStartObjects\getPossibleStarters(), and ilCourseContentGUI\managePersonalTimings().

590  : array
591  {
592  global $DIC;
593 
594  $tree = $DIC->repositoryTree();
595 
596  $items = [];
597 
598  $ref_ids = [];
599  foreach ($tree->getChilds($parent_id) as $item) {
600  if ($item['type'] !== 'rolf') {
601  $items[] = $item;
602  $ref_ids[] = (int) $item['ref_id'];
603  }
604  }
605 
606  if ($ref_ids) {
607  self::preloadData($ref_ids);
608 
609  foreach ($items as $idx => $item) {
610  if (!$with_list_data) {
611  $items[$idx] = array_merge($item, self::getItem((int) $item['ref_id']));
612  } else {
613  self::addAdditionalSubItemInformation($item);
614  $items[$idx] = $item;
615  }
616  }
617  }
618  return $items;
619  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getItemsByEvent()

static ilObjectActivation::getItemsByEvent ( int  $event_id)
static

Get session material / event items.

Definition at line 562 of file class.ilObjectActivation.php.

Referenced by ilAppointmentPresentationSessionGUI\collectPropertiesAndActions(), ilAppointmentSessionFileHandler\getFiles(), ilContainer\getSubItems(), ilContainerGUI\redrawListItemObject(), ILIAS\Containter\Content\ItemRenderer\renderItem(), ilContainerContentGUI\renderItem(), ilContainerRenderer\renderItemBlockSequence(), and ilObjSessionGUI\showJoinRequestButton().

562  : array
563  {
564  $event_items = new ilEventItems($event_id);
565  return self::processListItems($event_items->getItems());
566  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ getItemsByItemGroup()

static ilObjectActivation::getItemsByItemGroup ( int  $item_group_ref_id)
static

Get materials of item group.

Definition at line 571 of file class.ilObjectActivation.php.

Referenced by ILIAS\Container\Content\ItemBlock\ItemBlockSequenceGenerator\getItemGroupItemRefIds(), ilContainerContentGUI\renderItemGroup(), and ilRepositoryExplorerGUI\sortChilds().

571  : array
572  {
573  $ig_items = new ilItemGroupItems($item_group_ref_id);
574  $items = $ig_items->getValidItems();
575  return self::processListItems($items);
576  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ getItemsByObjective()

static ilObjectActivation::getItemsByObjective ( int  $objective_id)
static

Get objective items.

Definition at line 581 of file class.ilObjectActivation.php.

References ilCourseObjectiveMaterials\_getAssignedMaterials().

Referenced by ILIAS\Container\Content\ItemBlock\ItemBlockSequenceGenerator\getBlocksForPart(), and ILIAS\Containter\Content\ObjectiveRenderer\renderObjective().

581  : array
582  {
583  $item_ids = ilCourseObjectiveMaterials::_getAssignedMaterials($objective_id);
584  return self::processListItems($item_ids);
585  }
static _getAssignedMaterials(int $a_objective_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTimingEnd()

ilObjectActivation::getTimingEnd ( )

Definition at line 87 of file class.ilObjectActivation.php.

References $timing_end.

Referenced by update().

87  : ?int
88  {
89  return $this->timing_end;
90  }
+ Here is the caller graph for this function:

◆ getTimingsAdministrationItems()

static ilObjectActivation::getTimingsAdministrationItems ( int  $parent_id)
static

Get (sub) item data for timings administration view (active/inactive)

Definition at line 624 of file class.ilObjectActivation.php.

References ilArrayUtil\sortArray().

Referenced by ilCourseContentGUI\__renderUserItem(), ilCourseContentGUI\manageTimings(), and ilCourseContentGUI\showUserTimings().

624  : array
625  {
626  $items = self::getItems($parent_id, false);
627  $active = $availability = $inactive = [];
628  foreach ($items as $item) {
629  if ($item['timing_type'] == self::TIMINGS_DEACTIVATED) {
630  $inactive[] = $item;
631  } elseif ($item['timing_type'] == self::TIMINGS_ACTIVATION) {
632  $availability[] = $item;
633  } else {
634  $active[] = $item;
635  }
636  }
637  $active = ilArrayUtil::sortArray($active, 'suggestion_start');
638  $availability = ilArrayUtil::sortArray($availability, 'timing_start');
639  $inactive = ilArrayUtil::sortArray($inactive, 'title');
640 
641  $items = array_merge($active, $availability, $inactive);
642  return $items;
643  }
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTimingsItems()

static ilObjectActivation::getTimingsItems ( int  $container_ref_id)
static

Get (sub) item data for timings view (no session material, no side blocks)

Definition at line 648 of file class.ilObjectActivation.php.

References $DIC, and ilEventItems\_getItemsOfContainer().

Referenced by ilCalendarScheduleFilterTimings\addCustomEvents(), and ilObjCourse\prepareAppointments().

648  : array
649  {
650  global $DIC;
651 
652  $objDefinition = $DIC["objDefinition"];
653 
654  $filtered = [];
655 
656  $event_items = ilEventItems::_getItemsOfContainer($container_ref_id);
657  foreach (self::getTimingsAdministrationItems($container_ref_id) as $item) {
658  if (!in_array($item['ref_id'], $event_items) &&
659  !$objDefinition->isSideBlock($item['type'])) {
660  $filtered[] = $item;
661  }
662  }
663 
664  return $filtered;
665  }
static _getItemsOfContainer(int $a_ref_id)
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTimingStart()

ilObjectActivation::getTimingStart ( )

Definition at line 77 of file class.ilObjectActivation.php.

References $timing_start.

Referenced by update().

77  : ?int
78  {
79  return $this->timing_start;
80  }
+ Here is the caller graph for this function:

◆ getTimingType()

ilObjectActivation::getTimingType ( )

Definition at line 67 of file class.ilObjectActivation.php.

References $timing_type.

Referenced by update().

67  : int
68  {
69  return $this->timing_type;
70  }
+ Here is the caller graph for this function:

◆ hasChangeableTimings()

static ilObjectActivation::hasChangeableTimings ( int  $ref_id)
static

Check if there is any active changeable timing (in subtree)

Definition at line 501 of file class.ilObjectActivation.php.

References $DIC, $res, ilDBInterface\in(), ilDBInterface\query(), and ilDBInterface\quote().

Referenced by ilCourseContentGUI\__renderUserItem(), and ilCourseContentGUI\showUserTimings().

501  : bool
502  {
503  global $DIC;
504 
505  $tree = $DIC->repositoryTree();
506  $db = $DIC->database();
507 
508  $subtree = $tree->getSubTree($tree->getNodeData($ref_id));
509  $ref_ids = [];
510  foreach ($subtree as $node) {
511  $ref_ids[] = $node['ref_id'];
512  }
513 
514  $sql =
515  "SELECT parent_id" . PHP_EOL
516  . "FROM crs_items" . PHP_EOL
517  . "WHERE timing_type = " . $db->quote(self::TIMINGS_PRESETTING, 'integer') . PHP_EOL
518  . "AND changeable = " . $db->quote(1, 'integer') . PHP_EOL
519  . "AND " . $db->in('obj_id', $ref_ids, false, 'integer') . PHP_EOL
520  ;
521  $res = $db->query($sql);
522  return (bool) $res->numRows();
523  }
$res
Definition: ltiservices.php:69
quote($value, string $type)
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
query(string $query)
Run a (read-only) Query on the database.
in(string $field, array $values, bool $negate=false, string $type="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasTimings()

static ilObjectActivation::hasTimings ( int  $ref_id)
static

Check if there is any active timing (in subtree)

Definition at line 475 of file class.ilObjectActivation.php.

References $DIC, $res, ilDBInterface\in(), ilDBInterface\query(), and ilDBInterface\quote().

Referenced by ilCourseMembershipGUI\initParticipantTableGUI().

475  : bool
476  {
477  global $DIC;
478 
479  $tree = $DIC->repositoryTree();
480  $db = $DIC->database();
481 
482  $subtree = $tree->getSubTree($tree->getNodeData($ref_id));
483  $ref_ids = [];
484  foreach ($subtree as $node) {
485  $ref_ids[] = $node['ref_id'];
486  }
487 
488  $sql =
489  "SELECT parent_id" . PHP_EOL
490  . "FROM crs_items" . PHP_EOL
491  . "WHERE timing_type = " . $db->quote(self::TIMINGS_PRESETTING, 'integer') . PHP_EOL
492  . "AND " . $db->in('obj_id', $ref_ids, false, 'integer') . PHP_EOL
493  ;
494  $res = $db->query($sql);
495  return (bool) $res->numRows();
496  }
$res
Definition: ltiservices.php:69
quote($value, string $type)
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
query(string $query)
Run a (read-only) Query on the database.
in(string $field, array $values, bool $negate=false, string $type="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ preloadData()

static ilObjectActivation::preloadData ( array  $ref_ids)
static

Preload data to internal cache.

Definition at line 176 of file class.ilObjectActivation.php.

References $DIC, ilDBInterface\fetchAssoc(), ilDBInterface\in(), and ilDBInterface\query().

Referenced by ilNewsItem\getAggregatedNewsData(), ilTimingsUser\init(), and ilObjectListGUIPreloader\preload().

176  : void
177  {
178  global $DIC;
179  $db = $DIC->database();
180 
181  $sql =
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
186  ;
187  $set = $db->query($sql);
188  while ($row = $db->fetchAssoc($set)) {
189  self::$preloaded_data[$row["obj_id"]] = $row;
190  }
191  }
fetchAssoc(ilDBStatement $statement)
global $DIC
Definition: feed.php:28
query(string $query)
Run a (read-only) Query on the database.
in(string $field, array $values, bool $negate=false, string $type="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processListItems()

static ilObjectActivation::processListItems ( array  $ref_ids)
staticprotected

Validate ref ids and add list data.

Definition at line 528 of file class.ilObjectActivation.php.

References $DIC, and $res.

528  : array
529  {
530  global $DIC;
531 
532  $tree = $DIC->repositoryTree();
533 
534  $res = [];
535 
536  foreach (array_map('intval', $ref_ids) as $item_ref_id) {
537  if ($tree->isDeleted($item_ref_id)) {
538  continue;
539  }
540  // #7571: when node is removed from system, e.g. inactive trashcan, an empty array is returned
541  $node = $tree->getNodeData($item_ref_id);
542  if (!isset($node["ref_id"]) || (int) $node["ref_id"] !== $item_ref_id) {
543  continue;
544  }
545  $res[$item_ref_id] = $node;
546  }
547 
548  if (count($res)) {
549  self::preloadData(array_keys($res));
550  foreach ($res as $idx => $item) {
551  self::addAdditionalSubItemInformation($item);
552  $res[$idx] = $item;
553  }
554  }
555 
556  return array_values($res);
557  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28

◆ read()

ilObjectActivation::read ( int  $ref_id,
int  $parent_id = 0 
)

Definition at line 667 of file class.ilObjectActivation.php.

References $DIC, $res, ilDBConstants\FETCHMODE_OBJECT, ilDBInterface\query(), ilDBInterface\quote(), setSuggestionEnd(), setSuggestionEndRelative(), setSuggestionStart(), setSuggestionStartRelative(), setTimingEnd(), setTimingStart(), setTimingType(), toggleChangeable(), and toggleVisible().

667  : void
668  {
669  global $DIC;
670  $db = $DIC->database();
671 
672  $sql =
673  "SELECT parent_id, obj_id, timing_type, timing_start, timing_end, suggestion_start," . PHP_EOL
674  . "suggestion_end, changeable, visible, position, suggestion_start_rel, suggestion_end_rel" . PHP_EOL
675  . "FROM crs_items" . PHP_EOL
676  . "WHERE obj_id = " . $db->quote($ref_id, 'integer') . PHP_EOL
677  ;
678 
679  if ($parent_id) {
680  $sql .= "AND parent_id = " . $db->quote($parent_id, "integer") . PHP_EOL;
681  }
682 
683  $res = $db->query($sql);
684  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
685  $this->setSuggestionStart((int) $row->suggestion_start);
686  $this->setSuggestionEnd((int) $row->suggestion_end);
687  $this->setSuggestionStartRelative((int) $row->suggestion_start_rel);
688  $this->setSuggestionEndRelative((int) $row->suggestion_end_rel);
689  $this->toggleVisible((bool) $row->visible);
690  $this->toggleChangeable((bool) $row->changeable);
691  $this->setTimingType((int) $row->timing_type);
692  $this->setTimingStart((int) $row->timing_start);
693  $this->setTimingEnd((int) $row->timing_end);
694  }
695  }
$res
Definition: ltiservices.php:69
quote($value, string $type)
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
query(string $query)
Run a (read-only) Query on the database.
+ Here is the call graph for this function:

◆ setSuggestionEnd()

ilObjectActivation::setSuggestionEnd ( ?int  $end)

Definition at line 116 of file class.ilObjectActivation.php.

Referenced by read().

116  : void
117  {
118  if ($end === 0) {
119  $end = null;
120  }
121  $this->suggestion_end = $end;
122  }
+ Here is the caller graph for this function:

◆ setSuggestionEndRelative()

ilObjectActivation::setSuggestionEndRelative ( int  $end)

Definition at line 108 of file class.ilObjectActivation.php.

Referenced by read().

108  : void
109  {
110  if ($end === 0) {
111  $end = null;
112  }
113  $this->suggestion_end_rel = $end;
114  }
+ Here is the caller graph for this function:

◆ setSuggestionStart()

ilObjectActivation::setSuggestionStart ( ?int  $start)

Definition at line 92 of file class.ilObjectActivation.php.

Referenced by read().

92  : void
93  {
94  if ($start === 0) {
95  $start = null;
96  }
97  $this->suggestion_start = $start;
98  }
+ Here is the caller graph for this function:

◆ setSuggestionStartRelative()

ilObjectActivation::setSuggestionStartRelative ( ?int  $start)

Definition at line 100 of file class.ilObjectActivation.php.

Referenced by read().

100  : void
101  {
102  if ($start === 0) {
103  $start = null;
104  }
105  $this->suggestion_start_rel = $start;
106  }
+ Here is the caller graph for this function:

◆ setTimingEnd()

ilObjectActivation::setTimingEnd ( ?int  $end)

Definition at line 82 of file class.ilObjectActivation.php.

Referenced by read().

82  : void
83  {
84  $this->timing_end = $end;
85  }
+ Here is the caller graph for this function:

◆ setTimingStart()

ilObjectActivation::setTimingStart ( ?int  $start)

Definition at line 72 of file class.ilObjectActivation.php.

Referenced by read().

72  : void
73  {
74  $this->timing_start = $start;
75  }
+ Here is the caller graph for this function:

◆ setTimingType()

ilObjectActivation::setTimingType ( int  $type)

Definition at line 62 of file class.ilObjectActivation.php.

Referenced by read().

62  : void
63  {
64  $this->timing_type = $type;
65  }
+ Here is the caller graph for this function:

◆ toggleChangeable()

ilObjectActivation::toggleChangeable ( bool  $status)

Definition at line 134 of file class.ilObjectActivation.php.

References ILIAS\Repository\int().

Referenced by read().

134  : void
135  {
136  $this->changeable = (int) $status;
137  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toggleVisible()

ilObjectActivation::toggleVisible ( bool  $status)

Definition at line 124 of file class.ilObjectActivation.php.

Referenced by read().

124  : void
125  {
126  $this->visible = $status;
127  }
+ Here is the caller graph for this function:

◆ update()

ilObjectActivation::update ( int  $ref_id,
?int  $parent_id = null 
)

Definition at line 144 of file class.ilObjectActivation.php.

References $ref_id, enabledChangeable(), enabledVisible(), getTimingEnd(), getTimingStart(), getTimingType(), and ILIAS\Repository\int().

144  : bool
145  {
146  $values = [
147  "timing_type" => ["integer", $this->getTimingType()],
148  "timing_start" => ["integer", $this->getTimingStart() ?? 0],
149  "timing_end" => ["integer", $this->getTimingEnd() ?? 0],
150  "suggestion_start" => ["integer", $this->suggestion_start ?? 0],
151  "suggestion_end" => ["integer", $this->suggestion_end ?? 0],
152  "changeable" => ["integer", (int) $this->enabledChangeable()],
153  "suggestion_start_rel" => ["integer", $this->suggestion_start_rel ?? 0],
154  "suggestion_end_rel" => ["integer", $this->suggestion_end_rel ?? 0],
155  "visible" => ["integer", $this->enabledVisible()]
156  ];
157 
158  if (!is_null($parent_id)) {
159  $values["parent_id"] = ["integer", $parent_id];
160  }
161 
162  $where = [
163  "obj_id" => ["integer", $ref_id]
164  ];
165 
166  $this->db->update("crs_items", $values, $where);
167 
168  unset(self::$preloaded_data[$ref_id]);
169 
170  return true;
171  }
$ref_id
Definition: ltiauth.php:67
+ Here is the call graph for this function:

Field Documentation

◆ $changeable

int ilObjectActivation::$changeable = 0
protected

Definition at line 48 of file class.ilObjectActivation.php.

Referenced by enabledChangeable().

◆ $db

ilDBInterface ilObjectActivation::$db
protected

Definition at line 40 of file class.ilObjectActivation.php.

◆ $error

ilErrorHandling ilObjectActivation::$error
protected

Definition at line 38 of file class.ilObjectActivation.php.

◆ $lng

ilLanguage ilObjectActivation::$lng
protected

Definition at line 39 of file class.ilObjectActivation.php.

◆ $preloaded_data

array ilObjectActivation::$preloaded_data = []
staticprotected

Definition at line 36 of file class.ilObjectActivation.php.

◆ $suggestion_end

int ilObjectActivation::$suggestion_end = null
protected

Definition at line 46 of file class.ilObjectActivation.php.

◆ $suggestion_end_rel

int ilObjectActivation::$suggestion_end_rel = null
protected

Definition at line 51 of file class.ilObjectActivation.php.

◆ $suggestion_start

int ilObjectActivation::$suggestion_start = null
protected

Definition at line 45 of file class.ilObjectActivation.php.

◆ $suggestion_start_rel

int ilObjectActivation::$suggestion_start_rel = null
protected

Definition at line 50 of file class.ilObjectActivation.php.

◆ $timing_end

int ilObjectActivation::$timing_end = null
protected

Definition at line 44 of file class.ilObjectActivation.php.

Referenced by getTimingEnd().

◆ $timing_start

int ilObjectActivation::$timing_start = null
protected

Definition at line 43 of file class.ilObjectActivation.php.

Referenced by getTimingStart().

◆ $timing_type

int ilObjectActivation::$timing_type = 0
protected

Definition at line 42 of file class.ilObjectActivation.php.

Referenced by getTimingType().

◆ $visible

bool ilObjectActivation::$visible = false
protected

Definition at line 47 of file class.ilObjectActivation.php.

Referenced by enabledVisible().

◆ ERR_SUG_START_END

const ilObjectActivation::ERR_SUG_START_END = 1

Definition at line 29 of file class.ilObjectActivation.php.

◆ TIMINGS_ACTIVATION

◆ TIMINGS_DEACTIVATED

◆ TIMINGS_FIXED

const ilObjectActivation::TIMINGS_FIXED = 3

Definition at line 34 of file class.ilObjectActivation.php.

◆ TIMINGS_PRESETTING


The documentation for this class was generated from the following file: