ILIAS  trunk Revision v12.0_alpha-439-g30457d6d0bc
ilNewsItem Class Reference

A news item can be created by different sources. More...

+ Collaboration diagram for ilNewsItem:

Public Member Functions

 __construct (int $a_id=0)
 
 setId (int $a_id)
 
 getId ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setContent (string $a_content)
 
 getContent ()
 
 setContextObjId (int $a_context_obj_id)
 
 getContextObjId ()
 
 setContextObjType (string $a_context_obj_type)
 
 getContextObjType ()
 
 setContextSubObjId (int $a_context_sub_obj_id)
 
 getContextSubObjId ()
 
 setContextSubObjType (?string $a_context_sub_obj_type)
 
 getContextSubObjType ()
 
 setContentType (string $a_content_type="text")
 
 getContentType ()
 
 setCreationDate (string $a_creation_date)
 
 getCreationDate ()
 
 setUpdateDate (string $a_update_date)
 
 getUpdateDate ()
 
 setUserId (int $a_user_id)
 
 getUserId ()
 
 setUpdateUserId (int $a_val)
 
 getUpdateUserId ()
 
 setVisibility (string $a_visibility="users")
 
 getVisibility ()
 
 setContentLong (string $a_content_long)
 
 getContentLong ()
 
 setPriority (int $a_priority=1)
 
 getPriority ()
 
 setContentIsLangVar (bool $a_content_is_lang_var=false)
 
 getContentIsLangVar ()
 
 setMobId (int $a_mob_id)
 
 getMobId ()
 
 setPlaytime (string $a_playtime)
 
 getPlaytime ()
 
 setLimitation (bool $a_limitation)
 Set Limitation for number of items. More...
 
 getLimitation ()
 
 setContentTextIsLangVar (bool $a_val=false)
 
 getContentTextIsLangVar ()
 
 setMobPlayCounter (int $a_val)
 
 getMobPlayCounter ()
 
 setMobDownloadCounter (int $a_val)
 
 getMobDownloadCounter ()
 
 setContentHtml (bool $a_val)
 
 getContentHtml ()
 
 read ()
 Read item from database. More...
 
 create ()
 Create. More...
 
 update (bool $a_as_new=false)
 Update item in database. More...
 
 getNewsForRefId (int $a_ref_id, bool $a_only_public=false, bool $a_stopnesting=false, $a_time_period=0, bool $a_prevent_aggregation=true, bool $a_forum_group_sequences=false, bool $a_no_auto_generated=false, bool $a_ignore_date_filter=false, ?int $a_user_id=null, int $a_limit=0, array $a_excluded=[])
 Get News For Ref Id. More...
 
 setContext (int $a_obj_id, string $a_obj_type, int $a_sub_obj_id=0, string $a_sub_obj_type="")
 Set context for news. More...
 
 queryNewsForContext (bool $a_for_rss_use=false, $a_time_period=0, string $a_starting_date="", bool $a_no_auto_generated=false, bool $a_oldest_first=false, int $a_limit=0, array $a_exclude=[])
 Query news for a context. More...
 
 checkNewsExistsForObjects (array $objects, $a_time_period=1)
 
 delete ()
 Delete news item. More...
 
 deliverMobFile (string $a_purpose="Standard", bool $a_increase_download_cnt=false)
 Deliver mob file. More...
 
 increaseDownloadCounter ()
 Increase download counter. More...
 
 increasePlayCounter ()
 Increase play counter. More...
 

Static Public Member Functions

static queryNewsByIds (array $a_news_ids)
 Query news data by news ids. More...
 
static _setRead (int $a_user_id, int $a_news_id)
 Set item read. More...
 
static _setUnread (int $a_user_id, int $a_news_id)
 Set item unread. More...
 
static mergeNews (array $n1, array $n2)
 Merges two sets of news. More...
 
static _getDefaultVisibilityForRefId (int $a_ref_id)
 Get default visibility for reference id. More...
 
static getNewsOfContext (int $a_context_obj_id, string $a_context_obj_type, int $a_context_sub_obj_id=0, string $a_context_sub_obj_type="")
 Get all news of a context. More...
 
static deleteNewsOfContext (int $a_context_obj_id, string $a_context_obj_type, int $a_context_sub_obj_id=0, string $a_context_sub_obj_type="")
 Delete all news of a context. More...
 
static _lookupTitle (int $a_news_id)
 Lookup News Title. More...
 
static _lookupVisibility (int $a_news_id)
 Lookup News Visibility. More...
 
static _lookupMobId (int $a_news_id)
 Lookup mob id. More...
 
static filterObjIdsPerNews (array $a_obj_ids, $a_time_period=0, string $a_starting_date="", string $a_ending_date='', bool $ignore_period=false)
 Checks whether news are available for. More...
 
static determineNewsTitleByNewsId (int $a_news_id, int $a_agg_ref_id=0, array $a_aggregation=[])
 Determine title for news item entry. More...
 
static determineNewsTitle (string $a_context_obj_type, string $a_title, bool $a_content_is_lang_var, int $a_agg_ref_id=0, array $a_aggregation=[], ?ilLanguage $lng=null)
 Determine title for news item entry. More...
 
static determineNewsContent (string $a_context_obj_type, string $a_content, bool $a_is_lang_var, ?ilLanguage $lng=null)
 Determine new content. More...
 
static getFirstNewsIdForContext (int $a_context_obj_id, string $a_context_obj_type, int $a_context_sub_obj_id=0, string $a_context_sub_obj_type="")
 Get first new id of news set related to a certain context. More...
 
static getLastNewsIdForContext (int $a_context_obj_id, string $a_context_obj_type, int $a_context_sub_obj_id=0, string $a_context_sub_obj_type="", bool $a_only_today=false)
 Get last news id of news set related to a certain context. More...
 
static _lookupMediaObjectUsages (int $a_mob_id)
 Lookup media object usage(s) More...
 
static _lookupContextObjId (int $a_news_id)
 Context Object ID. More...
 
static _lookupDefaultPDPeriod ()
 
static _lookupUserPDPeriod (int $a_user_id)
 
static _lookupRSSPeriod ()
 
static setPrivateFeedId (int $a_userId)
 
static getPrivateFeedId ()
 

Protected Member Functions

 getAggregatedNewsData (int $a_ref_id, bool $a_only_public=false, $a_time_period=0, bool $a_prevent_aggregation=false, string $a_starting_date="", bool $a_no_auto_generated=false, ?int $a_user_id=null, int $a_limit=0, array $a_exclude=[])
 Get news aggregation (e.g. More...
 
 aggregateForums (array $news, bool $a_group_posting_sequence=false)
 
 aggregateFiles (array $news, int $a_ref_id)
 
 getAggregatedChildNewsData (int $a_ref_id, bool $a_only_public=false, int $a_time_period=0, bool $a_prevent_aggregation=false, string $a_starting_date="", bool $a_no_auto_generated=false, array $a_excluded=[])
 Get news aggregation for child objects (e.g. More...
 

Static Protected Member Functions

static handleTimePeriod ($a_time_period)
 Convert time period for DB-queries. More...
 

Protected Attributes

MediaObjectManager $media_manager
 
int $mob_cnt_play = 0
 
ilDBInterface $db
 
ilTree $tree
 
ilAccessHandler $access
 
ilObjectDataCache $obj_data_cache
 
ilObjUser $user
 
ilLanguage $lng
 
ilCtrl $ctrl
 
int $id = 0
 
string $title = ""
 
string $content = ""
 
bool $content_html = false
 
int $context_obj_id = 0
 
string $context_obj_type = ""
 
int $context_sub_obj_id = 0
 
string $context_sub_obj_type = null
 
string $content_type = "text"
 
string $creation_date = ""
 
string $update_date = ""
 
int $user_id = 0
 
int $update_user_id = 0
 
string $visibility = "users"
 
string $content_long = ""
 
int $priority = 1
 
bool $content_is_lang_var = false
 
int $mob_id = 0
 
string $playtime = ""
 
bool $content_text_is_lang_var = false
 
ilLogger $log
 

Private Member Functions

 queryNewsForMultipleContexts (array $a_contexts, bool $a_for_rss_use=false, $a_time_period=0, string $a_starting_date="", bool $a_no_auto_generated=false, ?int $a_user_id=null, int $a_limit=0, array $a_exclude=[])
 

Private Attributes

int $mob_cnt_download = 0
 
bool $limitation = false
 
ilGlobalTemplateInterface $main_tpl
 

Static Private Attributes

static int $privFeedId = 0
 

Detailed Description

A news item can be created by different sources.

E.g. when a new forum posting is created, or when a change in a learning module is announced.

Please note that this class contains a lot of deprectated functions that will be move to other classes in the future. Please avoid to use these functions. This class should be a pure data class without persistence in the future.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 43 of file class.ilNewsItem.php.

Constructor & Destructor Documentation

◆ __construct()

ilNewsItem::__construct ( int  $a_id = 0)

Definition at line 80 of file class.ilNewsItem.php.

81 {
82 global $DIC;
83 $this->main_tpl = $DIC->ui()->mainTemplate();
84
85 $this->db = $DIC->database();
86 $this->tree = $DIC->repositoryTree();
87 $this->access = $DIC->access();
88 $this->obj_data_cache = $DIC["ilObjDataCache"];
89 $this->user = $DIC->user();
90 $this->lng = $DIC->language();
91 $this->ctrl = $DIC->ctrl();
92 if ($a_id > 0) {
93 $this->setId($a_id);
94 $this->read();
95 }
96 $this->limitation = true;
97 $this->log = $DIC->logger()->news();
98 $this->media_manager = $DIC->mediaObjects()->internal()->domain()->mediaObject();
99 }
setId(int $a_id)
read()
Read item from database.
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), read(), setId(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ _getDefaultVisibilityForRefId()

static ilNewsItem::_getDefaultVisibilityForRefId ( int  $a_ref_id)
static

Get default visibility for reference id.

Deprecated:
will move to ilNewsData

Definition at line 1286 of file class.ilNewsItem.php.

1286 : string
1287 {
1288 global $DIC;
1289
1290 $tree = $DIC->repositoryTree();
1291
1292 $news_set = new ilSetting("news");
1293 $default_visibility = ($news_set->get("default_visibility") != "")
1294 ? $news_set->get("default_visibility")
1295 : "users";
1296
1297 if ($tree->isInTree($a_ref_id)) {
1298 $path = $tree->getPathFull($a_ref_id);
1299
1300 foreach ($path as $key => $row) {
1301 if (!in_array($row["type"], ["root", "cat", "crs", "fold", "grp"], true)) {
1302 continue;
1303 }
1304
1306 "news",
1307 "default_visibility",
1308 0,
1309 (int) $row["obj_id"]
1310 );
1311
1312 if ($visibility != "") {
1313 $default_visibility = $visibility;
1314 }
1315 }
1316 }
1317
1318 return $default_visibility;
1319 }
static _lookup(string $a_type, string $a_setting, int $a_user=0, int $a_block_id=0)
Lookup setting from database.
string $visibility
ILIAS Setting Class.
isInTree(?int $a_node_id)
get all information of a node.
getPathFull(int $a_endnode_id, int $a_startnode_id=0)
get path from a given startnode to a given endnode if startnode is not given the rootnode is startnod...
$path
Definition: ltiservices.php:30

References $DIC, $path, ilBlockSetting\_lookup(), ilTree\getPathFull(), and ilTree\isInTree().

Referenced by ilNewsForContextBlockGUI\addToSettingsForm(), createProperties(), ilObjForum\createSettings(), and ilNewsForContextBlockGUI\initSettingsForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupContextObjId()

static ilNewsItem::_lookupContextObjId ( int  $a_news_id)
static

Context Object ID.

Deprecated:
will move to ilNewsData

Definition at line 1722 of file class.ilNewsItem.php.

1722 : int
1723 {
1724 global $DIC;
1725
1726 $ilDB = $DIC->database();
1727
1728 $query = "SELECT context_obj_id " .
1729 "FROM il_news_item " .
1730 "WHERE " .
1731 " id = " . $ilDB->quote($a_news_id, "integer");
1732 $set = $ilDB->query($query);
1733 $rec = $ilDB->fetchAssoc($set);
1734
1735 return $rec["context_obj_id"];
1736 }

References $DIC, and $ilDB.

Referenced by ilNewsItemGUI\executeCommand(), and ilMediaObjectUsagesTableGUI\fillRow().

+ Here is the caller graph for this function:

◆ _lookupDefaultPDPeriod()

static ilNewsItem::_lookupDefaultPDPeriod ( )
static
Deprecated:
will move to settings

Definition at line 1741 of file class.ilNewsItem.php.

1741 : int
1742 {
1743 $news_set = new ilSetting("news");
1744 $per = $news_set->get("pd_period");
1745 if ((int) $per === 0) {
1746 $per = 30;
1747 }
1748
1749 return $per;
1750 }

Referenced by ilPDNewsBlockGUI\editSettings(), ILIAS\News\Dashboard\DashboardNewsManager\getPeriodOptions(), ilObjNewsSettingsGUI\getSettingsForm(), and ilPDNewsTableGUI\initFilter().

+ Here is the caller graph for this function:

◆ _lookupMediaObjectUsages()

static ilNewsItem::_lookupMediaObjectUsages ( int  $a_mob_id)
static

Lookup media object usage(s)

Deprecated:
will move to ilNewsData

Definition at line 1698 of file class.ilNewsItem.php.

1698 : array
1699 {
1700 global $DIC;
1701
1702 $ilDB = $DIC->database();
1703
1704 $query = "SELECT id " .
1705 "FROM il_news_item " .
1706 "WHERE " .
1707 " mob_id = " . $ilDB->quote($a_mob_id, "integer");
1708
1709 $usages = [];
1710 $set = $ilDB->query($query);
1711 while ($rec = $ilDB->fetchAssoc($set)) {
1712 $usages[$rec["id"]] = ["type" => "news", "id" => $rec["id"]];
1713 }
1714
1715 return $usages;
1716 }

References $DIC, and $ilDB.

◆ _lookupMobId()

static ilNewsItem::_lookupMobId ( int  $a_news_id)
static

Lookup mob id.

Deprecated:
will move to ilNewsData

Definition at line 1448 of file class.ilNewsItem.php.

1448 : int
1449 {
1450 global $DIC;
1451
1452 $ilDB = $DIC->database();
1453
1454 $query = "SELECT mob_id FROM il_news_item WHERE id = " .
1455 $ilDB->quote($a_news_id, "integer");
1456 $set = $ilDB->query($query);
1457 $rec = $ilDB->fetchAssoc($set);
1458 return (int) ($rec["mob_id"] ?? 0);
1459 }

References $DIC, and $ilDB.

Referenced by ilNewsExporter\getXmlExportHeadDependencies().

+ Here is the caller graph for this function:

◆ _lookupRSSPeriod()

static ilNewsItem::_lookupRSSPeriod ( )
static
Deprecated:
will move to settings

Definition at line 1783 of file class.ilNewsItem.php.

1783 : int
1784 {
1785 $news_set = new ilSetting("news");
1786 $rss_period = $news_set->get("rss_period");
1787 if ((int) $rss_period === 0) { // default to two weeks
1788 $rss_period = 14;
1789 }
1790 return $rss_period;
1791 }

Referenced by ilObjectFeedWriter\__construct(), ILIAS\MediaCast\Settings\SettingsGUI\getEditForm(), and ilObjNewsSettingsGUI\getSettingsForm().

+ Here is the caller graph for this function:

◆ _lookupTitle()

static ilNewsItem::_lookupTitle ( int  $a_news_id)
static

Lookup News Title.

Deprecated:
will move to ilNewsData

Definition at line 1413 of file class.ilNewsItem.php.

1413 : string
1414 {
1415 global $DIC;
1416
1417 $ilDB = $DIC->database();
1418
1419 $query = "SELECT title FROM il_news_item WHERE id = " .
1420 $ilDB->quote($a_news_id, "integer");
1421 $set = $ilDB->query($query);
1422 $rec = $ilDB->fetchAssoc($set);
1423 return $rec["title"] ?? '';
1424 }

References $DIC, and $ilDB.

◆ _lookupUserPDPeriod()

static ilNewsItem::_lookupUserPDPeriod ( int  $a_user_id)
static
Deprecated:
will move to settings->user

Definition at line 1755 of file class.ilNewsItem.php.

1755 : int
1756 {
1757 $news_set = new ilSetting("news");
1758 $allow_shorter_periods = $news_set->get("allow_shorter_periods");
1759 $allow_longer_periods = $news_set->get("allow_longer_periods");
1760 $default_per = self::_lookupDefaultPDPeriod();
1761
1763 "pdnews",
1764 "news_pd_period",
1765 $a_user_id,
1766 0
1767 );
1768
1769 // news period information
1770 if ($per <= 0 ||
1771 (!$allow_shorter_periods && ($per < $default_per)) ||
1772 (!$allow_longer_periods && ($per > $default_per))
1773 ) {
1774 $per = $default_per;
1775 }
1776
1777 return (int) $per;
1778 }
static _lookupDefaultPDPeriod()

References ilBlockSetting\_lookup().

Referenced by ilPDNewsBlockGUI\editSettings(), ILIAS\News\Dashboard\DashboardNewsManager\getDashboardNewsPeriod(), ilPDNewsTableGUI\initFilter(), and ilPDNewsBlockGUI\loadNewsData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupVisibility()

static ilNewsItem::_lookupVisibility ( int  $a_news_id)
static

Lookup News Visibility.

Deprecated:
will move to ilNewsData

Definition at line 1430 of file class.ilNewsItem.php.

1430 : string
1431 {
1432 global $DIC;
1433
1434 $ilDB = $DIC->database();
1435
1436 $query = "SELECT visibility FROM il_news_item WHERE id = " .
1437 $ilDB->quote($a_news_id, "integer");
1438 $set = $ilDB->query($query);
1439 $rec = $ilDB->fetchAssoc($set);
1440
1441 return $rec["visibility"] ?? NEWS_USERS;
1442 }
const NEWS_USERS

References $DIC, $ilDB, and NEWS_USERS.

Referenced by ilMobStakeholder\checkAccessMobUsage().

+ Here is the caller graph for this function:

◆ _setRead()

static ilNewsItem::_setRead ( int  $a_user_id,
int  $a_news_id 
)
static

Set item read.

Deprecated:
will move to ilNewsData

Definition at line 1218 of file class.ilNewsItem.php.

1221 : void {
1222 global $DIC;
1223
1224 $ilDB = $DIC->database();
1225 $ilAppEventHandler = $DIC["ilAppEventHandler"];
1226
1227 $ilDB->replace(
1228 "il_news_read",
1229 [
1230 "user_id" => ["integer", $a_user_id],
1231 "news_id" => ["integer", $a_news_id]
1232 ],
1233 []
1234 );
1235
1236 $ilAppEventHandler->raise(
1237 "components/ILIAS/News",
1238 "readNews",
1239 ["user_id" => $a_user_id, "news_ids" => [$a_news_id]]
1240 );
1241 }

◆ _setUnread()

static ilNewsItem::_setUnread ( int  $a_user_id,
int  $a_news_id 
)
static

Set item unread.

Deprecated:
will move to ilNewsData

Definition at line 1247 of file class.ilNewsItem.php.

1250 : void {
1251 global $DIC;
1252
1253 $ilDB = $DIC->database();
1254 $ilAppEventHandler = $DIC["ilAppEventHandler"];
1255
1256 $ilDB->manipulate("DELETE FROM il_news_read (user_id, news_id) VALUES (" .
1257 " WHERE user_id = " . $ilDB->quote($a_user_id, "integer") .
1258 " AND news_id = " . $ilDB->quote($a_news_id, "integer"));
1259
1260 $ilAppEventHandler->raise(
1261 "components/ILIAS/News",
1262 "unreadNews",
1263 ["user_id" => $a_user_id, "news_ids" => [$a_news_id]]
1264 );
1265 }

◆ aggregateFiles()

ilNewsItem::aggregateFiles ( array  $news,
int  $a_ref_id 
)
protected
Deprecated:
will be removed after migrating getNewsForRefId

Definition at line 787 of file class.ilNewsItem.php.

790 : array {
791 $first_file = "";
792 $to_del = [];
793 foreach ($news as $k => $v) {
794 // aggregate file related news
795 if ($v["context_obj_type"] === "file") {
796 if ($first_file === "") {
797 $first_file = $k;
798 } else {
799 $to_del[] = $k;
800 }
801 $news[$first_file]["aggregation"][$k] = $v;
802 $news[$first_file]["agg_ref_id"] = $a_ref_id;
803 $news[$first_file]["ref_id"] = $a_ref_id;
804 }
805 }
806
807 foreach ($to_del as $v) {
808 unset($news[$v]);
809 }
810
811 return $news;
812 }

◆ aggregateForums()

ilNewsItem::aggregateForums ( array  $news,
bool  $a_group_posting_sequence = false 
)
protected
Deprecated:
will be removed after migrating getNewsForRefId

Definition at line 739 of file class.ilNewsItem.php.

742 : array {
743 $to_del = [];
744 $forums = [];
745 $last_aggregation_forum = 0;
746
747 // aggregate
748 foreach ($news as $k => $v) {
749 if ($a_group_posting_sequence && $last_aggregation_forum > 0 &&
750 $last_aggregation_forum != $v["context_obj_id"]) {
751 $forums[$last_aggregation_forum] = null;
752 }
753
754 if ($v["context_obj_type"] === "frm") {
755 if (!isset($forums[$v["context_obj_id"]])) {
756 // $forums[forum_id] = news_id;
757 $forums[$v["context_obj_id"]] = $k;
758 $last_aggregation_forum = $v["context_obj_id"];
759 } else {
760 $to_del[] = $k;
761 }
762
763 $news[$k]["no_context_title"] = true;
764
765 // aggregate every forum into it's "k" news
766 $news[$forums[$news[$k]["context_obj_id"]]]["aggregation"][$k]
767 = $news[$k];
768 $news[$k]["agg_ref_id"]
769 = $news[$k]["ref_id"];
770 $news[$k]["content"] = "";
771 $news[$k]["content_long"] = "";
772 }
773 }
774
775 // delete double entries
776 foreach ($to_del as $k) {
777 unset($news[$k]);
778 }
779 //var_dump($news[14]["aggregation"]);
780
781 return $news;
782 }

◆ checkNewsExistsForObjects()

ilNewsItem::checkNewsExistsForObjects ( array  $objects,
  $a_time_period = 1 
)
Deprecated:
will move to ilNewsData
Returns
int[]
Parameters
string | int$a_time_period

Definition at line 1085 of file class.ilNewsItem.php.

1088 : array {
1089 $ilDB = $this->db;
1090
1091 $all = [];
1092
1093 $this->log->debug("time period: " . $a_time_period);
1094 $limit_ts = self::handleTimePeriod($a_time_period);
1095
1096 // are there any news items for relevant objects and?
1097 $query = $ilDB->query($q = "SELECT id,context_obj_id,context_obj_type" .
1098 " FROM il_news_item" .
1099 " WHERE " . $ilDB->in("context_obj_id", array_keys($objects), false, "integer") .
1100 " AND creation_date >= " . $ilDB->quote($limit_ts, "timestamp"));
1101 $this->log->debug($q);
1102 while ($rec = $ilDB->fetchAssoc($query)) {
1103 if ($objects[$rec["context_obj_id"]]["type"] == $rec["context_obj_type"]) {
1104 $all[] = (int) $rec["id"];
1105 }
1106 }
1107
1108 return $all;
1109 }
ilDBInterface $db
static handleTimePeriod($a_time_period)
Convert time period for DB-queries.
$q
Definition: shib_logout.php:23

◆ create()

ilNewsItem::create ( )

Create.

Deprecated:
(will migrate to ilNewsData or other class taking care of persistence)

Definition at line 385 of file class.ilNewsItem.php.

385 : void
386 {
388
389 // insert new record into db
390 $this->setId($ilDB->nextId("il_news_item"));
391 $ilDB->insert("il_news_item", [
392 "id" => ["integer", $this->getId()],
393 "title" => ["text", $this->getTitle()],
394 "content" => ["clob", $this->getContent()],
395 "content_html" => ["integer", (int) $this->getContentHtml()],
396 "context_obj_id" => ["integer", $this->getContextObjId()],
397 "context_obj_type" => ["text", $this->getContextObjType()],
398 "context_sub_obj_id" => ["integer", $this->getContextSubObjId()],
399 "context_sub_obj_type" => ["text", $this->getContextSubObjType()],
400 "content_type" => ["text", $this->getContentType()],
401 "creation_date" => ["timestamp", ilUtil::now()],
402 "update_date" => ["timestamp", ilUtil::now()],
403 "user_id" => ["integer", $this->getUserId()],
404 "update_user_id" => ["integer", $this->getUpdateUserId()],
405 "visibility" => ["text", $this->getVisibility()],
406 "content_long" => ["clob", $this->getContentLong()],
407 "priority" => ["integer", $this->getPriority()],
408 "content_is_lang_var" => ["integer", $this->getContentIsLangVar()],
409 "content_text_is_lang_var" => ["integer", (int) $this->getContentTextIsLangVar()],
410 "mob_id" => ["integer", $this->getMobId()],
411 "playtime" => ["text", $this->getPlaytime()]
412 ]);
413
414
415 $news_set = new ilSetting("news");
416 $max_items = $news_set->get("max_items");
417 if ($max_items <= 0) {
418 $max_items = 50;
419 }
420
421 // limit number of news
422 if ($this->getLimitation()) {
423 // Determine how many rows should be deleted
424 $query = "SELECT count(*) cnt " .
425 "FROM il_news_item " .
426 "WHERE " .
427 "context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
428 " AND context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text") .
429 " AND context_sub_obj_id = " . $ilDB->quote($this->getContextSubObjId(), "integer") .
430 " AND " . $ilDB->equals("context_sub_obj_type", $this->getContextSubObjType(), "text", true) . " ";
431
432 $set = $ilDB->query($query);
433 $rec = $ilDB->fetchAssoc($set);
434
435 // if we have more records than allowed, delete them
436 if (($rec["cnt"] > $max_items) && $this->getContextObjId() > 0) {
437 $query = "SELECT * " .
438 "FROM il_news_item " .
439 "WHERE " .
440 "context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
441 " AND context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text") .
442 " AND context_sub_obj_id = " . $ilDB->quote($this->getContextSubObjId(), "integer") .
443 " AND " . $ilDB->equals("context_sub_obj_type", $this->getContextSubObjType(), "text", true) .
444 " ORDER BY creation_date ASC";
445
446 $ilDB->setLimit($rec["cnt"] - $max_items, 0);
447 $del_set = $ilDB->query($query);
448 while ($del_item = $ilDB->fetchAssoc($del_set)) {
449 $del_news = new ilNewsItem((int) $del_item["id"]);
450 $del_news->delete();
451 }
452 }
453 }
454 }
A news item can be created by different sources.
static now()
Return current timestamp in Y-m-d H:i:s format.

References $ilDB, ILIAS\UI\Implementation\Component\Input\ViewControl\getContent(), ILIAS\Survey\Mode\getId(), ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle(), and ilUtil\now().

Referenced by ILIAS\News\Items\NewsItemManager\save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilNewsItem::delete ( )

Delete news item.

Deprecated:
will move to ilNewsData

Definition at line 1326 of file class.ilNewsItem.php.

1326 : void
1327 {
1328 $ilDB = $this->db;
1329
1330 // delete il_news_read entries
1331 $ilDB->manipulate("DELETE FROM il_news_read " .
1332 " WHERE news_id = " . $ilDB->quote($this->getId(), "integer"));
1333
1334 // delete multimedia object
1335 $mob = $this->getMobId();
1336
1337 // delete
1338 $query = "DELETE FROM il_news_item" .
1339 " WHERE id = " . $ilDB->quote($this->getId(), "integer");
1340 $ilDB->manipulate($query);
1341
1342 // delete mob after news, to have a "mob usage" of 0
1343 if ($mob > 0 && ilObject::_exists($mob)) {
1344 $mob = new ilObjMediaObject($mob);
1345 $mob->delete();
1346 }
1347 }
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data

References $ilDB, ilObject\_exists(), and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ deleteNewsOfContext()

static ilNewsItem::deleteNewsOfContext ( int  $a_context_obj_id,
string  $a_context_obj_type,
int  $a_context_sub_obj_id = 0,
string  $a_context_sub_obj_type = "" 
)
static

Delete all news of a context.

Deprecated:
will move to ilNewsData

Definition at line 1393 of file class.ilNewsItem.php.

1398 : void {
1399 foreach (self::getNewsOfContext(
1400 $a_context_obj_id,
1401 $a_context_obj_type,
1402 $a_context_sub_obj_id,
1403 $a_context_sub_obj_type
1404 ) as $n) {
1405 $n->delete();
1406 }
1407 }

Referenced by ilBlogPosting\delete(), ilPageObject\delete(), and ilBlogPosting\unpublish().

+ Here is the caller graph for this function:

◆ deliverMobFile()

ilNewsItem::deliverMobFile ( string  $a_purpose = "Standard",
bool  $a_increase_download_cnt = false 
)

Deliver mob file.

Definition at line 1813 of file class.ilNewsItem.php.

1816 : bool {
1817 $mob = $this->getMobId();
1818 $mob = new ilObjMediaObject($mob);
1819 $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
1820
1821 // check purpose
1822 if (!$mob->hasPurposeItem($a_purpose)) {
1823 return false;
1824 }
1825
1826 $m_item = $mob->getMediaItem($a_purpose);
1827 if ($m_item->getLocationType() !== "Reference") {
1828 $this->media_manager->deliverEntry($mob->getId(), "/" . $m_item->getLocation());
1829 if ($a_increase_download_cnt) {
1830 $this->increaseDownloadCounter();
1831 }
1832 $this->main_tpl->setOnScreenMessage('failure', "File not found!", true);
1833 return false;
1834 }
1835
1836 if ($a_increase_download_cnt) {
1837 $this->increaseDownloadCounter();
1838 }
1839
1840 ilUtil::redirect($m_item->getLocation());
1841 return true;
1842 }
increaseDownloadCounter()
Increase download counter.
static _getDirectory(int $a_mob_id)
Get absolute directory.
static redirect(string $a_script)

◆ determineNewsContent()

static ilNewsItem::determineNewsContent ( string  $a_context_obj_type,
string  $a_content,
bool  $a_is_lang_var,
?ilLanguage  $lng = null 
)
static

Determine new content.

Deprecated:
will move to util?

Definition at line 1599 of file class.ilNewsItem.php.

1604 : string {
1605 global $DIC;
1606
1607 if (is_null($lng)) {
1608 $lng = $DIC->language();
1609 }
1610 $obj_definition = $DIC["objDefinition"];
1611
1612 if ($a_is_lang_var) {
1613 if ($obj_definition->isPlugin($a_context_obj_type)) {
1614 return ilObjectPlugin::lookupTxtById($a_context_obj_type, $a_content);
1615 }
1616 $lng->loadLanguageModule($a_context_obj_type);
1617 return $lng->txt($a_content);
1618 }
1619
1620 return $a_content;
1621 }
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
ilLanguage $lng
static lookupTxtById(string $plugin_id, string $lang_var)

References $DIC, and $lng.

Referenced by ilObjectFeedWriter\__construct(), ilPDNewsTableGUI\fillRow(), and ilNewsDefaultRendererGUI\getDetailContent().

+ Here is the caller graph for this function:

◆ determineNewsTitle()

static ilNewsItem::determineNewsTitle ( string  $a_context_obj_type,
string  $a_title,
bool  $a_content_is_lang_var,
int  $a_agg_ref_id = 0,
array  $a_aggregation = [],
?ilLanguage  $lng = null 
)
static

Determine title for news item entry.

Deprecated:
will move to util?

Definition at line 1531 of file class.ilNewsItem.php.

1538 : string {
1539 global $DIC;
1540
1541 if (is_null($lng)) {
1542 $lng = $DIC->language();
1543 }
1544 $obj_definition = $DIC["objDefinition"];
1545 $tit = "";
1546
1547 if ($a_agg_ref_id > 0) {
1548 $cnt = count($a_aggregation);
1549
1550 // forums
1551 if ($a_context_obj_type === "frm") {
1552 if ($cnt > 1) {
1553 return sprintf($lng->txt("news_x_postings"), $cnt);
1554 }
1555
1556 return $lng->txt("news_1_postings");
1557 }
1558
1559 // files
1560 $up_cnt = $cr_cnt = 0;
1561 foreach ($a_aggregation as $item) {
1562 $title = $item instanceof NewsItem ? $item->getTitle() : $item['title'];
1563 if ($title === 'file_updated') {
1564 $up_cnt++;
1565 } else {
1566 $cr_cnt++;
1567 }
1568 }
1569 $sep = "";
1570 if ($cr_cnt === 1) {
1571 $tit = $lng->txt("news_1_file_created");
1572 $sep = "<br />";
1573 } elseif ($cr_cnt > 1) {
1574 $tit = sprintf($lng->txt("news_x_files_created"), $cr_cnt);
1575 $sep = "<br />";
1576 }
1577 if ($up_cnt === 1) {
1578 $tit .= $sep . $lng->txt("news_1_file_updated");
1579 } elseif ($up_cnt > 1) {
1580 $tit .= $sep . sprintf($lng->txt("news_x_files_updated"), $up_cnt);
1581 }
1582 return $tit;
1583 }
1584
1585 if ($a_content_is_lang_var) {
1586 if ($obj_definition->isPlugin($a_context_obj_type)) {
1587 return ilObjectPlugin::lookupTxtById($a_context_obj_type, $a_title);
1588 }
1589 return $lng->txt($a_title);
1590 }
1591
1592 return $a_title;
1593 }
News Item DTO for transfer of news items.
Definition: NewsItem.php:29

References $DIC, and $lng.

Referenced by ilObjectFeedWriter\__construct(), ilPDNewsTableGUI\fillRow(), ilNewsForContextBlockGUI\getNewsForId(), and ilNewsTimelineItemGUI\render().

+ Here is the caller graph for this function:

◆ determineNewsTitleByNewsId()

static ilNewsItem::determineNewsTitleByNewsId ( int  $a_news_id,
int  $a_agg_ref_id = 0,
array  $a_aggregation = [] 
)
static

Determine title for news item entry.

Definition at line 1504 of file class.ilNewsItem.php.

1508 : string {
1509 global $DIC;
1510
1511 $ilDB = $DIC->database();
1512
1513 $query = "SELECT context_obj_type, content_is_lang_var, title FROM il_news_item WHERE id = " .
1514 $ilDB->quote($a_news_id, "integer");
1515 $set = $ilDB->query($query);
1516 $rec = $ilDB->fetchAssoc($set);
1517
1519 $rec["context_obj_type"],
1520 $rec["title"],
1521 $rec["content_is_lang_var"],
1522 $a_agg_ref_id,
1523 $a_aggregation
1524 );
1525 }
static determineNewsTitle(string $a_context_obj_type, string $a_title, bool $a_content_is_lang_var, int $a_agg_ref_id=0, array $a_aggregation=[], ?ilLanguage $lng=null)
Determine title for news item entry.

◆ filterObjIdsPerNews()

static ilNewsItem::filterObjIdsPerNews ( array  $a_obj_ids,
  $a_time_period = 0,
string  $a_starting_date = "",
string  $a_ending_date = '',
bool  $ignore_period = false 
)
static

Checks whether news are available for.

Deprecated:
will move to ilNewsData
Parameters
array$a_obj_ids
string | int$a_time_period

Definition at line 1467 of file class.ilNewsItem.php.

1473 : array {
1474 global $DIC;
1475
1476 $ilDB = $DIC->database();
1477
1478 $and = "";
1479 if ($a_time_period > 0) {
1480 $limit_ts = self::handleTimePeriod($a_time_period);
1481 $and = " AND creation_date >= " . $ilDB->quote($limit_ts, "timestamp") . " ";
1482 }
1483
1484 if ($a_starting_date !== "") {
1485 $and .= " AND creation_date >= " . $ilDB->quote($a_starting_date, "timestamp");
1486 }
1487
1488 $query = "SELECT DISTINCT(context_obj_id) AS obj_id FROM il_news_item" .
1489 " WHERE " . $ilDB->in("context_obj_id", $a_obj_ids, false, "integer") . " " . $and;
1490 //" WHERE context_obj_id IN (".implode(ilUtil::quoteArray($a_obj_ids),",").")".$and;
1491
1492 $set = $ilDB->query($query);
1493 $objs = [];
1494 while ($rec = $ilDB->fetchAssoc($set)) {
1495 $objs[] = $rec["obj_id"];
1496 }
1497
1498 return $objs;
1499 }

References $ilDB.

◆ getAggregatedChildNewsData()

ilNewsItem::getAggregatedChildNewsData ( int  $a_ref_id,
bool  $a_only_public = false,
int  $a_time_period = 0,
bool  $a_prevent_aggregation = false,
string  $a_starting_date = "",
bool  $a_no_auto_generated = false,
array  $a_excluded = [] 
)
protected

Get news aggregation for child objects (e.g.

for categories)

Deprecated:
will be removed after migrating getNewsForRefId

Definition at line 820 of file class.ilNewsItem.php.

828 : array {
830 $ilAccess = $this->access;
831 $ref_id = [];
832 // get news of parent object
833 $data = $this->getNewsForRefId(
834 $a_ref_id,
835 $a_only_public,
836 true,
837 $a_time_period,
838 true,
839 false,
840 $a_no_auto_generated,
841 false,
842 null,
843 0,
844 $a_excluded
845 );
846 foreach ($data as $k => $v) {
847 $data[$k]["ref_id"] = $a_ref_id;
848 }
849
850 // get childs
851 $nodes = $tree->getChilds($a_ref_id);
852
853 // no check, for which of the objects any news are available
854 $obj_ids = [];
855 foreach ($nodes as $node) {
856 $obj_ids[] = $node["obj_id"];
857 }
858 $news_obj_ids = self::filterObjIdsPerNews($obj_ids, $a_time_period, $a_starting_date);
859 //$news_obj_ids = $obj_ids;
860
861 // get news for all subtree nodes
862 $contexts = [];
863 foreach ($nodes as $node) {
864 // only go on, if news are available
865 if (!in_array($node["obj_id"], $news_obj_ids)) {
866 continue;
867 }
868
869 if (!$a_only_public && !$ilAccess->checkAccess("read", "", (int) $node["child"])) {
870 continue;
871 }
872 $ref_id[$node["obj_id"]] = $node["child"];
873 $contexts[] = [
874 "obj_id" => $node["obj_id"],
875 "obj_type" => $node["type"]
876 ];
877 }
878
879 $news = $this->queryNewsForMultipleContexts(
880 $contexts,
881 $a_only_public,
882 $a_time_period,
883 $a_starting_date,
884 $a_no_auto_generated,
885 null,
886 0,
887 $a_excluded
888 );
889 foreach ($news as $k => $v) {
890 $news[$k]["ref_id"] = $ref_id[$v["context_obj_id"]];
891 }
892 $data = self::mergeNews($data, $news);
893
894 // sort and return
895 $data = ilArrayUtil::sortArray($data, "creation_date", "desc", false, true);
896
897 if (!$a_prevent_aggregation) {
898 $data = $this->aggregateFiles($data, $a_ref_id);
899 }
900
901 return $data;
902 }
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
getNewsForRefId(int $a_ref_id, bool $a_only_public=false, bool $a_stopnesting=false, $a_time_period=0, bool $a_prevent_aggregation=true, bool $a_forum_group_sequences=false, bool $a_no_auto_generated=false, bool $a_ignore_date_filter=false, ?int $a_user_id=null, int $a_limit=0, array $a_excluded=[])
Get News For Ref Id.
static mergeNews(array $n1, array $n2)
Merges two sets of news.
queryNewsForMultipleContexts(array $a_contexts, bool $a_for_rss_use=false, $a_time_period=0, string $a_starting_date="", bool $a_no_auto_generated=false, ?int $a_user_id=null, int $a_limit=0, array $a_exclude=[])
static filterObjIdsPerNews(array $a_obj_ids, $a_time_period=0, string $a_starting_date="", string $a_ending_date='', bool $ignore_period=false)
Checks whether news are available for.
aggregateFiles(array $news, int $a_ref_id)
ilAccessHandler $access
getChilds(int $a_node_id, string $a_order="", string $a_direction="ASC")
get child nodes of given node
$ref_id
Definition: ltiauth.php:66

◆ getAggregatedNewsData()

ilNewsItem::getAggregatedNewsData ( int  $a_ref_id,
bool  $a_only_public = false,
  $a_time_period = 0,
bool  $a_prevent_aggregation = false,
string  $a_starting_date = "",
bool  $a_no_auto_generated = false,
?int  $a_user_id = null,
int  $a_limit = 0,
array  $a_exclude = [] 
)
protected

Get news aggregation (e.g.

for courses, groups)

Parameters
string | int$a_time_period
Deprecated:
will be removed after migrating getNewsForRefId

Definition at line 632 of file class.ilNewsItem.php.

642 : array {
644 $ilAccess = $this->access;
645 $ilObjDataCache = $this->obj_data_cache;
646
647 // get news of parent object
648 $data = [];
649
650 // get subtree
651 $cur_node = $tree->getNodeData($a_ref_id);
652
653 // do not check for lft (materialized path)
654 if ($cur_node) {
655 $nodes = $tree->getSubTree($cur_node, true);
656 } else {
657 $nodes = [];
658 }
659
660 // preload object data cache
661 $ref_ids = [];
662 $obj_ids = [];
663 $ref_id = [];
664 foreach ($nodes as $node) {
665 $ref_ids[] = (int) $node["child"];
666 $obj_ids[] = (int) $node["obj_id"];
667 }
668
669 $ilObjDataCache->preloadReferenceCache($ref_ids);
670 if (!$a_only_public) {
672 }
673
674 // no check, for which of the objects any news are available
675 $news_obj_ids = self::filterObjIdsPerNews($obj_ids, $a_time_period, $a_starting_date);
676 //$news_obj_ids = $obj_ids;
677
678 // get news for all subtree nodes
679 $contexts = [];
680 foreach ($nodes as $node) {
681 // only go on, if news are available
682 if (!in_array($node["obj_id"], $news_obj_ids)) {
683 continue;
684 }
685
686 if (!$a_only_public) {
687 if (!$a_user_id) {
688 $acc = $ilAccess->checkAccess("read", "", (int) $node["child"]);
689 } else {
690 $acc = $ilAccess->checkAccessOfUser(
691 $a_user_id,
692 "read",
693 "",
694 (int) $node["child"]
695 );
696 }
697 if (!$acc) {
698 continue;
699 }
700 }
701
702 $ref_id[$node["obj_id"]] = $node["child"];
703 $contexts[] = [
704 "obj_id" => $node["obj_id"],
705 "obj_type" => $node["type"]
706 ];
707 }
708
709 // sort and return
710 $news = $this->queryNewsForMultipleContexts(
711 $contexts,
712 $a_only_public,
713 $a_time_period,
714 $a_starting_date,
715 $a_no_auto_generated,
716 $a_user_id,
717 $a_limit,
718 $a_exclude
719 );
720
721 $to_del = [];
722 foreach ($news as $k => $v) {
723 $news[$k]["ref_id"] = $ref_id[$v["context_obj_id"]];
724 }
725
726 $data = self::mergeNews($data, $news);
727 $data = ilArrayUtil::sortArray($data, "creation_date", "desc", false, true);
728
729 if (!$a_prevent_aggregation) {
730 $data = $this->aggregateFiles($data, $a_ref_id);
731 }
732
733 return $data;
734 }
ilObjectDataCache $obj_data_cache
static preloadData(array $ref_ids)
Preload data to internal cache.
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
getSubTree(array $a_node, bool $a_with_data=true, array $a_type=[])
get all nodes in the subtree under specified node

References ilTree\getSubTree().

+ Here is the call graph for this function:

◆ getContent()

ilNewsItem::getContent ( )

Definition at line 126 of file class.ilNewsItem.php.

126 : string
127 {
128 return $this->content;
129 }

References $content.

◆ getContentHtml()

ilNewsItem::getContentHtml ( )

Definition at line 340 of file class.ilNewsItem.php.

340 : bool
341 {
342 return $this->content_html;
343 }

◆ getContentIsLangVar()

ilNewsItem::getContentIsLangVar ( )

Definition at line 264 of file class.ilNewsItem.php.

264 : bool
265 {
267 }
bool $content_is_lang_var

◆ getContentLong()

ilNewsItem::getContentLong ( )

Definition at line 243 of file class.ilNewsItem.php.

243 : string
244 {
245 return $this->content_long;
246 }
string $content_long

◆ getContentTextIsLangVar()

ilNewsItem::getContentTextIsLangVar ( )

Definition at line 310 of file class.ilNewsItem.php.

310 : bool
311 {
313 }
bool $content_text_is_lang_var

◆ getContentType()

ilNewsItem::getContentType ( )

Definition at line 176 of file class.ilNewsItem.php.

176 : string
177 {
178 return $this->content_type;
179 }
string $content_type

References $content_type.

◆ getContextObjId()

ilNewsItem::getContextObjId ( )

Definition at line 136 of file class.ilNewsItem.php.

136 : int
137 {
139 }

References $context_obj_id.

◆ getContextObjType()

ilNewsItem::getContextObjType ( )

Definition at line 146 of file class.ilNewsItem.php.

146 : string
147 {
149 }
string $context_obj_type

References $context_obj_type.

◆ getContextSubObjId()

ilNewsItem::getContextSubObjId ( )

Definition at line 156 of file class.ilNewsItem.php.

156 : int
157 {
159 }

References $context_sub_obj_id.

◆ getContextSubObjType()

ilNewsItem::getContextSubObjType ( )

Definition at line 166 of file class.ilNewsItem.php.

166 : ?string
167 {
169 }
string $context_sub_obj_type

References $context_sub_obj_type.

◆ getCreationDate()

ilNewsItem::getCreationDate ( )

Definition at line 186 of file class.ilNewsItem.php.

186 : string
187 {
189 }
string $creation_date

References $creation_date.

◆ getFirstNewsIdForContext()

static ilNewsItem::getFirstNewsIdForContext ( int  $a_context_obj_id,
string  $a_context_obj_type,
int  $a_context_sub_obj_id = 0,
string  $a_context_sub_obj_type = "" 
)
static

Get first new id of news set related to a certain context.

Deprecated:
will move to ilNewsData

Definition at line 1627 of file class.ilNewsItem.php.

1632 : int {
1633 global $DIC;
1634
1635 $ilDB = $DIC->database();
1636
1637 // Determine how many rows should be deleted
1638 $query = "SELECT id " .
1639 "FROM il_news_item " .
1640 "WHERE " .
1641 "context_obj_id = " . $ilDB->quote($a_context_obj_id, "integer") .
1642 " AND context_obj_type = " . $ilDB->quote($a_context_obj_type, "text") .
1643 " AND context_sub_obj_id = " . $ilDB->quote($a_context_sub_obj_id, "integer") .
1644 " AND " . $ilDB->equals("context_sub_obj_type", $a_context_sub_obj_type, "text", true);
1645
1646 $set = $ilDB->query($query);
1647 $rec = $ilDB->fetchAssoc($set);
1648
1649 return (int) ($rec["id"] ?? 0);
1650 }

Referenced by ilForum\deletePost(), ilForumTopic\movePosts(), ilForum\postCensorship(), and ilObjForumGUI\savePostObject().

+ Here is the caller graph for this function:

◆ getId()

ilNewsItem::getId ( )

Definition at line 106 of file class.ilNewsItem.php.

106 : int
107 {
108 return $this->id;
109 }

References $id.

Referenced by ILIAS\News\Items\NewsItemManager\save().

+ Here is the caller graph for this function:

◆ getLastNewsIdForContext()

static ilNewsItem::getLastNewsIdForContext ( int  $a_context_obj_id,
string  $a_context_obj_type,
int  $a_context_sub_obj_id = 0,
string  $a_context_sub_obj_type = "",
bool  $a_only_today = false 
)
static

Get last news id of news set related to a certain context.

Deprecated:
will move to ilNewsData

Definition at line 1656 of file class.ilNewsItem.php.

1662 : int {
1663 global $DIC;
1664
1665 $ilDB = $DIC->database();
1666
1667 // Determine how many rows should be deleted
1668 $query = "SELECT id, update_date " .
1669 "FROM il_news_item " .
1670 "WHERE " .
1671 "context_obj_id = " . $ilDB->quote($a_context_obj_id, "integer") .
1672 " AND context_obj_type = " . $ilDB->quote($a_context_obj_type, "text") .
1673 " AND context_sub_obj_id = " . $ilDB->quote($a_context_sub_obj_id, "integer") .
1674 " AND " . $ilDB->equals("context_sub_obj_type", $a_context_sub_obj_type, "text", true) .
1675 " ORDER BY update_date DESC";
1676
1677 $ilDB->setLimit(1, 0);
1678 $set = $ilDB->query($query);
1679 $id = 0;
1680 if ($rec = $ilDB->fetchAssoc($set)) {
1681 $id = (int) $rec["id"];
1682 if ($a_only_today) {
1683 $now = ilUtil::now();
1684 if (strpos($rec["update_date"], substr($now, 0, 10)) !== 0) {
1685 $id = 0;
1686 }
1687 }
1688 }
1689
1690 return $id;
1691 }

References $id, ILIAS\Repository\int(), and ilUtil\now().

Referenced by ILIAS\Blog\News\NewsManager\handle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLimitation()

ilNewsItem::getLimitation ( )

Definition at line 300 of file class.ilNewsItem.php.

300 : bool
301 {
302 return $this->limitation;
303 }

◆ getMobDownloadCounter()

ilNewsItem::getMobDownloadCounter ( )

Definition at line 330 of file class.ilNewsItem.php.

330 : int
331 {
333 }

◆ getMobId()

ilNewsItem::getMobId ( )

Definition at line 274 of file class.ilNewsItem.php.

274 : int
275 {
276 return $this->mob_id;
277 }

Referenced by ilObjMediaCastGUI\initAddCastItemForm().

+ Here is the caller graph for this function:

◆ getMobPlayCounter()

ilNewsItem::getMobPlayCounter ( )

Definition at line 320 of file class.ilNewsItem.php.

320 : int
321 {
322 return $this->mob_cnt_play;
323 }

◆ getNewsForRefId()

ilNewsItem::getNewsForRefId ( int  $a_ref_id,
bool  $a_only_public = false,
bool  $a_stopnesting = false,
  $a_time_period = 0,
bool  $a_prevent_aggregation = true,
bool  $a_forum_group_sequences = false,
bool  $a_no_auto_generated = false,
bool  $a_ignore_date_filter = false,
?int  $a_user_id = null,
int  $a_limit = 0,
array  $a_excluded = [] 
)

Get News For Ref Id.

Parameters
string | int$a_time_period
int$a_limitcurrently only supported for groups and courses
int[]$a_excludedcurrently only supported for groups and courses (news ids)
Deprecated:
Use \ILIAS\News\Domain\NewsCollectionService::getNewsForContext instead

Definition at line 508 of file class.ilNewsItem.php.

520 : array {
521 $obj_id = ilObject::_lookupObjId($a_ref_id);
522 $obj_type = ilObject::_lookupType($obj_id);
523
524 // get starting date
525 $starting_date = "";
526 if ($obj_type === "grp" || $obj_type === "crs") {
527 // see #31471, #30687, and ilMembershipNotification
529 $obj_id,
530 'cont_use_news',
531 '1'
532 ) || (
534 $obj_id,
535 'cont_show_news',
536 '1'
538 $obj_id,
539 'news_timeline'
540 )
541 )) {
542 return [];
543 }
544
545 $hide_news_per_date = ilBlockSetting::_lookup(
546 "news",
547 "hide_news_per_date",
548 0,
549 $obj_id
550 );
551 if ($hide_news_per_date && !$a_ignore_date_filter) {
552 $starting_date = ilBlockSetting::_lookup(
553 "news",
554 "hide_news_date",
555 0,
556 $obj_id
557 );
558 }
559 }
560
561 if ($obj_type === "cat" && !$a_stopnesting) {
562 $news = $this->getAggregatedChildNewsData(
563 $a_ref_id,
564 $a_only_public,
565 $a_time_period,
566 $a_prevent_aggregation,
567 $starting_date,
568 $a_no_auto_generated,
569 $a_excluded
570 );
571 } elseif (($obj_type === "grp" || $obj_type === "crs") &&
572 !$a_stopnesting) {
573 $news = $this->getAggregatedNewsData(
574 $a_ref_id,
575 $a_only_public,
576 $a_time_period,
577 $a_prevent_aggregation,
578 $starting_date,
579 $a_no_auto_generated,
580 $a_user_id,
581 $a_limit,
582 $a_excluded
583 );
584 } else {
585 $news_item = new ilNewsItem();
586 $news_item->setContextObjId($obj_id);
587 $news_item->setContextObjType($obj_type);
588 $news = $news_item->queryNewsForContext(
589 $a_only_public,
590 $a_time_period,
591 $starting_date,
592 $a_no_auto_generated,
593 false,
594 0,
595 $a_excluded
596 );
597 $unset = [];
598 foreach ($news as $k => $v) {
599 if (!$a_only_public || $v["visibility"] == NEWS_PUBLIC ||
600 ($v["priority"] == 0 &&
602 "news",
603 "public_notifications",
604 0,
605 $obj_id
606 ))) {
607 $news[$k]["ref_id"] = $a_ref_id;
608 } else {
609 $unset[] = $k;
610 }
611 }
612 foreach ($unset as $un) {
613 unset($news[$un]);
614 }
615 }
616
617 if (!$a_prevent_aggregation) {
618 $news = $this->aggregateForums($news);
619 } elseif ($a_forum_group_sequences) {
620 $news = $this->aggregateForums($news, true);
621 }
622
623 return $news;
624 }
const NEWS_PUBLIC
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
getAggregatedChildNewsData(int $a_ref_id, bool $a_only_public=false, int $a_time_period=0, bool $a_prevent_aggregation=false, string $a_starting_date="", bool $a_no_auto_generated=false, array $a_excluded=[])
Get news aggregation for child objects (e.g.
getAggregatedNewsData(int $a_ref_id, bool $a_only_public=false, $a_time_period=0, bool $a_prevent_aggregation=false, string $a_starting_date="", bool $a_no_auto_generated=false, ?int $a_user_id=null, int $a_limit=0, array $a_exclude=[])
Get news aggregation (e.g.
aggregateForums(array $news, bool $a_group_posting_sequence=false)
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)

Referenced by ilNewsItemGUI\getNewsForContextTable().

+ Here is the caller graph for this function:

◆ getNewsOfContext()

static ilNewsItem::getNewsOfContext ( int  $a_context_obj_id,
string  $a_context_obj_type,
int  $a_context_sub_obj_id = 0,
string  $a_context_sub_obj_type = "" 
)
static

Get all news of a context.

Deprecated:
will move to ilNewsData
Returns
ilNewsItem[]

Definition at line 1354 of file class.ilNewsItem.php.

1359 : array {
1360 global $DIC;
1361
1362 $ilDB = $DIC->database();
1363 $and = "";
1364
1365 if ($a_context_obj_id === 0 || $a_context_obj_type === "") {
1366 return [];
1367 }
1368
1369 if ($a_context_sub_obj_id > 0) {
1370 $and = " AND context_sub_obj_id = " . $ilDB->quote($a_context_sub_obj_id, "integer") .
1371 " AND context_sub_obj_type = " . $ilDB->quote($a_context_sub_obj_type, "text");
1372 }
1373
1374 // get news records
1375 $query = "SELECT id FROM il_news_item" .
1376 " WHERE context_obj_id = " . $ilDB->quote($a_context_obj_id, "integer") .
1377 " AND context_obj_type = " . $ilDB->quote($a_context_obj_type, "text") .
1378 $and;
1379
1380 $news_set = $ilDB->query($query);
1381
1382 $news_arr = [];
1383 while ($news = $ilDB->fetchAssoc($news_set)) {
1384 $news_arr[] = new ilNewsItem((int) $news["id"]);
1385 }
1386 return $news_arr;
1387 }

◆ getPlaytime()

ilNewsItem::getPlaytime ( )

Definition at line 287 of file class.ilNewsItem.php.

287 : string
288 {
289 return $this->playtime;
290 }

◆ getPriority()

ilNewsItem::getPriority ( )

Definition at line 253 of file class.ilNewsItem.php.

253 : int
254 {
255 return $this->priority;
256 }

Referenced by ILIAS\News\Access\NewsAccess\canEdit().

+ Here is the caller graph for this function:

◆ getPrivateFeedId()

static ilNewsItem::getPrivateFeedId ( )
static
Deprecated:
will move to settings->user

Definition at line 1804 of file class.ilNewsItem.php.

1804 : int
1805 {
1806 return self::$privFeedId;
1807 }
static int $privFeedId

◆ getTitle()

ilNewsItem::getTitle ( )

Definition at line 116 of file class.ilNewsItem.php.

116 : string
117 {
118 return $this->title;
119 }

References $title.

◆ getUpdateDate()

ilNewsItem::getUpdateDate ( )

Definition at line 196 of file class.ilNewsItem.php.

196 : string
197 {
198 return $this->update_date;
199 }
string $update_date

References $update_date.

◆ getUpdateUserId()

ilNewsItem::getUpdateUserId ( )

Definition at line 216 of file class.ilNewsItem.php.

216 : int
217 {
219 }

References $update_user_id.

◆ getUserId()

ilNewsItem::getUserId ( )

Definition at line 206 of file class.ilNewsItem.php.

206 : int
207 {
208 return $this->user_id;
209 }

References $user_id.

Referenced by ILIAS\News\Access\NewsAccess\canEdit().

+ Here is the caller graph for this function:

◆ getVisibility()

ilNewsItem::getVisibility ( )

Definition at line 230 of file class.ilNewsItem.php.

230 : string
231 {
232 return $this->visibility;
233 }

◆ handleTimePeriod()

static ilNewsItem::handleTimePeriod (   $a_time_period)
staticprotected

Convert time period for DB-queries.

Parameters
string | int$a_time_period

Definition at line 923 of file class.ilNewsItem.php.

923 : string
924 {
925 // time period is number of days
926 if (is_numeric($a_time_period)) {
927 if ($a_time_period > 0) {
928 return date('Y-m-d H:i:s', time() - ($a_time_period * 24 * 60 * 60));
929 }
930 }
931 // time period is datetime
932 elseif (preg_match("/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/", $a_time_period)) {
933 return $a_time_period;
934 }
935 return "";
936 }

◆ increaseDownloadCounter()

ilNewsItem::increaseDownloadCounter ( )

Increase download counter.

Deprecated:
will move to data

Definition at line 1848 of file class.ilNewsItem.php.

1848 : void
1849 {
1850 $ilDB = $this->db;
1851
1852 $cnt = $this->getMobDownloadCounter();
1853 $cnt++;
1854 $this->setMobDownloadCounter($cnt);
1855 $ilDB->manipulate(
1856 "UPDATE il_news_item SET " .
1857 " mob_cnt_download = " . $ilDB->quote($cnt, "integer") .
1858 " WHERE id = " . $ilDB->quote($this->getId(), "integer")
1859 );
1860 }
setMobDownloadCounter(int $a_val)

References $ilDB.

◆ increasePlayCounter()

ilNewsItem::increasePlayCounter ( )

Increase play counter.

Deprecated:
will move to data

Definition at line 1867 of file class.ilNewsItem.php.

1867 : void
1868 {
1869 $ilDB = $this->db;
1870
1871 $cnt = $this->getMobPlayCounter();
1872 $cnt++;
1873 $this->setMobPlayCounter($cnt);
1874 $ilDB->manipulate(
1875 "UPDATE il_news_item SET " .
1876 " mob_cnt_play = " . $ilDB->quote($cnt, "integer") .
1877 " WHERE id = " . $ilDB->quote($this->getId(), "integer")
1878 );
1879 }
setMobPlayCounter(int $a_val)

References $ilDB.

◆ mergeNews()

static ilNewsItem::mergeNews ( array  $n1,
array  $n2 
)
static

Merges two sets of news.

Deprecated:
will move to ilNewsData

Definition at line 1271 of file class.ilNewsItem.php.

1274 : array {
1275 foreach ($n2 as $id => $news) {
1276 $n1[$id] = $news;
1277 }
1278
1279 return $n1;
1280 }

References $id.

◆ queryNewsByIds()

static ilNewsItem::queryNewsByIds ( array  $a_news_ids)
static

Query news data by news ids.

Parameters
int[]$a_news_ids
Returns
array[]

Definition at line 1067 of file class.ilNewsItem.php.

1067 : array
1068 {
1069 global $DIC;
1070 $ilDB = $DIC->database();
1071 $news = [];
1072 $set = $ilDB->query("SELECT * FROM il_news_item " .
1073 " WHERE " . $ilDB->in("id", $a_news_ids, false, "integer"));
1074 while ($rec = $ilDB->fetchAssoc($set)) {
1075 $news[$rec["id"]] = $rec;
1076 }
1077 return $news;
1078 }

References $DIC, and $ilDB.

Referenced by ilMembershipCronNotificationsData\loadMissingNews().

+ Here is the caller graph for this function:

◆ queryNewsForContext()

ilNewsItem::queryNewsForContext ( bool  $a_for_rss_use = false,
  $a_time_period = 0,
string  $a_starting_date = "",
bool  $a_no_auto_generated = false,
bool  $a_oldest_first = false,
int  $a_limit = 0,
array  $a_exclude = [] 
)

Query news for a context.

Parameters
string | int$a_time_period
Deprecated:
will be removed after migrating getNewsForRefId

Definition at line 944 of file class.ilNewsItem.php.

952 : array {
954 $ilUser = $this->user;
955
956 $and = "";
957 if ($a_time_period > 0) {
958 $limit_ts = self::handleTimePeriod($a_time_period);
959 $and = " AND creation_date >= " . $ilDB->quote($limit_ts, "timestamp") . " ";
960 }
961
962 if ($a_starting_date !== "") {
963 $and .= " AND creation_date > " . $ilDB->quote($a_starting_date, "timestamp") . " ";
964 }
965
966 if ($a_no_auto_generated) {
967 $and .= " AND priority = 1 AND content_type = " . $ilDB->quote("text", "text") . " ";
968 }
969
970 // this is changed with 4.1 (news table for lm pages)
971 if ($this->getContextSubObjId() > 0) {
972 $and .= " AND context_sub_obj_id = " . $ilDB->quote($this->getContextSubObjId(), "integer") .
973 " AND context_sub_obj_type = " . $ilDB->quote($this->getContextSubObjType(), "text");
974 }
975
976 if (count($a_exclude) > 0) {
977 $and .= " AND " . $ilDB->in("id", $a_exclude, true, "integer") . " ";
978 }
979
980 $ordering = ($a_oldest_first)
981 ? " creation_date ASC, id ASC "
982 : " creation_date DESC, id DESC ";
983
984 if ($a_for_rss_use && self::getPrivateFeedId() === 0) {
985 $query = "SELECT * " .
986 "FROM il_news_item " .
987 " WHERE " .
988 "context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
989 " AND context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text") .
990 $and .
991 " ORDER BY " . $ordering;
992 } elseif (self::getPrivateFeedId() > 0) {
993 $query = "SELECT il_news_item.* " .
994 ", il_news_read.user_id user_read " .
995 "FROM il_news_item LEFT JOIN il_news_read " .
996 "ON il_news_item.id = il_news_read.news_id AND " .
997 " il_news_read.user_id = " . $ilDB->quote(self::getPrivateFeedId(), "integer") .
998 " WHERE " .
999 "context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
1000 " AND context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text") .
1001 $and .
1002 " ORDER BY " . $ordering;
1003 } else {
1004 $query = "SELECT il_news_item.* " .
1005 ", il_news_read.user_id as user_read " .
1006 "FROM il_news_item LEFT JOIN il_news_read " .
1007 "ON il_news_item.id = il_news_read.news_id AND " .
1008 " il_news_read.user_id = " . $ilDB->quote($ilUser->getId(), "integer") .
1009 " WHERE " .
1010 "context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
1011 " AND context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text") .
1012 $and .
1013 " ORDER BY " . $ordering;
1014 }
1015 //echo $query;
1016 $set = $ilDB->query($query);
1017 $result = [];
1018 while ($rec = $ilDB->fetchAssoc($set)) {
1019 if ($a_limit > 0 && count($result) >= $a_limit) {
1020 continue;
1021 }
1022 if (!$a_for_rss_use || (self::getPrivateFeedId() > 0) || ($rec["visibility"] === NEWS_PUBLIC ||
1023 ((int) $rec["priority"] === 0 &&
1025 "news",
1026 "public_notifications",
1027 0,
1028 (int) $rec["context_obj_id"]
1029 )))) {
1030 $result[$rec["id"]] = $rec;
1031 }
1032 }
1033
1034 // do we get data for rss and may the time limit by an issue?
1035 // do a second query without time limit.
1036 // this is not very performant, but I do not have a better
1037 // idea. The keep_rss_min setting is currently (Jul 2012) only set
1038 // by mediacasts
1039 if ($a_time_period && $a_for_rss_use) {
1040 $keep_rss_min = ilBlockSetting::_lookup(
1041 "news",
1042 "keep_rss_min",
1043 0,
1044 $this->getContextObjId()
1045 );
1046 if ($keep_rss_min > 0) {
1047 return $this->queryNewsForContext(
1048 true,
1049 0,
1050 $a_starting_date,
1051 $a_no_auto_generated,
1052 $a_oldest_first,
1053 (int) $keep_rss_min,
1054 $a_exclude
1055 );
1056 }
1057 }
1058
1059 return $result;
1060 }
queryNewsForContext(bool $a_for_rss_use=false, $a_time_period=0, string $a_starting_date="", bool $a_no_auto_generated=false, bool $a_oldest_first=false, int $a_limit=0, array $a_exclude=[])
Query news for a context.
ilObjUser $user

References $ilDB.

Referenced by ilNewsItemGUI\getNewsForContextBlock(), and ilNewsItemGUI\getNewsForContextTable().

+ Here is the caller graph for this function:

◆ queryNewsForMultipleContexts()

ilNewsItem::queryNewsForMultipleContexts ( array  $a_contexts,
bool  $a_for_rss_use = false,
  $a_time_period = 0,
string  $a_starting_date = "",
bool  $a_no_auto_generated = false,
?int  $a_user_id = null,
int  $a_limit = 0,
array  $a_exclude = [] 
)
private
Parameters
string | int$a_time_period
Deprecated:
will be removed after migrating getNewsForRefId

Definition at line 1116 of file class.ilNewsItem.php.

1125 : array {
1126 $ilDB = $this->db;
1127 $ilUser = $this->user;
1128
1129 $and = "";
1130 if ($a_time_period > 0) {
1131 $limit_ts = self::handleTimePeriod($a_time_period);
1132 $and = " AND creation_date >= " . $ilDB->quote($limit_ts, "timestamp") . " ";
1133 }
1134
1135 if ($a_starting_date !== "") {
1136 $and .= " AND creation_date > " . $ilDB->quote($a_starting_date, "timestamp") . " ";
1137 }
1138
1139 if ($a_no_auto_generated) {
1140 $and .= " AND priority = 1 AND content_type = " . $ilDB->quote("text", "text") . " ";
1141 }
1142
1143 if ($a_limit > 0) {
1144 $ilDB->setLimit($a_limit, 0);
1145 }
1146
1147 if (is_array($a_exclude) && count($a_exclude) > 0) {
1148 $and .= " AND " . $ilDB->in("id", $a_exclude, true, "integer") . " ";
1149 }
1150
1151 $ids = [];
1152 $type = [];
1153
1154 foreach ($a_contexts as $cont) {
1155 $ids[] = $cont["obj_id"];
1156 $type[$cont["obj_id"]] = $cont["obj_type"];
1157 }
1158
1159 if ($a_for_rss_use && self::getPrivateFeedId() === 0) {
1160 $query = "SELECT * " .
1161 "FROM il_news_item " .
1162 " WHERE " .
1163 $ilDB->in("context_obj_id", $ids, false, "integer") . " " .
1164 $and .
1165 " ORDER BY creation_date DESC ";
1166 } elseif (self::getPrivateFeedId() > 0) {
1167 $query = "SELECT il_news_item.* " .
1168 ", il_news_read.user_id as user_read " .
1169 "FROM il_news_item LEFT JOIN il_news_read " .
1170 "ON il_news_item.id = il_news_read.news_id AND " .
1171 " il_news_read.user_id = " . $ilDB->quote(self::getPrivateFeedId(), "integer") .
1172 " WHERE " .
1173 $ilDB->in("context_obj_id", $ids, false, "integer") . " " .
1174 $and .
1175 " ORDER BY creation_date DESC ";
1176 } else {
1177 if ($a_user_id) {
1178 $user_id = $a_user_id;
1179 } else {
1180 $user_id = $ilUser->getId();
1181 }
1182 $query = "SELECT il_news_item.* " .
1183 ", il_news_read.user_id as user_read " .
1184 "FROM il_news_item LEFT JOIN il_news_read " .
1185 "ON il_news_item.id = il_news_read.news_id AND " .
1186 " il_news_read.user_id = " . $ilDB->quote($user_id, "integer") .
1187 " WHERE " .
1188 $ilDB->in("context_obj_id", $ids, false, "integer") . " " .
1189 $and .
1190 " ORDER BY creation_date DESC ";
1191 }
1192
1193 $set = $ilDB->query($query);
1194 $result = [];
1195 while ($rec = $ilDB->fetchAssoc($set)) {
1196 if ($type[$rec["context_obj_id"]] == $rec["context_obj_type"]) {
1197 if (!$a_for_rss_use || self::getPrivateFeedId() > 0 || ($rec["visibility"] === NEWS_PUBLIC ||
1198 ((int) $rec["priority"] === 0 &&
1200 "news",
1201 "public_notifications",
1202 0,
1203 (int) $rec["context_obj_id"]
1204 )))) {
1205 $result[$rec["id"]] = $rec;
1206 }
1207 }
1208 }
1209
1210 return $result;
1211 }

References $ilDB.

◆ read()

ilNewsItem::read ( )

Read item from database.

Deprecated:
(will migrate to ilNewsData or other class taking care of persistence)

Definition at line 349 of file class.ilNewsItem.php.

349 : void
350 {
352
353 $query = "SELECT * FROM il_news_item WHERE id = " .
354 $ilDB->quote($this->getId(), "integer");
355 $set = $ilDB->query($query);
356 if ($rec = $ilDB->fetchAssoc($set)) {
357 $this->setTitle((string) $rec["title"]);
358 $this->setContent((string) $rec["content"]);
359 $this->setContextObjId((int) $rec["context_obj_id"]);
360 $this->setContextObjType($rec["context_obj_type"]);
361 $this->setContextSubObjId((int) $rec["context_sub_obj_id"]);
362 $this->setContextSubObjType((string) $rec["context_sub_obj_type"]);
363 $this->setContentType((string) $rec["content_type"]);
364 $this->setCreationDate((string) $rec["creation_date"]);
365 $this->setUpdateDate((string) $rec["update_date"]);
366 $this->setUserId((int) $rec["user_id"]);
367 $this->setUpdateUserId((int) $rec["update_user_id"]);
368 $this->setVisibility((string) $rec["visibility"]);
369 $this->setContentLong((string) $rec["content_long"]);
370 $this->setPriority((int) $rec["priority"]);
371 $this->setContentIsLangVar((bool) $rec["content_is_lang_var"]);
372 $this->setContentTextIsLangVar((bool) $rec["content_text_is_lang_var"]);
373 $this->setMobId((int) $rec["mob_id"]);
374 $this->setPlaytime((string) $rec["playtime"]);
375 $this->setMobPlayCounter((int) $rec["mob_cnt_play"]);
376 $this->setMobDownloadCounter((int) $rec["mob_cnt_download"]);
377 $this->setContentHtml((bool) $rec["content_html"]);
378 }
379 }
setContentType(string $a_content_type="text")
setPriority(int $a_priority=1)
setUserId(int $a_user_id)
setContextObjType(string $a_context_obj_type)
setContextSubObjId(int $a_context_sub_obj_id)
setContentIsLangVar(bool $a_content_is_lang_var=false)
setContent(string $a_content)
setContentTextIsLangVar(bool $a_val=false)
setMobId(int $a_mob_id)
setContentHtml(bool $a_val)
setPlaytime(string $a_playtime)
setVisibility(string $a_visibility="users")
setUpdateUserId(int $a_val)
setContextSubObjType(?string $a_context_sub_obj_type)
setContextObjId(int $a_context_obj_id)
setTitle(string $a_title)
setContentLong(string $a_content_long)
setCreationDate(string $a_creation_date)
setUpdateDate(string $a_update_date)

References $ilDB, and ILIAS\Survey\Mode\getId().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setContent()

ilNewsItem::setContent ( string  $a_content)

Definition at line 121 of file class.ilNewsItem.php.

121 : void
122 {
123 $this->content = $a_content;
124 }

◆ setContentHtml()

ilNewsItem::setContentHtml ( bool  $a_val)

Definition at line 335 of file class.ilNewsItem.php.

335 : void
336 {
337 $this->content_html = $a_val;
338 }

◆ setContentIsLangVar()

ilNewsItem::setContentIsLangVar ( bool  $a_content_is_lang_var = false)

Definition at line 258 of file class.ilNewsItem.php.

260 : void {
261 $this->content_is_lang_var = $a_content_is_lang_var;
262 }

◆ setContentLong()

ilNewsItem::setContentLong ( string  $a_content_long)
Parameters
string$a_content_longLong content of news

Definition at line 238 of file class.ilNewsItem.php.

238 : void
239 {
240 $this->content_long = $a_content_long;
241 }

◆ setContentTextIsLangVar()

ilNewsItem::setContentTextIsLangVar ( bool  $a_val = false)

Definition at line 305 of file class.ilNewsItem.php.

305 : void
306 {
307 $this->content_text_is_lang_var = $a_val;
308 }

◆ setContentType()

ilNewsItem::setContentType ( string  $a_content_type = "text")

Definition at line 171 of file class.ilNewsItem.php.

171 : void
172 {
173 $this->content_type = $a_content_type;
174 }

◆ setContext()

ilNewsItem::setContext ( int  $a_obj_id,
string  $a_obj_type,
int  $a_sub_obj_id = 0,
string  $a_sub_obj_type = "" 
)

Set context for news.

Definition at line 907 of file class.ilNewsItem.php.

912 : void {
913 $this->setContextObjId($a_obj_id);
914 $this->setContextObjType($a_obj_type);
915 $this->setContextSubObjId($a_sub_obj_id);
916 $this->setContextSubObjType($a_sub_obj_type);
917 }

◆ setContextObjId()

ilNewsItem::setContextObjId ( int  $a_context_obj_id)

Definition at line 131 of file class.ilNewsItem.php.

131 : void
132 {
133 $this->context_obj_id = $a_context_obj_id;
134 }

Referenced by ilNewsItemGUI\getNewsForContextBlock(), and ilNewsItemGUI\getNewsForContextTable().

+ Here is the caller graph for this function:

◆ setContextObjType()

ilNewsItem::setContextObjType ( string  $a_context_obj_type)

Definition at line 141 of file class.ilNewsItem.php.

141 : void
142 {
143 $this->context_obj_type = $a_context_obj_type;
144 }

Referenced by ilNewsItemGUI\getNewsForContextBlock(), and ilNewsItemGUI\getNewsForContextTable().

+ Here is the caller graph for this function:

◆ setContextSubObjId()

ilNewsItem::setContextSubObjId ( int  $a_context_sub_obj_id)

Definition at line 151 of file class.ilNewsItem.php.

151 : void
152 {
153 $this->context_sub_obj_id = $a_context_sub_obj_id;
154 }

Referenced by ilNewsItemGUI\getNewsForContextBlock(), and ilNewsItemGUI\getNewsForContextTable().

+ Here is the caller graph for this function:

◆ setContextSubObjType()

ilNewsItem::setContextSubObjType ( ?string  $a_context_sub_obj_type)

Definition at line 161 of file class.ilNewsItem.php.

161 : void
162 {
163 $this->context_sub_obj_type = $a_context_sub_obj_type;
164 }

Referenced by ilNewsItemGUI\getNewsForContextBlock(), and ilNewsItemGUI\getNewsForContextTable().

+ Here is the caller graph for this function:

◆ setCreationDate()

ilNewsItem::setCreationDate ( string  $a_creation_date)

Definition at line 181 of file class.ilNewsItem.php.

181 : void
182 {
183 $this->creation_date = $a_creation_date;
184 }

◆ setId()

ilNewsItem::setId ( int  $a_id)

Definition at line 101 of file class.ilNewsItem.php.

101 : void
102 {
103 $this->id = $a_id;
104 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setLimitation()

ilNewsItem::setLimitation ( bool  $a_limitation)

Set Limitation for number of items.

Definition at line 295 of file class.ilNewsItem.php.

295 : void
296 {
297 $this->limitation = $a_limitation;
298 }

◆ setMobDownloadCounter()

ilNewsItem::setMobDownloadCounter ( int  $a_val)

Definition at line 325 of file class.ilNewsItem.php.

325 : void
326 {
327 $this->mob_cnt_download = $a_val;
328 }

◆ setMobId()

ilNewsItem::setMobId ( int  $a_mob_id)

Definition at line 269 of file class.ilNewsItem.php.

269 : void
270 {
271 $this->mob_id = $a_mob_id;
272 }

◆ setMobPlayCounter()

ilNewsItem::setMobPlayCounter ( int  $a_val)

Definition at line 315 of file class.ilNewsItem.php.

315 : void
316 {
317 $this->mob_cnt_play = $a_val;
318 }

◆ setPlaytime()

ilNewsItem::setPlaytime ( string  $a_playtime)
Parameters
string$a_playtimePlay Time, hh:mm:ss (of attached media file)

Definition at line 282 of file class.ilNewsItem.php.

282 : void
283 {
284 $this->playtime = $a_playtime;
285 }

◆ setPriority()

ilNewsItem::setPriority ( int  $a_priority = 1)

Definition at line 248 of file class.ilNewsItem.php.

248 : void
249 {
250 $this->priority = $a_priority;
251 }

◆ setPrivateFeedId()

static ilNewsItem::setPrivateFeedId ( int  $a_userId)
static
Deprecated:
will move to settings->user

Definition at line 1796 of file class.ilNewsItem.php.

1796 : void
1797 {
1798 self::$privFeedId = $a_userId;
1799 }

Referenced by ilObjectFeedWriter\__construct().

+ Here is the caller graph for this function:

◆ setTitle()

ilNewsItem::setTitle ( string  $a_title)

Definition at line 111 of file class.ilNewsItem.php.

111 : void
112 {
113 $this->title = $a_title;
114 }

◆ setUpdateDate()

ilNewsItem::setUpdateDate ( string  $a_update_date)

Definition at line 191 of file class.ilNewsItem.php.

191 : void
192 {
193 $this->update_date = $a_update_date;
194 }

◆ setUpdateUserId()

ilNewsItem::setUpdateUserId ( int  $a_val)

Definition at line 211 of file class.ilNewsItem.php.

211 : void
212 {
213 $this->update_user_id = $a_val;
214 }

◆ setUserId()

ilNewsItem::setUserId ( int  $a_user_id)

Definition at line 201 of file class.ilNewsItem.php.

201 : void
202 {
203 $this->user_id = $a_user_id;
204 }

◆ setVisibility()

ilNewsItem::setVisibility ( string  $a_visibility = "users")
Parameters
string$a_visibilityAccess level of news.

Definition at line 224 of file class.ilNewsItem.php.

226 : void {
227 $this->visibility = $a_visibility;
228 }

◆ update()

ilNewsItem::update ( bool  $a_as_new = false)

Update item in database.

Deprecated:
(will migrate to ilNewsData or other class taking care of persistence)
Parameters
bool$a_as_newIf true, creation date is set "now"

Definition at line 462 of file class.ilNewsItem.php.

462 : void
463 {
465
466 $fields = [
467 "title" => ["text", $this->getTitle()],
468 "content" => ["clob", $this->getContent()],
469 "content_html" => ["integer", (int) $this->getContentHtml()],
470 "context_obj_id" => ["integer", $this->getContextObjId()],
471 "context_obj_type" => ["text", $this->getContextObjType()],
472 "context_sub_obj_id" => ["integer", $this->getContextSubObjId()],
473 "context_sub_obj_type" => ["text", $this->getContextSubObjType()],
474 "content_type" => ["text", $this->getContentType()],
475 "user_id" => ["integer", $this->getUserId()],
476 "update_user_id" => ["integer", $this->getUpdateUserId()],
477 "visibility" => ["text", $this->getVisibility()],
478 "content_long" => ["clob", $this->getContentLong()],
479 "priority" => ["integer", $this->getPriority()],
480 "content_is_lang_var" => ["integer", $this->getContentIsLangVar()],
481 "content_text_is_lang_var" => ["integer", (int) $this->getContentTextIsLangVar()],
482 "mob_id" => ["integer", $this->getMobId()],
483 "mob_cnt_play" => ["integer", $this->getMobPlayCounter()],
484 "mob_cnt_download" => ["integer", $this->getMobDownloadCounter()],
485 "playtime" => ["text", $this->getPlaytime()]
486 ];
487
488 $now = ilUtil::now();
489 if ($a_as_new) {
490 $fields["creation_date"] = ["timestamp", $now];
491 }
492 $fields["update_date"] = ["timestamp", $now];
493
494 $ilDB->update("il_news_item", $fields, [
495 "id" => ["integer", $this->getId()]
496 ]);
497 }

References $ilDB, ILIAS\UI\Implementation\Component\Input\ViewControl\getContent(), ILIAS\Survey\Mode\getId(), ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle(), ILIAS\Repository\int(), and ilUtil\now().

Referenced by ILIAS\News\Items\NewsItemManager\save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilNewsItem::$access
protected

Definition at line 50 of file class.ilNewsItem.php.

◆ $content

string ilNewsItem::$content = ""
protected

Definition at line 57 of file class.ilNewsItem.php.

Referenced by getContent().

◆ $content_html

bool ilNewsItem::$content_html = false
protected

Definition at line 58 of file class.ilNewsItem.php.

◆ $content_is_lang_var

bool ilNewsItem::$content_is_lang_var = false
protected

Definition at line 71 of file class.ilNewsItem.php.

◆ $content_long

string ilNewsItem::$content_long = ""
protected

Definition at line 69 of file class.ilNewsItem.php.

◆ $content_text_is_lang_var

bool ilNewsItem::$content_text_is_lang_var = false
protected

Definition at line 76 of file class.ilNewsItem.php.

◆ $content_type

string ilNewsItem::$content_type = "text"
protected

Definition at line 63 of file class.ilNewsItem.php.

Referenced by getContentType().

◆ $context_obj_id

int ilNewsItem::$context_obj_id = 0
protected

Definition at line 59 of file class.ilNewsItem.php.

Referenced by getContextObjId().

◆ $context_obj_type

string ilNewsItem::$context_obj_type = ""
protected

Definition at line 60 of file class.ilNewsItem.php.

Referenced by getContextObjType().

◆ $context_sub_obj_id

int ilNewsItem::$context_sub_obj_id = 0
protected

Definition at line 61 of file class.ilNewsItem.php.

Referenced by getContextSubObjId().

◆ $context_sub_obj_type

string ilNewsItem::$context_sub_obj_type = null
protected

Definition at line 62 of file class.ilNewsItem.php.

Referenced by getContextSubObjType().

◆ $creation_date

string ilNewsItem::$creation_date = ""
protected

Definition at line 64 of file class.ilNewsItem.php.

Referenced by getCreationDate().

◆ $ctrl

ilCtrl ilNewsItem::$ctrl
protected

Definition at line 54 of file class.ilNewsItem.php.

◆ $db

ilDBInterface ilNewsItem::$db
protected

Definition at line 48 of file class.ilNewsItem.php.

◆ $id

int ilNewsItem::$id = 0
protected

Definition at line 55 of file class.ilNewsItem.php.

Referenced by getId().

◆ $limitation

bool ilNewsItem::$limitation = false
private

Definition at line 75 of file class.ilNewsItem.php.

◆ $lng

ilLanguage ilNewsItem::$lng
protected

Definition at line 53 of file class.ilNewsItem.php.

◆ $log

ilLogger ilNewsItem::$log
protected

Definition at line 78 of file class.ilNewsItem.php.

◆ $main_tpl

ilGlobalTemplateInterface ilNewsItem::$main_tpl
private

Definition at line 77 of file class.ilNewsItem.php.

◆ $media_manager

MediaObjectManager ilNewsItem::$media_manager
protected

Definition at line 46 of file class.ilNewsItem.php.

◆ $mob_cnt_download

int ilNewsItem::$mob_cnt_download = 0
private

Definition at line 45 of file class.ilNewsItem.php.

◆ $mob_cnt_play

int ilNewsItem::$mob_cnt_play = 0
protected

Definition at line 47 of file class.ilNewsItem.php.

◆ $mob_id

int ilNewsItem::$mob_id = 0
protected

Definition at line 72 of file class.ilNewsItem.php.

◆ $obj_data_cache

ilObjectDataCache ilNewsItem::$obj_data_cache
protected

Definition at line 51 of file class.ilNewsItem.php.

◆ $playtime

string ilNewsItem::$playtime = ""
protected

Definition at line 73 of file class.ilNewsItem.php.

◆ $priority

int ilNewsItem::$priority = 1
protected

Definition at line 70 of file class.ilNewsItem.php.

◆ $privFeedId

int ilNewsItem::$privFeedId = 0
staticprivate

Definition at line 74 of file class.ilNewsItem.php.

◆ $title

string ilNewsItem::$title = ""
protected

Definition at line 56 of file class.ilNewsItem.php.

Referenced by getTitle().

◆ $tree

ilTree ilNewsItem::$tree
protected

Definition at line 49 of file class.ilNewsItem.php.

◆ $update_date

string ilNewsItem::$update_date = ""
protected

Definition at line 65 of file class.ilNewsItem.php.

Referenced by getUpdateDate().

◆ $update_user_id

int ilNewsItem::$update_user_id = 0
protected

Definition at line 67 of file class.ilNewsItem.php.

Referenced by getUpdateUserId().

◆ $user

ilObjUser ilNewsItem::$user
protected

Definition at line 52 of file class.ilNewsItem.php.

◆ $user_id

int ilNewsItem::$user_id = 0
protected

Definition at line 66 of file class.ilNewsItem.php.

Referenced by getUserId().

◆ $visibility

string ilNewsItem::$visibility = "users"
protected

Definition at line 68 of file class.ilNewsItem.php.


The documentation for this class was generated from the following file: