3 declare(strict_types=1);
    43         $this->tree = $DIC->repositoryTree();
    44         $this->db = $DIC->database();
    56         static $instances = [];
    58         if (!isset($instances[$obj_id])) {
    60             $class = self::getTypeClass($type);
    62                 $instance = 
new $class($obj_id);
    67             $instances[
$obj_id] = $instance;
    75         $objDefinition = $DIC[
"objDefinition"];
    76         if (self::isSupportedObjectType($type)) {
    82                     return 'ilCourseReferenceLP';
    92                     return "ilLearningModuleLP";
    94                     return "ilHTMLLearningModuleLP";
   102                     return "ilExerciseLP";
   106                     return "ilMediaCastLP";
   108                     return  "ilSessionLP";
   112                     return "ilStudyProgrammeLP";
   114                     return "ilIndividualAssessmentLP";
   116                     return "ilContentPageLP";
   118                     return ilCmiXapiLP::class;
   120                     return ilLTIConsumerLP::class;
   122                     return ilForumLP::class;
   124             if ($objDefinition->isPluginTypeName($type)) {
   134         $component_repository = $DIC[
"component.repository"];
   159         $plugins = $component_repository->getPluginSlotById(
"robj")->getActivePlugins();
   160         foreach ($plugins as 
$plugin) {
   161             $type = $plugin->getId();
   173         $valid = self::getSupportedObjectTypes();
   175         if (in_array($type, 
$valid)) {
   185         $this->collection_instance = null;
   209         if ($this->mode === null) {
   213                 if ($mode === null) {
   221                 if ($mode === null) {
   226             $this->mode = (
int) $mode;
   263         if ($this->collection_instance === null) {
   281         foreach (array_reverse(
$path) as $path_ref_id) {
   283             $all = $olp->getMembers(
false);
   284             if (is_array($all)) {
   294         if (
sizeof($user_ids)) {
   301         if ($recursive && method_exists($this, 
"getPossibleCollectionItems")) { 
   302             $subitems = $this->getPossibleCollectionItems();
   303             if (is_array($subitems)) {
   304                 foreach ($subitems as $sub_ref_id) {
   306                     $olp->resetLPDataForUserIds($user_ids, 
false);
   334     final public static function handleMove(
int $source_ref_id): void
   338         $tree = $DIC->repositoryTree();
   339         $ilDB = $DIC->database();
   342         $ref_ids[] = $source_ref_id;
   345         $new_path = $tree->
getPathId($source_ref_id);
   346         array_pop($new_path);
   347         $new_path = implode(
"/", $new_path);
   351             "SELECT DISTINCT(ut_lp_collections.obj_id) obj_id" . PHP_EOL
   352             . 
"FROM object_reference" . PHP_EOL
   353             . 
"JOIN ut_lp_collections ON" . PHP_EOL
   354             . 
"(" . 
$ilDB->in(
"object_reference.ref_id", $ref_ids, 
false, 
"integer") . PHP_EOL
   355             . 
"AND object_reference.ref_id = ut_lp_collections.item_id)" . PHP_EOL
   357         $result = 
$ilDB->query($sql);
   358         while ($row = 
$ilDB->fetchAssoc($result)) {
   361                 $coll_ref_id = array_pop($coll_ref_id);
   364                 if ($coll_ref_id == $source_ref_id) {
   369                 if ($tree->
isGrandChild($source_ref_id, $coll_ref_id)) {
   374                 $coll_path = $tree->
getPathId($coll_ref_id);
   375                 $coll_path = implode(
"/", $coll_path);
   378                 if (!stristr($new_path, $coll_path)) {
   381                         "DELETE FROM ut_lp_collections" . PHP_EOL
   382                         . 
"WHERE obj_id = " . 
$ilDB->quote($row[
"obj_id"], 
"integer") . PHP_EOL
   383                         . 
"AND " . 
$ilDB->in(
"item_id", $ref_ids, 
false, 
"integer") . PHP_EOL
   385                     $ilDB->manipulate($sql);
   406             $collection->delete();
   416             "SELECT ut_lp_collections.obj_id obj_id" . PHP_EOL
   417             . 
"FROM object_reference" . PHP_EOL
   418             . 
"JOIN ut_lp_collections ON" . PHP_EOL
   419             . 
"(object_reference.obj_id = " . $this->db->quote($this->obj_id, 
"integer") . PHP_EOL
   420             . 
"AND object_reference.ref_id = ut_lp_collections.item_id)" . PHP_EOL
   422         $result = $this->db->query($sql);
   423         while ($row = $this->db->fetchAssoc($result)) {
   427                     "DELETE FROM ut_lp_collections" . PHP_EOL
   428                     . 
"WHERE obj_id = " . $this->db->quote($row[
"obj_id"], 
"integer") . PHP_EOL
   429                     . 
"AND item_id = " . $this->db->quote($this->obj_id, 
"integer") . PHP_EOL
   431                 $this->db->manipulate($sql);
   441     protected static function isLPMember(array &
$res, 
int $usr_id, array $obj_ids): bool
   455         bool $mapped_ref_ids = 
false   459         $tree = $DIC->repositoryTree();
   465         foreach (array_reverse(
$path) as $path_ref_id) {
   467             if ($type == 
"crs" || $type == 
"grp") {
   468                 $class = self::getTypeClass($type);
   471                 $class::isLPMember($chk, $usr_id, [$path_ob_id]);
   472                 if (!$mapped_ref_ids) {
   474                     foreach ($obj_ids as $obj_id) {
   476                         if ($chk[$path_ob_id] ?? 
false) {
   482                     foreach ($obj_ids as $obj_id => $ref_ids) {
   483                         foreach ($ref_ids as 
$ref_id) {
   486                                 if ($chk[$path_ob_id] ?? 
false) {
   507         ?
int $parent_ref_id = null,
   508         bool $mapped_ref_ids = 
false   512         $ilDB = $DIC->database();
   513         $tree = $DIC->repositoryTree();
   519         if ($mapped_ref_ids) {
   521             $obj_ids = array_keys($obj_ids);
   529             "SELECT obj_id, type" . PHP_EOL
   530             . 
"FROM object_data" . PHP_EOL
   531             . 
"WHERE " . 
$ilDB->in(
"obj_id", $obj_ids, 
false, 
"integer") . PHP_EOL
   533         $result = 
$ilDB->query($sql);
   534         while ($row = 
$ilDB->fetchAssoc($result)) {
   535             $types_map[$row[
"type"]][] = (
int) $row[
"obj_id"];
   536             $res[(
int) $row[
"obj_id"]] = 
false;
   539         $find_by_parent = [];
   540         foreach ($types_map as $type => $type_obj_ids) {
   541             $class = self::getTypeClass($type);
   544                 if (!$class::isLPMember(
$res, $usr_id, $type_obj_ids)) {
   545                     $find_by_parent = array_merge($find_by_parent, $type_obj_ids);
   550         if (
sizeof($find_by_parent)) {
   552             if ($parent_ref_id) {
   553                 if (self::findMembershipsByPath(
$res, $usr_id, $parent_ref_id, $find_by_parent)) {
   555                     $find_by_parent = null;
   559             elseif (is_array($ref_map) && count($ref_map) > 0) {
   560                 foreach ($find_by_parent as $obj_id) {
   562                     if (
$res[$obj_id] === 
false) {
   563                         if (isset($ref_map[$obj_id]) && is_array($ref_map[$obj_id])) {
   565                             foreach ($ref_map[$obj_id] as 
$ref_id) {
   573                                 $found = self::findMembershipsByPath(
$res, $usr_id, $parent_ref_id, $ref_map, 
true);
   574                                 if (is_array($found) && count($found) > 0) {
   577                                     foreach ($found as $found_obj_id => $found_ref_ids) {
   578                                         $diff = array_diff($ref_map[$found_obj_id], $found_ref_ids);
   582                                             $ref_map[$found_obj_id] = $diff;
   586                                             unset($ref_map[$found_obj_id]);
   596                 $find_by_parent = array_keys($ref_map);
   600             if (is_array($find_by_parent) && count($find_by_parent) > 0) {
   602                     "SELECT obj_id" . PHP_EOL
   603                     . 
"FROM read_event" . PHP_EOL
   604                     . 
"WHERE " . 
$ilDB->in(
"obj_id", $find_by_parent, 
false, 
"integer") . PHP_EOL
   605                     . 
"AND usr_id = " . 
$ilDB->quote($usr_id, 
"integer") . PHP_EOL
   607                 $result = 
$ilDB->query($sql);
   608                 while ($row = 
$ilDB->fetchAssoc($result)) {
   609                     $res[(
int) $row[
"obj_id"]] = 
true;
   629         return !in_array($obj_type, [
"exc", 
"file", 
"mcst", 
"mob", 
"htlm", 
"copa", 
'cmix', 
'lti', 
'frm']);
   634         return !in_array($obj_type, [
"lm", 
"dbk"]);
   639         $types = [
'svy', 
'tst', 
'htlm', 
'exc', 
'sess', 
'file', 
'frm', 
'prg', 
'copa', 
'cmix', 
'lti',
'crsr', 
'iass'];
   640         return !in_array($obj_type, $types);
   655         $ilDB = $DIC->database();
   657         if (is_null(self::$type_defaults)) {
   658             self::$type_defaults = [];
   659             $result = 
$ilDB->query(
"SELECT type_id, lp_mode FROM ut_lp_defaults");
   660             while ($row = 
$ilDB->fetchAssoc($result)) {
   661                 self::$type_defaults[(string) $row[
"type_id"]] = (
int) $row[
"lp_mode"];
   664         return self::$type_defaults[$type] ?? null;
   670         $ilDB = $DIC->database();
   672         $ilDB->manipulate(
"DELETE FROM ut_lp_defaults");
   673         foreach ($data as $type => $mode) {
   674             $ilDB->insert(
"ut_lp_defaults", [
   675                 "type_id" => [
"text", $type],
   676                 "lp_mode" => [
"integer", $mode]
   683         $db = self::getTypeDefaultFromDB($type);
   688         $class = self::getTypeClass($type);
   689         $olp = 
new $class(0);
   690         return $olp->getDefaultMode();
 
static _delete(int $a_obj_id)
Delete object entries. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
appendModeConfiguration(int $mode, ilRadioOption $modeElement)
 
static getLPMemberships(int $usr_id, array $obj_ids, ?int $parent_ref_id=null, bool $mapped_ref_ids=false)
Get all objects where given user is member (from LP POV) 
 
static isSupportedObjectType(string $type)
 
static getTypeDefaultFromDB(string $type)
 
resetCustomLPDataForUserIds(array $user_ids, bool $recursive=true)
 
ilObjectDefinition $objectDefinition
 
static supportsMatrixView(string $obj_type)
 
fetchIndividualModeFromFormSubmission(ilPropertyFormGUI $form)
 
static handleMove(int $source_ref_id)
 
static _getAllUserIds(int $a_obj_id)
 
static getSupportedObjectTypes()
 
static _getAllReferences(int $id)
get all reference ids for object ID 
 
static _mode2InfoText(int $a_mode)
 
static getTypeDefault(string $type)
 
static findMembershipsByPath(array &$res, int $usr_id, int $parent_ref_id, array $obj_ids, bool $mapped_ref_ids=false)
Find (lp-relevant) memberships by path. 
 
getSubTreeIds(int $a_ref_id)
Get all ids of subnodes. 
 
shouldFetchIndividualModeFromFormSubmission()
 
static getDefaultModes(bool $lp_active)
Get available type-specific default modes (no administration needed) 
 
static saveTypeDefaults(array $data)
 
updateParentCollections()
 
saveModeConfiguration(ilPropertyFormGUI $form, bool &$modeChanged)
 
static _lookupObjId(int $ref_id)
 
isGrandChild(int $a_startnode_id, int $a_querynode_id)
checks if a node is in the path of an other node 
 
static array $type_defaults
 
getMembers(bool $search=true)
 
static getInstanceByMode(int $a_obj_id, int $a_mode)
 
static _enabledLearningProgress()
 
static deleteObject(int $a_obj_id)
 
static _deleteForUsers(int $a_obj_id, array $a_user_ids)
 
static _refreshStatus(int $a_obj_id, ?array $a_users=null)
 
initInvidualModeOptions(ilRadioGroupInputGUI $modeRadio)
 
ilLPCollection $collection_instance
 
getParentId(int $a_node_id)
get parent id of given node 
 
static _lookupDBMode(int $a_obj_id)
 
resetLPDataForCompleteObject(bool $recursive=true)
 
hasIndividualModeOptions()
 
LP collection base class. 
 
static isTypePluginWithLP(string $a_type, bool $a_active_status=true)
 
static supportsSpentSeconds(string $obj_type)
 
const LP_MODE_DEACTIVATED
 
getPathId(int $a_endnode_id, int $a_startnode_id=0)
get path from a given startnode to a given endnode if startnode is not given the rootnode is startnod...
 
resetLPDataForUserIds(array $user_ids, bool $recursive=true)
 
getModeInfoText(int $mode)
 
static getTypeClass(string $type)
 
static _deleteReadEventsForUsers(int $a_obj_id, array $a_user_ids)
 
static supportsMark(string $obj_type)
 
static _lookupType(int $id, bool $reference=false)
 
static getInstance(int $obj_id)
 
static _getAllUserIds(int $a_obj_id)
 
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
 
static isLPMember(array &$res, int $usr_id, array $obj_ids)
Find (lp-relevant) members for given object ids. 
 
static _mode2Text(int $a_mode)