4define(
"NEWS_NOTICE", 0);
 
    5define(
"NEWS_MESSAGE", 1);
 
    6define(
"NEWS_WARNING", 2);
 
    8define(
"NEWS_TEXT", 
"text");
 
    9define(
"NEWS_HTML", 
"html");
 
   10define(
"NEWS_AUDIO", 
"audio");
 
   11define(
"NEWS_USERS", 
"users");
 
   12define(
"NEWS_PUBLIC", 
"public");
 
  107        $this->db = 
$DIC->database();
 
  108        $this->tree = 
$DIC->repositoryTree();
 
  109        $this->access = 
$DIC->access();
 
  110        $this->obj_data_cache = 
$DIC[
"ilObjDataCache"];
 
  111        $this->
user = $DIC->user();
 
  112        $this->lng = 
$DIC->language();
 
  113        $this->ctrl = 
$DIC->ctrl();
 
  118        $this->limitation = 
true;
 
  148        $this->title = $a_title;
 
  168        $this->content = $a_content;
 
  188        $this->context_obj_id = $a_context_obj_id;
 
  208        $this->context_obj_type = $a_context_obj_type;
 
  228        $this->context_sub_obj_id = $a_context_sub_obj_id;
 
  248        $this->context_sub_obj_type = $a_context_sub_obj_type;
 
  268        $this->content_type = $a_content_type;
 
  288        $this->creation_date = $a_creation_date;
 
  308        $this->update_date = $a_update_date;
 
  328        $this->user_id = $a_user_id;
 
  348        $this->update_user_id = $a_val;
 
  368        $this->visibility = $a_visibility;
 
  388        $this->content_long = $a_content_long;
 
  408        $this->priority = $a_priority;
 
  428        $this->content_is_lang_var = $a_content_is_lang_var;
 
  448        $this->mob_id = $a_mob_id;
 
  468        $this->playtime = $a_playtime;
 
  489        $this->limitation = $a_limitation;
 
  509        $this->content_text_is_lang_var = $a_val;
 
  519        return $this->content_text_is_lang_var;
 
  529        $this->mob_cnt_play = $a_val;
 
  539        return $this->mob_cnt_play;
 
  549        $this->mob_cnt_download = $a_val;
 
  559        return $this->mob_cnt_download;
 
  569        $this->content_html = $a_val;
 
  590        $query = 
"SELECT * FROM il_news_item WHERE id = " .
 
  593        $rec = 
$ilDB->fetchAssoc($set);
 
  628        $ilDB->insert(
"il_news_item", array(
 
  629            "id" => array(
"integer", $this->
getId()),
 
  630            "title" => array(
"text", $this->
getTitle()),
 
  631            "content" => array(
"clob", $this->
getContent()),
 
  632            "content_html" => array(
"integer", (
int) $this->
getContentHtml()),
 
  638            "creation_date" => array(
"timestamp", 
ilUtil::now()),
 
  639            "update_date" => array(
"timestamp", 
ilUtil::now()),
 
  640            "user_id" => array(
"integer", $this->
getUserId()),
 
  644            "priority" => array(
"integer", $this->
getPriority()),
 
  647            "mob_id" => array(
"integer", $this->
getMobId()),
 
  653        $max_items = $news_set->get(
"max_items");
 
  654        if ($max_items <= 0) {
 
  661            $query = 
"SELECT count(*) cnt " .
 
  662                "FROM il_news_item " .
 
  670            $rec = 
$ilDB->fetchAssoc($set);
 
  675                    "FROM il_news_item " .
 
  681                        " ORDER BY creation_date ASC";
 
  683                $ilDB->setLimit($rec[
"cnt"] - $max_items);
 
  685                while ($del_item = 
$ilDB->fetchAssoc($del_set)) {
 
  699    public function update($a_as_new = 
false)
 
  704            "title" => array(
"text", $this->
getTitle()),
 
  705            "content" => array(
"clob", $this->
getContent()),
 
  706            "content_html" => array(
"integer", (
int) $this->
getContentHtml()),
 
  712            "user_id" => array(
"integer", $this->
getUserId()),
 
  716            "priority" => array(
"integer", $this->
getPriority()),
 
  719            "mob_id" => array(
"integer", $this->
getMobId()),
 
  727            $fields[
"creation_date"] = array(
"timestamp", $now);
 
  728            $fields[
"update_date"] = array(
"timestamp", $now);
 
  730            $fields[
"update_date"] = array(
"timestamp", $now);
 
  733        $ilDB->update(
"il_news_item", $fields, array(
 
  734            "id" => array(
"integer", $this->
getId())
 
  745        $a_only_public = 
false,
 
  746        $a_prevent_aggregation = 
false,
 
  752        $ilAccess = 
$DIC->access();
 
  761        include_once(
"./Services/News/classes/class.ilNewsSubscription.php");
 
  762        include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
 
  769            $pd_items = $fav_rep->getFavouritesOfUser($a_user_id);
 
  770            foreach ($pd_items as $item) {
 
  771                if (!in_array($item[
"ref_id"], $ref_ids)) {
 
  772                    $ref_ids[] = $item[
"ref_id"];
 
  777            include_once 
'Services/Membership/classes/class.ilParticipants.php';
 
  780            $items = array_merge($crs_mbs, $grp_mbs);
 
  781            foreach ($items as 
$i) {
 
  783                if (is_array($item_references) && count($item_references)) {
 
  784                    foreach ($item_references as $ref_id) {
 
  785                        if (!in_array($ref_id, $ref_ids)) {
 
  786                            $ref_ids[] = $ref_id;
 
  795        foreach ($ref_ids as $ref_id) {
 
  796            if (!$a_only_public) {
 
  798                $acc = $ilAccess->checkAccessOfUser($a_user_id, 
"read", 
"", $ref_id);
 
  807                $rbacsystem = 
$DIC->rbac()->system();
 
  817            $news = $news_item->getNewsForRefId(
 
  822                $a_prevent_aggregation,
 
  830            if (!is_null($a_cnt)) {
 
  831                $a_cnt[$ref_id] = count($news);
 
  862        $a_only_public = 
false,
 
  863        $a_stopnesting = 
false,
 
  865        $a_prevent_aggregation = 
true,
 
  866        $a_forum_group_sequences = 
false,
 
  867        $a_no_auto_generated = 
false,
 
  868        $a_ignore_date_filter = 
false,
 
  871        $a_excluded = array()
 
  878        if ($obj_type == 
"grp" || $obj_type == 
"crs") {
 
  897            include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
 
  900                "hide_news_per_date",
 
  904            if ($hide_news_per_date && !$a_ignore_date_filter) {
 
  914        if ($obj_type == 
"cat" && !$a_stopnesting) {
 
  919                $a_prevent_aggregation,
 
  923        } elseif (($obj_type == 
"grp" || $obj_type == 
"crs") &&
 
  929                $a_prevent_aggregation,
 
  931                $a_no_auto_generated,
 
  938            $news_item->setContextObjId($obj_id);
 
  939            $news_item->setContextObjType($obj_type);
 
  940            $news = $news_item->queryNewsForContext(
 
  947            foreach ($news as $k => $v) {
 
  948                if (!$a_only_public || $v[
"visibility"] == 
NEWS_PUBLIC ||
 
  949                    ($v[
"priority"] == 0 &&
 
  952                            "public_notifications",
 
  956                    $news[$k][
"ref_id"] = $a_ref_id;
 
  961            foreach ($unset as $un) {
 
  966        if (!$a_prevent_aggregation) {
 
  968        } elseif ($a_forum_group_sequences) {
 
  981        $a_only_public = 
false,
 
  983        $a_prevent_aggregation = 
false,
 
  984        $a_starting_date = 
"",
 
  985        $a_no_auto_generated = 
false,
 
  999        $cur_node = 
$tree->getNodeData($a_ref_id);
 
 1003            $nodes = (array) 
$tree->getSubTree($cur_node, 
true);
 
 1011        foreach ($nodes as $node) {
 
 1012            $ref_ids[] = $node[
"child"];
 
 1013            $obj_ids[] = $node[
"obj_id"];
 
 1016        $ilObjDataCache->preloadReferenceCache($ref_ids);
 
 1017        if (!$a_only_public) {
 
 1018            include_once 
"Services/Object/classes/class.ilObjectActivation.php";
 
 1027        $contexts = array();
 
 1028        foreach ($nodes as $node) {
 
 1030            if (!in_array($node[
"obj_id"], $news_obj_ids)) {
 
 1034            if (!$a_only_public) {
 
 1036                    $acc = $ilAccess->checkAccess(
"read", 
"", $node[
"child"]);
 
 1038                    $acc = $ilAccess->checkAccessOfUser(
 
 1050            $ref_id[$node[
"obj_id"]] = $node[
"child"];
 
 1051            $contexts[] = array(
"obj_id" => $node[
"obj_id"],
 
 1052                "obj_type" => $node[
"type"]);
 
 1061            $a_no_auto_generated,
 
 1068        foreach ($news as $k => $v) {
 
 1069            $news[$k][
"ref_id"] = $ref_id[$v[
"context_obj_id"]];
 
 1075        if (!$a_prevent_aggregation) {
 
 1094        foreach ($news as $k => $v) {
 
 1095            if ($a_group_posting_sequence && $last_aggregation_forum > 0 &&
 
 1096                $last_aggregation_forum != $news[$k][
"context_obj_id"]) {
 
 1097                $forums[$last_aggregation_forum] = 
"";
 
 1100            if ($news[$k][
"context_obj_type"] == 
"frm") {
 
 1101                if ($forums[$news[$k][
"context_obj_id"]] == 
"") {
 
 1103                    $forums[$news[$k][
"context_obj_id"]] = $k;
 
 1104                    $last_aggregation_forum = $news[$k][
"context_obj_id"];
 
 1109                $news[$k][
"no_context_title"] = 
true;
 
 1112                $news[$forums[$news[$k][
"context_obj_id"]]][
"aggregation"][$k]
 
 1114                $news[$k][
"agg_ref_id"]
 
 1115                    = $news[$k][
"ref_id"];
 
 1116                $news[$k][
"content"] = 
"";
 
 1117                $news[$k][
"content_long"] = 
"";
 
 1122        foreach ($to_del as $k) {
 
 1141        foreach ($news as $k => $v) {
 
 1143            if ($news[$k][
"context_obj_type"] == 
"file") {
 
 1144                if ($first_file == 
"") {
 
 1149                $news[$first_file][
"aggregation"][$k] = $news[$k];
 
 1150                $news[$first_file][
"agg_ref_id"] = $a_ref_id;
 
 1151                $news[$first_file][
"ref_id"] = $a_ref_id;
 
 1155        foreach ($to_del as $v) {
 
 1176        $a_only_public = 
false,
 
 1178        $a_prevent_aggregation = 
false,
 
 1179        $a_starting_date = 
"",
 
 1180        $a_no_auto_generated = 
false 
 1194            $a_no_auto_generated
 
 1196        foreach (
$data as $k => $v) {
 
 1197            $data[$k][
"ref_id"] = $a_ref_id;
 
 1201        $nodes = 
$tree->getChilds($a_ref_id);
 
 1205        foreach ($nodes as $node) {
 
 1206            $obj_ids[] = $node[
"obj_id"];
 
 1212        $contexts = array();
 
 1213        foreach ($nodes as $node) {
 
 1215            if (!in_array($node[
"obj_id"], $news_obj_ids)) {
 
 1219            if (!$a_only_public && !$ilAccess->checkAccess(
"read", 
"", $node[
"child"])) {
 
 1222            $ref_id[$node[
"obj_id"]] = $node[
"child"];
 
 1223            $contexts[] = array(
"obj_id" => $node[
"obj_id"],
 
 1224                "obj_type" => $node[
"type"]);
 
 1232            $a_no_auto_generated
 
 1234        foreach ($news as $k => $v) {
 
 1235            $news[$k][
"ref_id"] = $ref_id[$v[
"context_obj_id"]];
 
 1242        if (!$a_prevent_aggregation) {
 
 1257    public function setContext(
int $a_obj_id, 
string $a_obj_type, 
int $a_sub_obj_id = 0, 
string $a_sub_obj_type = 
"")
 
 1274        if (is_numeric($a_time_period)) {
 
 1275            if ($a_time_period > 0) {
 
 1276                return date(
'Y-m-d H:i:s', time() - ($a_time_period * 24 * 60 * 60));
 
 1280        elseif (preg_match(
"/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/", $a_time_period)) {
 
 1281            return $a_time_period;
 
 1296        $a_for_rss_use = 
false,
 
 1298        $a_starting_date = 
"",
 
 1299        $a_no_auto_generated = 
false,
 
 1300        $a_oldest_first = 
false,
 
 1308        if ($a_time_period > 0) {
 
 1310            $and = 
" AND creation_date >= " . 
$ilDB->quote($limit_ts, 
"timestamp") . 
" ";
 
 1313        if ($a_starting_date != 
"") {
 
 1314            $and .= 
" AND creation_date > " . 
$ilDB->quote($a_starting_date, 
"timestamp") . 
" ";
 
 1317        if ($a_no_auto_generated) {
 
 1318            $and .= 
" AND priority = 1 AND content_type = " . 
$ilDB->quote(
"text", 
"text") . 
" ";
 
 1327        $ordering = ($a_oldest_first)
 
 1328            ? 
" creation_date ASC, id ASC " 
 1329            : 
" creation_date DESC, id DESC ";
 
 1333                "FROM il_news_item " .
 
 1336                    " AND context_obj_type = " . 
$ilDB->quote($this->getContextObjType(), 
"text") .
 
 1338                    " ORDER BY " . $ordering;
 
 1340            $query = 
"SELECT il_news_item.* " .
 
 1341                ", il_news_read.user_id user_read " .
 
 1342                "FROM il_news_item LEFT JOIN il_news_read " .
 
 1343                "ON il_news_item.id = il_news_read.news_id AND " .
 
 1349                    " ORDER BY " . $ordering;
 
 1351            $query = 
"SELECT il_news_item.* " .
 
 1352                ", il_news_read.user_id as user_read " .
 
 1353                "FROM il_news_item LEFT JOIN il_news_read " .
 
 1354                "ON il_news_item.id = il_news_read.news_id AND " .
 
 1355                " il_news_read.user_id = " . 
$ilDB->quote(
$ilUser->getId(), 
"integer") .
 
 1360                    " ORDER BY " . $ordering;
 
 1365        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
 1366            if ($a_limit > 0 && count(
$result) >= $a_limit) {
 
 1370                ($rec[
"priority"] == 0 &&
 
 1373                    "public_notifications",
 
 1375                    $rec[
"context_obj_id"]
 
 1386        if ($a_time_period != 
"" && $a_for_rss_use) {
 
 1387            include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
 
 1394            if ($keep_rss_min > 0) {
 
 1399                    $a_no_auto_generated,
 
 1420        $set = 
$ilDB->query(
"SELECT * FROM il_news_item " .
 
 1421            " WHERE " . 
$ilDB->in(
"id", $a_news_ids, 
false, 
"integer"));
 
 1422        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
 1423            $news[$rec[
"id"]] = $rec;
 
 1444        $query = 
$ilDB->query(
"SELECT id,context_obj_id,context_obj_type" .
 
 1445            " FROM il_news_item" .
 
 1446            " WHERE " . 
$ilDB->in(
"context_obj_id", array_keys($objects), 
false, 
"integer") .
 
 1447            " AND creation_date >= " . 
$ilDB->quote($limit_ts, 
"timestamp"));
 
 1449            if ($objects[$rec[
"context_obj_id"]][
"type"] == $rec[
"context_obj_type"]) {
 
 1450                $all[] = $rec[
"id"];
 
 1472        $a_for_rss_use = 
false,
 
 1474        $a_starting_date = 
"",
 
 1475        $a_no_auto_generated = 
false,
 
 1478        $a_exclude = array()
 
 1486        if ($a_time_period > 0) {
 
 1488            $and = 
" AND creation_date >= " . 
$ilDB->quote($limit_ts, 
"timestamp") . 
" ";
 
 1491        if ($a_starting_date != 
"") {
 
 1492            $and .= 
" AND creation_date > " . 
$ilDB->quote($a_starting_date, 
"timestamp") . 
" ";
 
 1495        if ($a_no_auto_generated) {
 
 1496            $and .= 
" AND priority = 1 AND content_type = " . 
$ilDB->quote(
"text", 
"text") . 
" ";
 
 1500            $ilDB->setLimit($a_limit, 0);
 
 1503        if (is_array($a_exclude) && count($a_exclude) > 0) {
 
 1504            $and .= 
" AND " . 
$ilDB->in(
"id", $a_exclude, 
true, 
"integer") . 
" ";
 
 1510        foreach ($a_contexts as $cont) {
 
 1511            $ids[] = $cont[
"obj_id"];
 
 1512            $type[$cont[
"obj_id"]] = $cont[
"obj_type"];
 
 1517                "FROM il_news_item " .
 
 1519                    $ilDB->in(
"context_obj_id", $ids, 
false, 
"integer") . 
" " .
 
 1521                    " ORDER BY creation_date DESC ";
 
 1523            $query = 
"SELECT il_news_item.* " .
 
 1524                ", il_news_read.user_id as user_read " .
 
 1525                "FROM il_news_item LEFT JOIN il_news_read " .
 
 1526                "ON il_news_item.id = il_news_read.news_id AND " .
 
 1529                    $ilDB->in(
"context_obj_id", $ids, 
false, 
"integer") . 
" " .
 
 1531                    " ORDER BY creation_date DESC ";
 
 1538            $query = 
"SELECT il_news_item.* " .
 
 1539                ", il_news_read.user_id as user_read " .
 
 1540                "FROM il_news_item LEFT JOIN il_news_read " .
 
 1541                "ON il_news_item.id = il_news_read.news_id AND " .
 
 1542                " il_news_read.user_id = " . 
$ilDB->quote(
$user_id, 
"integer") .
 
 1544                    $ilDB->in(
"context_obj_id", $ids, 
false, 
"integer") . 
" " .
 
 1546                    " ORDER BY creation_date DESC ";
 
 1551        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
 1552            if (
$type[$rec[
"context_obj_id"]] == $rec[
"context_obj_type"]) {
 
 1554                    ($rec[
"priority"] == 0 &&
 
 1557                        "public_notifications",
 
 1559                        $rec[
"context_obj_id"]
 
 1574    public static function _setRead($a_user_id, $a_news_id)
 
 1579        $ilAppEventHandler = 
$DIC[
"ilAppEventHandler"];
 
 1584                "user_id" => array(
"integer", $a_user_id),
 
 1585                "news_id" => array(
"integer", $a_news_id)
 
 1598        $ilAppEventHandler->raise(
 
 1601            array(
"user_id" => $a_user_id, 
"news_ids" => array($a_news_id))
 
 1614        $ilAppEventHandler = 
$DIC[
"ilAppEventHandler"];
 
 1616        $ilDB->manipulate(
"DELETE FROM il_news_read (user_id, news_id) VALUES (" .
 
 1617            " WHERE user_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
 1618            " AND news_id = " . 
$ilDB->quote($a_news_id, 
"integer"));
 
 1620        $ilAppEventHandler->raise(
 
 1623            array(
"user_id" => $a_user_id, 
"news_ids" => array($a_news_id))
 
 1637        foreach ($n2 as 
$id => $news) {
 
 1656        include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
 
 1659        $default_visibility = ($news_set->get(
"default_visibility") != 
"")
 
 1660                ? $news_set->get(
"default_visibility")
 
 1663        if (
$tree->isInTree($a_ref_id)) {
 
 1664            $path = 
$tree->getPathFull($a_ref_id);
 
 1666            foreach ($path as $key => $row) {
 
 1667                if (!in_array($row[
"type"], array(
"root", 
"cat",
"crs", 
"fold", 
"grp"))) {
 
 1673                    "default_visibility",
 
 1684        return $default_visibility;
 
 1692    public function delete()
 
 1697        $ilDB->manipulate(
"DELETE FROM il_news_read " .
 
 1698            " WHERE news_id = " . 
$ilDB->quote($this->getId(), 
"integer"));
 
 1704        $query = 
"DELETE FROM il_news_item" .
 
 1705            " WHERE id = " . 
$ilDB->quote($this->
getId(), 
"integer");
 
 1710            include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
 1722        $a_context_obj_type,
 
 1723        $a_context_sub_obj_id = 0,
 
 1724        $a_context_sub_obj_type = 
"" 
 1730        if ($a_context_obj_id == 0 || $a_context_obj_type == 
"") {
 
 1734        if ($a_context_sub_obj_id > 0) {
 
 1735            $and = 
" AND context_sub_obj_id = " . 
$ilDB->quote($a_context_sub_obj_id, 
"integer") .
 
 1736                " AND context_sub_obj_type = " . 
$ilDB->quote($a_context_sub_obj_type, 
"text");
 
 1740        $query = 
"SELECT * FROM il_news_item" .
 
 1741            " WHERE context_obj_id = " . 
$ilDB->quote($a_context_obj_id, 
"integer") .
 
 1742            " AND context_obj_type = " . 
$ilDB->quote($a_context_obj_type, 
"text") .
 
 1748        while ($news = 
$ilDB->fetchAssoc($news_set)) {
 
 1760        $a_context_obj_type,
 
 1761        $a_context_sub_obj_id = 0,
 
 1762        $a_context_sub_obj_type = 
"" 
 1764        foreach (self::getNewsOfContext(
 
 1766            $a_context_obj_type,
 
 1767            $a_context_sub_obj_id,
 
 1768            $a_context_sub_obj_type
 
 1784        $query = 
"SELECT title FROM il_news_item WHERE id = " .
 
 1785            $ilDB->quote($a_news_id, 
"integer");
 
 1787        $rec = 
$ilDB->fetchAssoc($set);
 
 1788        return $rec[
"title"];
 
 1801        $query = 
"SELECT visibility FROM il_news_item WHERE id = " .
 
 1802            $ilDB->quote($a_news_id, 
"integer");
 
 1804        $rec = 
$ilDB->fetchAssoc($set);
 
 1806        return $rec[
"visibility"];
 
 1819        $query = 
"SELECT mob_id FROM il_news_item WHERE id = " .
 
 1820            $ilDB->quote($a_news_id, 
"integer");
 
 1822        $rec = 
$ilDB->fetchAssoc($set);
 
 1823        return $rec[
"mob_id"];
 
 1830    public static function filterObjIdsPerNews($a_obj_ids, $a_time_period = 0, $a_starting_date = 
"", $a_ending_date = 
'', $ignore_period = 
false)
 
 1837        if ($a_time_period > 0) {
 
 1839            $and = 
" AND creation_date >= " . 
$ilDB->quote($limit_ts, 
"timestamp") . 
" ";
 
 1842        if ($a_starting_date != 
"") {
 
 1843            $and .= 
" AND creation_date >= " . 
$ilDB->quote($a_starting_date, 
"timestamp");
 
 1846        $query = 
"SELECT DISTINCT(context_obj_id) AS obj_id FROM il_news_item" .
 
 1847            " WHERE " . 
$ilDB->in(
"context_obj_id", $a_obj_ids, 
false, 
"integer") . 
" " . $and;
 
 1852        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
 1853            $objs[] = $rec[
"obj_id"];
 
 1868        $query = 
"SELECT context_obj_type, content_is_lang_var, title FROM il_news_item WHERE id = " .
 
 1869            $ilDB->quote($a_news_id, 
"integer");
 
 1871        $rec = 
$ilDB->fetchAssoc($set);
 
 1874            $rec[
"context_obj_type"],
 
 1876            $rec[
"content_is_lang_var"],
 
 1887        $a_context_obj_type,
 
 1889        $a_content_is_lang_var,
 
 1896        $obj_definition = 
$DIC[
"objDefinition"];
 
 1898        if ($a_agg_ref_id > 0) {
 
 1899            $cnt = count($a_aggregation);
 
 1902            if ($a_context_obj_type == 
"frm") {
 
 1904                    return sprintf(
$lng->txt(
"news_x_postings"), $cnt);
 
 1906                    return $lng->txt(
"news_1_postings");
 
 1909                $up_cnt = $cr_cnt = 0;
 
 1910                foreach ($a_aggregation as $item) {
 
 1911                    if ($item[
"title"] == 
"file_updated") {
 
 1919                    $tit = 
$lng->txt(
"news_1_file_created");
 
 1921                } elseif ($cr_cnt > 1) {
 
 1922                    $tit = sprintf(
$lng->txt(
"news_x_files_created"), $cr_cnt);
 
 1926                    $tit .= $sep . 
$lng->txt(
"news_1_file_updated");
 
 1927                } elseif ($up_cnt > 1) {
 
 1928                    $tit .= $sep . sprintf(
$lng->txt(
"news_x_files_updated"), $up_cnt);
 
 1933            if ($a_content_is_lang_var) {
 
 1934                if ($obj_definition->isPlugin($a_context_obj_type)) {
 
 1937                return $lng->txt($a_title);
 
 1955        $obj_definition = 
$DIC[
"objDefinition"];
 
 1957        if ($a_is_lang_var) {
 
 1958            if ($obj_definition->isPlugin($a_context_obj_type)) {
 
 1961            $lng->loadLanguageModule($a_context_obj_type);
 
 1962            return $lng->txt($a_content);
 
 1976        $a_context_obj_type,
 
 1977        $a_context_sub_obj_id = 
"",
 
 1978        $a_context_sub_obj_type = 
"" 
 1986            "FROM il_news_item " .
 
 1988                "context_obj_id = " . 
$ilDB->quote($a_context_obj_id, 
"integer") .
 
 1989                " AND context_obj_type = " . 
$ilDB->quote($a_context_obj_type, 
"text") .
 
 1990                " AND context_sub_obj_id = " . 
$ilDB->quote($a_context_sub_obj_id, 
"integer") .
 
 1991                " AND " . 
$ilDB->equals(
"context_sub_obj_type", $a_context_sub_obj_type, 
"text", 
true);
 
 1994        $rec = 
$ilDB->fetchAssoc($set);
 
 2005        $a_context_obj_type,
 
 2006        $a_context_sub_obj_id = 
"",
 
 2007        $a_context_sub_obj_type = 
"",
 
 2008        $a_only_today = 
false 
 2015        $query = 
"SELECT id, update_date " .
 
 2016            "FROM il_news_item " .
 
 2018                "context_obj_id = " . 
$ilDB->quote($a_context_obj_id, 
"integer") .
 
 2019                " AND context_obj_type = " . 
$ilDB->quote($a_context_obj_type, 
"text") .
 
 2020                " AND context_sub_obj_id = " . 
$ilDB->quote($a_context_sub_obj_id, 
"integer") .
 
 2021                " AND " . 
$ilDB->equals(
"context_sub_obj_type", $a_context_sub_obj_type, 
"text", 
true) .
 
 2022            " ORDER BY update_date DESC";
 
 2026        $rec = 
$ilDB->fetchAssoc($set);
 
 2028        $id = (int) $rec[
"id"];
 
 2029        if ($a_only_today) {
 
 2031            if (substr($now, 0, 10) != substr($rec[
"update_date"], 0, 10)) {
 
 2051            "FROM il_news_item " .
 
 2053                " mob_id = " . 
$ilDB->quote($a_mob_id, 
"integer");
 
 2057        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
 2058            $usages[$rec[
"id"]] = array(
"type" => 
"news", 
"id" => $rec[
"id"]);
 
 2075            "FROM il_news_item " .
 
 2077                " id = " . 
$ilDB->quote($a_news_id, 
"integer");
 
 2079        $rec = 
$ilDB->fetchAssoc($set);
 
 2081        return $rec[
"context_obj_id"];
 
 2090        $per = $news_set->get(
"pd_period");
 
 2104        $allow_shorter_periods = $news_set->get(
"allow_shorter_periods");
 
 2105        $allow_longer_periods = $news_set->get(
"allow_longer_periods");
 
 2108        include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
 
 2118            (!$allow_shorter_periods && ($per < $default_per)) ||
 
 2119            (!$allow_longer_periods && ($per > $default_per))
 
 2121            $per = $default_per;
 
 2133        $rss_period = $news_set->get(
"rss_period");
 
 2134        if ($rss_period == 0) {         
 
 2164    public function deliverMobFile($a_purpose = 
"Standard", $a_increase_download_cnt = 
false)
 
 2167        include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
 2172        if (!$mob->hasPurposeItem($a_purpose)) {
 
 2176        $m_item = $mob->getMediaItem($a_purpose);
 
 2177        if ($m_item->getLocationType() != 
"Reference") {
 
 2178            $file = $mob_dir . 
"/" . $m_item->getLocation();
 
 2179            if (file_exists($file) && is_file($file)) {
 
 2180                if ($a_increase_download_cnt) {
 
 2190            if ($a_increase_download_cnt) {
 
 2209            "UPDATE il_news_item SET " .
 
 2210            " mob_cnt_download = " . 
$ilDB->quote($cnt, 
"integer") .
 
 2211            " WHERE id = " . 
$ilDB->quote($this->getId(), 
"integer")
 
 2228            "UPDATE il_news_item SET " .
 
 2229            " mob_cnt_play = " . 
$ilDB->quote($cnt, 
"integer") .
 
 2230            " WHERE id = " . 
$ilDB->quote($this->getId(), 
"integer")
 
 2247        $news_ids = array_keys(
$data);
 
 2248        $set = 
$ilDB->query(
"SELECT id FROM il_news_item " .
 
 2249            " WHERE " . 
$ilDB->in(
"id", $news_ids, 
false, 
"integer"));
 
 2250        $existing_ids = array();
 
 2251        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
 2252            $existing_ids[] = $rec[
"id"];
 
 2255        $existing_news = array();
 
 2256        foreach (
$data as $k => $v) {
 
 2257            if (in_array($k, $existing_ids)) {
 
 2258                $existing_news[$k] = $v;
 
 2265        return $existing_news;
 
An exception for terminatinating execution or to throw for unit testing.
static _lookup($a_type, $a_setting, $a_user=0, $a_block_id=0)
Lookup setting from database.
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
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.
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, $a_limit=0, $a_excluded=array())
Get News For Ref Id.
static _lookupTitle($a_news_id)
Lookup News Title.
setContent($a_content)
Set Content.
__construct($a_id=0)
Constructor.
static getPrivateFeedId()
static _lookupRSSPeriod()
setMobId($a_mob_id)
Set MobId.
getContentIsLangVar()
Get ContentIsLangVar.
static _setUnread($a_user_id, $a_news_id)
Set item unread.
setCreationDate($a_creation_date)
Set CreationDate.
static _lookupMobId($a_news_id)
Lookup mob id.
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.
read()
Read item from database.
setMobPlayCounter($a_val)
Set mob play counter.
getUpdateDate()
Get UpdateDate.
static handleTimePeriod($a_time_period)
Convert time period for DB-queries.
getPlaytime()
Get Playtime.
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, $a_limit=0, $a_exclude=array())
Get news aggregation (e.g.
aggregateForums($news, $a_group_posting_sequence=false)
setContentIsLangVar($a_content_is_lang_var=0)
Set ContentIsLangVar.
getContextSubObjId()
Get ContextSubObjId.
getContextSubObjType()
Get ContextSubObjType.
setUserId($a_user_id)
Set UserId.
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.
setContextObjId($a_context_obj_id)
Set ContextObjId.
setContextSubObjId($a_context_sub_obj_id)
Set ContextSubObjId.
checkNewsExistsForObjects($objects, $a_time_period=1)
static getNewsOfContext( $a_context_obj_id, $a_context_obj_type, $a_context_sub_obj_id=0, $a_context_sub_obj_type="")
Get all news of a context.
increasePlayCounter()
Increase play counter.
setLimitation($a_limitation)
Set Limitation for number of items.
increaseDownloadCounter()
Increase download counter.
static _setRead($a_user_id, $a_news_id)
Set item read.
getVisibility()
Get Visibility.
static filterObjIdsPerNews($a_obj_ids, $a_time_period=0, $a_starting_date="", $a_ending_date='', $ignore_period=false)
Checks whether news are available for.
setUpdateDate($a_update_date)
Set UpdateDate.
setContext(int $a_obj_id, string $a_obj_type, int $a_sub_obj_id=0, string $a_sub_obj_type="")
Set context for news.
static determineNewsContent($a_context_obj_type, $a_content, $a_is_lang_var)
Determine new content.
setTitle($a_title)
Set Title.
static prepareNewsDataFromCache($a_cres)
Prepare news data from cache.
getContentType()
Get ContentType.
setUpdateUserId($a_val)
Set update user id.
getLimitation()
Get Limitation for number of items.
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.
setPlaytime($a_playtime)
Set Playtime.
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)
Query news for a context.
static _lookupUserPDPeriod($a_user_id)
setContextObjType($a_context_obj_type)
Set ContextObjType.
setPriority($a_priority=1)
Set Priority.
setContentLong($a_content_long)
Set ContentLong.
static determineNewsTitleByNewsId($a_news_id, $a_agg_ref_id=0, $a_aggregation="")
Determine title for news item entry.
static queryNewsByIds(array $a_news_ids)
Query news data by news ids.
static setPrivateFeedId($a_userId)
getContentLong()
Get ContentLong.
static mergeNews($n1, $n2)
Merges two sets of news.
static _lookupDefaultPDPeriod()
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.
setContentTextIsLangVar($a_val=0)
Set content text ist lang var.
getPriority()
Get Priority.
setVisibility($a_visibility="users")
Set Visibility.
getContextObjId()
Get ContextObjId.
setContentType($a_content_type="text")
Set ContentType.
getMobPlayCounter()
Get 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, $a_limit=0, $a_exclude=array())
Query News for multiple Contexts.
setContextSubObjType($a_context_sub_obj_type)
Set ContextSubObjType.
setContentHtml($a_val)
Is content HTML (tiny used?)
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.
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.
getMobDownloadCounter()
Get mob download counter.
setMobDownloadCounter($a_val)
Set mob download counter.
getCreationDate()
Get CreationDate.
getContentTextIsLangVar()
Get content text ist lang var.
aggregateFiles($news, $a_ref_id)
static _lookupContextObjId($a_news_id)
Context Object ID.
getContextObjType()
Get ContextObjType.
getUpdateUserId()
Get update user id.
getContentHtml()
Get content as html.
static _lookupMediaObjectUsages($a_mob_id)
Lookup media object usage(s)
static _getSubscriptionsOfUser($a_user_id)
Get subscriptions of user.
static _lookupPref($a_usr_id, $a_keyword)
static preloadData(array $a_ref_ids)
Preload data to internal cache.
static lookupTxtById($plugin_id, $lang_var)
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)
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.