Exemplo n.º 1
0
 /**
  * Get subitems of container
  * 
  * @param bool administration panel enabled
  * @param bool side blocks enabled
  *
  * @return	array
  */
 function getSubItems($a_admin_panel_enabled = false, $a_include_side_block = false, $a_get_single = 0)
 {
     global $objDefinition, $ilBench, $tree, $ilObjDataCache, $ilUser, $rbacsystem, $ilSetting;
     // Caching
     if (is_array($this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]) && !$a_get_single) {
         return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block];
     }
     $type_grps = $this->getGroupedObjTypes();
     $objects = $tree->getChilds($this->getRefId(), "title");
     // using long descriptions?
     $short_desc = $ilSetting->get("rep_shorten_description");
     $short_desc_max_length = $ilSetting->get("rep_shorten_description_length");
     if (!$short_desc || $short_desc_max_length != ilObject::TITLE_LENGTH) {
         // using (part of) shortened description
         if ($short_desc && $short_desc_max_length && $short_desc_max_length < ilObject::TITLE_LENGTH) {
             foreach ($objects as $key => $object) {
                 $objects[$key]["description"] = ilUtil::shortenText($object["description"], $short_desc_max_length, true);
             }
         } else {
             $obj_ids = array();
             foreach ($objects as $key => $object) {
                 $obj_ids[] = $object["obj_id"];
             }
             if (sizeof($obj_ids)) {
                 $long_desc = ilObject::getLongDescriptions($obj_ids);
                 foreach ($objects as $key => $object) {
                     // #12166 - keep translation, ignore long description
                     if ($ilObjDataCache->isTranslatedDescription($object["obj_id"])) {
                         $long_desc[$object["obj_id"]] = $object["description"];
                     }
                     if ($short_desc && $short_desc_max_length) {
                         $long_desc[$object["obj_id"]] = ilUtil::shortenText($long_desc[$object["obj_id"]], $short_desc_max_length, true);
                     }
                     $objects[$key]["description"] = $long_desc[$object["obj_id"]];
                 }
             }
         }
     }
     $found = false;
     $all_ref_ids = array();
     if (!self::$data_preloaded) {
         include_once "./Services/Object/classes/class.ilObjectListGUIPreloader.php";
         $preloader = new ilObjectListGUIPreloader(ilObjectListGUI::CONTEXT_REPOSITORY);
     }
     include_once 'Services/Container/classes/class.ilContainerSorting.php';
     $sort = ilContainerSorting::_getInstance($this->getId());
     // TODO: check this
     // get items attached to a session
     include_once './Modules/Session/classes/class.ilEventItems.php';
     $event_items = ilEventItems::_getItemsOfContainer($this->getRefId());
     foreach ($objects as $key => $object) {
         if ($a_get_single > 0 && $object["child"] != $a_get_single) {
             continue;
         }
         // hide object types in devmode
         if ($objDefinition->getDevMode($object["type"]) || $object["type"] == "adm" || $object["type"] == "rolf") {
             continue;
         }
         // remove inactive plugins
         if ($objDefinition->isInactivePlugin($object["type"])) {
             continue;
         }
         // BEGIN WebDAV: Don't display hidden Files, Folders and Categories
         if (in_array($object['type'], array('file', 'fold', 'cat'))) {
             include_once 'Modules/File/classes/class.ilObjFileAccess.php';
             if (ilObjFileAccess::_isFileHidden($object['title'])) {
                 $this->setHiddenFilesFound(true);
                 if (!$a_admin_panel_enabled) {
                     continue;
                 }
             }
         }
         // END WebDAV: Don't display hidden Files, Folders and Categories
         // including event items!
         if (!self::$data_preloaded) {
             $preloader->addItem($object["obj_id"], $object["type"], $object["child"]);
         }
         // filter out items that are attached to an event
         if (in_array($object['ref_id'], $event_items)) {
             continue;
         }
         // filter side block items
         if (!$a_include_side_block && $objDefinition->isSideBlock($object['type'])) {
             continue;
         }
         $all_ref_ids[] = $object["child"];
     }
     // data preloader
     if (!self::$data_preloaded) {
         $preloader->preload();
         unset($preloader);
         self::$data_preloaded = true;
     }
     foreach ($objects as $key => $object) {
         // see above, objects were filtered
         if (!in_array($object["child"], $all_ref_ids)) {
             continue;
         }
         // group object type groups together (e.g. learning resources)
         $type = $objDefinition->getGroupOfObj($object["type"]);
         if ($type == "") {
             $type = $object["type"];
         }
         // this will add activation properties
         $this->addAdditionalSubItemInformation($object);
         $this->items[$type][$key] = $object;
         $this->items["_all"][$key] = $object;
         if ($object["type"] != "sess") {
             $this->items["_non_sess"][$key] = $object;
         }
     }
     $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block] = $sort->sortItems($this->items);
     return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block];
 }
 /**
  * Get subitems of container
  * 
  * @param bool administration panel enabled
  * @param bool side blocks enabled
  *
  * @return	array
  */
 function getSubItems($a_admin_panel_enabled = false, $a_include_side_block = false, $a_get_single = 0)
 {
     global $objDefinition, $ilBench, $tree, $ilObjDataCache, $ilUser, $rbacsystem, $ilSetting;
     // Caching
     if (is_array($this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]) && !$a_get_single) {
         return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block];
     }
     $type_grps = $this->getGroupedObjTypes();
     $objects = $tree->getChilds($this->getRefId(), "title");
     // using long descriptions?
     $short_desc = $ilSetting->get("rep_shorten_description");
     $short_desc_max_length = $ilSetting->get("rep_shorten_description_length");
     if (!$short_desc || $short_desc_max_length != ilObject::TITLE_LENGTH) {
         // using (part of) shortened description
         if ($short_desc && $short_desc_max_length && $short_desc_max_length < ilObject::TITLE_LENGTH) {
             foreach ($objects as $key => $object) {
                 $objects[$key]["description"] = ilUtil::shortenText($object["description"], $short_desc_max_length, true);
             }
         } else {
             $obj_ids = array();
             foreach ($objects as $key => $object) {
                 $obj_ids[] = $object["obj_id"];
             }
             if (sizeof($obj_ids)) {
                 $long_desc = ilObject::getLongDescriptions($obj_ids);
                 foreach ($objects as $key => $object) {
                     if ($short_desc && $short_desc_max_length) {
                         $long_desc[$object["obj_id"]] = ilUtil::shortenText($long_desc[$object["obj_id"]], $short_desc_max_length, true);
                     }
                     $objects[$key]["description"] = $long_desc[$object["obj_id"]];
                 }
             }
         }
     }
     $found = false;
     $all_obj_types = array();
     $all_ref_ids = array();
     $all_obj_ids = array();
     include_once 'Services/Container/classes/class.ilContainerSorting.php';
     $sort = ilContainerSorting::_getInstance($this->getId());
     // TODO: check this
     // get items attached to a session
     include_once './Modules/Session/classes/class.ilEventItems.php';
     $event_items = ilEventItems::_getItemsOfContainer($this->getRefId());
     foreach ($objects as $key => $object) {
         if ($a_get_single > 0 && $object["child"] != $a_get_single) {
             continue;
         }
         // hide object types in devmode
         if ($objDefinition->getDevMode($object["type"]) || $object["type"] == "adm" || $object["type"] == "rolf") {
             continue;
         }
         // remove inactive plugins
         if ($objDefinition->isInactivePlugin($object["type"])) {
             continue;
         }
         // BEGIN WebDAV: Don't display hidden Files, Folders and Categories
         if (in_array($object['type'], array('file', 'fold', 'cat'))) {
             include_once 'Modules/File/classes/class.ilObjFileAccess.php';
             if (ilObjFileAccess::_isFileHidden($object['title'])) {
                 $this->setHiddenFilesFound(true);
                 if (!$a_admin_panel_enabled) {
                     continue;
                 }
             }
         }
         // END WebDAV: Don't display hidden Files, Folders and Categories
         // filter out items that are attached to an event
         if (in_array($object['ref_id'], $event_items)) {
             continue;
         }
         // filter side block items
         if (!$a_include_side_block && $objDefinition->isSideBlock($object['type'])) {
             continue;
         }
         $all_obj_types[$object["type"]] = $object["type"];
         $obj_ids_of_type[$object["type"]][] = $object["obj_id"];
         $ref_ids_of_type[$object["type"]][] = $object["child"];
         $all_ref_ids[] = $object["child"];
         $all_obj_ids[] = $object["obj_id"];
     }
     // data preloader
     if (!self::$data_preloaded && sizeof($all_ref_ids)) {
         // type specific preloads
         foreach ($all_obj_types as $t) {
             // condition handler: preload conditions
             include_once "./Services/AccessControl/classes/class.ilConditionHandler.php";
             ilConditionHandler::preloadConditionsForTargetRecords($t, $obj_ids_of_type[$t]);
             $class = $objDefinition->getClassName($t);
             $location = $objDefinition->getLocation($t);
             $full_class = "ilObj" . $class . "Access";
             include_once $location . "/class." . $full_class . ".php";
             call_user_func(array($full_class, "_preloadData"), $obj_ids_of_type[$t], $ref_ids_of_type[$t]);
         }
         // general preloads
         $tree->preloadDeleted($all_ref_ids);
         $tree->preloadDepthParent($all_ref_ids);
         $ilObjDataCache->preloadReferenceCache($all_ref_ids, false);
         ilObjUser::preloadIsDesktopItem($ilUser->getId(), $all_ref_ids);
         $rbacsystem->preloadRbacPaCache($all_ref_ids, $ilUser->getId());
         include_once "./Services/Object/classes/class.ilObjectListGUI.php";
         ilObjectListGUI::preloadCommonProperties($all_obj_ids);
         include_once "./Services/Object/classes/class.ilObjectActivation.php";
         ilObjectActivation::preloadData($all_ref_ids);
         self::$data_preloaded = true;
     }
     foreach ($objects as $key => $object) {
         // see above, objects were filtered
         if (!in_array($object["child"], $all_ref_ids)) {
             continue;
         }
         // group object type groups together (e.g. learning resources)
         $type = $objDefinition->getGroupOfObj($object["type"]);
         if ($type == "") {
             $type = $object["type"];
         }
         // this will add activation properties (ilObjActivation)
         $this->addAdditionalSubItemInformation($object);
         $this->items[$type][$key] = $object;
         $this->items["_all"][$key] = $object;
         if ($object["type"] != "sess") {
             $this->items["_non_sess"][$key] = $object;
         }
     }
     $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block] = $sort->sortItems($this->items);
     return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block];
 }