4define(
"NEWS_NOTICE", 0);
 
    5define(
"NEWS_MESSAGE", 1);
 
    6define(
"NEWS_WARNING", 2);
 
    8include_once(
"./Services/News/classes/class.ilNewsItemGen.php");
 
   35                parent::__construct($a_id);
 
   36                $this->limitation = 
true;
 
   47                $this->limitation = $a_limitation;
 
   67                $this->content_text_is_lang_var = $a_val;
 
   77                return $this->content_text_is_lang_var;
 
   87                $this->mob_cnt_play = $a_val;
 
   97                return $this->mob_cnt_play;
 
  107                $this->mob_cnt_download = $a_val;
 
  117                return $this->mob_cnt_download;
 
  127                $query = 
"SELECT * FROM il_news_item WHERE id = ".
 
  130                $rec = 
$ilDB->fetchAssoc($set);
 
  162                $this->
setId($ilDB->nextId(
"il_news_item"));
 
  163                $ilDB->insert(
"il_news_item", array(
 
  164                        "id" => array(
"integer", $this->
getId()),
 
  165                        "title" => array(
"text", $this->
getTitle()),
 
  166                        "content" => array(
"clob", $this->
getContent()),
 
  172                        "creation_date" => array(
"timestamp", 
ilUtil::now()),
 
  173                        "update_date" => array(
"timestamp", 
ilUtil::now()),
 
  174                        "user_id" => array(
"integer", $this->
getUserId()),
 
  177                        "priority" => array(
"integer", $this->
getPriority()),
 
  180                        "mob_id" => array(
"integer", $this->
getMobId()),
 
  186                $max_items = $news_set->get(
"max_items");
 
  196                        $query = 
"SELECT count(*) cnt ".
 
  197                                "FROM il_news_item ".
 
  205                        $rec = 
$ilDB->fetchAssoc($set);
 
  211                                        "FROM il_news_item ".
 
  217                        " ORDER BY creation_date ASC";
 
  219                                $ilDB->setLimit($rec[
"cnt"] - $max_items);
 
  221                                while ($del_item = 
$ilDB->fetchAssoc($del_set))
 
  235        public function update($a_as_new = 
false)
 
  240                        "title" => array(
"text", $this->
getTitle()),
 
  241                        "content" => array(
"clob", $this->
getContent()),
 
  247                        "user_id" => array(
"integer", $this->
getUserId()),
 
  250                        "priority" => array(
"integer", $this->
getPriority()),
 
  253                        "mob_id" => array(
"integer", $this->
getMobId()),
 
  262                        $fields[
"creation_date"] = array(
"timestamp", $now);
 
  263                        $fields[
"update_date"] = array(
"timestamp", $now);
 
  267                        $fields[
"update_date"] = array(
"timestamp", $now);
 
  270                $ilDB->update(
"il_news_item", $fields, array(
 
  271                        "id" => array(
"integer", $this->
getId())
 
  281                $a_prevent_aggregation = 
false, $a_per = 0, &$a_cnt = NULL)
 
  290                include_once(
"./Services/News/classes/class.ilNewsSubscription.php");
 
  291                include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
 
  300                        foreach($pd_items as $item)
 
  302                                if (!in_array($item[
"ref_id"], $ref_ids))
 
  304                                        $ref_ids[] = $item[
"ref_id"];
 
  309                        include_once 
'Services/Membership/classes/class.ilParticipants.php';
 
  312                        $items = array_merge($crs_mbs, $grp_mbs);
 
  313                        foreach($items as $i)
 
  316                                if(is_array($item_references) && count($item_references))
 
  318                                        foreach($item_references as 
$ref_id)
 
  320                                                if (!in_array(
$ref_id, $ref_ids))
 
  336                                $acc = $ilAccess->checkAccessOfUser($a_user_id, 
"read", 
"", 
$ref_id);
 
  355                        $news = $news_item->getNewsForRefId(
$ref_id, $a_only_public, 
false,
 
  356                                $per, $a_prevent_aggregation, 
false, 
false, 
false, $a_user_id);
 
  359                        if (!is_null($a_cnt))
 
  361                                $a_cnt[
$ref_id] = count($news);
 
  378                $a_time_period = 0, $a_prevent_aggregation = 
true, $a_forum_group_sequences = 
false,
 
  379                $a_no_auto_generated = 
false, $a_ignore_date_filter = 
false, $a_user_id = 
null)
 
  386                if ($obj_type == 
"grp" || $obj_type == 
"crs" || $obj_type == 
"cat")
 
  388                        include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
 
  391                        if ($hide_news_per_date && !$a_ignore_date_filter)
 
  398                if ($obj_type == 
"cat" && !$a_stopnesting)
 
  401                $a_prevent_aggregation, $starting_date, $a_no_auto_generated);
 
  403                else if (($obj_type == 
"grp" || $obj_type == 
"crs") &&
 
  407                $a_prevent_aggregation, $starting_date, $a_no_auto_generated, $a_user_id);
 
  412                        $news_item->setContextObjId($obj_id);
 
  413                        $news_item->setContextObjType($obj_type);
 
  414                        $news = $news_item->queryNewsForContext($a_only_public, $a_time_period,
 
  415                $starting_date, $a_no_auto_generated);
 
  417                        foreach ($news as $k => $v)
 
  419                                if (!$a_only_public || $v[
"visibility"] == 
NEWS_PUBLIC ||
 
  420                    ($v[
"priority"] == 0 &&
 
  424                                        $news[$k][
"ref_id"] = $a_ref_id;
 
  431                        foreach ($unset as $un)
 
  437                if (!$a_prevent_aggregation)
 
  441                else if ($a_forum_group_sequences)
 
  453        $a_prevent_aggregation = 
false, $a_starting_date = 
"", $a_no_auto_generated = 
false,
 
  456                global $tree, $ilAccess, $ilObjDataCache;
 
  463                $cur_node = $tree->getNodeData($a_ref_id);
 
  468                        $nodes = (array) $tree->getSubTree($cur_node,
true);
 
  478                foreach($nodes as $node)
 
  480                        $ref_ids[] = $node[
"child"];
 
  481                        $obj_ids[] = $node[
"obj_id"];
 
  484                $ilObjDataCache->preloadReferenceCache($ref_ids);
 
  487                        include_once 
"Services/Object/classes/class.ilObjectActivation.php";
 
  497                foreach($nodes as $node)
 
  500                        if (!in_array($node[
"obj_id"], $news_obj_ids))
 
  509                                        $acc = $ilAccess->checkAccess(
"read", 
"", $node[
"child"]);
 
  513                                        $acc = $ilAccess->checkAccessOfUser($a_user_id, 
"read", 
"",
 
  522                        $ref_id[$node[
"obj_id"]] = $node[
"child"];
 
  523                        $contexts[] = array(
"obj_id" => $node[
"obj_id"],
 
  524                                "obj_type" => $node[
"type"]);
 
  529            $a_starting_date, $a_no_auto_generated, $a_user_id);
 
  532                foreach ($news as $k => $v)
 
  534                        $news[$k][
"ref_id"] = 
$ref_id[$v[
"context_obj_id"]];
 
  540                if (!$a_prevent_aggregation)
 
  554                foreach ($news as $k => $v)
 
  556                        if ($a_group_posting_sequence && $last_aggregation_forum > 0 &&
 
  557                                $last_aggregation_forum != $news[$k][
"context_obj_id"])
 
  559                                $forums[$last_aggregation_forum] = 
"";
 
  562                        if ($news[$k][
"context_obj_type"] == 
"frm")
 
  564                                if ($forums[$news[$k][
"context_obj_id"]] == 
"")
 
  567                                        $forums[$news[$k][
"context_obj_id"]] = $k;
 
  568                                        $last_aggregation_forum = $news[$k][
"context_obj_id"];
 
  575                                $news[$k][
"no_context_title"] = 
true;
 
  578                                $news[$forums[$news[$k][
"context_obj_id"]]][
"aggregation"][$k]
 
  580                                $news[$k][
"agg_ref_id"]
 
  581                                        = $news[$k][
"ref_id"];
 
  582                                $news[$k][
"content"] = 
"";
 
  583                                $news[$k][
"content_long"] = 
"";
 
  588                foreach($to_del as $k)
 
  602                foreach ($news as $k => $v)
 
  605                        if ($news[$k][
"context_obj_type"] == 
"file")
 
  607                                if ($first_file == 
"")
 
  615                                $news[$first_file][
"aggregation"][$k] = $news[$k];
 
  616                                $news[$first_file][
"agg_ref_id"] = $a_ref_id;
 
  617                                $news[$first_file][
"ref_id"] = $a_ref_id;
 
  621                foreach($to_del as $v)
 
  634                $a_time_period = 0, $a_prevent_aggregation = 
false, $a_starting_date = 
"",
 
  635        $a_no_auto_generated = 
false)
 
  637                global $tree, $ilAccess;
 
  641                        true, 
false, 
false, $a_no_auto_generated);
 
  642                foreach (
$data as $k => $v)
 
  644                        $data[$k][
"ref_id"] = $a_ref_id;
 
  648                $nodes = $tree->getChilds($a_ref_id);
 
  652                foreach($nodes as $node)
 
  654                        $obj_ids[] = $node[
"obj_id"];
 
  661                foreach($nodes as $node)
 
  664                        if (!in_array($node[
"obj_id"], $news_obj_ids))
 
  669                        if (!$a_only_public && !$ilAccess->checkAccess(
"read", 
"", $node[
"child"]))
 
  673                        $ref_id[$node[
"obj_id"]] = $node[
"child"];
 
  674                        $contexts[] = array(
"obj_id" => $node[
"obj_id"],
 
  675                                "obj_type" => $node[
"type"]);
 
  679            $a_starting_date, $a_no_auto_generated);
 
  680                foreach ($news as $k => $v)
 
  682                        $news[$k][
"ref_id"] = 
$ref_id[$v[
"context_obj_id"]];
 
  689                if (!$a_prevent_aggregation)
 
  700        function setContext($a_obj_id, $a_obj_type, $a_sub_obj_id = 0, $a_sub_obj_type = 
"")
 
  717                if(is_numeric($a_time_period))
 
  719                        if($a_time_period > 0)
 
  721                                return date(
'Y-m-d H:i:s', time() - ($a_time_period * 24 * 60 * 60));
 
  725                else if(preg_match(
"/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/", $a_time_period))
 
  727                        return $a_time_period;
 
  741        $a_starting_date = 
"", $a_no_auto_generated = 
false, $a_oldest_first = 
false, $a_limit = 0)
 
  746                if ($a_time_period > 0)
 
  749                        $and = 
" AND creation_date >= ".$ilDB->quote($limit_ts, 
"timestamp").
" ";
 
  752                if ($a_starting_date != 
"")
 
  754                        $and.= 
" AND creation_date > ".$ilDB->quote($a_starting_date, 
"timestamp").
" ";
 
  757                if ($a_no_auto_generated)
 
  759                        $and.= 
" AND priority = 1 AND content_type = ".$ilDB->quote(
"text", 
"text").
" ";
 
  765                        $and.= 
" AND context_sub_obj_id = ".$ilDB->quote($this->
getContextSubObjId(), 
"integer").
 
  769                $ordering = ($a_oldest_first)
 
  770            ? 
" creation_date ASC, id ASC " 
  771            : 
" creation_date DESC, id DESC ";
 
  776                                "FROM il_news_item ".
 
  779                                        " AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), 
"text").
 
  781                                        " ORDER BY ".$ordering;
 
  785                        $query = 
"SELECT il_news_item.* ".
 
  786                                ", il_news_read.user_id user_read ".
 
  787                                "FROM il_news_item LEFT JOIN il_news_read ".
 
  788                                "ON il_news_item.id = il_news_read.news_id AND ".
 
  794                                        " ORDER BY ".$ordering;
 
  798                        $query = 
"SELECT il_news_item.* ".
 
  799                                ", il_news_read.user_id as user_read ".
 
  800                                "FROM il_news_item LEFT JOIN il_news_read ".
 
  801                                "ON il_news_item.id = il_news_read.news_id AND ".
 
  802                                " il_news_read.user_id = ".$ilDB->quote(
$ilUser->getId(), 
"integer").
 
  807                                        " ORDER BY ".$ordering;
 
  812                while($rec = 
$ilDB->fetchAssoc($set))
 
  814                        if ($a_limit > 0 && count(
$result) >= $a_limit)
 
  819                                ($rec[
"priority"] == 0 &&
 
  821                                0, $rec[
"context_obj_id"]))))
 
  832                if ($a_time_period != 
"" && $a_for_rss_use)
 
  834                        include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
 
  837                        if ($keep_rss_min > 0)
 
  840                                        $a_starting_date, $a_no_auto_generated, $a_oldest_first, $keep_rss_min);
 
  861                if(!$tree->isDeleted($a_ref_id))
 
  865                        $node = $tree->getNodeData($a_ref_id);                                  
 
  866                        foreach($tree->getSubTree($node) as $child)
 
  868                                if($child[
"type"] != 
"rolf")
 
  870                                        $nodes[$child[
"obj_id"]] = $child[
"type"];
 
  877                        $query = 
$ilDB->query(
"SELECT id,context_obj_id,context_obj_type".
 
  878                                " FROM il_news_item".
 
  879                                " WHERE ".
$ilDB->in(
"context_obj_id", array_keys($nodes), 
false, 
"integer").
 
  880                                " AND creation_date >= ".
$ilDB->quote($limit_ts, 
"timestamp"));
 
  883                                if ($nodes[$rec[
"context_obj_id"]] == $rec[
"context_obj_type"])
 
  899        $a_time_period = 0, $a_starting_date = 
"", $a_no_auto_generated = 
false,
 
  905                if ($a_time_period > 0)
 
  908                        $and = 
" AND creation_date >= ".$ilDB->quote($limit_ts, 
"timestamp").
" ";
 
  911                if ($a_starting_date != 
"")
 
  913                        $and.= 
" AND creation_date > ".$ilDB->quote($a_starting_date, 
"timestamp").
" ";
 
  916                if ($a_no_auto_generated)
 
  918                        $and.= 
" AND priority = 1 AND content_type = ".$ilDB->quote(
"text", 
"text").
" ";
 
  923                foreach($a_contexts as $cont)
 
  925                        $ids[] = $cont[
"obj_id"];
 
  926                        $type[$cont[
"obj_id"]] = $cont[
"obj_type"];
 
  932                                "FROM il_news_item ".
 
  934                                        $ilDB->in(
"context_obj_id", $ids, 
false, 
"integer").
" ".
 
  936                    " ORDER BY creation_date DESC ";
 
  940                        $query = 
"SELECT il_news_item.* ".
 
  941                                ", il_news_read.user_id as user_read ".
 
  942                                "FROM il_news_item LEFT JOIN il_news_read ".
 
  943                                "ON il_news_item.id = il_news_read.news_id AND ".
 
  946                                        $ilDB->in(
"context_obj_id", $ids, 
false, 
"integer").
" ".
 
  948                    " ORDER BY creation_date DESC ";
 
  960                        $query = 
"SELECT il_news_item.* ".
 
  961                                ", il_news_read.user_id as user_read ".
 
  962                                "FROM il_news_item LEFT JOIN il_news_read ".
 
  963                                "ON il_news_item.id = il_news_read.news_id AND ".
 
  964                                " il_news_read.user_id = ".$ilDB->quote(
$user_id, 
"integer").
 
  966                                        $ilDB->in(
"context_obj_id", $ids, 
false, 
"integer").
" ".
 
  968                    " ORDER BY creation_date DESC ";
 
  973                while($rec = 
$ilDB->fetchAssoc($set))
 
  975                        if ($type[$rec[
"context_obj_id"]] == $rec[
"context_obj_type"])
 
  978                                        ($rec[
"priority"] == 0 &&
 
  980                                        0, $rec[
"context_obj_id"]))))
 
  997                global 
$ilDB, $ilAppEventHandler;
 
  999                $ilDB->replace(
"il_news_read",
 
 1001                                "user_id" => array(
"integer", $a_user_id),
 
 1002                                "news_id" => array(
"integer", $a_news_id)
 
 1015                $ilAppEventHandler->raise(
"Services/News", 
"readNews",
 
 1016                        array(
"user_id" => $a_user_id, 
"news_ids" => array($a_news_id)));
 
 1024                global 
$ilDB, $ilAppEventHandler;
 
 1026                $ilDB->manipulate(
"DELETE FROM il_news_read (user_id, news_id) VALUES (".
 
 1027                        " WHERE user_id = ".
$ilDB->quote($a_user_id, 
"integer").
 
 1028                        " AND news_id = ".$ilDB->quote($a_news_id, 
"integer"));
 
 1030                $ilAppEventHandler->raise(
"Services/News", 
"unreadNews",
 
 1031                        array(
"user_id" => $a_user_id, 
"news_ids" => array($a_news_id)));
 
 1044                foreach($n2 as 
$id => $news)
 
 1061                include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
 
 1064                $default_visibility = ($news_set->get(
"default_visibility") != 
"")
 
 1065                                ? $news_set->get(
"default_visibility")
 
 1068                if ($tree->isInTree($a_ref_id))
 
 1070                        $path = $tree->getPathFull($a_ref_id);
 
 1074                                if (!in_array(
$row[
"type"], array(
"root", 
"cat",
"crs", 
"fold", 
"grp")))
 
 1089                return $default_visibility;
 
 1097        public function delete()
 
 1102                $ilDB->manipulate(
"DELETE FROM il_news_read ".
 
 1103                        " WHERE news_id = ".
$ilDB->quote($this->getId(), 
"integer"));
 
 1114                        include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
 1125                $a_context_obj_type, $a_context_sub_obj_id = 0, $a_context_sub_obj_type = 
"")
 
 1129                if ($a_context_obj_id == 0 || $a_context_obj_type == 
"")
 
 1134                if ($a_context_sub_obj_id > 0)
 
 1136                        $and = 
" AND context_sub_obj_id = ".$ilDB->quote($a_context_sub_obj_id, 
"integer").
 
 1137                                " AND context_sub_obj_type = ".$ilDB->quote($a_context_sub_obj_type, 
"text");
 
 1141                $query = 
"SELECT * FROM il_news_item".
 
 1142                        " WHERE context_obj_id = ".$ilDB->quote($a_context_obj_id, 
"integer").
 
 1143                        " AND context_obj_type = ".$ilDB->quote($a_context_obj_type, 
"text").
 
 1148                while ($news = 
$ilDB->fetchAssoc($news_set))
 
 1151                        $news_obj->delete();
 
 1162                $query = 
"SELECT title FROM il_news_item WHERE id = ".
 
 1163                        $ilDB->quote($a_news_id, 
"integer");
 
 1165                $rec = 
$ilDB->fetchAssoc($set);
 
 1166                return $rec[
"title"];
 
 1176                $query = 
"SELECT visibility FROM il_news_item WHERE id = ".
 
 1177                        $ilDB->quote($a_news_id, 
"integer");
 
 1179                $rec = 
$ilDB->fetchAssoc($set);
 
 1181                return $rec[
"visibility"];
 
 1191                $query = 
"SELECT mob_id FROM il_news_item WHERE id = ".
 
 1192                        $ilDB->quote($a_news_id, 
"integer");
 
 1194                $rec = 
$ilDB->fetchAssoc($set);
 
 1195                return $rec[
"mob_id"];
 
 1201        static function filterObjIdsPerNews($a_obj_ids, $a_time_period = 0, $a_starting_date = 
"",$a_ending_date = 
'', $ignore_period = 
false)
 
 1206                if ($a_time_period > 0)
 
 1209                        $and = 
" AND creation_date >= ".$ilDB->quote($limit_ts, 
"timestamp").
" ";
 
 1212                if ($a_starting_date != 
"")
 
 1214                        $and.= 
" AND creation_date >= ".$ilDB->quote($a_starting_date, 
"timestamp");
 
 1217                $query = 
"SELECT DISTINCT(context_obj_id) AS obj_id FROM il_news_item".
 
 1218                        " WHERE ".$ilDB->in(
"context_obj_id", $a_obj_ids, 
false, 
"integer").
" ".$and;
 
 1223                while($rec = 
$ilDB->fetchAssoc($set))
 
 1225                        $objs[] = $rec[
"obj_id"];
 
 1235                $a_agg_ref_id = 0, $a_aggregation = 
"")
 
 1239                if ($a_agg_ref_id > 0)
 
 1241                        $cnt = count($a_aggregation);
 
 1244                        if ($a_context_obj_type == 
"frm")
 
 1248                                        return sprintf(
$lng->txt(
"news_x_postings"), $cnt);
 
 1252                                        return $lng->txt(
"news_1_postings");
 
 1257                                $up_cnt = $cr_cnt = 0;
 
 1258                                foreach($a_aggregation as $item)
 
 1260                                        if ($item[
"title"] == 
"file_updated")
 
 1272                                        $tit = 
$lng->txt(
"news_1_file_created");
 
 1275                                else if ($cr_cnt > 1)
 
 1277                                        $tit = sprintf(
$lng->txt(
"news_x_files_created"), $cr_cnt);
 
 1282                                        $tit .= $sep.$lng->txt(
"news_1_file_updated");
 
 1284                                else if ($up_cnt > 1)
 
 1286                                        $tit .= $sep.sprintf(
$lng->txt(
"news_x_files_updated"), $up_cnt);
 
 1293                        if ($a_content_is_lang_var)
 
 1295                                return $lng->txt($a_title);
 
 1315                        $lng->loadLanguageModule($a_context_obj_type);
 
 1316                        return $lng->txt($a_content);
 
 1330                $a_context_obj_type, $a_context_sub_obj_id = 
"", $a_context_sub_obj_type = 
"")
 
 1336                        "FROM il_news_item ".
 
 1338                                "context_obj_id = ".$ilDB->quote($a_context_obj_id, 
"integer").
 
 1339                                " AND context_obj_type = ".$ilDB->quote($a_context_obj_type, 
"text").
 
 1340                                " AND context_sub_obj_id = ".$ilDB->quote($a_context_sub_obj_id, 
"integer").
 
 1341                                " AND ".$ilDB->equals(
"context_sub_obj_type", $a_context_sub_obj_type, 
"text", 
true);
 
 1344                $rec = 
$ilDB->fetchAssoc($set);
 
 1353                $a_context_obj_type, $a_context_sub_obj_id = 
"", $a_context_sub_obj_type = 
"",
 
 1354                $a_only_today = 
false)
 
 1359                $query = 
"SELECT id, update_date ".
 
 1360                        "FROM il_news_item ".
 
 1362                                "context_obj_id = ".$ilDB->quote($a_context_obj_id, 
"integer").
 
 1363                                " AND context_obj_type = ".$ilDB->quote($a_context_obj_type, 
"text").
 
 1364                                " AND context_sub_obj_id = ".$ilDB->quote($a_context_sub_obj_id, 
"integer").
 
 1365                                " AND ".$ilDB->equals(
"context_sub_obj_type", $a_context_sub_obj_type, 
"text", 
true).
 
 1366                        " ORDER BY update_date DESC";
 
 1370                $rec = 
$ilDB->fetchAssoc($set);
 
 1372                $id = (int) $rec[
"id"];
 
 1376                        if (substr($now, 0, 10) != substr($rec[
"update_date"], 0, 10))
 
 1394                        "FROM il_news_item ".
 
 1396                                " mob_id = ".$ilDB->quote($a_mob_id, 
"integer");
 
 1400                while ($rec = 
$ilDB->fetchAssoc($set))
 
 1402                        $usages[$rec[
"id"]] = array(
"type" => 
"news", 
"id" => $rec[
"id"]);
 
 1416                        "FROM il_news_item ".
 
 1418                                " id = ".$ilDB->quote($a_news_id, 
"integer");
 
 1420                $rec = 
$ilDB->fetchAssoc($set);
 
 1422                return $rec[
"context_obj_id"];
 
 1428                $per = $news_set->get(
"pd_period");
 
 1442                $allow_shorter_periods = $news_set->get(
"allow_shorter_periods");
 
 1443                $allow_longer_periods = $news_set->get(
"allow_longer_periods");
 
 1446                include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
 
 1452                        (!$allow_shorter_periods && ($per < $default_per)) ||
 
 1453                        (!$allow_longer_periods && ($per > $default_per))
 
 1456                        $per = $default_per;
 
 1465                $rss_period = $news_set->get(
"rss_period");
 
 1466                if ($rss_period == 0)           
 
 1491                include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
 1496                if (!$mob->hasPurposeItem($a_purpose))
 
 1501                $m_item = $mob->getMediaItem($a_purpose);
 
 1502                if ($m_item->getLocationType() != 
"Reference")
 
 1504                    $file = $mob_dir.
"/".$m_item->getLocation();
 
 1507                        if ($a_increase_download_cnt)
 
 1522                        if ($a_increase_download_cnt)
 
 1543                $ilDB->manipulate(
"UPDATE il_news_item SET ".
 
 1544                        " mob_cnt_download = ".
$ilDB->quote($cnt, 
"integer").
 
 1545                        " WHERE id = ".$ilDB->quote($this->getId(), 
"integer")
 
 1562                $ilDB->manipulate(
"UPDATE il_news_item SET ".
 
 1563                        " mob_cnt_play = ".
$ilDB->quote($cnt, 
"integer").
 
 1564                        " WHERE id = ".$ilDB->quote($this->getId(), 
"integer")
 
 1578                $data = unserialize($a_cres);
 
 1579                $news_ids = array_keys(
$data);
 
 1580                $set = 
$ilDB->query(
"SELECT id FROM il_news_item ".
 
 1581                        " WHERE ".
$ilDB->in(
"id", $news_ids, 
false, 
"integer"));
 
 1582                $existing_ids = array();
 
 1583                while ($rec = 
$ilDB->fetchAssoc($set))
 
 1585                        $existing_ids[] = $rec[
"id"];
 
 1588                $existing_news = array();
 
 1589                foreach (
$data as $k => $v)
 
 1591                        if (in_array($k, $existing_ids))
 
 1593                                $existing_news[$k] = $v;
 
 1600                return $existing_news;
 
static _lookup($a_type, $a_setting, $a_user=0, $a_block_id=0)
Lookup setting from database.
A news item can be created by different sources.
getContextObjId()
Get ContextObjId.
setTitle($a_title)
Set Title.
setContentType($a_content_type="text")
Set ContentType.
setCreationDate($a_creation_date)
Set CreationDate.
setVisibility($a_visibility="users")
Set Visibility.
setContextSubObjType($a_context_sub_obj_type)
Set ContextSubObjType.
setPlaytime($a_playtime)
Set Playtime.
setContentIsLangVar($a_content_is_lang_var=0)
Set ContentIsLangVar.
setUserId($a_user_id)
Set UserId.
setContextObjType($a_context_obj_type)
Set ContextObjType.
getPriority()
Get Priority.
setContextObjId($a_context_obj_id)
Set ContextObjId.
getContentType()
Get ContentType.
setContextSubObjId($a_context_sub_obj_id)
Set ContextSubObjId.
setContent($a_content)
Set Content.
setPriority($a_priority=1)
Set Priority.
setUpdateDate($a_update_date)
Set UpdateDate.
getContextObjType()
Get ContextObjType.
setMobId($a_mob_id)
Set MobId.
getContextSubObjId()
Get ContextSubObjId.
getContentIsLangVar()
Get ContentIsLangVar.
getPlaytime()
Get Playtime.
getContextSubObjType()
Get ContextSubObjType.
queryNewsForContext()
Query NewsForContext.
getContentLong()
Get ContentLong.
setContentLong($a_content_long)
Set ContentLong.
getVisibility()
Get Visibility.
getAggregatedChildNewsData($a_ref_id, $a_only_public=false, $a_time_period=0, $a_prevent_aggregation=false, $a_starting_date="", $a_no_auto_generated=false)
Get news aggregation for child objects (e.g.
update($a_as_new=false)
Update item in database.
deliverMobFile($a_purpose="Standard", $a_increase_download_cnt=false)
Deliver mob file.
static _getDefaultVisibilityForRefId($a_ref_id)
Get default visibility for reference id.
static _lookupVisibility($a_news_id)
Lookup News Visibility.
static _lookupTitle($a_news_id)
Lookup News Title.
static _getNewsItemsOfUser($a_user_id, $a_only_public=false, $a_prevent_aggregation=false, $a_per=0, &$a_cnt=NULL)
Get all news items for a user.
__construct($a_id=0)
Constructor.
static getFirstNewsIdForContext($a_context_obj_id, $a_context_obj_type, $a_context_sub_obj_id="", $a_context_sub_obj_type="")
Get first new id of news set related to a certain context.
static _lookupMobId($a_news_id)
Lookup mob id.
setContext($a_obj_id, $a_obj_type, $a_sub_obj_id=0, $a_sub_obj_type="")
Convenient function to set the whole context information.
read()
Read item from database.
setMobPlayCounter($a_val)
Set mob play counter.
queryNewsForMultipleContexts($a_contexts, $a_for_rss_use=false, $a_time_period=0, $a_starting_date="", $a_no_auto_generated=false, $a_user_id=null)
Query News for multiple Contexts.
static handleTimePeriod($a_time_period)
Convert time period for DB-queries.
aggregateForums($news, $a_group_posting_sequence=false)
increasePlayCounter()
Increase play counter.
setLimitation($a_limitation)
Set Limitation for number of items.
increaseDownloadCounter()
Increase download counter.
static filterObjIdsPerNews($a_obj_ids, $a_time_period=0, $a_starting_date="", $a_ending_date='', $ignore_period=false)
Checks whether news are available for.
static determineNewsContent($a_context_obj_type, $a_content, $a_is_lang_var)
Determine new content.
_setRead($a_user_id, $a_news_id)
Set item read.
static determineNewsTitle($a_context_obj_type, $a_title, $a_content_is_lang_var, $a_agg_ref_id=0, $a_aggregation="")
Determine title for news item entry.
checkNewsExistsForGroupCourse($a_ref_id, $a_time_period=1)
_setUnread($a_user_id, $a_news_id)
Set item unread.
static prepareNewsDataFromCache($a_cres)
Prepare news data from cache.
static deleteNewsOfContext($a_context_obj_id, $a_context_obj_type, $a_context_sub_obj_id=0, $a_context_sub_obj_type="")
Delete all news of a context.
getLimitation()
Get Limitation for number of items.
_lookupUserPDPeriod($a_user_id)
mergeNews($n1, $n2)
Merges two sets of news.
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)
Get news aggregation (e.g.
setContentTextIsLangVar($a_val=0)
Set content text ist lang var.
static getLastNewsIdForContext($a_context_obj_id, $a_context_obj_type, $a_context_sub_obj_id="", $a_context_sub_obj_type="", $a_only_today=false)
Get last news id of news set related to a certain context.
getNewsForRefId($a_ref_id, $a_only_public=false, $a_stopnesting=false, $a_time_period=0, $a_prevent_aggregation=true, $a_forum_group_sequences=false, $a_no_auto_generated=false, $a_ignore_date_filter=false, $a_user_id=null)
Get News For Ref Id.
getMobPlayCounter()
Get mob play counter.
getMobDownloadCounter()
Get mob download counter.
setMobDownloadCounter($a_val)
Set mob download counter.
getContentTextIsLangVar()
Get content text ist lang var.
aggregateFiles($news, $a_ref_id)
queryNewsForContext($a_for_rss_use=false, $a_time_period=0, $a_starting_date="", $a_no_auto_generated=false, $a_oldest_first=false, $a_limit=0)
static _lookupContextObjId($a_news_id)
Context Object ID.
setPrivateFeedId($a_userId)
static _lookupMediaObjectUsages($a_mob_id)
Lookup media object usage(s)
static _getSubscriptionsOfUser($a_user_id)
Get subscriptions of user.
static _lookupDesktopItems($user_id, $a_types="")
get all desktop items of user and specified type
_lookupPref($a_usr_id, $a_keyword)
static preloadData(array $a_ref_ids)
Preload data to internal cache.
static _lookupObjId($a_id)
static _getAllReferences($a_id)
get all reference ids of object
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static redirect($a_script)
http redirect to other script
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static now()
Return current timestamp in Y-m-d H:i:s format.
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.