ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilNewsItem Class Reference
+ Collaboration diagram for ilNewsItem:

Public Member Functions

 __construct ($a_id=0)
 Constructor. More...
 
 setId ($a_id)
 Set Id. More...
 
 getId ()
 Get Id. More...
 
 setTitle ($a_title)
 Set Title. More...
 
 getTitle ()
 Get Title. More...
 
 setContent ($a_content)
 Set Content. More...
 
 getContent ()
 Get Content. More...
 
 setContextObjId ($a_context_obj_id)
 Set ContextObjId. More...
 
 getContextObjId ()
 Get ContextObjId. More...
 
 setContextObjType ($a_context_obj_type)
 Set ContextObjType. More...
 
 getContextObjType ()
 Get ContextObjType. More...
 
 setContextSubObjId ($a_context_sub_obj_id)
 Set ContextSubObjId. More...
 
 getContextSubObjId ()
 Get ContextSubObjId. More...
 
 setContextSubObjType ($a_context_sub_obj_type)
 Set ContextSubObjType. More...
 
 getContextSubObjType ()
 Get ContextSubObjType. More...
 
 setContentType ($a_content_type="text")
 Set ContentType. More...
 
 getContentType ()
 Get ContentType. More...
 
 setCreationDate ($a_creation_date)
 Set CreationDate. More...
 
 getCreationDate ()
 Get CreationDate. More...
 
 setUpdateDate ($a_update_date)
 Set UpdateDate. More...
 
 getUpdateDate ()
 Get UpdateDate. More...
 
 setUserId ($a_user_id)
 Set UserId. More...
 
 getUserId ()
 Get UserId. More...
 
 setUpdateUserId ($a_val)
 Set update user id. More...
 
 getUpdateUserId ()
 Get update user id. More...
 
 setVisibility ($a_visibility="users")
 Set Visibility. More...
 
 getVisibility ()
 Get Visibility. More...
 
 setContentLong ($a_content_long)
 Set ContentLong. More...
 
 getContentLong ()
 Get ContentLong. More...
 
 setPriority ($a_priority=1)
 Set Priority. More...
 
 getPriority ()
 Get Priority. More...
 
 setContentIsLangVar ($a_content_is_lang_var=0)
 Set ContentIsLangVar. More...
 
 getContentIsLangVar ()
 Get ContentIsLangVar. More...
 
 setMobId ($a_mob_id)
 Set MobId. More...
 
 getMobId ()
 Get MobId. More...
 
 setPlaytime ($a_playtime)
 Set Playtime. More...
 
 getPlaytime ()
 Get Playtime. More...
 
 setLimitation ($a_limitation)
 Set Limitation for number of items. More...
 
 getLimitation ()
 Get Limitation for number of items. More...
 
 setContentTextIsLangVar ($a_val=0)
 Set content text ist lang var. More...
 
 getContentTextIsLangVar ()
 Get content text ist lang var. More...
 
 setMobPlayCounter ($a_val)
 Set mob play counter. More...
 
 getMobPlayCounter ()
 Get mob play counter. More...
 
 setMobDownloadCounter ($a_val)
 Set mob download counter. More...
 
 getMobDownloadCounter ()
 Get mob download counter. More...
 
 setContentHtml ($a_val)
 Is content HTML (tiny used?) More...
 
 getContentHtml ()
 Get content as html. More...
 
 read ()
 Read item from database. More...
 
 create ()
 Create. More...
 
 update ($a_as_new=false)
 Update item in database. More...
 
 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. More...
 
 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. More...
 
 aggregateForums ($news, $a_group_posting_sequence=false)
 
 aggregateFiles ($news, $a_ref_id)
 
 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. More...
 
 setContext ($a_obj_id, $a_obj_type, $a_sub_obj_id=0, $a_sub_obj_type="")
 Convenient function to set the whole context information. More...
 
 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. More...
 
 checkNewsExistsForGroupCourse ($a_ref_id, $a_time_period=1)
 
 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. More...
 
 delete ()
 Delete news item. More...
 
 deliverMobFile ($a_purpose="Standard", $a_increase_download_cnt=false)
 Deliver mob file. More...
 
 increaseDownloadCounter ()
 Increase download counter. More...
 
 increasePlayCounter ()
 Increase play counter. More...
 

Static Public Member Functions

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. More...
 
static _setRead ($a_user_id, $a_news_id)
 Set item read. More...
 
static _setUnread ($a_user_id, $a_news_id)
 Set item unread. More...
 
static mergeNews ($n1, $n2)
 Merges two sets of news. More...
 
static _getDefaultVisibilityForRefId ($a_ref_id)
 Get default visibility for reference id. More...
 
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. More...
 
static _lookupTitle ($a_news_id)
 Lookup News Title. More...
 
static _lookupVisibility ($a_news_id)
 Lookup News Visibility. More...
 
static _lookupMobId ($a_news_id)
 Lookup mob id. More...
 
static filterObjIdsPerNews ($a_obj_ids, $a_time_period=0, $a_starting_date="", $a_ending_date='', $ignore_period=false)
 Checks whether news are available for. More...
 
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. More...
 
static determineNewsContent ($a_context_obj_type, $a_content, $a_is_lang_var)
 Determine new content. More...
 
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. More...
 
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. More...
 
static _lookupMediaObjectUsages ($a_mob_id)
 Lookup media object usage(s) More...
 
static _lookupContextObjId ($a_news_id)
 Context Object ID. More...
 
static _lookupDefaultPDPeriod ()
 
static _lookupUserPDPeriod ($a_user_id)
 
static _lookupRSSPeriod ()
 
static setPrivateFeedId ($a_userId)
 
static getPrivateFeedId ()
 
static prepareNewsDataFromCache ($a_cres)
 Prepare news data from cache. More...
 

Static Protected Member Functions

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

Protected Attributes

 $db
 
 $tree
 
 $access
 
 $obj_data_cache
 
 $user
 
 $lng
 
 $ctrl
 
 $id
 
 $title
 
 $content
 
 $content_html
 
 $context_obj_id
 
 $context_obj_type
 
 $context_sub_obj_id
 
 $context_sub_obj_type
 
 $content_type = "text"
 
 $creation_date
 
 $update_date
 
 $user_id
 
 $update_user_id
 
 $visibility = "users"
 
 $content_long
 
 $priority = 1
 
 $content_is_lang_var = 0
 
 $mob_id
 
 $playtime
 

Private Attributes

 $limitation
 

Static Private Attributes

static $privFeedId = false
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilNewsItem::__construct (   $a_id = 0)

Constructor.

Parameters
int$a_id

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

100 {
101 global $DIC;
102
103 $this->db = $DIC->database();
104 $this->tree = $DIC->repositoryTree();
105 $this->access = $DIC->access();
106 $this->obj_data_cache = $DIC["ilObjDataCache"];
107 $this->user = $DIC->user();
108 $this->lng = $DIC->language();
109 $this->ctrl = $DIC->ctrl();
110 if ($a_id > 0) {
111 $this->setId($a_id);
112 $this->read();
113 }
114 $this->limitation = true;
115 }
user()
Definition: user.php:4
read()
Read item from database.
setId($a_id)
Set Id.
global $DIC
Definition: saml.php:7

References $DIC, read(), setId(), and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ _getDefaultVisibilityForRefId()

static ilNewsItem::_getDefaultVisibilityForRefId (   $a_ref_id)
static

Get default visibility for reference id.

Parameters
$a_ref_idreference id

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

1584 {
1585 global $DIC;
1586
1587 $tree = $DIC->repositoryTree();
1588 $ilSetting = $DIC->settings();
1589
1590 include_once("./Services/Block/classes/class.ilBlockSetting.php");
1591
1592 $news_set = new ilSetting("news");
1593 $default_visibility = ($news_set->get("default_visibility") != "")
1594 ? $news_set->get("default_visibility")
1595 : "users";
1596
1597 if ($tree->isInTree($a_ref_id)) {
1598 $path = $tree->getPathFull($a_ref_id);
1599
1600 foreach ($path as $key => $row) {
1601 if (!in_array($row["type"], array("root", "cat","crs", "fold", "grp"))) {
1602 continue;
1603 }
1604
1606 "news",
1607 "default_visibility",
1608 0,
1609 $row["obj_id"]
1610 );
1611
1612 if ($visibility != "") {
1613 $default_visibility = $visibility;
1614 }
1615 }
1616 }
1617
1618 return $default_visibility;
1619 }
static _lookup($a_type, $a_setting, $a_user=0, $a_block_id=0)
Lookup setting from database.
ILIAS Setting Class.
$key
Definition: croninfo.php:18
global $ilSetting
Definition: privfeed.php:17

References $DIC, $ilSetting, $key, $path, $row, $tree, $visibility, and ilBlockSetting\_lookup().

Referenced by ilObjFile\createProperties(), ilObjForum\createSettings(), ilNewsItemGUI\getEditForm(), and ilNewsForContextBlockGUI\initSettingsForm().

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

◆ _getNewsItemsOfUser()

static ilNewsItem::_getNewsItemsOfUser (   $a_user_id,
  $a_only_public = false,
  $a_prevent_aggregation = false,
  $a_per = 0,
$a_cnt = null 
)
static

Get all news items for a user.

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

741 {
742 global $DIC;
743
744 $ilAccess = $DIC->access();
745
746 $news_item = new ilNewsItem();
747 $news_set = new ilSetting("news");
748
749 $per = $a_per;
750
751 include_once("./Services/News/classes/class.ilNewsSubscription.php");
752 include_once("./Services/Block/classes/class.ilBlockSetting.php");
753
754 // this is currently not used
755 $ref_ids = ilNewsSubscription::_getSubscriptionsOfUser($a_user_id);
756
757 if (ilObjUser::_lookupPref($a_user_id, "pd_items_news") != "n") {
758 // get all items of the personal desktop
759 $pd_items = ilObjUser::_lookupDesktopItems($a_user_id);
760 foreach ($pd_items as $item) {
761 if (!in_array($item["ref_id"], $ref_ids)) {
762 $ref_ids[] = $item["ref_id"];
763 }
764 }
765
766 // get all memberships
767 include_once 'Services/Membership/classes/class.ilParticipants.php';
768 $crs_mbs = ilParticipants::_getMembershipByType($a_user_id, 'crs');
769 $grp_mbs = ilParticipants::_getMembershipByType($a_user_id, 'grp');
770 $items = array_merge($crs_mbs, $grp_mbs);
771 foreach ($items as $i) {
772 $item_references = ilObject::_getAllReferences($i);
773 if (is_array($item_references) && count($item_references)) {
774 foreach ($item_references as $ref_id) {
775 if (!in_array($ref_id, $ref_ids)) {
776 $ref_ids[] = $ref_id;
777 }
778 }
779 }
780 }
781 }
782
783 $data = array();
784
785 foreach ($ref_ids as $ref_id) {
786 if (!$a_only_public) {
787 // this loop should not cost too much performance
788 $acc = $ilAccess->checkAccessOfUser($a_user_id, "read", "", $ref_id);
789
790 if (!$acc) {
791 continue;
792 }
793 }
794 if (ilNewsItem::getPrivateFeedId() != false) {
795 global $DIC;
796
797 $rbacsystem = $DIC->rbac()->system();
798 $acc = $rbacsystem->checkAccessOfUser(ilNewsItem::getPrivateFeedId(), "read", $ref_id);
799
800 if (!$acc) {
801 continue;
802 }
803 }
804
805 $obj_id = ilObject::_lookupObjId($ref_id);
806 $obj_type = ilObject::_lookupType($obj_id);
807 $news = $news_item->getNewsForRefId(
808 $ref_id,
809 $a_only_public,
810 false,
811 $per,
812 $a_prevent_aggregation,
813 false,
814 false,
815 false,
816 $a_user_id
817 );
818
819 // counter
820 if (!is_null($a_cnt)) {
821 $a_cnt[$ref_id] = count($news);
822 }
823
825 }
826
827 $data = ilUtil::sortArray($data, "creation_date", "desc", false, true);
828
829 return $data;
830 }
static getPrivateFeedId()
static mergeNews($n1, $n2)
Merges two sets of news.
static _getSubscriptionsOfUser($a_user_id)
Get subscriptions of user.
static _lookupPref($a_usr_id, $a_keyword)
static _lookupDesktopItems($user_id, $a_types="")
get all desktop items of user and specified type
static _lookupObjId($a_id)
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
$i
Definition: disco.tpl.php:19

References $data, $DIC, $i, ilObject\_getAllReferences(), ilParticipants\_getMembershipByType(), ilNewsSubscription\_getSubscriptionsOfUser(), ilObjUser\_lookupDesktopItems(), ilObject\_lookupObjId(), ilObjUser\_lookupPref(), ilObject\_lookupType(), getPrivateFeedId(), mergeNews(), and ilUtil\sortArray().

Referenced by ilUserFeedWriter\__construct(), and ilPDNewsBlockGUI\getNewsData().

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

◆ _lookupContextObjId()

static ilNewsItem::_lookupContextObjId (   $a_news_id)
static

Context Object ID.

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

1941 {
1942 global $DIC;
1943
1944 $ilDB = $DIC->database();
1945
1946 $query = "SELECT * " .
1947 "FROM il_news_item " .
1948 "WHERE " .
1949 " id = " . $ilDB->quote($a_news_id, "integer");
1950 $set = $ilDB->query($query);
1951 $rec = $ilDB->fetchAssoc($set);
1952
1953 return $rec["context_obj_id"];
1954 }
$query
global $ilDB

References $DIC, $ilDB, and $query.

Referenced by ilNewsItemGUI\executeCommand(), ilObjMediaObject\getParentObjectIdForUsage(), and ilNewsForContextBlockGUI\showNews().

+ Here is the caller graph for this function:

◆ _lookupDefaultPDPeriod()

static ilNewsItem::_lookupDefaultPDPeriod ( )
static

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

1957 {
1958 $news_set = new ilSetting("news");
1959 $per = $news_set->get("pd_period");
1960 if ($per == 0) {
1961 $per = 30;
1962 }
1963
1964 return $per;
1965 }

Referenced by _lookupUserPDPeriod(), ilObjNewsSettingsGUI\editSettings(), ilPDNewsBlockGUI\editSettings(), and ilPDNewsTableGUI\initFilter().

+ Here is the caller graph for this function:

◆ _lookupMediaObjectUsages()

static ilNewsItem::_lookupMediaObjectUsages (   $a_mob_id)
static

Lookup media object usage(s)

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

1918 {
1919 global $DIC;
1920
1921 $ilDB = $DIC->database();
1922
1923 $query = "SELECT * " .
1924 "FROM il_news_item " .
1925 "WHERE " .
1926 " mob_id = " . $ilDB->quote($a_mob_id, "integer");
1927
1928 $usages = array();
1929 $set = $ilDB->query($query);
1930 while ($rec = $ilDB->fetchAssoc($set)) {
1931 $usages[$rec["id"]] = array("type" => "news", "id" => $rec["id"]);
1932 }
1933
1934 return $usages;
1935 }

References $DIC, $ilDB, and $query.

Referenced by ilObjMediaObject\lookupUsages().

+ Here is the caller graph for this function:

◆ _lookupMobId()

static ilNewsItem::_lookupMobId (   $a_news_id)
static

Lookup mob id.

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

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

References $DIC, $ilDB, and $query.

Referenced by ilNewsExporter\getXmlExportHeadDependencies().

+ Here is the caller graph for this function:

◆ _lookupRSSPeriod()

static ilNewsItem::_lookupRSSPeriod ( )
static

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

1994 {
1995 $news_set = new ilSetting("news");
1996 $rss_period = $news_set->get("rss_period");
1997 if ($rss_period == 0) { // default to two weeks
1998 $rss_period = 14;
1999 }
2000 return $rss_period;
2001 }

Referenced by ilObjectFeedWriter\__construct(), ilUserFeedWriter\__construct(), ilObjNewsSettingsGUI\editSettings(), and ilObjMediaCastGUI\initSettingsForm().

+ Here is the caller graph for this function:

◆ _lookupTitle()

static ilNewsItem::_lookupTitle (   $a_news_id)
static

Lookup News Title.

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

1691 {
1692 global $DIC;
1693
1694 $ilDB = $DIC->database();
1695
1696 $query = "SELECT title FROM il_news_item WHERE id = " .
1697 $ilDB->quote($a_news_id, "integer");
1698 $set = $ilDB->query($query);
1699 $rec = $ilDB->fetchAssoc($set);
1700 return $rec["title"];
1701 }

References $DIC, $ilDB, and $query.

◆ _lookupUserPDPeriod()

static ilNewsItem::_lookupUserPDPeriod (   $a_user_id)
static

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

1968 {
1969 $news_set = new ilSetting("news");
1970 $allow_shorter_periods = $news_set->get("allow_shorter_periods");
1971 $allow_longer_periods = $news_set->get("allow_longer_periods");
1972 $default_per = ilNewsItem::_lookupDefaultPDPeriod();
1973
1974 include_once("./Services/Block/classes/class.ilBlockSetting.php");
1976 "pdnews",
1977 "news_pd_period",
1978 $a_user_id,
1979 0
1980 );
1981
1982 // news period information
1983 if ($per <= 0 ||
1984 (!$allow_shorter_periods && ($per < $default_per)) ||
1985 (!$allow_longer_periods && ($per > $default_per))
1986 ) {
1987 $per = $default_per;
1988 }
1989
1990 return $per;
1991 }
static _lookupDefaultPDPeriod()

References ilBlockSetting\_lookup(), and _lookupDefaultPDPeriod().

Referenced by ilPDNewsBlockGUI\editSettings(), ilPDNewsBlockGUI\getHTML(), ilPDNewsBlockGUI\getNewsData(), ilPDNewsTableGUI\initFilter(), and ilPDNewsGUI\view().

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

◆ _lookupVisibility()

static ilNewsItem::_lookupVisibility (   $a_news_id)
static

Lookup News Visibility.

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

1707 {
1708 global $DIC;
1709
1710 $ilDB = $DIC->database();
1711
1712 $query = "SELECT visibility FROM il_news_item WHERE id = " .
1713 $ilDB->quote($a_news_id, "integer");
1714 $set = $ilDB->query($query);
1715 $rec = $ilDB->fetchAssoc($set);
1716
1717 return $rec["visibility"];
1718 }

References $DIC, $ilDB, and $query.

◆ _setRead()

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

Set item read.

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

1510 {
1511 global $DIC;
1512
1513 $ilDB = $DIC->database();
1514 $ilAppEventHandler = $DIC["ilAppEventHandler"];
1515
1516 $ilDB->replace(
1517 "il_news_read",
1518 array(
1519 "user_id" => array("integer", $a_user_id),
1520 "news_id" => array("integer", $a_news_id)
1521 ),
1522 array()
1523 );
1524
1525 /*
1526 $ilDB->manipulate("DELETE FROM il_news_read WHERE ".
1527 "user_id = ".$ilDB->quote($a_user_id, "integer").
1528 " AND news_id = ".$ilDB->quote($a_news_id, "integer"));
1529 $ilDB->manipulate("INSERT INTO il_news_read (user_id, news_id) VALUES (".
1530 $ilDB->quote($a_user_id, "integer").",".
1531 $ilDB->quote($a_news_id, "integer").")");*/
1532
1533 $ilAppEventHandler->raise(
1534 "Services/News",
1535 "readNews",
1536 array("user_id" => $a_user_id, "news_ids" => array($a_news_id))
1537 );
1538 }

References $DIC, and $ilDB.

Referenced by ilNewsForContextBlockGUI\showNews().

+ Here is the caller graph for this function:

◆ _setUnread()

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

Set item unread.

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

1544 {
1545 global $DIC;
1546
1547 $ilDB = $DIC->database();
1548 $ilAppEventHandler = $DIC["ilAppEventHandler"];
1549
1550 $ilDB->manipulate("DELETE FROM il_news_read (user_id, news_id) VALUES (" .
1551 " WHERE user_id = " . $ilDB->quote($a_user_id, "integer") .
1552 " AND news_id = " . $ilDB->quote($a_news_id, "integer"));
1553
1554 $ilAppEventHandler->raise(
1555 "Services/News",
1556 "unreadNews",
1557 array("user_id" => $a_user_id, "news_ids" => array($a_news_id))
1558 );
1559 }

References $DIC, and $ilDB.

◆ aggregateFiles()

ilNewsItem::aggregateFiles (   $news,
  $a_ref_id 
)

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

1095 {
1096 $first_file = "";
1097 $to_del = array();
1098 foreach ($news as $k => $v) {
1099 // aggregate file related news
1100 if ($news[$k]["context_obj_type"] == "file") {
1101 if ($first_file == "") {
1102 $first_file = $k;
1103 } else {
1104 $to_del[] = $k;
1105 }
1106 $news[$first_file]["aggregation"][$k] = $news[$k];
1107 $news[$first_file]["agg_ref_id"] = $a_ref_id;
1108 $news[$first_file]["ref_id"] = $a_ref_id;
1109 }
1110 }
1111
1112 foreach ($to_del as $v) {
1113 unset($news[$v]);
1114 }
1115
1116 return $news;
1117 }

Referenced by getAggregatedChildNewsData(), and getAggregatedNewsData().

+ Here is the caller graph for this function:

◆ aggregateForums()

ilNewsItem::aggregateForums (   $news,
  $a_group_posting_sequence = false 
)

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

1052 {
1053 $to_del = array();
1054 $forums = array();
1055
1056 // aggregate
1057 foreach ($news as $k => $v) {
1058 if ($a_group_posting_sequence && $last_aggregation_forum > 0 &&
1059 $last_aggregation_forum != $news[$k]["context_obj_id"]) {
1060 $forums[$last_aggregation_forum] = "";
1061 }
1062
1063 if ($news[$k]["context_obj_type"] == "frm") {
1064 if ($forums[$news[$k]["context_obj_id"]] == "") {
1065 // $forums[forum_id] = news_id;
1066 $forums[$news[$k]["context_obj_id"]] = $k;
1067 $last_aggregation_forum = $news[$k]["context_obj_id"];
1068 } else {
1069 $to_del[] = $k;
1070 }
1071
1072 $news[$k]["no_context_title"] = true;
1073
1074 // aggregate every forum into it's "k" news
1075 $news[$forums[$news[$k]["context_obj_id"]]]["aggregation"][$k]
1076 = $news[$k];
1077 $news[$k]["agg_ref_id"]
1078 = $news[$k]["ref_id"];
1079 $news[$k]["content"] = "";
1080 $news[$k]["content_long"] = "";
1081 }
1082 }
1083
1084 // delete double entries
1085 foreach ($to_del as $k) {
1086 unset($news[$k]);
1087 }
1088 //var_dump($news[14]["aggregation"]);
1089
1090
1091 return $news;
1092 }

Referenced by getNewsForRefId().

+ Here is the caller graph for this function:

◆ checkNewsExistsForGroupCourse()

ilNewsItem::checkNewsExistsForGroupCourse (   $a_ref_id,
  $a_time_period = 1 
)
Parameters
int$a_ref_id
int$a_time_periodhours
Returns
array news item ids

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

1360 {
1362 $ilDB = $this->db;
1363
1364 $all = array();
1365
1366 if (!$tree->isDeleted($a_ref_id)) {
1367 // parse repository branch of group
1368 $nodes = array();
1369 $node = $tree->getNodeData($a_ref_id);
1370 foreach ($tree->getSubTree($node) as $child) {
1371 if ($child["type"] != "rolf") {
1372 $nodes[$child["obj_id"]] = $child["type"];
1373 }
1374 }
1375
1376 $limit_ts = self::handleTimePeriod($a_time_period);
1377
1378 // are there any news items for relevant objects and?
1379 $query = $ilDB->query("SELECT id,context_obj_id,context_obj_type" .
1380 " FROM il_news_item" .
1381 " WHERE " . $ilDB->in("context_obj_id", array_keys($nodes), false, "integer") .
1382 " AND creation_date >= " . $ilDB->quote($limit_ts, "timestamp"));
1383 while ($rec = $ilDB->fetchAssoc($query)) {
1384 if ($nodes[$rec["context_obj_id"]] == $rec["context_obj_type"]) {
1385 $all[] = $rec["id"];
1386 }
1387 }
1388 }
1389
1390 return $all;
1391 }
static handleTimePeriod($a_time_period)
Convert time period for DB-queries.

References $db, $ilDB, $query, $tree, and handleTimePeriod().

+ Here is the call graph for this function:

◆ create()

ilNewsItem::create ( )

Create.

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

617 {
619
620 // insert new record into db
621 $this->setId($ilDB->nextId("il_news_item"));
622 $ilDB->insert("il_news_item", array(
623 "id" => array("integer", $this->getId()),
624 "title" => array("text", $this->getTitle()),
625 "content" => array("clob", $this->getContent()),
626 "content_html" => array("integer", (int) $this->getContentHtml()),
627 "context_obj_id" => array("integer", (int) $this->getContextObjId()),
628 "context_obj_type" => array("text", $this->getContextObjType()),
629 "context_sub_obj_id" => array("integer", (int) $this->getContextSubObjId()),
630 "context_sub_obj_type" => array("text", $this->getContextSubObjType()),
631 "content_type" => array("text", $this->getContentType()),
632 "creation_date" => array("timestamp", ilUtil::now()),
633 "update_date" => array("timestamp", ilUtil::now()),
634 "user_id" => array("integer", $this->getUserId()),
635 "update_user_id" => array("integer", (int) $this->getUpdateUserId()),
636 "visibility" => array("text", $this->getVisibility()),
637 "content_long" => array("clob", $this->getContentLong()),
638 "priority" => array("integer", $this->getPriority()),
639 "content_is_lang_var" => array("integer", $this->getContentIsLangVar()),
640 "content_text_is_lang_var" => array("integer", (int) $this->getContentTextIsLangVar()),
641 "mob_id" => array("integer", $this->getMobId()),
642 "playtime" => array("text", $this->getPlaytime())
643 ));
644
645
646 $news_set = new ilSetting("news");
647 $max_items = $news_set->get("max_items");
648 if ($max_items <= 0) {
649 $max_items = 50;
650 }
651
652 // limit number of news
653 if ($this->getLimitation()) {
654 // Determine how many rows should be deleted
655 $query = "SELECT count(*) cnt " .
656 "FROM il_news_item " .
657 "WHERE " .
658 "context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
659 " AND context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text") .
660 " AND context_sub_obj_id = " . $ilDB->quote($this->getContextSubObjId(), "integer") .
661 " AND " . $ilDB->equals("context_sub_obj_type", $this->getContextSubObjType(), "text", true) . " ";
662
663 $set = $ilDB->query($query);
664 $rec = $ilDB->fetchAssoc($set);
665
666 // if we have more records than allowed, delete them
667 if (($rec["cnt"] > $max_items) && $this->getContextObjId() > 0) {
668 $query = "SELECT * " .
669 "FROM il_news_item " .
670 "WHERE " .
671 "context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
672 " AND context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text") .
673 " AND context_sub_obj_id = " . $ilDB->quote($this->getContextSubObjId(), "integer") .
674 " AND " . $ilDB->equals("context_sub_obj_type", $this->getContextSubObjType(), "text", true) .
675 " ORDER BY creation_date ASC";
676
677 $ilDB->setLimit($rec["cnt"] - $max_items);
678 $del_set = $ilDB->query($query);
679 while ($del_item = $ilDB->fetchAssoc($del_set)) {
680 $del_news = new ilNewsItem($del_item["id"]);
681 $del_news->delete();
682 }
683 }
684 }
685 }
getContentIsLangVar()
Get ContentIsLangVar.
getPlaytime()
Get Playtime.
getContextSubObjId()
Get ContextSubObjId.
getContextSubObjType()
Get ContextSubObjType.
getMobId()
Get MobId.
getVisibility()
Get Visibility.
getTitle()
Get Title.
getContentType()
Get ContentType.
getLimitation()
Get Limitation for number of items.
getContent()
Get Content.
getContentLong()
Get ContentLong.
getPriority()
Get Priority.
getContextObjId()
Get ContextObjId.
getUserId()
Get UserId.
getContentTextIsLangVar()
Get content text ist lang var.
getContextObjType()
Get ContextObjType.
getUpdateUserId()
Get update user id.
getContentHtml()
Get content as html.
static now()
Return current timestamp in Y-m-d H:i:s format.

References $db, $ilDB, $query, getContent(), getContentHtml(), getContentIsLangVar(), getContentLong(), getContentTextIsLangVar(), getContentType(), getContextObjId(), getContextObjType(), getContextSubObjId(), getContextSubObjType(), getId(), getLimitation(), getMobId(), getPlaytime(), getPriority(), getTitle(), getUpdateUserId(), getUserId(), getVisibility(), ilUtil\now(), and setId().

+ Here is the call graph for this function:

◆ delete()

ilNewsItem::delete ( )

Delete news item.

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

1627 {
1628 $ilDB = $this->db;
1629
1630 // delete il_news_read entries
1631 $ilDB->manipulate("DELETE FROM il_news_read " .
1632 " WHERE news_id = " . $ilDB->quote($this->getId(), "integer"));
1633
1634 // delete multimedia object
1635 $mob = $this->getMobId();
1636
1637 // delete
1638 $query = "DELETE FROM il_news_item" .
1639 " WHERE id = " . $ilDB->quote($this->getId(), "integer");
1640 $ilDB->manipulate($query);
1641
1642 // delete mob after news, to have a "mob usage" of 0
1643 if ($mob > 0 and ilObject::_exists($mob)) {
1644 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1645 $mob = new ilObjMediaObject($mob);
1646 $mob->delete();
1647 }
1648 }
Class ilObjMediaObject.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public

References $db, $ilDB, $query, ilObject\_exists(), getId(), and getMobId().

+ Here is the call graph for this function:

◆ deleteNewsOfContext()

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

Delete all news of a context.

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

1659 {
1660 global $DIC;
1661
1662 $ilDB = $DIC->database();
1663
1664 if ($a_context_obj_id == 0 || $a_context_obj_type == "") {
1665 return [];
1666 }
1667
1668 if ($a_context_sub_obj_id > 0) {
1669 $and = " AND context_sub_obj_id = " . $ilDB->quote($a_context_sub_obj_id, "integer") .
1670 " AND context_sub_obj_type = " . $ilDB->quote($a_context_sub_obj_type, "text");
1671 }
1672
1673 // get news records
1674 $query = "SELECT * FROM il_news_item" .
1675 " WHERE context_obj_id = " . $ilDB->quote($a_context_obj_id, "integer") .
1676 " AND context_obj_type = " . $ilDB->quote($a_context_obj_type, "text") .
1677 $and;
1678
1679 $news_set = $ilDB->query($query);
1680
1681 while ($news = $ilDB->fetchAssoc($news_set)) {
1682 $news_obj = new ilNewsItem($news["id"]);
1683 $news_obj->delete();
1684 }
1685 }

References $DIC, $ilDB, and $query.

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

+ Here is the caller graph for this function:

◆ deliverMobFile()

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

Deliver mob file.

Parameters

return

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

2019 {
2020 $mob = $this->getMobId();
2021 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2022 $mob = new ilObjMediaObject($mob);
2023 $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
2024
2025 // check purpose
2026 if (!$mob->hasPurposeItem($a_purpose)) {
2027 return false;
2028 }
2029
2030 $m_item = $mob->getMediaItem($a_purpose);
2031 if ($m_item->getLocationType() != "Reference") {
2032 $file = $mob_dir . "/" . $m_item->getLocation();
2033 if (file_exists($file) && is_file($file)) {
2034 if ($a_increase_download_cnt) {
2035 $this->increaseDownloadCounter();
2036 }
2037 ilUtil::deliverFile($file, $m_item->getLocation(), "", false, false, false);
2038 return true;
2039 } else {
2040 ilUtil::sendFailure("File not found!", true);
2041 return false;
2042 }
2043 } else {
2044 if ($a_increase_download_cnt) {
2045 $this->increaseDownloadCounter();
2046 }
2047 ilUtil::redirect($m_item->getLocation());
2048 }
2049 }
increaseDownloadCounter()
Increase download counter.
static _getDirectory($a_mob_id)
get directory for files of media object (static)
static redirect($a_script)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file

References $file, ilObjMediaObject\_getDirectory(), ilUtil\deliverFile(), getMobId(), increaseDownloadCounter(), ilUtil\redirect(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ determineNewsContent()

static ilNewsItem::determineNewsContent (   $a_context_obj_type,
  $a_content,
  $a_is_lang_var 
)
static

Determine new content.

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

1831 {
1832 global $DIC;
1833
1834 $lng = $DIC->language();
1835
1836 if ($a_is_lang_var) {
1837 $lng->loadLanguageModule($a_context_obj_type);
1838 return $lng->txt($a_content);
1839 } else {
1840 return $a_content;
1841 }
1842 }
$a_content
Definition: workflow.php:93

References $a_content, $DIC, and $lng.

Referenced by ilObjectFeedWriter\__construct(), ilUserFeedWriter\__construct(), ilPDNewsTableGUI\fillRow(), and ilMembershipCronNotifications\parseNewsItem().

+ Here is the caller graph for this function:

◆ determineNewsTitle()

static ilNewsItem::determineNewsTitle (   $a_context_obj_type,
  $a_title,
  $a_content_is_lang_var,
  $a_agg_ref_id = 0,
  $a_aggregation = "" 
)
static

Determine title for news item entry.

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

1777 {
1778 global $DIC;
1779
1780 $lng = $DIC->language();
1781
1782 if ($a_agg_ref_id > 0) {
1783 $cnt = count($a_aggregation);
1784
1785 // forums
1786 if ($a_context_obj_type == "frm") {
1787 if ($cnt > 1) {
1788 return sprintf($lng->txt("news_x_postings"), $cnt);
1789 } else {
1790 return $lng->txt("news_1_postings");
1791 }
1792 } else { // files
1793 $up_cnt = $cr_cnt = 0;
1794 foreach ($a_aggregation as $item) {
1795 if ($item["title"] == "file_updated") {
1796 $up_cnt++;
1797 } else {
1798 $cr_cnt++;
1799 }
1800 }
1801 $sep = "";
1802 if ($cr_cnt == 1) {
1803 $tit = $lng->txt("news_1_file_created");
1804 $sep = "<br />";
1805 } elseif ($cr_cnt > 1) {
1806 $tit = sprintf($lng->txt("news_x_files_created"), $cr_cnt);
1807 $sep = "<br />";
1808 }
1809 if ($up_cnt == 1) {
1810 $tit .= $sep . $lng->txt("news_1_file_updated");
1811 } elseif ($up_cnt > 1) {
1812 $tit .= $sep . sprintf($lng->txt("news_x_files_updated"), $up_cnt);
1813 }
1814 return $tit;
1815 }
1816 } else {
1817 if ($a_content_is_lang_var) {
1818 return $lng->txt($a_title);
1819 } else {
1820 return $a_title;
1821 }
1822 }
1823
1824 return "";
1825 }
sprintf('%.4f', $callTime)

References $DIC, $lng, and sprintf.

Referenced by ilObjectFeedWriter\__construct(), ilUserFeedWriter\__construct(), ilNewsForContextBlockGUI\fillRow(), ilMembershipCronNotifications\parseNewsItem(), and ilNewsForContextBlockGUI\showNews().

+ Here is the caller graph for this function:

◆ filterObjIdsPerNews()

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

Checks whether news are available for.

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

1740 {
1741 global $DIC;
1742
1743 $ilDB = $DIC->database();
1744
1745 $and = "";
1746 if ($a_time_period > 0) {
1747 $limit_ts = self::handleTimePeriod($a_time_period);
1748 $and = " AND creation_date >= " . $ilDB->quote($limit_ts, "timestamp") . " ";
1749 }
1750
1751 if ($a_starting_date != "") {
1752 $and.= " AND creation_date >= " . $ilDB->quote($a_starting_date, "timestamp");
1753 }
1754
1755 $query = "SELECT DISTINCT(context_obj_id) AS obj_id FROM il_news_item" .
1756 " WHERE " . $ilDB->in("context_obj_id", $a_obj_ids, false, "integer") . " " . $and;
1757 //" WHERE context_obj_id IN (".implode(ilUtil::quoteArray($a_obj_ids),",").")".$and;
1758
1759 $set = $ilDB->query($query);
1760 $objs = array();
1761 while ($rec = $ilDB->fetchAssoc($set)) {
1762 $objs[] = $rec["obj_id"];
1763 }
1764
1765 return $objs;
1766 }

References $DIC, $ilDB, $query, and handleTimePeriod().

Referenced by getAggregatedChildNewsData(), getAggregatedNewsData(), and ilPDNewsGUI\view().

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

◆ getAggregatedChildNewsData()

ilNewsItem::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.

for categories)

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

1130 {
1132 $ilAccess = $this->access;
1133
1134 // get news of parent object
1135 $data = $this->getNewsForRefId(
1136 $a_ref_id,
1137 $a_only_public,
1138 true,
1139 $a_time_period,
1140 true,
1141 false,
1142 false,
1143 $a_no_auto_generated
1144 );
1145 foreach ($data as $k => $v) {
1146 $data[$k]["ref_id"] = $a_ref_id;
1147 }
1148
1149 // get childs
1150 $nodes = $tree->getChilds($a_ref_id);
1151
1152 // no check, for which of the objects any news are available
1153 $obj_ids = array();
1154 foreach ($nodes as $node) {
1155 $obj_ids[] = $node["obj_id"];
1156 }
1157 $news_obj_ids = ilNewsItem::filterObjIdsPerNews($obj_ids, $a_time_period, $a_starting_date);
1158 //$news_obj_ids = $obj_ids;
1159
1160 // get news for all subtree nodes
1161 $contexts = array();
1162 foreach ($nodes as $node) {
1163 // only go on, if news are available
1164 if (!in_array($node["obj_id"], $news_obj_ids)) {
1165 continue;
1166 }
1167
1168 if (!$a_only_public && !$ilAccess->checkAccess("read", "", $node["child"])) {
1169 continue;
1170 }
1171 $ref_id[$node["obj_id"]] = $node["child"];
1172 $contexts[] = array("obj_id" => $node["obj_id"],
1173 "obj_type" => $node["type"]);
1174 }
1175
1176 $news = $this->queryNewsForMultipleContexts(
1177 $contexts,
1178 $a_only_public,
1179 $a_time_period,
1180 $a_starting_date,
1181 $a_no_auto_generated
1182 );
1183 foreach ($news as $k => $v) {
1184 $news[$k]["ref_id"] = $ref_id[$v["context_obj_id"]];
1185 }
1187
1188 // sort and return
1189 $data = ilUtil::sortArray($data, "creation_date", "desc", false, true);
1190
1191 if (!$a_prevent_aggregation) {
1192 $data = $this->aggregateFiles($data, $a_ref_id);
1193 }
1194
1195 return $data;
1196 }
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 filterObjIdsPerNews($a_obj_ids, $a_time_period=0, $a_starting_date="", $a_ending_date='', $ignore_period=false)
Checks whether news are available for.
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.
aggregateFiles($news, $a_ref_id)

References $access, $data, $tree, aggregateFiles(), filterObjIdsPerNews(), getNewsForRefId(), mergeNews(), queryNewsForMultipleContexts(), and ilUtil\sortArray().

Referenced by getNewsForRefId().

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

◆ getAggregatedNewsData()

ilNewsItem::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.

for courses, groups)

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

958 {
960 $ilAccess = $this->access;
961 $ilObjDataCache = $this->obj_data_cache;
962
963 // get news of parent object
964
965 $data = array();
966
967 // get subtree
968 $cur_node = $tree->getNodeData($a_ref_id);
969
970 // do not check for lft (materialized path)
971 if ($cur_node) {
972 $nodes = (array) $tree->getSubTree($cur_node, true);
973 } else {
974 $nodes = array();
975 }
976
977 // preload object data cache
978 $ref_ids = array();
979 $obj_ids = array();
980 foreach ($nodes as $node) {
981 $ref_ids[] = $node["child"];
982 $obj_ids[] = $node["obj_id"];
983 }
984
985 $ilObjDataCache->preloadReferenceCache($ref_ids);
986 if (!$a_only_public) {
987 include_once "Services/Object/classes/class.ilObjectActivation.php";
989 }
990
991 // no check, for which of the objects any news are available
992 $news_obj_ids = ilNewsItem::filterObjIdsPerNews($obj_ids, $a_time_period, $a_starting_date);
993 //$news_obj_ids = $obj_ids;
994
995 // get news for all subtree nodes
996 $contexts = array();
997 foreach ($nodes as $node) {
998 // only go on, if news are available
999 if (!in_array($node["obj_id"], $news_obj_ids)) {
1000 continue;
1001 }
1002
1003 if (!$a_only_public) {
1004 if (!$a_user_id) {
1005 $acc = $ilAccess->checkAccess("read", "", $node["child"]);
1006 } else {
1007 $acc = $ilAccess->checkAccessOfUser(
1008 $a_user_id,
1009 "read",
1010 "",
1011 $node["child"]
1012 );
1013 }
1014 if (!$acc) {
1015 continue;
1016 }
1017 }
1018
1019 $ref_id[$node["obj_id"]] = $node["child"];
1020 $contexts[] = array("obj_id" => $node["obj_id"],
1021 "obj_type" => $node["type"]);
1022 }
1023
1024 // sort and return
1025 $news = $this->queryNewsForMultipleContexts(
1026 $contexts,
1027 $a_only_public,
1028 $a_time_period,
1029 $a_starting_date,
1030 $a_no_auto_generated,
1031 $a_user_id,
1032 $a_limit,
1033 $a_exclude
1034 );
1035
1036 $to_del = array();
1037 foreach ($news as $k => $v) {
1038 $news[$k]["ref_id"] = $ref_id[$v["context_obj_id"]];
1039 }
1040
1042 $data = ilUtil::sortArray($data, "creation_date", "desc", false, true);
1043
1044 if (!$a_prevent_aggregation) {
1045 $data = $this->aggregateFiles($data, $a_ref_id);
1046 }
1047
1048 return $data;
1049 }
static preloadData(array $a_ref_ids)
Preload data to internal cache.

References $access, $data, $obj_data_cache, $tree, aggregateFiles(), filterObjIdsPerNews(), mergeNews(), ilObjectActivation\preloadData(), queryNewsForMultipleContexts(), and ilUtil\sortArray().

Referenced by getNewsForRefId().

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

◆ getContent()

ilNewsItem::getContent ( )

Get Content.

Returns
string Content of news.

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

173 {
174 return $this->content;
175 }

References $content.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getContentHtml()

ilNewsItem::getContentHtml ( )

Get content as html.

Returns
bool

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

574 {
575 return $this->content_html;
576 }

References $content_html.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getContentIsLangVar()

ilNewsItem::getContentIsLangVar ( )

Get ContentIsLangVar.

Returns
boolean

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

433 {
435 }

References $content_is_lang_var.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getContentLong()

ilNewsItem::getContentLong ( )

Get ContentLong.

Returns
string Long content of news

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

393 {
394 return $this->content_long;
395 }

References $content_long.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getContentTextIsLangVar()

ilNewsItem::getContentTextIsLangVar ( )

Get content text ist lang var.

Returns
boolean

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

514 {
515 return $this->content_text_is_lang_var;
516 }

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getContentType()

ilNewsItem::getContentType ( )

Get ContentType.

Returns
string Content type.

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

273 {
274 return $this->content_type;
275 }

References $content_type.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getContextObjId()

ilNewsItem::getContextObjId ( )

Get ContextObjId.

Returns
int

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

193 {
195 }

References $context_obj_id.

Referenced by create(), queryNewsForContext(), and update().

+ Here is the caller graph for this function:

◆ getContextObjType()

ilNewsItem::getContextObjType ( )

Get ContextObjType.

Returns
int

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

213 {
215 }

References $context_obj_type.

Referenced by create(), queryNewsForContext(), and update().

+ Here is the caller graph for this function:

◆ getContextSubObjId()

ilNewsItem::getContextSubObjId ( )

Get ContextSubObjId.

Returns
int

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

233 {
235 }

References $context_sub_obj_id.

Referenced by create(), queryNewsForContext(), and update().

+ Here is the caller graph for this function:

◆ getContextSubObjType()

ilNewsItem::getContextSubObjType ( )

Get ContextSubObjType.

Returns
int

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

253 {
255 }

References $context_sub_obj_type.

Referenced by create(), queryNewsForContext(), and update().

+ Here is the caller graph for this function:

◆ getCreationDate()

ilNewsItem::getCreationDate ( )

Get CreationDate.

Returns
string Date of creation.

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

293 {
295 }

References $creation_date.

◆ getFirstNewsIdForContext()

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

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

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

1854 {
1855 global $DIC;
1856
1857 $ilDB = $DIC->database();
1858
1859 // Determine how many rows should be deleted
1860 $query = "SELECT * " .
1861 "FROM il_news_item " .
1862 "WHERE " .
1863 "context_obj_id = " . $ilDB->quote($a_context_obj_id, "integer") .
1864 " AND context_obj_type = " . $ilDB->quote($a_context_obj_type, "text") .
1865 " AND context_sub_obj_id = " . $ilDB->quote($a_context_sub_obj_id, "integer") .
1866 " AND " . $ilDB->equals("context_sub_obj_type", $a_context_sub_obj_type, "text", true);
1867
1868 $set = $ilDB->query($query);
1869 $rec = $ilDB->fetchAssoc($set);
1870
1871 return $rec["id"];
1872 }

References $DIC, $ilDB, and $query.

Referenced by ilForum\deletePost(), ilForumTopic\movePosts(), ilForum\postCensorship(), and ilObjTest\saveToDb().

+ Here is the caller graph for this function:

◆ getId()

ilNewsItem::getId ( )

Get Id.

Returns
int

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

133 {
134 return $this->id;
135 }

References $id.

Referenced by create(), delete(), read(), and update().

+ Here is the caller graph for this function:

◆ getLastNewsIdForContext()

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

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

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

1883 {
1884 global $DIC;
1885
1886 $ilDB = $DIC->database();
1887
1888 // Determine how many rows should be deleted
1889 $query = "SELECT id, update_date " .
1890 "FROM il_news_item " .
1891 "WHERE " .
1892 "context_obj_id = " . $ilDB->quote($a_context_obj_id, "integer") .
1893 " AND context_obj_type = " . $ilDB->quote($a_context_obj_type, "text") .
1894 " AND context_sub_obj_id = " . $ilDB->quote($a_context_sub_obj_id, "integer") .
1895 " AND " . $ilDB->equals("context_sub_obj_type", $a_context_sub_obj_type, "text", true) .
1896 " ORDER BY update_date DESC";
1897
1898 $ilDB->setLimit(1);
1899 $set = $ilDB->query($query);
1900 $rec = $ilDB->fetchAssoc($set);
1901
1902 $id = (int) $rec["id"];
1903 if ($a_only_today) {
1904 $now = ilUtil::now();
1905 if (substr($now, 0, 10) != substr($rec["update_date"], 0, 10)) {
1906 $id = 0;
1907 }
1908 }
1909
1910 return $id;
1911 }

References $DIC, $id, $ilDB, $query, and ilUtil\now().

Referenced by ilBlogPosting\handleNews(), and ilWikiPage\updateNews().

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

◆ getLimitation()

ilNewsItem::getLimitation ( )

Get Limitation for number of items.

Returns
boolean Limitation for number of items

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

494 {
495 return $this->limitation;
496 }

References $limitation.

Referenced by create().

+ Here is the caller graph for this function:

◆ getMobDownloadCounter()

ilNewsItem::getMobDownloadCounter ( )

Get mob download counter.

Returns
int counter

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

554 {
555 return $this->mob_cnt_download;
556 }

Referenced by increaseDownloadCounter(), and update().

+ Here is the caller graph for this function:

◆ getMobId()

ilNewsItem::getMobId ( )

Get MobId.

Returns
int Media Object ID (if news includes attachement)

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

453 {
454 return $this->mob_id;
455 }

References $mob_id.

Referenced by create(), delete(), deliverMobFile(), and update().

+ Here is the caller graph for this function:

◆ getMobPlayCounter()

ilNewsItem::getMobPlayCounter ( )

Get mob play counter.

Returns
int counter

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

534 {
535 return $this->mob_cnt_play;
536 }

Referenced by increasePlayCounter(), and update().

+ Here is the caller graph for this function:

◆ getNewsForRefId()

ilNewsItem::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.

Parameters
int$a_ref_id
bool$a_only_public
bool$a_stopnesting
int$a_time_period
bool$a_prevent_aggregation
bool$a_forum_group_sequences
bool$a_no_auto_generated
bool$a_ignore_date_filter
null$a_user_id
int$a_limitcurrently only supported for groups and courses
int[]$a_excludedcurrently only supported for groups and courses (news ids)
Returns
array|mixed

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

860 {
861 $obj_id = ilObject::_lookupObjId($a_ref_id);
862 $obj_type = ilObject::_lookupType($obj_id);
863
864 // get starting date
865 $starting_date = "";
866 if ($obj_type == "grp" || $obj_type == "crs" || $obj_type == "cat") {
867 include_once("./Services/Block/classes/class.ilBlockSetting.php");
868 $hide_news_per_date = ilBlockSetting::_lookup(
869 "news",
870 "hide_news_per_date",
871 0,
872 $obj_id
873 );
874 if ($hide_news_per_date && !$a_ignore_date_filter) {
875 $starting_date = ilBlockSetting::_lookup(
876 "news",
877 "hide_news_date",
878 0,
879 $obj_id
880 );
881 }
882 }
883
884 if ($obj_type == "cat" && !$a_stopnesting) {
885 $news = $this->getAggregatedChildNewsData(
886 $a_ref_id,
887 $a_only_public,
888 $a_time_period,
889 $a_prevent_aggregation,
890 $starting_date,
891 $a_no_auto_generated
892 );
893 } elseif (($obj_type == "grp" || $obj_type == "crs") &&
894 !$a_stopnesting) {
895 $news = $this->getAggregatedNewsData(
896 $a_ref_id,
897 $a_only_public,
898 $a_time_period,
899 $a_prevent_aggregation,
900 $starting_date,
901 $a_no_auto_generated,
902 $a_user_id,
903 $a_limit,
904 $a_excluded
905 );
906 } else {
907 $news_item = new ilNewsItem();
908 $news_item->setContextObjId($obj_id);
909 $news_item->setContextObjType($obj_type);
910 $news = $news_item->queryNewsForContext(
911 $a_only_public,
912 $a_time_period,
913 $starting_date,
914 $a_no_auto_generated
915 );
916 $unset = array();
917 foreach ($news as $k => $v) {
918 if (!$a_only_public || $v["visibility"] == NEWS_PUBLIC ||
919 ($v["priority"] == 0 &&
921 "news",
922 "public_notifications",
923 0,
924 $obj_id
925 ))) {
926 $news[$k]["ref_id"] = $a_ref_id;
927 } else {
928 $unset[] = $k;
929 }
930 }
931 foreach ($unset as $un) {
932 unset($news[$un]);
933 }
934 }
935
936 if (!$a_prevent_aggregation) {
937 $news = $this->aggregateForums($news);
938 } elseif ($a_forum_group_sequences) {
939 $news = $this->aggregateForums($news, true);
940 }
941
942 return $news;
943 }
const NEWS_PUBLIC
getAggregatedNewsData( $a_ref_id, $a_only_public=false, $a_time_period=0, $a_prevent_aggregation=false, $a_starting_date="", $a_no_auto_generated=false, $a_user_id=null, $a_limit=0, $a_exclude=array())
Get news aggregation (e.g.
aggregateForums($news, $a_group_posting_sequence=false)
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.

References ilBlockSetting\_lookup(), ilObject\_lookupObjId(), ilObject\_lookupType(), aggregateForums(), getAggregatedChildNewsData(), getAggregatedNewsData(), and NEWS_PUBLIC.

Referenced by getAggregatedChildNewsData().

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

◆ getPlaytime()

ilNewsItem::getPlaytime ( )

Get Playtime.

Returns
string Play Time, hh:mm:ss (of attached media file)

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

473 {
474 return $this->playtime;
475 }

References $playtime.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getPriority()

ilNewsItem::getPriority ( )

Get Priority.

Returns
int News Priority

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

413 {
414 return $this->priority;
415 }

References $priority.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getPrivateFeedId()

static ilNewsItem::getPrivateFeedId ( )
static

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

2008 {
2010 }
static $privFeedId

References $privFeedId.

Referenced by _getNewsItemsOfUser(), queryNewsForContext(), and queryNewsForMultipleContexts().

+ Here is the caller graph for this function:

◆ getTitle()

ilNewsItem::getTitle ( )

Get Title.

Returns
string Title of news item.

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

153 {
154 return $this->title;
155 }

References $title.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getUpdateDate()

ilNewsItem::getUpdateDate ( )

Get UpdateDate.

Returns
string Date of last update.

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

313 {
314 return $this->update_date;
315 }

References $update_date.

◆ getUpdateUserId()

ilNewsItem::getUpdateUserId ( )

Get update user id.

Returns
int update user id

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

353 {
355 }

References $update_user_id.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getUserId()

ilNewsItem::getUserId ( )

Get UserId.

Returns
int User Id of last update.

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

333 {
334 return $this->user_id;
335 }

References $user_id.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getVisibility()

ilNewsItem::getVisibility ( )

Get Visibility.

Returns
string Access level of news.

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

373 {
374 return $this->visibility;
375 }

References $visibility.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ handleTimePeriod()

static ilNewsItem::handleTimePeriod (   $a_time_period)
staticprotected

Convert time period for DB-queries.

Parameters
mixed$a_time_period
Returns
string

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

1216 {
1217 // time period is number of days
1218 if (is_numeric($a_time_period)) {
1219 if ($a_time_period > 0) {
1220 return date('Y-m-d H:i:s', time() - ($a_time_period * 24 * 60 * 60));
1221 }
1222 }
1223 // time period is datetime
1224 elseif (preg_match("/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/", $a_time_period)) {
1225 return $a_time_period;
1226 }
1227 // :TODO: what to return?
1228 }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())

References date.

Referenced by checkNewsExistsForGroupCourse(), filterObjIdsPerNews(), queryNewsForContext(), and queryNewsForMultipleContexts().

+ Here is the caller graph for this function:

◆ increaseDownloadCounter()

ilNewsItem::increaseDownloadCounter ( )

Increase download counter.

Parameters

return

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

2058 {
2059 $ilDB = $this->db;
2060
2061 $cnt = $this->getMobDownloadCounter();
2062 $cnt++;
2063 $this->setMobDownloadCounter($cnt);
2064 $ilDB->manipulate(
2065 "UPDATE il_news_item SET " .
2066 " mob_cnt_download = " . $ilDB->quote($cnt, "integer") .
2067 " WHERE id = " . $ilDB->quote($this->getId(), "integer")
2068 );
2069 }
getMobDownloadCounter()
Get mob download counter.
setMobDownloadCounter($a_val)
Set mob download counter.

References $db, $ilDB, getMobDownloadCounter(), and setMobDownloadCounter().

Referenced by deliverMobFile().

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

◆ increasePlayCounter()

ilNewsItem::increasePlayCounter ( )

Increase play counter.

Parameters

return

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

2078 {
2079 $ilDB = $this->db;
2080
2081 $cnt = $this->getMobPlayCounter();
2082 $cnt++;
2083 $this->setMobPlayCounter($cnt);
2084 $ilDB->manipulate(
2085 "UPDATE il_news_item SET " .
2086 " mob_cnt_play = " . $ilDB->quote($cnt, "integer") .
2087 " WHERE id = " . $ilDB->quote($this->getId(), "integer")
2088 );
2089 }
setMobPlayCounter($a_val)
Set mob play counter.
getMobPlayCounter()
Get mob play counter.

References $db, $ilDB, getMobPlayCounter(), and setMobPlayCounter().

+ Here is the call graph for this function:

◆ mergeNews()

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

Merges two sets of news.

Parameters
array$n1Array of news
array$n2Array of news
Returns
array Array of news

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

1570 {
1571 foreach ($n2 as $id => $news) {
1572 $n1[$id] = $news;
1573 }
1574
1575 return $n1;
1576 }

References $id.

Referenced by _getNewsItemsOfUser(), getAggregatedChildNewsData(), and getAggregatedNewsData().

+ Here is the caller graph for this function:

◆ prepareNewsDataFromCache()

static ilNewsItem::prepareNewsDataFromCache (   $a_cres)
static

Prepare news data from cache.

Parameters
string$a_crescache string
Returns
array news array

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

2098 {
2099 global $DIC;
2100
2101 $ilDB = $DIC->database();
2102
2103 $data = $a_cres;
2104 $news_ids = array_keys($data);
2105 $set = $ilDB->query("SELECT id FROM il_news_item " .
2106 " WHERE " . $ilDB->in("id", $news_ids, false, "integer"));
2107 $existing_ids = array();
2108 while ($rec = $ilDB->fetchAssoc($set)) {
2109 $existing_ids[] = $rec["id"];
2110 }
2111 //var_dump($existing_ids);
2112 $existing_news = array();
2113 foreach ($data as $k => $v) {
2114 if (in_array($k, $existing_ids)) {
2115 $existing_news[$k] = $v;
2116 }
2117 }
2118
2119 //var_dump($data);
2120 //var_dump($existing_news);
2121
2122 return $existing_news;
2123 }

References $data, $DIC, and $ilDB.

Referenced by ilNewsForContextBlockGUI\__construct(), and ilPDNewsBlockGUI\__construct().

+ Here is the caller graph for this function:

◆ queryNewsForContext()

ilNewsItem::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.

Parameters
booleanquery for outgoing rss feed
inttime period in seconds
stringstartind date
booleando not include auto generated news items

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

1245 {
1246 $ilDB = $this->db;
1248 $lng = $this->lng;
1249
1250 $and = "";
1251 if ($a_time_period > 0) {
1252 $limit_ts = self::handleTimePeriod($a_time_period);
1253 $and = " AND creation_date >= " . $ilDB->quote($limit_ts, "timestamp") . " ";
1254 }
1255
1256 if ($a_starting_date != "") {
1257 $and.= " AND creation_date > " . $ilDB->quote($a_starting_date, "timestamp") . " ";
1258 }
1259
1260 if ($a_no_auto_generated) {
1261 $and.= " AND priority = 1 AND content_type = " . $ilDB->quote("text", "text") . " ";
1262 }
1263
1264 // this is changed with 4.1 (news table for lm pages)
1265 if ($this->getContextSubObjId() > 0) {
1266 $and.= " AND context_sub_obj_id = " . $ilDB->quote($this->getContextSubObjId(), "integer") .
1267 " AND context_sub_obj_type = " . $ilDB->quote($this->getContextSubObjType(), "text");
1268 }
1269
1270 $ordering = ($a_oldest_first)
1271 ? " creation_date ASC, id ASC "
1272 : " creation_date DESC, id DESC ";
1273
1274 if ($a_for_rss_use && ilNewsItem::getPrivateFeedId() == false) {
1275 $query = "SELECT * " .
1276 "FROM il_news_item " .
1277 " WHERE " .
1278 "context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
1279 " AND context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text") .
1280 $and .
1281 " ORDER BY " . $ordering;
1282 } elseif (ilNewsItem::getPrivateFeedId() != false) {
1283 $query = "SELECT il_news_item.* " .
1284 ", il_news_read.user_id user_read " .
1285 "FROM il_news_item LEFT JOIN il_news_read " .
1286 "ON il_news_item.id = il_news_read.news_id AND " .
1287 " il_news_read.user_id = " . $ilDB->quote(ilNewsItem::getPrivateFeedId(), "integer") .
1288 " WHERE " .
1289 "context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
1290 " AND context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text") .
1291 $and .
1292 " ORDER BY " . $ordering;
1293 } else {
1294 $query = "SELECT il_news_item.* " .
1295 ", il_news_read.user_id as user_read " .
1296 "FROM il_news_item LEFT JOIN il_news_read " .
1297 "ON il_news_item.id = il_news_read.news_id AND " .
1298 " il_news_read.user_id = " . $ilDB->quote($ilUser->getId(), "integer") .
1299 " WHERE " .
1300 "context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
1301 " AND context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text") .
1302 $and .
1303 " ORDER BY " . $ordering;
1304 }
1305 //echo $query;
1306 $set = $ilDB->query($query);
1307 $result = array();
1308 while ($rec = $ilDB->fetchAssoc($set)) {
1309 if ($a_limit > 0 && count($result) >= $a_limit) {
1310 continue;
1311 }
1312 if (!$a_for_rss_use || (ilNewsItem::getPrivateFeedId() != false) || ($rec["visibility"] == NEWS_PUBLIC ||
1313 ($rec["priority"] == 0 &&
1315 "news",
1316 "public_notifications",
1317 0,
1318 $rec["context_obj_id"]
1319 )))) {
1320 $result[$rec["id"]] = $rec;
1321 }
1322 }
1323
1324 // do we get data for rss and may the time limit by an issue?
1325 // do a second query without time limit.
1326 // this is not very performant, but I do not have a better
1327 // idea. The keep_rss_min setting is currently (Jul 2012) only set
1328 // by mediacasts
1329 if ($a_time_period != "" && $a_for_rss_use) {
1330 include_once("./Services/Block/classes/class.ilBlockSetting.php");
1331 $keep_rss_min = ilBlockSetting::_lookup(
1332 "news",
1333 "keep_rss_min",
1334 0,
1335 $this->getContextObjId()
1336 );
1337 if ($keep_rss_min > 0) {
1338 return $this->queryNewsForContext(
1339 true,
1340 0,
1341 $a_starting_date,
1342 $a_no_auto_generated,
1343 $a_oldest_first,
1344 $keep_rss_min
1345 );
1346 }
1347 }
1348
1349 return $result;
1350 }
$result
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.
$ilUser
Definition: imgupload.php:18

References $db, $ilDB, $ilUser, $lng, $query, $result, $user, ilBlockSetting\_lookup(), getContextObjId(), getContextObjType(), getContextSubObjId(), getContextSubObjType(), getPrivateFeedId(), handleTimePeriod(), NEWS_PUBLIC, and queryNewsForContext().

Referenced by queryNewsForContext().

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

◆ queryNewsForMultipleContexts()

ilNewsItem::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.

Parameters
array$a_contexts
bool$a_for_rss_use
int$a_time_period
string$a_starting_date
bool$a_no_auto_generated
null$a_user_id
int$a_limit
int[]$a_exclude
Returns
array

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

1415 {
1416 $ilDB = $this->db;
1418 $lng = $this->lng;
1420
1421 $and = "";
1422 if ($a_time_period > 0) {
1423 $limit_ts = self::handleTimePeriod($a_time_period);
1424 $and = " AND creation_date >= " . $ilDB->quote($limit_ts, "timestamp") . " ";
1425 }
1426
1427 if ($a_starting_date != "") {
1428 $and.= " AND creation_date > " . $ilDB->quote($a_starting_date, "timestamp") . " ";
1429 }
1430
1431 if ($a_no_auto_generated) {
1432 $and.= " AND priority = 1 AND content_type = " . $ilDB->quote("text", "text") . " ";
1433 }
1434
1435 if ($a_limit > 0) {
1436 $ilDB->setLimit($a_limit, 0);
1437 }
1438
1439 if (is_array($a_exclude) && count($a_exclude) > 0) {
1440 $and.= " AND " . $ilDB->in("id", $a_exclude, true, "integer") . " ";
1441 }
1442
1443 $ids = array();
1444 $type = array();
1445
1446 foreach ($a_contexts as $cont) {
1447 $ids[] = $cont["obj_id"];
1448 $type[$cont["obj_id"]] = $cont["obj_type"];
1449 }
1450
1451 if ($a_for_rss_use && ilNewsItem::getPrivateFeedId() == false) {
1452 $query = "SELECT * " .
1453 "FROM il_news_item " .
1454 " WHERE " .
1455 $ilDB->in("context_obj_id", $ids, false, "integer") . " " .
1456 $and .
1457 " ORDER BY creation_date DESC ";
1458 } elseif (ilNewsItem::getPrivateFeedId() != false) {
1459 $query = "SELECT il_news_item.* " .
1460 ", il_news_read.user_id as user_read " .
1461 "FROM il_news_item LEFT JOIN il_news_read " .
1462 "ON il_news_item.id = il_news_read.news_id AND " .
1463 " il_news_read.user_id = " . $ilDB->quote(ilNewsItem::getPrivateFeedId(), "integer") .
1464 " WHERE " .
1465 $ilDB->in("context_obj_id", $ids, false, "integer") . " " .
1466 $and .
1467 " ORDER BY creation_date DESC ";
1468 } else {
1469 if ($a_user_id) {
1470 $user_id = $a_user_id;
1471 } else {
1472 $user_id = $ilUser->getId();
1473 }
1474 $query = "SELECT il_news_item.* " .
1475 ", il_news_read.user_id as user_read " .
1476 "FROM il_news_item LEFT JOIN il_news_read " .
1477 "ON il_news_item.id = il_news_read.news_id AND " .
1478 " il_news_read.user_id = " . $ilDB->quote($user_id, "integer") .
1479 " WHERE " .
1480 $ilDB->in("context_obj_id", $ids, false, "integer") . " " .
1481 $and .
1482 " ORDER BY creation_date DESC ";
1483 }
1484
1485 $set = $ilDB->query($query);
1486 $result = array();
1487 while ($rec = $ilDB->fetchAssoc($set)) {
1488 if ($type[$rec["context_obj_id"]] == $rec["context_obj_type"]) {
1489 if (!$a_for_rss_use || ilNewsItem::getPrivateFeedId() != false || ($rec["visibility"] == NEWS_PUBLIC ||
1490 ($rec["priority"] == 0 &&
1492 "news",
1493 "public_notifications",
1494 0,
1495 $rec["context_obj_id"]
1496 )))) {
1497 $result[$rec["id"]] = $rec;
1498 }
1499 }
1500 }
1501
1502 return $result;
1503 }
global $ilCtrl
Definition: ilias.php:18
$type

References $ctrl, $db, $ilCtrl, $ilDB, $ilUser, $lng, $query, $result, $type, $user, $user_id, ilBlockSetting\_lookup(), getPrivateFeedId(), handleTimePeriod(), and NEWS_PUBLIC.

Referenced by getAggregatedChildNewsData(), and getAggregatedNewsData().

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

◆ read()

ilNewsItem::read ( )

Read item from database.

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

582 {
584
585 $query = "SELECT * FROM il_news_item WHERE id = " .
586 $ilDB->quote($this->getId(), "integer");
587 $set = $ilDB->query($query);
588 $rec = $ilDB->fetchAssoc($set);
589
590 $this->setTitle($rec["title"]);
591 $this->setContent($rec["content"]);
592 $this->setContextObjId((int) $rec["context_obj_id"]);
593 $this->setContextObjType($rec["context_obj_type"]);
594 $this->setContextSubObjId((int) $rec["context_sub_obj_id"]);
595 $this->setContextSubObjType($rec["context_sub_obj_type"]);
596 $this->setContentType($rec["content_type"]);
597 $this->setCreationDate($rec["creation_date"]);
598 $this->setUpdateDate($rec["update_date"]);
599 $this->setUserId($rec["user_id"]);
600 $this->setUpdateUserId($rec["update_user_id"]);
601 $this->setVisibility($rec["visibility"]);
602 $this->setContentLong($rec["content_long"]);
603 $this->setPriority($rec["priority"]);
604 $this->setContentIsLangVar($rec["content_is_lang_var"]);
605 $this->setContentTextIsLangVar((int) $rec["content_text_is_lang_var"]);
606 $this->setMobId($rec["mob_id"]);
607 $this->setPlaytime($rec["playtime"]);
608 $this->setMobPlayCounter($rec["mob_cnt_play"]);
609 $this->setMobDownloadCounter($rec["mob_cnt_download"]);
610 $this->setContentHtml($rec["content_html"]);
611 }
setContent($a_content)
Set Content.
setMobId($a_mob_id)
Set MobId.
setCreationDate($a_creation_date)
Set CreationDate.
setContentIsLangVar($a_content_is_lang_var=0)
Set ContentIsLangVar.
setUserId($a_user_id)
Set UserId.
setContextObjId($a_context_obj_id)
Set ContextObjId.
setContextSubObjId($a_context_sub_obj_id)
Set ContextSubObjId.
setUpdateDate($a_update_date)
Set UpdateDate.
setTitle($a_title)
Set Title.
setUpdateUserId($a_val)
Set update user id.
setPlaytime($a_playtime)
Set Playtime.
setContextObjType($a_context_obj_type)
Set ContextObjType.
setPriority($a_priority=1)
Set Priority.
setContentLong($a_content_long)
Set ContentLong.
setContentTextIsLangVar($a_val=0)
Set content text ist lang var.
setVisibility($a_visibility="users")
Set Visibility.
setContentType($a_content_type="text")
Set ContentType.
setContextSubObjType($a_context_sub_obj_type)
Set ContextSubObjType.
setContentHtml($a_val)
Is content HTML (tiny used?)

References $db, $ilDB, $query, getId(), setContent(), setContentHtml(), setContentIsLangVar(), setContentLong(), setContentTextIsLangVar(), setContentType(), setContextObjId(), setContextObjType(), setContextSubObjId(), setContextSubObjType(), setCreationDate(), setMobDownloadCounter(), setMobId(), setMobPlayCounter(), setPlaytime(), setPriority(), setTitle(), setUpdateDate(), setUpdateUserId(), setUserId(), and setVisibility().

Referenced by __construct().

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

◆ setContent()

ilNewsItem::setContent (   $a_content)

Set Content.

Parameters
string$a_contentContent of news.

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

163 {
164 $this->content = $a_content;
165 }

References $a_content.

Referenced by read().

+ Here is the caller graph for this function:

◆ setContentHtml()

ilNewsItem::setContentHtml (   $a_val)

Is content HTML (tiny used?)

Parameters
bool$a_val

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

564 {
565 $this->content_html = $a_val;
566 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setContentIsLangVar()

ilNewsItem::setContentIsLangVar (   $a_content_is_lang_var = 0)

Set ContentIsLangVar.

Parameters
boolean$a_content_is_lang_var

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

423 {
424 $this->content_is_lang_var = $a_content_is_lang_var;
425 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setContentLong()

ilNewsItem::setContentLong (   $a_content_long)

Set ContentLong.

Parameters
string$a_content_longLong content of news

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

383 {
384 $this->content_long = $a_content_long;
385 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setContentTextIsLangVar()

ilNewsItem::setContentTextIsLangVar (   $a_val = 0)

Set content text ist lang var.

Parameters
boolean$a_content_is_lang_var

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

504 {
505 $this->content_text_is_lang_var = $a_val;
506 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setContentType()

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

Set ContentType.

Parameters
string$a_content_typeContent type.

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

263 {
264 $this->content_type = $a_content_type;
265 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setContext()

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

Convenient function to set the whole context information.

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

1202 {
1203 $this->setContextObjId($a_obj_id);
1204 $this->setContextObjType($a_obj_type);
1205 $this->setContextSubObjId($a_sub_obj_id);
1206 $this->setContextSubObjType($a_sub_obj_type);
1207 }

References setContextObjId(), setContextObjType(), setContextSubObjId(), and setContextSubObjType().

+ Here is the call graph for this function:

◆ setContextObjId()

ilNewsItem::setContextObjId (   $a_context_obj_id)

Set ContextObjId.

Parameters
int$a_context_obj_id

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

183 {
184 $this->context_obj_id = $a_context_obj_id;
185 }

Referenced by read(), and setContext().

+ Here is the caller graph for this function:

◆ setContextObjType()

ilNewsItem::setContextObjType (   $a_context_obj_type)

Set ContextObjType.

Parameters
int$a_context_obj_type

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

203 {
204 $this->context_obj_type = $a_context_obj_type;
205 }

Referenced by read(), and setContext().

+ Here is the caller graph for this function:

◆ setContextSubObjId()

ilNewsItem::setContextSubObjId (   $a_context_sub_obj_id)

Set ContextSubObjId.

Parameters
int$a_context_sub_obj_id

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

223 {
224 $this->context_sub_obj_id = $a_context_sub_obj_id;
225 }

Referenced by read(), and setContext().

+ Here is the caller graph for this function:

◆ setContextSubObjType()

ilNewsItem::setContextSubObjType (   $a_context_sub_obj_type)

Set ContextSubObjType.

Parameters
int$a_context_sub_obj_type

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

243 {
244 $this->context_sub_obj_type = $a_context_sub_obj_type;
245 }

Referenced by read(), and setContext().

+ Here is the caller graph for this function:

◆ setCreationDate()

ilNewsItem::setCreationDate (   $a_creation_date)

Set CreationDate.

Parameters
string$a_creation_dateDate of creation.

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

283 {
284 $this->creation_date = $a_creation_date;
285 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setId()

ilNewsItem::setId (   $a_id)

Set Id.

Parameters
int$a_id

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

123 {
124 $this->id = $a_id;
125 }

Referenced by __construct(), and create().

+ Here is the caller graph for this function:

◆ setLimitation()

ilNewsItem::setLimitation (   $a_limitation)

Set Limitation for number of items.

Parameters
boolean$a_limitationLimitation for number of items

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

484 {
485 $this->limitation = $a_limitation;
486 }

◆ setMobDownloadCounter()

ilNewsItem::setMobDownloadCounter (   $a_val)

Set mob download counter.

Parameters
int$a_valcounter

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

544 {
545 $this->mob_cnt_download = $a_val;
546 }

Referenced by increaseDownloadCounter(), and read().

+ Here is the caller graph for this function:

◆ setMobId()

ilNewsItem::setMobId (   $a_mob_id)

Set MobId.

Parameters
int$a_mob_idMedia Object ID (if news includes attachement)

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

443 {
444 $this->mob_id = $a_mob_id;
445 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setMobPlayCounter()

ilNewsItem::setMobPlayCounter (   $a_val)

Set mob play counter.

Parameters
int$a_valcounter

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

524 {
525 $this->mob_cnt_play = $a_val;
526 }

Referenced by increasePlayCounter(), and read().

+ Here is the caller graph for this function:

◆ setPlaytime()

ilNewsItem::setPlaytime (   $a_playtime)

Set Playtime.

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

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

463 {
464 $this->playtime = $a_playtime;
465 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setPriority()

ilNewsItem::setPriority (   $a_priority = 1)

Set Priority.

Parameters
int$a_priorityNews Priority

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

403 {
404 $this->priority = $a_priority;
405 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setPrivateFeedId()

static ilNewsItem::setPrivateFeedId (   $a_userId)
static

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

2003 {
2004 ilNewsItem::$privFeedId = $a_userId;
2005 }

References $privFeedId.

Referenced by ilObjectFeedWriter\__construct().

+ Here is the caller graph for this function:

◆ setTitle()

ilNewsItem::setTitle (   $a_title)

Set Title.

Parameters
string$a_titleTitle of news item.

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

143 {
144 $this->title = $a_title;
145 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setUpdateDate()

ilNewsItem::setUpdateDate (   $a_update_date)

Set UpdateDate.

Parameters
string$a_update_dateDate of last update.

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

303 {
304 $this->update_date = $a_update_date;
305 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setUpdateUserId()

ilNewsItem::setUpdateUserId (   $a_val)

Set update user id.

Parameters
int$a_valupdate user id

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

343 {
344 $this->update_user_id = $a_val;
345 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setUserId()

ilNewsItem::setUserId (   $a_user_id)

Set UserId.

Parameters
int$a_user_idUser Id of last update.

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

323 {
324 $this->user_id = $a_user_id;
325 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setVisibility()

ilNewsItem::setVisibility (   $a_visibility = "users")

Set Visibility.

Parameters
string$a_visibilityAccess level of news.

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

363 {
364 $this->visibility = $a_visibility;
365 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilNewsItem::update (   $a_as_new = false)

Update item in database.

Parameters
boolean$a_as_newIf true, creation date is set "now"

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

693 {
695
696 $fields = array(
697 "title" => array("text", $this->getTitle()),
698 "content" => array("clob", $this->getContent()),
699 "content_html" => array("integer", (int) $this->getContentHtml()),
700 "context_obj_id" => array("integer", $this->getContextObjId()),
701 "context_obj_type" => array("text", $this->getContextObjType()),
702 "context_sub_obj_id" => array("integer", $this->getContextSubObjId()),
703 "context_sub_obj_type" => array("text", $this->getContextSubObjType()),
704 "content_type" => array("text", $this->getContentType()),
705 "user_id" => array("integer", $this->getUserId()),
706 "update_user_id" => array("integer", (int) $this->getUpdateUserId()),
707 "visibility" => array("text", $this->getVisibility()),
708 "content_long" => array("clob", $this->getContentLong()),
709 "priority" => array("integer", $this->getPriority()),
710 "content_is_lang_var" => array("integer", $this->getContentIsLangVar()),
711 "content_text_is_lang_var" => array("integer", (int) $this->getContentTextIsLangVar()),
712 "mob_id" => array("integer", $this->getMobId()),
713 "mob_cnt_play" => array("integer", $this->getMobPlayCounter()),
714 "mob_cnt_download" => array("integer", $this->getMobDownloadCounter()),
715 "playtime" => array("text", $this->getPlaytime())
716 );
717
718 $now = ilUtil::now();
719 if ($a_as_new) {
720 $fields["creation_date"] = array("timestamp", $now);
721 $fields["update_date"] = array("timestamp", $now);
722 } else {
723 $fields["update_date"] = array("timestamp", $now);
724 }
725
726 $ilDB->update("il_news_item", $fields, array(
727 "id" => array("integer", $this->getId())
728 ));
729 }

References $db, $ilDB, getContent(), getContentHtml(), getContentIsLangVar(), getContentLong(), getContentTextIsLangVar(), getContentType(), getContextObjId(), getContextObjType(), getContextSubObjId(), getContextSubObjType(), getId(), getMobDownloadCounter(), getMobId(), getMobPlayCounter(), getPlaytime(), getPriority(), getTitle(), getUpdateUserId(), getUserId(), getVisibility(), and ilUtil\now().

+ Here is the call graph for this function:

Field Documentation

◆ $access

ilNewsItem::$access
protected

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

Referenced by getAggregatedChildNewsData(), and getAggregatedNewsData().

◆ $content

ilNewsItem::$content
protected

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

Referenced by getContent().

◆ $content_html

ilNewsItem::$content_html
protected

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

Referenced by getContentHtml().

◆ $content_is_lang_var

ilNewsItem::$content_is_lang_var = 0
protected

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

Referenced by getContentIsLangVar().

◆ $content_long

ilNewsItem::$content_long
protected

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

Referenced by getContentLong().

◆ $content_type

ilNewsItem::$content_type = "text"
protected

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

Referenced by getContentType().

◆ $context_obj_id

ilNewsItem::$context_obj_id
protected

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

Referenced by getContextObjId().

◆ $context_obj_type

ilNewsItem::$context_obj_type
protected

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

Referenced by getContextObjType().

◆ $context_sub_obj_id

ilNewsItem::$context_sub_obj_id
protected

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

Referenced by getContextSubObjId().

◆ $context_sub_obj_type

ilNewsItem::$context_sub_obj_type
protected

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

Referenced by getContextSubObjType().

◆ $creation_date

ilNewsItem::$creation_date
protected

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

Referenced by getCreationDate().

◆ $ctrl

ilNewsItem::$ctrl
protected

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

Referenced by queryNewsForMultipleContexts().

◆ $db

◆ $id

ilNewsItem::$id
protected

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

Referenced by getId(), getLastNewsIdForContext(), and mergeNews().

◆ $limitation

ilNewsItem::$limitation
private

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

Referenced by getLimitation().

◆ $lng

ilNewsItem::$lng
protected

◆ $mob_id

ilNewsItem::$mob_id
protected

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

Referenced by getMobId().

◆ $obj_data_cache

ilNewsItem::$obj_data_cache
protected

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

Referenced by getAggregatedNewsData().

◆ $playtime

ilNewsItem::$playtime
protected

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

Referenced by getPlaytime().

◆ $priority

ilNewsItem::$priority = 1
protected

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

Referenced by getPriority().

◆ $privFeedId

ilNewsItem::$privFeedId = false
staticprivate

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

Referenced by getPrivateFeedId(), and setPrivateFeedId().

◆ $title

ilNewsItem::$title
protected

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

Referenced by getTitle().

◆ $tree

◆ $update_date

ilNewsItem::$update_date
protected

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

Referenced by getUpdateDate().

◆ $update_user_id

ilNewsItem::$update_user_id
protected

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

Referenced by getUpdateUserId().

◆ $user

ilNewsItem::$user
protected

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

Referenced by queryNewsForContext(), and queryNewsForMultipleContexts().

◆ $user_id

ilNewsItem::$user_id
protected

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

Referenced by getUserId(), and queryNewsForMultipleContexts().

◆ $visibility

ilNewsItem::$visibility = "users"
protected

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

Referenced by _getDefaultVisibilityForRefId(), and getVisibility().


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