public function preload()
 {
     global $objDefinition, $tree, $ilObjDataCache, $ilUser, $rbacsystem;
     if (!$this->obj_ids) {
         return;
     }
     $this->obj_ids = array_unique($this->obj_ids);
     $this->types = array_unique($this->types);
     if ($this->ref_ids) {
         $this->ref_ids = array_unique($this->ref_ids);
     }
     // type specific preloads
     include_once "./Services/AccessControl/classes/class.ilConditionHandler.php";
     foreach ($this->types as $type) {
         $this->obj_ids_by_type[$type] = array_unique($this->obj_ids_by_type[$type]);
         if (is_array($this->ref_ids_by_type[$type])) {
             $this->ref_ids_by_type[$type] = array_unique($this->ref_ids_by_type[$type]);
         }
         if ($this->context == ilObjectListGUI::CONTEXT_REPOSITORY || $this->context == ilObjectListGUI::CONTEXT_PERSONAL_DESKTOP || $this->context == ilObjectListGUI::CONTEXT_SEARCH) {
             ilConditionHandler::preloadConditionsForTargetRecords($type, $this->obj_ids_by_type[$type]);
         }
         $class = $objDefinition->getClassName($type);
         $location = $objDefinition->getLocation($type);
         if ($class && $location) {
             $full_class = "ilObj" . $class . "Access";
             include_once $location . "/class." . $full_class . ".php";
             if (class_exists($full_class)) {
                 call_user_func(array($full_class, "_preloadData"), $this->obj_ids_by_type[$type], $this->ref_ids_by_type[$type]);
             }
         }
     }
     if ($this->ref_ids) {
         $tree->preloadDeleted($this->ref_ids);
         $tree->preloadDepthParent($this->ref_ids);
         $ilObjDataCache->preloadReferenceCache($this->ref_ids, false);
         $rbacsystem->preloadRbacPaCache($this->ref_ids, $ilUser->getId());
         if ($ilUser->getId != ANONYMOUS_USER_ID && $this->context != ilObjectListGUI::CONTEXT_PERSONAL_DESKTOP) {
             ilObjUser::preloadIsDesktopItem($ilUser->getId(), $this->ref_ids);
         }
         include_once "./Services/Object/classes/class.ilObjectActivation.php";
         ilObjectActivation::preloadData($this->ref_ids);
     }
     include_once "./Services/Object/classes/class.ilObjectListGUI.php";
     ilObjectListGUI::preloadCommonProperties($this->obj_ids, $this->context);
     if ($this->context == ilObjectListGUI::CONTEXT_REPOSITORY) {
         include_once "./Services/Rating/classes/class.ilRating.php";
         include_once "./Services/Rating/classes/class.ilRatingGUI.php";
         ilRating::preloadListGUIData($this->obj_ids);
         include_once "./Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php";
         ilAdvancedMDValues::preloadByObjIds($this->obj_ids);
     }
     if ($this->context == ilObjectListGUI::CONTEXT_REPOSITORY || $this->context == ilObjectListGUI::CONTEXT_PERSONAL_DESKTOP || $this->context == ilObjectListGUI::CONTEXT_SEARCH) {
         include_once "./Services/Tracking/classes/class.ilLPStatus.php";
         ilLPStatus::preloadListGUIData($this->obj_ids);
     }
 }
 /**
  * get selected items per type
  */
 function getSelectedItemsPerLocation(&$tpl)
 {
     global $ilUser, $rbacsystem, $objDefinition, $ilBench, $ilSetting, $ilObjDataCache, $tree;
     $output = false;
     $items = $ilUser->getDesktopItems();
     $item_html = array();
     $cur_obj_type = "";
     if (count($items) > 0) {
         // preload object data cache
         $ref_ids = $obj_ids = array();
         foreach ($items as $item) {
             $ref_ids[] = $item["ref_id"];
             $obj_ids[] = $item["obj_id"];
         }
         reset($items);
         $tree->preloadDeleted($ref_ids);
         $tree->preloadDepthParent($ref_ids);
         $ilObjDataCache->preloadReferenceCache($ref_ids);
         include_once "Services/Tracking/classes/class.ilLPStatus.php";
         ilLPStatus::preloadListGUIData($obj_ids);
         include_once "Services/Object/classes/class.ilObjectActivation.php";
         ilObjectActivation::preloadData($ref_ids);
         foreach ($items as $item) {
             //echo "1";
             // get list gui class for each object type
             if ($cur_obj_type != $item["type"]) {
                 $item_list_gui =& $this->getItemListGUI($item["type"]);
                 if (!$item_list_gui) {
                     continue;
                 }
                 ilObjectActivation::addListGUIActivationProperty($item_list_gui, $item);
                 // notes, comment currently do not work properly
                 $item_list_gui->enableNotes(false);
                 $item_list_gui->enableComments(false);
                 $item_list_gui->enableTags(false);
                 $item_list_gui->enableIcon(true);
                 $item_list_gui->enableDelete(false);
                 $item_list_gui->enableCut(false);
                 $item_list_gui->enableCopy(false);
                 $item_list_gui->enablePayment(false);
                 $item_list_gui->enableLink(false);
                 $item_list_gui->enableInfoScreen(true);
                 if ($this->getCurrentDetailLevel() < 3 || $this->manage) {
                     //echo "3";
                     $item_list_gui->enableDescription(false);
                     $item_list_gui->enableProperties(false);
                     $item_list_gui->enablePreconditions(false);
                 }
                 if ($this->getCurrentDetailLevel() < 2 || $this->manage) {
                     $item_list_gui->enableCommands(true, true);
                 }
             }
             // render item row
             $ilBench->start("ilPersonalDesktopGUI", "getListHTML");
             $item_list_gui->setContainerObject($this);
             $html = $item_list_gui->getListItemHTML($item["ref_id"], $item["obj_id"], $item["title"], $item["description"]);
             $ilBench->stop("ilPersonalDesktopGUI", "getListHTML");
             if ($html != "") {
                 // BEGIN WebDAV: Use $item_list_gui to determine icon image type
                 $item_html[] = array("html" => $html, "item_ref_id" => $item["ref_id"], "item_obj_id" => $item["obj_id"], "parent_ref" => $item["parent_ref"], "type" => $item["type"], 'item_icon_image_type' => $item_list_gui->getIconImageType());
                 // END WebDAV: Use $item_list_gui to determine icon image type
             }
         }
         // output block for resource type
         if (count($item_html) > 0) {
             $cur_parent_ref = 0;
             // content row
             foreach ($item_html as $item) {
                 // add a parent header row for each new parent
                 if ($cur_parent_ref != $item["parent_ref"]) {
                     if ($ilSetting->get("icon_position_in_lists") == "item_rows") {
                         $this->addParentRow($tpl, $item["parent_ref"], false);
                     } else {
                         $this->addParentRow($tpl, $item["parent_ref"]);
                     }
                     $this->resetRowType();
                     $cur_parent_ref = $item["parent_ref"];
                 }
                 // BEGIN WebDAV: Use $item_list_gui to determine icon image type.
                 $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"], $item['item_icon_image_type'], "th_" . $cur_parent_ref);
                 // END WebDAV: Use $item_list_gui to determine icon image type.
                 $output = true;
             }
         }
     }
     return $output;
 }
Ejemplo n.º 3
0
 /**
  * Get news aggregation (e.g. for courses, groups)
  */
 function getAggregatedNewsData($a_ref_id, $a_only_public = false, $a_time_period = 0, $a_prevent_aggregation = false, $a_starting_date = "", $a_no_auto_generated = false, $a_user_id = null)
 {
     global $tree, $ilAccess, $ilObjDataCache;
     // get news of parent object
     $data = array();
     // get subtree
     $cur_node = $tree->getNodeData($a_ref_id);
     if ($cur_node["lft"] != "") {
         $nodes = $tree->getSubTree($cur_node, true);
     } else {
         $nodes = array();
     }
     // preload object data cache
     $ref_ids = array();
     $obj_ids = array();
     foreach ($nodes as $node) {
         $ref_ids[] = $node["child"];
         $obj_ids[] = $node["obj_id"];
     }
     $ilObjDataCache->preloadReferenceCache($ref_ids);
     if (!$a_only_public) {
         include_once "Services/Object/classes/class.ilObjectActivation.php";
         ilObjectActivation::preloadData($ref_ids);
     }
     // no check, for which of the objects any news are available
     $news_obj_ids = ilNewsItem::filterObjIdsPerNews($obj_ids, $a_time_period, $a_starting_date);
     //$news_obj_ids = $obj_ids;
     // get news for all subtree nodes
     $contexts = array();
     foreach ($nodes as $node) {
         // only go on, if news are available
         if (!in_array($node["obj_id"], $news_obj_ids)) {
             continue;
         }
         if (!$a_only_public) {
             if (!$a_user_id) {
                 $acc = $ilAccess->checkAccess("read", "", $node["child"]);
             } else {
                 $acc = $ilAccess->checkAccessOfUser($a_user_id, "read", "", $node["child"]);
             }
             if (!$acc) {
                 continue;
             }
         }
         $ref_id[$node["obj_id"]] = $node["child"];
         $contexts[] = array("obj_id" => $node["obj_id"], "obj_type" => $node["type"]);
     }
     // sort and return
     $news = $this->queryNewsForMultipleContexts($contexts, $a_only_public, $a_time_period, $a_starting_date, $a_no_auto_generated, $a_user_id);
     $to_del = array();
     foreach ($news as $k => $v) {
         $news[$k]["ref_id"] = $ref_id[$v["context_obj_id"]];
     }
     $data = ilNewsItem::mergeNews($data, $news);
     $data = ilUtil::sortArray($data, "creation_date", "desc", false, true);
     if (!$a_prevent_aggregation) {
         $data = $this->aggregateFiles($data, $a_ref_id);
     }
     return $data;
 }
 /**
  * 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];
 }