ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilObjectActivation Class Reference

Class ilObjectActivation. More...

+ Inheritance diagram for ilObjectActivation:
+ Collaboration diagram for ilObjectActivation:

Public Member Functions

 __construct ()
 
 setTimingType ($a_type)
 Set timing type. More...
 
 getTimingType ()
 get timing type More...
 
 setTimingStart ($a_start)
 Set timing start. More...
 
 getTimingStart ()
 Get timing start. More...
 
 setTimingEnd ($a_end)
 Set timing end. More...
 
 getTimingEnd ()
 Get timing end. More...
 
 setSuggestionStart ($a_start)
 Set suggestion start. More...
 
 getSuggestionStart ()
 Get suggestion start. More...
 
 setSuggestionEnd ($a_end)
 Set suggestion end. More...
 
 getSuggestionEnd ()
 Get suggestion end. More...
 
 setEarliestStart ($a_start)
 Set earliest start. More...
 
 getEarliestStart ()
 Get earliest start. More...
 
 setLatestEnd ($a_end)
 Set latest end. More...
 
 getLatestEnd ()
 Get latest end. More...
 
 toggleVisible ($a_status)
 Set visible status. More...
 
 enabledVisible ()
 Get visible status. More...
 
 toggleChangeable ($a_status)
 Set changeable status. More...
 
 enabledChangeable ()
 Get changeable status. More...
 
 validateActivation ()
 Validate current properties. More...
 
 update ($a_ref_id, $a_parent_id=null)
 Update db entry. More...
 

Static Public Member Functions

static preloadData (array $a_ref_ids)
 Preload data to internal cache. More...
 
static getItem ($a_ref_id)
 Get item data. More...
 
static addAdditionalSubItemInformation (array &$a_item)
 Parse item data for list entries. More...
 
static addListGUIActivationProperty (ilObjectListGUI $a_list_gui, array &$a_item)
 Get timing details for list gui. More...
 
static deleteAllEntries ($a_ref_id)
 Delete all db entries for ref id. More...
 
static cloneDependencies ($a_ref_id, $a_target_id, $a_copy_id)
 Clone dependencies. More...
 
static hasTimings ($a_ref_id)
 Check if there is any active timing (in subtree) More...
 
static hasChangeableTimings ($a_ref_id)
 Check if there is any active changeable timing (in subtree) More...
 
static getItemsByEvent ($a_event_id)
 Get session material / event items. More...
 
static getItemsByItemGroup ($a_item_group_ref_id)
 Get materials of item group. More...
 
static getItemsByObjective ($a_objective_id)
 Get objective items. More...
 
static getItems ($a_parent_id, $a_with_list_data=true)
 Get sub item data. More...
 
static getTimingsAdministrationItems ($a_parent_id)
 Get (sub) item data for timings administration view (active/inactive) More...
 
static getTimingsItems ($a_container_ref_id)
 Get (sub) item data for timings view (no session material, no side blocks) More...
 

Data Fields

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

Static Protected Member Functions

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

Protected Attributes

 $error
 
 $lng
 
 $db
 
 $timing_type
 
 $timing_start
 
 $timing_end
 
 $suggestion_start
 
 $suggestion_end
 
 $earliest_start
 
 $latest_end
 
 $visible
 
 $changeable
 

Static Protected Attributes

static $preloaded_data = array()
 

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 12 of file class.ilObjectActivation.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjectActivation::__construct ( )

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

References $DIC.

47  {
48  global $DIC;
49 
50  $this->error = $DIC["ilErr"];
51  $this->lng = $DIC->language();
52  $this->db = $DIC->database();
53  }
global $DIC
Definition: saml.php:7

Member Function Documentation

◆ addAdditionalSubItemInformation()

static ilObjectActivation::addAdditionalSubItemInformation ( array $a_item)
static

Parse item data for list entries.

Parameters
array&$a_item

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

References $DIC, $ilUser, $info, ilTimingPlaned\_getPlanedTimings(), ilSessionAppointment\_lookupAppointment(), ilObject\_lookupObjId(), and ilObject\_lookupType().

Referenced by ilObjRootFolder\addAdditionalSubItemInformation(), ilObjCategory\addAdditionalSubItemInformation(), ilObjFolder\addAdditionalSubItemInformation(), ilObjGroup\addAdditionalSubItemInformation(), and ilObjCourse\addAdditionalSubItemInformation().

354  {
355  global $DIC;
356 
357  $ilUser = $DIC->user();
358 
359  $item = self::getItem($a_item['ref_id']);
360 
361  $a_item['obj_id'] = ($a_item['obj_id'] > 0)
362  ? $a_item['obj_id']
363  : ilObject::_lookupObjId($a_item['ref_id']);
364  $a_item['type'] = ($a_item['type'] != '')
365  ? $a_item['type']
366  : ilObject::_lookupType($a_item['obj_id']);
367 
368  $a_item['timing_type'] = $item['timing_type'];
369 
370  if ($item['changeable'] &&
371  $item['timing_type'] == self::TIMINGS_PRESETTING) {
372  include_once 'Modules/Course/classes/Timings/class.ilTimingPlaned.php';
373  $user_data = ilTimingPlaned::_getPlanedTimings($ilUser->getId(), $a_item['ref_id']);
374  if ($user_data['planed_start']) {
375  $a_item['start'] = $user_data['planed_start'];
376  $a_item['end'] = $user_data['planed_end'];
377  $a_item['activation_info'] = 'crs_timings_planed_info';
378  } else {
379  $a_item['start'] = $item['suggestion_start'];
380  $a_item['end'] = $item['suggestion_end'];
381  $a_item['activation_info'] = 'crs_timings_suggested_info';
382  }
383  } elseif ($item['timing_type'] == self::TIMINGS_PRESETTING) {
384  $a_item['start'] = $item['suggestion_start'];
385  $a_item['end'] = $item['suggestion_end'];
386  $a_item['activation_info'] = 'crs_timings_suggested_info';
387  } elseif ($item['timing_type'] == self::TIMINGS_ACTIVATION) {
388  $a_item['start'] = $item['timing_start'];
389  $a_item['end'] = $item['timing_end'];
390  $a_item['activation_info'] = 'obj_activation_list_gui';
391  } else {
392  $a_item['start'] = 'abc';
393  }
394 
395  // #7359 - session sorting should always base on appointment date
396  if ($a_item['type'] == 'sess') {
397  include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
398  $info = ilSessionAppointment::_lookupAppointment($a_item['obj_id']);
399 
400  // #11987
401  $a_item['masked_start'] = $a_item['start'];
402  $a_item['masked_end'] = $a_item['end'];
403  $a_item['start'] = $info['start'];
404  $a_item['end'] = $info['end'];
405  }
406  }
global $DIC
Definition: saml.php:7
static _lookupObjId($a_id)
$ilUser
Definition: imgupload.php:18
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getPlanedTimings($a_usr_id, $a_item_id)
static _lookupAppointment($a_obj_id)
lookup appointment
$info
Definition: index.php:5
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addListGUIActivationProperty()

static ilObjectActivation::addListGUIActivationProperty ( ilObjectListGUI  $a_list_gui,
array $a_item 
)
static

Get timing details for list gui.

Parameters
ilObjectListGUI$a_list_gui
array&$a_item
Returns
array caption, value

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

References $DIC, $end, $lng, ilObjectListGUI\addCustomProperty(), ilDatePresentation\formatPeriod(), IL_CAL_UNIX, TIMINGS_ACTIVATION, and TIMINGS_PRESETTING.

Referenced by ilSearchResultTableGUI\fillRow(), ilObjSessionGUI\modifyItemGUI(), ilContainerContentGUI\renderItem(), and ilPDSelectedItemsBlockGUI\setFooterLinks().

416  {
417  global $DIC;
418 
419  $lng = $DIC->language();
420 
421  self::addAdditionalSubItemInformation($a_item);
422  if (isset($a_item['timing_type'])) {
423  if (!isset($a_item['masked_start'])) {
424  $start = $a_item['start'];
425  $end = $a_item['end'];
426  } else {
427  $start = $a_item['masked_start'];
428  $end = $a_item['masked_end'];
429  }
430  $activation = '';
431  switch ($a_item['timing_type']) {
433  $activation = ilDatePresentation::formatPeriod(
434  new ilDateTime($start, IL_CAL_UNIX),
436  );
437  break;
438 
440  $activation = ilDatePresentation::formatPeriod(
441  new ilDate($start, IL_CAL_UNIX),
442  new ilDate($end, IL_CAL_UNIX)
443  );
444  break;
445  }
446  if ($activation != "") {
447  global $DIC;
448 
449  $lng = $DIC->language();
450  $lng->loadLanguageModule('crs');
451 
452  $a_list_gui->addCustomProperty(
453  $lng->txt($a_item['activation_info']),
454  $activation,
455  false,
456  true
457  );
458  }
459  }
460  }
global $DIC
Definition: saml.php:7
$end
Definition: saml1-acs.php:18
const IL_CAL_UNIX
addCustomProperty( $a_property="", $a_value="", $a_alert=false, $a_newline=false)
add custom property
Class for single dates.
Date and time handling
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cloneDependencies()

static ilObjectActivation::cloneDependencies (   $a_ref_id,
  $a_target_id,
  $a_copy_id 
)
static

Clone dependencies.

Parameters
int$a_ref_id
int$a_target_id
int$a_copy_id

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

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

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

568  {
569  global $DIC;
570 
571  $ilLog = $DIC["ilLog"];
572 
573  $ilLog->write(__METHOD__ . ': Begin course items...');
574 
575  $items = self::getItems($a_ref_id);
576  if (!$items) {
577  $ilLog->write(__METHOD__ . ': No course items found.');
578  return true;
579  }
580 
581  // new course item object
582  if (!is_object($new_container = ilObjectFactory::getInstanceByRefId($a_target_id, false))) {
583  $ilLog->write(__METHOD__ . ': Cannot create target object.');
584  return false;
585  }
586 
587  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
588  $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
589  $mappings = $cp_options->getMappings();
590 
591  foreach ($items as $item) {
592  if (!isset($mappings[$item['parent_id']]) or !$mappings[$item['parent_id']]) {
593  $ilLog->write(__METHOD__ . ': No mapping for parent nr. ' . $item['parent_id']);
594  continue;
595  }
596  if (!isset($mappings[$item['obj_id']]) or !$mappings[$item['obj_id']]) {
597  $ilLog->write(__METHOD__ . ': No mapping for item nr. ' . $item['obj_id']);
598  continue;
599  }
600  $new_item_id = $mappings[$item['obj_id']];
601  $new_parent = $mappings[$item['parent_id']];
602 
603  $new_item = new self();
604  $new_item->setTimingType($item['timing_type']);
605  $new_item->setTimingStart($item['timing_start']);
606  $new_item->setTimingEnd($item['timing_end']);
607  $new_item->setSuggestionStart($item['suggestion_start']);
608  $new_item->setSuggestionEnd($item['suggestion_end']);
609  $new_item->toggleChangeable($item['changeable']);
610  $new_item->setEarliestStart($item['earliest_start']);
611  $new_item->setLatestEnd($item['latest_end']);
612  $new_item->toggleVisible($item['visible']);
613  $new_item->update($new_item_id, $new_parent);
614 
615  $ilLog->write(__METHOD__ . ': Added new entry for item nr. ' . $item['obj_id']);
616  }
617  $ilLog->write(__METHOD__ . ': Finished course items.');
618  }
global $DIC
Definition: saml.php:7
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createDefaultEntry()

static ilObjectActivation::createDefaultEntry (   $a_ref_id)
staticprotected

Create db entry with default values.

Parameters
int$a_ref_id
Returns
array

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

References $DIC, $ilDB, $query, array, ilDBInterface\manipulate(), ilDBInterface\numRows(), ilDBInterface\query(), ilDBInterface\quote(), and time.

469  {
470  global $DIC;
471 
472  $ilDB = $DIC->database();
473  $tree = $DIC->repositoryTree();
474 
475  $parent_id = $tree->getParentId($a_ref_id);
476  if (!$parent_id) {
477  return;
478  }
479 
480 
481  $ilAtomQuery = $ilDB->buildAtomQuery();
482  $ilAtomQuery->addTableLock("crs_items");
483 
484  $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDB) use ($a_ref_id, $parent_id, &$a_item) {
485  $sql = "SELECT * FROM crs_items" .
486  " WHERE obj_id = " . $ilDB->quote($a_ref_id, "integer");
487  $set = $ilDB->query($sql);
488  if (!$ilDB->numRows($set)) {
489  $now = time();
490  $now_parts = getdate($now);
491 
492  $a_item = array();
493  $a_item["timing_type"] = self::TIMINGS_DEACTIVATED;
494  $a_item["timing_start"] = $now;
495  $a_item["timing_end"] = $now;
496  $a_item["suggestion_start"] = $now;
497  $a_item["suggestion_end"] = $now;
498  $a_item['visible'] = 0;
499  $a_item['changeable'] = 0;
500  $a_item['earliest_start'] = $now;
501  $a_item['latest_end'] = mktime(23, 55, 00, $now_parts["mon"], $now_parts["mday"], $now_parts["year"]);
502  $a_item['visible'] = 0;
503  $a_item['changeable'] = 0;
504 
505  $query = "INSERT INTO crs_items (parent_id,obj_id,timing_type,timing_start,timing_end," .
506  "suggestion_start,suggestion_end, " .
507  "changeable,earliest_start,latest_end,visible,position) " .
508  "VALUES( " .
509  $ilDB->quote($parent_id, 'integer') . "," .
510  $ilDB->quote($a_ref_id, 'integer') . "," .
511  $ilDB->quote($a_item["timing_type"], 'integer') . "," .
512  $ilDB->quote($a_item["timing_start"], 'integer') . "," .
513  $ilDB->quote($a_item["timing_end"], 'integer') . "," .
514  $ilDB->quote($a_item["suggestion_start"], 'integer') . "," .
515  $ilDB->quote($a_item["suggestion_end"], 'integer') . "," .
516  $ilDB->quote($a_item["changeable"], 'integer') . "," .
517  $ilDB->quote($a_item['earliest_start'], 'integer') . ", " .
518  $ilDB->quote($a_item['latest_end'], 'integer') . ", " .
519  $ilDB->quote($a_item["visible"], 'integer') . ", " .
520  $ilDB->quote(0, 'integer') . ")";
521  $ilDB->manipulate($query);
522  }
523  });
524 
525  $ilAtomQuery->run();
526 
527  // #9982 - to make getItem()-cache work
528  $a_item["obj_id"] = $a_ref_id;
529  $a_item["parent_id"] = $parent_id;
530 
531  return $a_item;
532  }
global $DIC
Definition: saml.php:7
numRows($query_result)
Interface ilDBInterface.
quote($value, $type)
$query
Create styles array
The data for the language used.
global $ilDB
query($query)
Run a (read-only) Query on the database.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
manipulate($query)
Run a (write) Query on the database.
+ Here is the call graph for this function:

◆ deleteAllEntries()

static ilObjectActivation::deleteAllEntries (   $a_ref_id)
static

Delete all db entries for ref id.

Parameters
int$a_ref_id

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

References $DIC, $ilDB, and $query.

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

540  {
541  global $DIC;
542 
543  $ilDB = $DIC->database();
544 
545  if (!$a_ref_id) {
546  return;
547  }
548 
549  $query = "DELETE FROM crs_items " .
550  "WHERE obj_id = " . $ilDB->quote($a_ref_id, 'integer');
551  $ilDB->manipulate($query);
552 
553  $query = "DELETE FROM crs_items " .
554  "WHERE parent_id = " . $ilDB->quote($a_ref_id, 'integer');
555  $ilDB->manipulate($query);
556 
557  return true;
558  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ Here is the caller graph for this function:

◆ enabledChangeable()

ilObjectActivation::enabledChangeable ( )

Get changeable status.

Returns
bool

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

References $changeable.

Referenced by update().

233  {
234  return (bool) $this->changeable;
235  }
+ Here is the caller graph for this function:

◆ enabledVisible()

ilObjectActivation::enabledVisible ( )

Get visible status.

Returns
bool

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

References $visible.

Referenced by update().

213  {
214  return (bool) $this->visible;
215  }
+ Here is the caller graph for this function:

◆ getEarliestStart()

ilObjectActivation::getEarliestStart ( )

Get earliest start.

Returns
timestamp

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

References $earliest_start.

Referenced by update().

173  {
174  return $this->earliest_start;
175  }
+ Here is the caller graph for this function:

◆ getItem()

static ilObjectActivation::getItem (   $a_ref_id)
static

Get item data.

Parameters
int$a_ref_id
Returns
array

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

References $DIC, $ilDB, and $row.

Referenced by ilObjectXMLWriter\__appendTimeTargets(), ilObjCourse\__readSettings(), ilTimingCache\_getTimings(), ilObjPollAccess\_isActivated(), ilObjCourseAccess\_isActivated(), ilObjSurvey\checkReminder(), ilAccess\doActivationCheck(), ilObjPortfolioTemplate\doRead(), ilObjPoll\doRead(), ilObjectActivationGUI\getValues(), ilObjChatroomAccess\isActivated(), ilObjSurvey\loadFromDb(), ilObjTest\loadFromDb(), ilObjChatroom\read(), ilTimingCache\readObjectInformation(), ilObjSurvey\saveToDb(), ilObjTest\saveToDb(), ilObjPortfolioTemplate\updateActivation(), ilSoapObjectAdministration\updateReferences(), ilObjCourse\updateSettings(), ilCourseContentGUI\updateTimings(), ilTimingPlaned\validate(), and ilContainerXmlWriter\writeCourseItemInformation().

325  {
326  global $DIC;
327 
328  $ilDB = $DIC->database();
329 
330  if (isset(self::$preloaded_data[$a_ref_id])) {
331  return self::$preloaded_data[$a_ref_id];
332  }
333 
334  $sql = "SELECT * FROM crs_items" .
335  " WHERE obj_id = " . $ilDB->quote($a_ref_id, "integer");
336  $set = $ilDB->query($sql);
337  $row = $ilDB->fetchAssoc($set);
338 
339  if (!isset($row["obj_id"])) {
340  $row = self::createDefaultEntry($a_ref_id);
341  }
342  if ($row["obj_id"]) {
343  self::$preloaded_data[$row["obj_id"]] = $row;
344  }
345  return $row;
346  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ getItems()

static ilObjectActivation::getItems (   $a_parent_id,
  $a_with_list_data = true 
)
static

Get sub item data.

Parameters
int$a_parent_id
bool$a_with_list_data
Returns
array

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

References $DIC, and array.

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

763  {
764  global $DIC;
765 
766  $tree = $DIC->repositoryTree();
767 
768  $items = array();
769 
770  $ref_ids = array();
771  foreach ($tree->getChilds($a_parent_id) as $item) {
772  if ($item['type'] != 'rolf') {
773  $items[] = $item;
774  $ref_ids[] = $item['ref_id'];
775  }
776  }
777 
778  if ($ref_ids) {
779  self::preloadData($ref_ids);
780 
781  foreach ($items as $idx => $item) {
782  if (!$a_with_list_data) {
783  $items[$idx] = array_merge($item, self::getItem($item['ref_id']));
784  } else {
785  self::addAdditionalSubItemInformation($item);
786  $items[$idx] = $item;
787  }
788  }
789  }
790 
791  return $items;
792  }
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getItemsByEvent()

static ilObjectActivation::getItemsByEvent (   $a_event_id)
static

Get session material / event items.

Parameters
int$a_event_id(object id)
Returns
array

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

Referenced by ilAppointmentSessionFileHandler\getFiles(), ilObjSessionGUI\infoScreen(), ilContainerGUI\redrawListItemObject(), and ilContainerContentGUI\renderItem().

722  {
723  include_once 'Modules/Session/classes/class.ilEventItems.php';
724  $event_items = new ilEventItems($a_event_id);
725  return self::processListItems($event_items->getItems());
726  }
class ilEvent
+ Here is the caller graph for this function:

◆ getItemsByItemGroup()

static ilObjectActivation::getItemsByItemGroup (   $a_item_group_ref_id)
static

Get materials of item group.

Parameters
int$a_item_group_id(object id)
Returns
array

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

Referenced by ilContainerContentGUI\renderItemGroup(), and ilRepositoryExplorerGUI\sortChilds().

735  {
736  include_once 'Modules/ItemGroup/classes/class.ilItemGroupItems.php';
737  $ig_items = new ilItemGroupItems($a_item_group_ref_id);
738  $items = $ig_items->getValidItems();
739  return self::processListItems($items);
740  }
Item group items.
+ Here is the caller graph for this function:

◆ getItemsByObjective()

static ilObjectActivation::getItemsByObjective (   $a_objective_id)
static

Get objective items.

Parameters
int$a_objective_id
Returns
array

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

References ilCourseObjectiveMaterials\_getAssignedMaterials().

Referenced by ilContainerObjectiveGUI\renderObjective().

749  {
750  include_once('./Modules/Course/classes/class.ilCourseObjectiveMaterials.php');
751  $item_ids = ilCourseObjectiveMaterials::_getAssignedMaterials($a_objective_id);
752  return self::processListItems($item_ids);
753  }
static _getAssignedMaterials($a_objective_id)
get assigned materials
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLatestEnd()

ilObjectActivation::getLatestEnd ( )

Get latest end.

Returns
timestamp

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

References $latest_end.

Referenced by update().

193  {
194  return $this->latest_end;
195  }
+ Here is the caller graph for this function:

◆ getSuggestionEnd()

ilObjectActivation::getSuggestionEnd ( )

Get suggestion end.

Returns
timestamp

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

References $suggestion_end.

Referenced by update(), and validateActivation().

153  {
154  return $this->suggestion_end;
155  }
+ Here is the caller graph for this function:

◆ getSuggestionStart()

ilObjectActivation::getSuggestionStart ( )

Get suggestion start.

Returns
timestamp

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

References $suggestion_start.

Referenced by update(), and validateActivation().

133  {
135  }
+ Here is the caller graph for this function:

◆ getTimingEnd()

ilObjectActivation::getTimingEnd ( )

Get timing end.

Returns
timestamp

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

References $timing_end.

Referenced by update(), and validateActivation().

113  {
114  return $this->timing_end;
115  }
+ Here is the caller graph for this function:

◆ getTimingsAdministrationItems()

static ilObjectActivation::getTimingsAdministrationItems (   $a_parent_id)
static

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

Parameters
int$a_parent_id
Returns
array

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

References array, and ilUtil\sortArray().

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

801  {
802  $items = self::getItems($a_parent_id, false);
803 
804  if ($items) {
805  $active = $inactive = array();
806  foreach ($items as $item) {
807  // active should be first in order
808  if ($item['timing_type'] == self::TIMINGS_DEACTIVATED) {
809  $inactive[] = $item;
810  } else {
811  $active[] = $item;
812  }
813  }
814 
815  $active = ilUtil::sortArray($active, 'start', 'asc');
816  $inactive = ilUtil::sortArray($inactive, 'title', 'asc');
817  $items = array_merge($active, $inactive);
818  }
819 
820  return $items;
821  }
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTimingsItems()

static ilObjectActivation::getTimingsItems (   $a_container_ref_id)
static

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

Parameters
int$a_container_ref_id
Returns
array

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

References $DIC, ilEventItems\_getItemsOfContainer(), and array.

Referenced by ilCourseContentGUI\__editAdvancedUserTimings(), ilCourseContentGUI\__editUserTimings(), and ilCourseContentGUI\__renderItem().

830  {
831  global $DIC;
832 
833  $objDefinition = $DIC["objDefinition"];
834 
835  $filtered = array();
836 
837  include_once 'Modules/Session/classes/class.ilEventItems.php';
838  $event_items = ilEventItems::_getItemsOfContainer($a_container_ref_id);
839  foreach (self::getTimingsAdministrationItems($a_container_ref_id) as $item) {
840  if (!in_array($item['ref_id'], $event_items) &&
841  !$objDefinition->isSideBlock($item['type'])) {
842  $filtered[] = $item;
843  }
844  }
845 
846  return $filtered;
847  }
global $DIC
Definition: saml.php:7
static _getItemsOfContainer($a_ref_id)
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTimingStart()

ilObjectActivation::getTimingStart ( )

Get timing start.

Returns
timestamp

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

References $timing_start.

Referenced by update(), and validateActivation().

+ Here is the caller graph for this function:

◆ getTimingType()

ilObjectActivation::getTimingType ( )

get timing type

See also
class constants
Returns
int

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

References $timing_type.

Referenced by update(), and validateActivation().

+ Here is the caller graph for this function:

◆ hasChangeableTimings()

static ilObjectActivation::hasChangeableTimings (   $a_ref_id)
static

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

Parameters
intref_id
Returns
bool

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

References $DIC, $ilDB, $query, $res, and array.

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

658  {
659  global $DIC;
660 
661  $tree = $DIC->repositoryTree();
662  $ilDB = $DIC->database();
663 
664  $subtree = $tree->getSubTree($tree->getNodeData($a_ref_id));
665  $ref_ids = array();
666  foreach ($subtree as $node) {
667  $ref_ids[] = $node['ref_id'];
668  }
669 
670  $query = "SELECT * FROM crs_items " .
671  "WHERE timing_type = " . $ilDB->quote(self::TIMINGS_PRESETTING, 'integer') . " " .
672  "AND changeable = " . $ilDB->quote(1, 'integer') . " " .
673  "AND " . $ilDB->in('obj_id', $ref_ids, false, 'integer');
674  $res = $ilDB->query($query);
675  return $res->numRows() ? true : false;
676  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ hasTimings()

static ilObjectActivation::hasTimings (   $a_ref_id)
static

Check if there is any active timing (in subtree)

Parameters
intref_id
Returns
bool

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

References $DIC, $ilDB, $query, $res, and array.

Referenced by ilCourseMembershipGUI\initParticipantTableGUI().

632  {
633  global $DIC;
634 
635  $tree = $DIC->repositoryTree();
636  $ilDB = $DIC->database();
637 
638  $subtree = $tree->getSubTree($tree->getNodeData($a_ref_id));
639  $ref_ids = array();
640  foreach ($subtree as $node) {
641  $ref_ids[] = $node['ref_id'];
642  }
643 
644  $query = "SELECT * FROM crs_items " .
645  "WHERE timing_type = " . $ilDB->quote(self::TIMINGS_PRESETTING, 'integer') . " " .
646  "AND " . $ilDB->in('obj_id', $ref_ids, false, 'integer');
647  $res = $ilDB->query($query);
648  return $res->numRows() ? true :false;
649  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ preloadData()

static ilObjectActivation::preloadData ( array  $a_ref_ids)
static

Preload data to internal cache.

Parameters
array$a_ref_ids

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

References $DIC, $ilDB, and $row.

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

305  {
306  global $DIC;
307 
308  $ilDB = $DIC->database();
309 
310  $sql = "SELECT * FROM crs_items" .
311  " WHERE " . $ilDB->in("obj_id", $a_ref_ids, "", "integer");
312  $set = $ilDB->query($sql);
313  while ($row = $ilDB->fetchAssoc($set)) {
314  self::$preloaded_data[$row["obj_id"]] = $row;
315  }
316  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ processListItems()

static ilObjectActivation::processListItems ( array  $a_ref_ids)
staticprotected

Validate ref ids and add list data.

Parameters
array$a_ref_ids
Returns
array

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

References $DIC, $res, and array.

685  {
686  global $DIC;
687 
688  $tree = $DIC->repositoryTree();
689 
690  $res = array();
691 
692  foreach ($a_ref_ids as $item_ref_id) {
693  if ($tree->isDeleted($item_ref_id)) {
694  continue;
695  }
696  // #7571: when node is removed from system, e.g. inactive trashcan, an empty array is returned
697  $node = $tree->getNodeData($item_ref_id);
698  if ($node["ref_id"] != $item_ref_id) {
699  continue;
700  }
701  $res[$item_ref_id] = $node;
702  }
703 
704  if (sizeof($res)) {
705  self::preloadData(array_keys($res));
706  foreach ($res as $idx => $item) {
707  self::addAdditionalSubItemInformation($item);
708  $res[$idx] = $item;
709  }
710  }
711 
712  return array_values($res);
713  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.

◆ setEarliestStart()

ilObjectActivation::setEarliestStart (   $a_start)

Set earliest start.

Parameters
timestamp$a_start

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

163  {
164  $this->earliest_start = $a_start;
165  }

◆ setLatestEnd()

ilObjectActivation::setLatestEnd (   $a_end)

Set latest end.

Parameters
timestamp$a_end

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

183  {
184  $this->latest_end = $a_end;
185  }

◆ setSuggestionEnd()

ilObjectActivation::setSuggestionEnd (   $a_end)

Set suggestion end.

Parameters
timestamp$a_end

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

143  {
144  $this->suggestion_end = $a_end;
145  }

◆ setSuggestionStart()

ilObjectActivation::setSuggestionStart (   $a_start)

Set suggestion start.

Parameters
timestamp$a_start

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

123  {
124  $this->suggestion_start = $a_start;
125  }

◆ setTimingEnd()

ilObjectActivation::setTimingEnd (   $a_end)

Set timing end.

Parameters
timestamp$a_end

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

103  {
104  $this->timing_end = $a_end;
105  }

◆ setTimingStart()

ilObjectActivation::setTimingStart (   $a_start)

Set timing start.

Parameters
timestamp$a_start

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

83  {
84  $this->timing_start = $a_start;
85  }

◆ setTimingType()

ilObjectActivation::setTimingType (   $a_type)

Set timing type.

See also
class constants
Parameters
int$a_type

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

References $a_type.

Referenced by ilObjSurvey\saveToDb(), ilObjTest\saveToDb(), ilObjPortfolioTemplate\updateActivation(), and ilObjCourse\updateSettings().

62  {
63  $this->timing_type = $a_type;
64  }
$a_type
Definition: workflow.php:92
+ Here is the caller graph for this function:

◆ toggleChangeable()

ilObjectActivation::toggleChangeable (   $a_status)

Set changeable status.

Parameters
bool$a_status

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

223  {
224  $this->changeable = (int) $a_status;
225  }

◆ toggleVisible()

ilObjectActivation::toggleVisible (   $a_status)

Set visible status.

Parameters
bool$a_status

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

203  {
204  $this->visible = (int) $a_status;
205  }

◆ update()

ilObjectActivation::update (   $a_ref_id,
  $a_parent_id = null 
)

Update db entry.

Parameters
int$a_ref_id
int$a_parent_id

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

References $db, $ilDB, $query, enabledChangeable(), enabledVisible(), getEarliestStart(), getLatestEnd(), getSuggestionEnd(), getSuggestionStart(), getTimingEnd(), getTimingStart(), and getTimingType().

272  {
273  $ilDB = $this->db;
274 
275  // #10110
276  $query = "UPDATE crs_items SET " .
277  "timing_type = " . $ilDB->quote($this->getTimingType(), 'integer') . ", " .
278  "timing_start = " . $ilDB->quote((int) $this->getTimingStart(), 'integer') . ", " .
279  "timing_end = " . $ilDB->quote((int) $this->getTimingEnd(), 'integer') . ", " .
280  "suggestion_start = " . $ilDB->quote((int) $this->getSuggestionStart(), 'integer') . ", " .
281  "suggestion_end = " . $ilDB->quote((int) $this->getSuggestionEnd(), 'integer') . ", " .
282  "changeable = " . $ilDB->quote($this->enabledChangeable(), 'integer') . ", " .
283  "earliest_start = " . $ilDB->quote((int) $this->getEarliestStart(), 'integer') . ", " .
284  "latest_end = " . $ilDB->quote((int) $this->getLatestEnd(), 'integer') . ", ";
285 
286  if ($a_parent_id) {
287  $query .= "parent_id = " . $ilDB->quote($a_parent_id, 'integer') . ", ";
288  }
289 
290  $query .= "visible = " . $ilDB->quote($this->enabledVisible(), 'integer') . " " .
291  "WHERE obj_id = " . $ilDB->quote($a_ref_id, 'integer');
292  $ilDB->manipulate($query);
293 
294  unset(self::$preloaded_data[$a_ref_id]);
295 
296  return true;
297  }
getTimingEnd()
Get timing end.
enabledVisible()
Get visible status.
getSuggestionEnd()
Get suggestion end.
getTimingStart()
Get timing start.
$query
getTimingType()
get timing type
getSuggestionStart()
Get suggestion start.
enabledChangeable()
Get changeable status.
getLatestEnd()
Get latest end.
global $ilDB
getEarliestStart()
Get earliest start.
+ Here is the call graph for this function:

◆ validateActivation()

ilObjectActivation::validateActivation ( )

Validate current properties.

Returns
boolean

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

References $error, $ilErr, $lng, getSuggestionEnd(), getSuggestionStart(), getTimingEnd(), getTimingStart(), and getTimingType().

243  {
245  $lng = $this->lng;
246 
247  $ilErr->setMessage('');
248 
249  if ($this->getTimingType() == self::TIMINGS_ACTIVATION) {
250  if ($this->getTimingStart() > $this->getTimingEnd()) {
251  $ilErr->appendMessage($lng->txt("crs_activation_start_invalid"));
252  }
253  } elseif ($this->getTimingType() == self::TIMINGS_PRESETTING) {
254  if ($this->getSuggestionStart() > $this->getSuggestionEnd()) {
255  $ilErr->appendMessage($lng->txt('crs_latest_end_not_valid'));
256  }
257  }
258 
259  if ($ilErr->getMessage()) {
260  return false;
261  }
262  return true;
263  }
getTimingEnd()
Get timing end.
global $ilErr
Definition: raiseError.php:16
getSuggestionEnd()
Get suggestion end.
getTimingStart()
Get timing start.
getTimingType()
get timing type
getSuggestionStart()
Get suggestion start.
+ Here is the call graph for this function:

Field Documentation

◆ $changeable

ilObjectActivation::$changeable
protected

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

Referenced by enabledChangeable().

◆ $db

ilObjectActivation::$db
protected

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

Referenced by update().

◆ $earliest_start

ilObjectActivation::$earliest_start
protected

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

Referenced by getEarliestStart().

◆ $error

ilObjectActivation::$error
protected

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

Referenced by validateActivation().

◆ $latest_end

ilObjectActivation::$latest_end
protected

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

Referenced by getLatestEnd().

◆ $lng

ilObjectActivation::$lng
protected

◆ $preloaded_data

ilObjectActivation::$preloaded_data = array()
staticprotected

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

◆ $suggestion_end

ilObjectActivation::$suggestion_end
protected

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

Referenced by getSuggestionEnd().

◆ $suggestion_start

ilObjectActivation::$suggestion_start
protected

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

Referenced by getSuggestionStart().

◆ $timing_end

ilObjectActivation::$timing_end
protected

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

Referenced by getTimingEnd().

◆ $timing_start

ilObjectActivation::$timing_start
protected

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

Referenced by getTimingStart().

◆ $timing_type

ilObjectActivation::$timing_type
protected

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

Referenced by getTimingType().

◆ $visible

ilObjectActivation::$visible
protected

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

Referenced by enabledVisible().

◆ TIMINGS_ACTIVATION

◆ TIMINGS_DEACTIVATED

◆ TIMINGS_FIXED

const ilObjectActivation::TIMINGS_FIXED = 3

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

◆ TIMINGS_PRESETTING


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