4 define(
"NEWS_NOTICE", 0);
5 define(
"NEWS_MESSAGE", 1);
6 define(
"NEWS_WARNING", 2);
8 define(
"NEWS_TEXT",
"text");
9 define(
"NEWS_HTML",
"html");
10 define(
"NEWS_AUDIO",
"audio");
11 define(
"NEWS_USERS",
"users");
12 define(
"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;
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();
759 include_once(
"./Services/News/classes/class.ilNewsSubscription.php");
760 include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
768 foreach ($pd_items as $item) {
769 if (!in_array($item[
"ref_id"], $ref_ids)) {
770 $ref_ids[] = $item[
"ref_id"];
775 include_once
'Services/Membership/classes/class.ilParticipants.php';
778 $items = array_merge($crs_mbs, $grp_mbs);
779 foreach ($items as
$i) {
781 if (is_array($item_references) && count($item_references)) {
782 foreach ($item_references as $ref_id) {
783 if (!in_array($ref_id, $ref_ids)) {
784 $ref_ids[] = $ref_id;
793 foreach ($ref_ids as $ref_id) {
794 if (!$a_only_public) {
796 $acc = $ilAccess->checkAccessOfUser($a_user_id,
"read",
"", $ref_id);
805 $rbacsystem = $DIC->rbac()->system();
815 $news = $news_item->getNewsForRefId(
820 $a_prevent_aggregation,
828 if (!is_null($a_cnt)) {
829 $a_cnt[$ref_id] = count($news);
860 $a_only_public =
false,
861 $a_stopnesting =
false,
863 $a_prevent_aggregation =
true,
864 $a_forum_group_sequences =
false,
865 $a_no_auto_generated =
false,
866 $a_ignore_date_filter =
false,
869 $a_excluded = array()
876 if ($obj_type ==
"grp" || $obj_type ==
"crs" || $obj_type ==
"cat") {
877 include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
880 "hide_news_per_date",
884 if ($hide_news_per_date && !$a_ignore_date_filter) {
894 if ($obj_type ==
"cat" && !$a_stopnesting) {
899 $a_prevent_aggregation,
903 } elseif (($obj_type ==
"grp" || $obj_type ==
"crs") &&
909 $a_prevent_aggregation,
911 $a_no_auto_generated,
918 $news_item->setContextObjId($obj_id);
919 $news_item->setContextObjType($obj_type);
920 $news = $news_item->queryNewsForContext(
927 foreach ($news as $k => $v) {
928 if (!$a_only_public || $v[
"visibility"] ==
NEWS_PUBLIC ||
929 ($v[
"priority"] == 0 &&
932 "public_notifications",
936 $news[$k][
"ref_id"] = $a_ref_id;
941 foreach ($unset as $un) {
946 if (!$a_prevent_aggregation) {
948 } elseif ($a_forum_group_sequences) {
961 $a_only_public =
false,
963 $a_prevent_aggregation =
false,
964 $a_starting_date =
"",
965 $a_no_auto_generated =
false,
979 $cur_node =
$tree->getNodeData($a_ref_id);
983 $nodes = (array)
$tree->getSubTree($cur_node,
true);
991 foreach (
$nodes as $node) {
992 $ref_ids[] = $node[
"child"];
993 $obj_ids[] = $node[
"obj_id"];
996 $ilObjDataCache->preloadReferenceCache($ref_ids);
997 if (!$a_only_public) {
998 include_once
"Services/Object/classes/class.ilObjectActivation.php";
1007 $contexts = array();
1008 foreach (
$nodes as $node) {
1010 if (!in_array($node[
"obj_id"], $news_obj_ids)) {
1014 if (!$a_only_public) {
1016 $acc = $ilAccess->checkAccess(
"read",
"", $node[
"child"]);
1018 $acc = $ilAccess->checkAccessOfUser(
1030 $ref_id[$node[
"obj_id"]] = $node[
"child"];
1031 $contexts[] = array(
"obj_id" => $node[
"obj_id"],
1032 "obj_type" => $node[
"type"]);
1041 $a_no_auto_generated,
1048 foreach ($news as $k => $v) {
1049 $news[$k][
"ref_id"] = $ref_id[$v[
"context_obj_id"]];
1055 if (!$a_prevent_aggregation) {
1074 foreach ($news as $k => $v) {
1075 if ($a_group_posting_sequence && $last_aggregation_forum > 0 &&
1076 $last_aggregation_forum != $news[$k][
"context_obj_id"]) {
1077 $forums[$last_aggregation_forum] =
"";
1080 if ($news[$k][
"context_obj_type"] ==
"frm") {
1081 if ($forums[$news[$k][
"context_obj_id"]] ==
"") {
1083 $forums[$news[$k][
"context_obj_id"]] = $k;
1084 $last_aggregation_forum = $news[$k][
"context_obj_id"];
1089 $news[$k][
"no_context_title"] =
true;
1092 $news[$forums[$news[$k][
"context_obj_id"]]][
"aggregation"][$k]
1094 $news[$k][
"agg_ref_id"]
1095 = $news[$k][
"ref_id"];
1096 $news[$k][
"content"] =
"";
1097 $news[$k][
"content_long"] =
"";
1102 foreach ($to_del as $k) {
1121 foreach ($news as $k => $v) {
1123 if ($news[$k][
"context_obj_type"] ==
"file") {
1124 if ($first_file ==
"") {
1129 $news[$first_file][
"aggregation"][$k] = $news[$k];
1130 $news[$first_file][
"agg_ref_id"] = $a_ref_id;
1131 $news[$first_file][
"ref_id"] = $a_ref_id;
1135 foreach ($to_del as $v) {
1156 $a_only_public =
false,
1158 $a_prevent_aggregation =
false,
1159 $a_starting_date =
"",
1160 $a_no_auto_generated =
false 1174 $a_no_auto_generated
1176 foreach (
$data as $k => $v) {
1177 $data[$k][
"ref_id"] = $a_ref_id;
1185 foreach (
$nodes as $node) {
1186 $obj_ids[] = $node[
"obj_id"];
1192 $contexts = array();
1193 foreach (
$nodes as $node) {
1195 if (!in_array($node[
"obj_id"], $news_obj_ids)) {
1199 if (!$a_only_public && !$ilAccess->checkAccess(
"read",
"", $node[
"child"])) {
1202 $ref_id[$node[
"obj_id"]] = $node[
"child"];
1203 $contexts[] = array(
"obj_id" => $node[
"obj_id"],
1204 "obj_type" => $node[
"type"]);
1212 $a_no_auto_generated
1214 foreach ($news as $k => $v) {
1215 $news[$k][
"ref_id"] = $ref_id[$v[
"context_obj_id"]];
1222 if (!$a_prevent_aggregation) {
1237 public function setContext(
int $a_obj_id,
string $a_obj_type,
int $a_sub_obj_id = 0,
string $a_sub_obj_type =
"")
1254 if (is_numeric($a_time_period)) {
1255 if ($a_time_period > 0) {
1256 return date(
'Y-m-d H:i:s', time() - ($a_time_period * 24 * 60 * 60));
1260 elseif (preg_match(
"/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/", $a_time_period)) {
1261 return $a_time_period;
1276 $a_for_rss_use =
false,
1278 $a_starting_date =
"",
1279 $a_no_auto_generated =
false,
1280 $a_oldest_first =
false,
1288 if ($a_time_period > 0) {
1289 $limit_ts = self::handleTimePeriod($a_time_period);
1290 $and =
" AND creation_date >= " .
$ilDB->quote($limit_ts,
"timestamp") .
" ";
1293 if ($a_starting_date !=
"") {
1294 $and .=
" AND creation_date > " .
$ilDB->quote($a_starting_date,
"timestamp") .
" ";
1297 if ($a_no_auto_generated) {
1298 $and .=
" AND priority = 1 AND content_type = " .
$ilDB->quote(
"text",
"text") .
" ";
1307 $ordering = ($a_oldest_first)
1308 ?
" creation_date ASC, id ASC " 1309 :
" creation_date DESC, id DESC ";
1313 "FROM il_news_item " .
1318 " ORDER BY " . $ordering;
1320 $query =
"SELECT il_news_item.* " .
1321 ", il_news_read.user_id user_read " .
1322 "FROM il_news_item LEFT JOIN il_news_read " .
1323 "ON il_news_item.id = il_news_read.news_id AND " .
1329 " ORDER BY " . $ordering;
1331 $query =
"SELECT il_news_item.* " .
1332 ", il_news_read.user_id as user_read " .
1333 "FROM il_news_item LEFT JOIN il_news_read " .
1334 "ON il_news_item.id = il_news_read.news_id AND " .
1335 " il_news_read.user_id = " .
$ilDB->quote(
$ilUser->getId(),
"integer") .
1337 "context_obj_id = " .
$ilDB->quote($this->getContextObjId(),
"integer") .
1338 " AND context_obj_type = " .
$ilDB->quote($this->getContextObjType(),
"text") .
1340 " ORDER BY " . $ordering;
1345 while ($rec =
$ilDB->fetchAssoc($set)) {
1346 if ($a_limit > 0 && count(
$result) >= $a_limit) {
1350 ($rec[
"priority"] == 0 &&
1353 "public_notifications",
1355 $rec[
"context_obj_id"]
1366 if ($a_time_period !=
"" && $a_for_rss_use) {
1367 include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
1374 if ($keep_rss_min > 0) {
1379 $a_no_auto_generated,
1398 $ilDB = $DIC->database();
1400 $set =
$ilDB->query(
"SELECT * FROM il_news_item " .
1401 " WHERE " .
$ilDB->in(
"id", $a_news_ids,
false,
"integer"));
1402 while ($rec =
$ilDB->fetchAssoc($set)) {
1403 $news[$rec[
"id"]] = $rec;
1421 $limit_ts = self::handleTimePeriod($a_time_period);
1424 $query =
$ilDB->query(
"SELECT id,context_obj_id,context_obj_type" .
1425 " FROM il_news_item" .
1426 " WHERE " .
$ilDB->in(
"context_obj_id", array_keys($objects),
false,
"integer") .
1427 " AND creation_date >= " .
$ilDB->quote($limit_ts,
"timestamp"));
1429 if ($objects[$rec[
"context_obj_id"]][
"type"] == $rec[
"context_obj_type"]) {
1430 $all[] = $rec[
"id"];
1452 $a_for_rss_use =
false,
1454 $a_starting_date =
"",
1455 $a_no_auto_generated =
false,
1458 $a_exclude = array()
1466 if ($a_time_period > 0) {
1467 $limit_ts = self::handleTimePeriod($a_time_period);
1468 $and =
" AND creation_date >= " .
$ilDB->quote($limit_ts,
"timestamp") .
" ";
1471 if ($a_starting_date !=
"") {
1472 $and .=
" AND creation_date > " .
$ilDB->quote($a_starting_date,
"timestamp") .
" ";
1475 if ($a_no_auto_generated) {
1476 $and .=
" AND priority = 1 AND content_type = " .
$ilDB->quote(
"text",
"text") .
" ";
1480 $ilDB->setLimit($a_limit, 0);
1483 if (is_array($a_exclude) && count($a_exclude) > 0) {
1484 $and .=
" AND " .
$ilDB->in(
"id", $a_exclude,
true,
"integer") .
" ";
1490 foreach ($a_contexts as $cont) {
1491 $ids[] = $cont[
"obj_id"];
1492 $type[$cont[
"obj_id"]] = $cont[
"obj_type"];
1497 "FROM il_news_item " .
1499 $ilDB->in(
"context_obj_id", $ids,
false,
"integer") .
" " .
1501 " ORDER BY creation_date DESC ";
1503 $query =
"SELECT il_news_item.* " .
1504 ", il_news_read.user_id as user_read " .
1505 "FROM il_news_item LEFT JOIN il_news_read " .
1506 "ON il_news_item.id = il_news_read.news_id AND " .
1509 $ilDB->in(
"context_obj_id", $ids,
false,
"integer") .
" " .
1511 " ORDER BY creation_date DESC ";
1518 $query =
"SELECT il_news_item.* " .
1519 ", il_news_read.user_id as user_read " .
1520 "FROM il_news_item LEFT JOIN il_news_read " .
1521 "ON il_news_item.id = il_news_read.news_id AND " .
1522 " il_news_read.user_id = " .
$ilDB->quote(
$user_id,
"integer") .
1524 $ilDB->in(
"context_obj_id", $ids,
false,
"integer") .
" " .
1526 " ORDER BY creation_date DESC ";
1531 while ($rec =
$ilDB->fetchAssoc($set)) {
1532 if (
$type[$rec[
"context_obj_id"]] == $rec[
"context_obj_type"]) {
1534 ($rec[
"priority"] == 0 &&
1537 "public_notifications",
1539 $rec[
"context_obj_id"]
1554 public static function _setRead($a_user_id, $a_news_id)
1558 $ilDB = $DIC->database();
1559 $ilAppEventHandler = $DIC[
"ilAppEventHandler"];
1564 "user_id" => array(
"integer", $a_user_id),
1565 "news_id" => array(
"integer", $a_news_id)
1578 $ilAppEventHandler->raise(
1581 array(
"user_id" => $a_user_id,
"news_ids" => array($a_news_id))
1593 $ilDB = $DIC->database();
1594 $ilAppEventHandler = $DIC[
"ilAppEventHandler"];
1596 $ilDB->manipulate(
"DELETE FROM il_news_read (user_id, news_id) VALUES (" .
1597 " WHERE user_id = " .
$ilDB->quote($a_user_id,
"integer") .
1598 " AND news_id = " .
$ilDB->quote($a_news_id,
"integer"));
1600 $ilAppEventHandler->raise(
1603 array(
"user_id" => $a_user_id,
"news_ids" => array($a_news_id))
1617 foreach ($n2 as
$id => $news) {
1633 $tree = $DIC->repositoryTree();
1636 include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
1639 $default_visibility = ($news_set->get(
"default_visibility") !=
"")
1640 ? $news_set->get(
"default_visibility")
1643 if (
$tree->isInTree($a_ref_id)) {
1647 if (!in_array(
$row[
"type"], array(
"root",
"cat",
"crs",
"fold",
"grp"))) {
1653 "default_visibility",
1664 return $default_visibility;
1672 public function delete()
1677 $ilDB->manipulate(
"DELETE FROM il_news_read " .
1678 " WHERE news_id = " .
$ilDB->quote($this->getId(),
"integer"));
1684 $query =
"DELETE FROM il_news_item" .
1685 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
1690 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1702 $a_context_obj_type,
1703 $a_context_sub_obj_id = 0,
1704 $a_context_sub_obj_type =
"" 1708 $ilDB = $DIC->database();
1710 if ($a_context_obj_id == 0 || $a_context_obj_type ==
"") {
1714 if ($a_context_sub_obj_id > 0) {
1715 $and =
" AND context_sub_obj_id = " .
$ilDB->quote($a_context_sub_obj_id,
"integer") .
1716 " AND context_sub_obj_type = " .
$ilDB->quote($a_context_sub_obj_type,
"text");
1720 $query =
"SELECT * FROM il_news_item" .
1721 " WHERE context_obj_id = " .
$ilDB->quote($a_context_obj_id,
"integer") .
1722 " AND context_obj_type = " .
$ilDB->quote($a_context_obj_type,
"text") .
1728 while ($news =
$ilDB->fetchAssoc($news_set)) {
1740 $a_context_obj_type,
1741 $a_context_sub_obj_id = 0,
1742 $a_context_sub_obj_type =
"" 1744 foreach (self::getNewsOfContext(
1746 $a_context_obj_type,
1747 $a_context_sub_obj_id,
1748 $a_context_sub_obj_type
1762 $ilDB = $DIC->database();
1764 $query =
"SELECT title FROM il_news_item WHERE id = " .
1765 $ilDB->quote($a_news_id,
"integer");
1767 $rec =
$ilDB->fetchAssoc($set);
1768 return $rec[
"title"];
1779 $ilDB = $DIC->database();
1781 $query =
"SELECT visibility FROM il_news_item WHERE id = " .
1782 $ilDB->quote($a_news_id,
"integer");
1784 $rec =
$ilDB->fetchAssoc($set);
1786 return $rec[
"visibility"];
1797 $ilDB = $DIC->database();
1799 $query =
"SELECT mob_id FROM il_news_item WHERE id = " .
1800 $ilDB->quote($a_news_id,
"integer");
1802 $rec =
$ilDB->fetchAssoc($set);
1803 return $rec[
"mob_id"];
1810 public static function filterObjIdsPerNews($a_obj_ids, $a_time_period = 0, $a_starting_date =
"", $a_ending_date =
'', $ignore_period =
false)
1814 $ilDB = $DIC->database();
1817 if ($a_time_period > 0) {
1818 $limit_ts = self::handleTimePeriod($a_time_period);
1819 $and =
" AND creation_date >= " .
$ilDB->quote($limit_ts,
"timestamp") .
" ";
1822 if ($a_starting_date !=
"") {
1823 $and .=
" AND creation_date >= " .
$ilDB->quote($a_starting_date,
"timestamp");
1826 $query =
"SELECT DISTINCT(context_obj_id) AS obj_id FROM il_news_item" .
1827 " WHERE " .
$ilDB->in(
"context_obj_id", $a_obj_ids,
false,
"integer") .
" " . $and;
1832 while ($rec =
$ilDB->fetchAssoc($set)) {
1833 $objs[] = $rec[
"obj_id"];
1846 $ilDB = $DIC->database();
1848 $query =
"SELECT context_obj_type, content_is_lang_var, title FROM il_news_item WHERE id = " .
1849 $ilDB->quote($a_news_id,
"integer");
1851 $rec =
$ilDB->fetchAssoc($set);
1853 return self::determineNewsTitle(
1854 $rec[
"context_obj_type"],
1856 $rec[
"content_is_lang_var"],
1867 $a_context_obj_type,
1869 $a_content_is_lang_var,
1875 $lng = $DIC->language();
1876 $obj_definition = $DIC[
"objDefinition"];
1878 if ($a_agg_ref_id > 0) {
1879 $cnt = count($a_aggregation);
1882 if ($a_context_obj_type ==
"frm") {
1884 return sprintf(
$lng->txt(
"news_x_postings"), $cnt);
1886 return $lng->txt(
"news_1_postings");
1889 $up_cnt = $cr_cnt = 0;
1890 foreach ($a_aggregation as $item) {
1891 if ($item[
"title"] ==
"file_updated") {
1899 $tit =
$lng->txt(
"news_1_file_created");
1901 } elseif ($cr_cnt > 1) {
1902 $tit = sprintf(
$lng->txt(
"news_x_files_created"), $cr_cnt);
1906 $tit .= $sep .
$lng->txt(
"news_1_file_updated");
1907 } elseif ($up_cnt > 1) {
1908 $tit .= $sep . sprintf(
$lng->txt(
"news_x_files_updated"), $up_cnt);
1913 if ($a_content_is_lang_var) {
1914 if ($obj_definition->isPlugin($a_context_obj_type)) {
1917 return $lng->txt($a_title);
1934 $lng = $DIC->language();
1935 $obj_definition = $DIC[
"objDefinition"];
1937 if ($a_is_lang_var) {
1938 if ($obj_definition->isPlugin($a_context_obj_type)) {
1941 $lng->loadLanguageModule($a_context_obj_type);
1956 $a_context_obj_type,
1957 $a_context_sub_obj_id =
"",
1958 $a_context_sub_obj_type =
"" 1962 $ilDB = $DIC->database();
1966 "FROM il_news_item " .
1968 "context_obj_id = " .
$ilDB->quote($a_context_obj_id,
"integer") .
1969 " AND context_obj_type = " .
$ilDB->quote($a_context_obj_type,
"text") .
1970 " AND context_sub_obj_id = " .
$ilDB->quote($a_context_sub_obj_id,
"integer") .
1971 " AND " .
$ilDB->equals(
"context_sub_obj_type", $a_context_sub_obj_type,
"text",
true);
1974 $rec =
$ilDB->fetchAssoc($set);
1985 $a_context_obj_type,
1986 $a_context_sub_obj_id =
"",
1987 $a_context_sub_obj_type =
"",
1988 $a_only_today =
false 1992 $ilDB = $DIC->database();
1995 $query =
"SELECT id, update_date " .
1996 "FROM il_news_item " .
1998 "context_obj_id = " .
$ilDB->quote($a_context_obj_id,
"integer") .
1999 " AND context_obj_type = " .
$ilDB->quote($a_context_obj_type,
"text") .
2000 " AND context_sub_obj_id = " .
$ilDB->quote($a_context_sub_obj_id,
"integer") .
2001 " AND " .
$ilDB->equals(
"context_sub_obj_type", $a_context_sub_obj_type,
"text",
true) .
2002 " ORDER BY update_date DESC";
2006 $rec =
$ilDB->fetchAssoc($set);
2008 $id = (int) $rec[
"id"];
2009 if ($a_only_today) {
2011 if (substr($now, 0, 10) != substr($rec[
"update_date"], 0, 10)) {
2028 $ilDB = $DIC->database();
2031 "FROM il_news_item " .
2033 " mob_id = " .
$ilDB->quote($a_mob_id,
"integer");
2037 while ($rec =
$ilDB->fetchAssoc($set)) {
2038 $usages[$rec[
"id"]] = array(
"type" =>
"news",
"id" => $rec[
"id"]);
2052 $ilDB = $DIC->database();
2055 "FROM il_news_item " .
2057 " id = " .
$ilDB->quote($a_news_id,
"integer");
2059 $rec =
$ilDB->fetchAssoc($set);
2061 return $rec[
"context_obj_id"];
2070 $per = $news_set->get(
"pd_period");
2084 $allow_shorter_periods = $news_set->get(
"allow_shorter_periods");
2085 $allow_longer_periods = $news_set->get(
"allow_longer_periods");
2088 include_once(
"./Services/Block/classes/class.ilBlockSetting.php");
2098 (!$allow_shorter_periods && ($per < $default_per)) ||
2099 (!$allow_longer_periods && ($per > $default_per))
2101 $per = $default_per;
2113 $rss_period = $news_set->get(
"rss_period");
2114 if ($rss_period == 0) {
2144 public function deliverMobFile($a_purpose =
"Standard", $a_increase_download_cnt =
false)
2147 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2152 if (!$mob->hasPurposeItem($a_purpose)) {
2156 $m_item = $mob->getMediaItem($a_purpose);
2157 if ($m_item->getLocationType() !=
"Reference") {
2158 $file = $mob_dir .
"/" . $m_item->getLocation();
2159 if (file_exists($file) && is_file($file)) {
2160 if ($a_increase_download_cnt) {
2170 if ($a_increase_download_cnt) {
2189 "UPDATE il_news_item SET " .
2190 " mob_cnt_download = " .
$ilDB->quote($cnt,
"integer") .
2191 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer")
2208 "UPDATE il_news_item SET " .
2209 " mob_cnt_play = " .
$ilDB->quote($cnt,
"integer") .
2210 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer")
2224 $ilDB = $DIC->database();
2227 $news_ids = array_keys(
$data);
2228 $set =
$ilDB->query(
"SELECT id FROM il_news_item " .
2229 " WHERE " .
$ilDB->in(
"id", $news_ids,
false,
"integer"));
2230 $existing_ids = array();
2231 while ($rec =
$ilDB->fetchAssoc($set)) {
2232 $existing_ids[] = $rec[
"id"];
2235 $existing_news = array();
2236 foreach (
$data as $k => $v) {
2237 if (in_array($k, $existing_ids)) {
2238 $existing_news[$k] = $v;
2245 return $existing_news;
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
getContentHtml()
Get content as html.
setContentTextIsLangVar($a_val=0)
Set content text ist lang var.
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.
static _lookupRSSPeriod()
static lookupTxtById($plugin_id, $lang_var)
setVisibility($a_visibility="users")
Set Visibility.
setContextSubObjId($a_context_sub_obj_id)
Set ContextSubObjId.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
static _setUnread($a_user_id, $a_news_id)
Set item unread.
static handleTimePeriod($a_time_period)
Convert time period for DB-queries.
setContextSubObjType($a_context_sub_obj_type)
Set ContextSubObjType.
getContentType()
Get ContentType.
increaseDownloadCounter()
Increase download counter.
static _lookupUserPDPeriod($a_user_id)
getPriority()
Get Priority.
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
setCreationDate($a_creation_date)
Set CreationDate.
getPlaytime()
Get Playtime.
read()
Read item from database.
static _lookupVisibility($a_news_id)
Lookup News Visibility.
setTitle($a_title)
Set Title.
__construct($a_id=0)
Constructor.
static mergeNews($n1, $n2)
Merges two sets of news.
static prepareNewsDataFromCache($a_cres)
Prepare news data from cache.
getCreationDate()
Get CreationDate.
getContentTextIsLangVar()
Get content text ist lang var.
getContentLong()
Get ContentLong.
getContextObjType()
Get ContextObjType.
static now()
Return current timestamp in Y-m-d H:i:s format.
setPriority($a_priority=1)
Set Priority.
getContextSubObjType()
Get ContextSubObjType.
static _getAllReferences($a_id)
get all reference ids of object
getMobDownloadCounter()
Get mob download counter.
static queryNewsByIds(array $a_news_ids)
Query news data by news ids.
static _lookupTitle($a_news_id)
Lookup News Title.
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 determineNewsTitleByNewsId($a_news_id, $a_agg_ref_id=0, $a_aggregation="")
Determine title for news item entry.
setContentIsLangVar($a_content_is_lang_var=0)
Set ContentIsLangVar.
setContent($a_content)
Set Content.
static _lookupMobId($a_news_id)
Lookup mob id.
getContentIsLangVar()
Get ContentIsLangVar.
static _getSubscriptionsOfUser($a_user_id)
Get subscriptions of user.
setContextObjId($a_context_obj_id)
Set ContextObjId.
setUpdateUserId($a_val)
Set update user 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.
static _lookupMediaObjectUsages($a_mob_id)
Lookup media object usage(s)
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.
static determineNewsContent($a_context_obj_type, $a_content, $a_is_lang_var)
Determine new content.
aggregateForums($news, $a_group_posting_sequence=false)
static _setRead($a_user_id, $a_news_id)
Set item read.
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 _lookupObjId($a_id)
setLimitation($a_limitation)
Set Limitation for number of items.
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.
static _lookup($a_type, $a_setting, $a_user=0, $a_block_id=0)
Lookup setting from database.
setMobDownloadCounter($a_val)
Set mob download counter.
getUpdateDate()
Get UpdateDate.
deliverMobFile($a_purpose="Standard", $a_increase_download_cnt=false)
Deliver mob file.
static preloadData(array $a_ref_ids)
Preload data to internal cache.
update($a_as_new=false)
Update item in database.
setUserId($a_user_id)
Set UserId.
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
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.
getLimitation()
Get Limitation for number of items.
getContextSubObjId()
Get ContextSubObjId.
getVisibility()
Get Visibility.
setContentType($a_content_type="text")
Set ContentType.
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.
getMobPlayCounter()
Get mob play counter.
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 _lookupDesktopItems($user_id, $a_types="")
get all desktop items of user and specified type
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.
static getPrivateFeedId()
static _lookupPref($a_usr_id, $a_keyword)
setContentHtml($a_val)
Is content HTML (tiny used?)
checkNewsExistsForObjects($objects, $a_time_period=1)
setMobId($a_mob_id)
Set MobId.
setContentLong($a_content_long)
Set ContentLong.
static _getDefaultVisibilityForRefId($a_ref_id)
Get default visibility for reference id.
static _lookupContextObjId($a_news_id)
Context Object ID.
setContextObjType($a_context_obj_type)
Set ContextObjType.
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 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.
setPlaytime($a_playtime)
Set Playtime.
static redirect($a_script)
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.
getUpdateUserId()
Get update user id.
static _lookupDefaultPDPeriod()
setMobPlayCounter($a_val)
Set mob play counter.
increasePlayCounter()
Increase play counter.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static setPrivateFeedId($a_userId)
aggregateFiles($news, $a_ref_id)
getContextObjId()
Get ContextObjId.