function view() { global $ilUser, $lng, $tpl, $ilCtrl; $ref_ids = array(); $obj_ids = array(); $pd_items = $ilUser->getDesktopItems(); foreach ($pd_items as $item) { $ref_ids[] = $item["ref_id"]; $obj_ids[] = $item["obj_id"]; } $sel_ref_id = $_GET["news_ref_id"] > 0 ? $_GET["news_ref_id"] : $ilUser->getPref("news_sel_ref_id"); include_once "./Services/News/classes/class.ilNewsItem.php"; $per = $_SESSION["news_pd_news_per"] != "" ? $_SESSION["news_pd_news_per"] : ilNewsItem::_lookupUserPDPeriod($ilUser->getId()); $news_obj_ids = ilNewsItem::filterObjIdsPerNews($obj_ids, $per); // related objects (contexts) of news $contexts[0] = $lng->txt("news_all_items"); $conts = array(); $sel_has_news = false; foreach ($ref_ids as $ref_id) { $obj_id = ilObject::_lookupObjId($ref_id); $title = ilObject::_lookupTitle($obj_id); $conts[$ref_id] = $title; if ($sel_ref_id == $ref_id) { $sel_has_news = true; } } $cnt = array(); $nitem = new ilNewsItem(); $news_items = $nitem->_getNewsItemsOfUser($ilUser->getId(), false, true, $per, $cnt); // reset selected news ref id, if no news are given for id if (!$sel_has_news) { $sel_ref_id = ""; } asort($conts); foreach ($conts as $ref_id => $title) { $contexts[$ref_id] = $title . " (" . (int) $cnt[$ref_id] . ")"; } if ($sel_ref_id > 0) { $obj_id = ilObject::_lookupObjId($sel_ref_id); $obj_type = ilObject::_lookupType($obj_id); $nitem->setContextObjId($obj_id); $nitem->setContextObjType($obj_type); $news_items = $nitem->getNewsForRefId($sel_ref_id, false, false, $per, true); } include_once "./Services/News/classes/class.ilPDNewsTableGUI.php"; $pd_news_table = new ilPDNewsTableGUI($this, "view", $contexts, $sel_ref_id); $pd_news_table->setData($news_items); $pd_news_table->setNoEntriesText($lng->txt("news_no_news_items")); $tpl->setContent($pd_news_table->getHTML()); }
/** * Get news aggregation for child objects (e.g. for categories) */ function getAggregatedChildNewsData($a_ref_id, $a_only_public = false, $a_time_period = 0, $a_prevent_aggregation = false, $a_starting_date = "", $a_no_auto_generated = false) { global $tree, $ilAccess; // get news of parent object $data = $this->getNewsForRefId($a_ref_id, $a_only_public, true, $a_time_period, true, false, false, $a_no_auto_generated); foreach ($data as $k => $v) { $data[$k]["ref_id"] = $a_ref_id; } // get childs $nodes = $tree->getChilds($a_ref_id); // no check, for which of the objects any news are available $obj_ids = array(); foreach ($nodes as $node) { $obj_ids[] = $node["obj_id"]; } $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 && !$ilAccess->checkAccess("read", "", $node["child"])) { continue; } $ref_id[$node["obj_id"]] = $node["child"]; $contexts[] = array("obj_id" => $node["obj_id"], "obj_type" => $node["type"]); } $news = $this->queryNewsForMultipleContexts($contexts, $a_only_public, $a_time_period, $a_starting_date, $a_no_auto_generated); foreach ($news as $k => $v) { $news[$k]["ref_id"] = $ref_id[$v["context_obj_id"]]; } $data = ilNewsItem::mergeNews($data, $news); // sort and return $data = ilUtil::sortArray($data, "creation_date", "desc", false, true); if (!$a_prevent_aggregation) { $data = $this->aggregateFiles($data, $a_ref_id); } return $data; }