ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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)
 
 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

 $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 64 of file class.ilNewsItem.php.

65 {
66 if ($a_id > 0)
67 {
68 $this->setId($a_id);
69 $this->read();
70 }
71 $this->limitation = true;
72 }
read()
Read item from database.
setId($a_id)
Set Id.

References read(), and setId().

+ 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 1508 of file class.ilNewsItem.php.

1509 {
1510 global $tree, $ilSetting;
1511
1512 include_once("./Services/Block/classes/class.ilBlockSetting.php");
1513
1514 $news_set = new ilSetting("news");
1515 $default_visibility = ($news_set->get("default_visibility") != "")
1516 ? $news_set->get("default_visibility")
1517 : "users";
1518
1519 if ($tree->isInTree($a_ref_id))
1520 {
1521 $path = $tree->getPathFull($a_ref_id);
1522
1523 foreach ($path as $key => $row)
1524 {
1525 if (!in_array($row["type"], array("root", "cat","crs", "fold", "grp")))
1526 {
1527 continue;
1528 }
1529
1530 $visibility = ilBlockSetting::_lookup("news", "default_visibility",
1531 0, $row["obj_id"]);
1532
1533 if ($visibility != "")
1534 {
1535 $default_visibility = $visibility;
1536 }
1537 }
1538 }
1539
1540 return $default_visibility;
1541 }
$path
Definition: aliased.php:25
static _lookup($a_type, $a_setting, $a_user=0, $a_block_id=0)
Lookup setting from database.
ILIAS Setting Class.
global $ilSetting
Definition: privfeed.php:17

References $ilSetting, $path, $row, $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 701 of file class.ilNewsItem.php.

703 {
704 global $ilAccess;
705
706 $news_item = new ilNewsItem();
707 $news_set = new ilSetting("news");
708
709 $per = $a_per;
710
711 include_once("./Services/News/classes/class.ilNewsSubscription.php");
712 include_once("./Services/Block/classes/class.ilBlockSetting.php");
713
714 // this is currently not used
715 $ref_ids = ilNewsSubscription::_getSubscriptionsOfUser($a_user_id);
716
717 if (ilObjUser::_lookupPref($a_user_id, "pd_items_news") != "n")
718 {
719 // get all items of the personal desktop
720 $pd_items = ilObjUser::_lookupDesktopItems($a_user_id);
721 foreach($pd_items as $item)
722 {
723 if (!in_array($item["ref_id"], $ref_ids))
724 {
725 $ref_ids[] = $item["ref_id"];
726 }
727 }
728
729 // get all memberships
730 include_once 'Services/Membership/classes/class.ilParticipants.php';
731 $crs_mbs = ilParticipants::_getMembershipByType($a_user_id, 'crs');
732 $grp_mbs = ilParticipants::_getMembershipByType($a_user_id, 'grp');
733 $items = array_merge($crs_mbs, $grp_mbs);
734 foreach($items as $i)
735 {
736 $item_references = ilObject::_getAllReferences($i);
737 if(is_array($item_references) && count($item_references))
738 {
739 foreach($item_references as $ref_id)
740 {
741 if (!in_array($ref_id, $ref_ids))
742 {
743 $ref_ids[] = $ref_id;
744 }
745 }
746 }
747 }
748 }
749
750 $data = array();
751
752 foreach($ref_ids as $ref_id)
753 {
754 if (!$a_only_public)
755 {
756 // this loop should not cost too much performance
757 $acc = $ilAccess->checkAccessOfUser($a_user_id, "read", "", $ref_id);
758
759 if (!$acc)
760 {
761 continue;
762 }
763 }
764 if (ilNewsItem::getPrivateFeedId() != false) {
765 global $rbacsystem;
766 $acc = $rbacsystem->checkAccessOfUser(ilNewsItem::getPrivateFeedId(),"read", $ref_id);
767
768 if (!$acc)
769 {
770 continue;
771 }
772 }
773
775 $obj_type = ilObject::_lookupType($obj_id);
776 $news = $news_item->getNewsForRefId($ref_id, $a_only_public, false,
777 $per, $a_prevent_aggregation, false, false, false, $a_user_id);
778
779 // counter
780 if (!is_null($a_cnt))
781 {
782 $a_cnt[$ref_id] = count($news);
783 }
784
786 }
787
788 $data = ilUtil::sortArray($data, "creation_date", "desc", false, true);
789
790 return $data;
791 }
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
$ref_id
Definition: sahs_server.php:39

References $data, $ref_id, 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 1864 of file class.ilNewsItem.php.

1865 {
1866 global $ilDB;
1867
1868 $query = "SELECT * ".
1869 "FROM il_news_item ".
1870 "WHERE ".
1871 " id = ".$ilDB->quote($a_news_id, "integer");
1872 $set = $ilDB->query($query);
1873 $rec = $ilDB->fetchAssoc($set);
1874
1875 return $rec["context_obj_id"];
1876 }
global $ilDB

References $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 1878 of file class.ilNewsItem.php.

1879 {
1880 $news_set = new ilSetting("news");
1881 $per = $news_set->get("pd_period");
1882 if ($per == 0)
1883 {
1884 $per = 30;
1885 }
1886
1887 return $per;
1888 }

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 1842 of file class.ilNewsItem.php.

1843 {
1844 global $ilDB;
1845
1846 $query = "SELECT * ".
1847 "FROM il_news_item ".
1848 "WHERE ".
1849 " mob_id = ".$ilDB->quote($a_mob_id, "integer");
1850
1851 $usages = array();
1852 $set = $ilDB->query($query);
1853 while ($rec = $ilDB->fetchAssoc($set))
1854 {
1855 $usages[$rec["id"]] = array("type" => "news", "id" => $rec["id"]);
1856 }
1857
1858 return $usages;
1859 }

References $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 1640 of file class.ilNewsItem.php.

1641 {
1642 global $ilDB;
1643
1644 $query = "SELECT mob_id FROM il_news_item WHERE id = ".
1645 $ilDB->quote($a_news_id, "integer");
1646 $set = $ilDB->query($query);
1647 $rec = $ilDB->fetchAssoc($set);
1648 return $rec["mob_id"];
1649 }

References $ilDB, and $query.

Referenced by ilNewsExporter\getXmlExportHeadDependencies().

+ Here is the caller graph for this function:

◆ _lookupRSSPeriod()

static ilNewsItem::_lookupRSSPeriod ( )
static

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

1914 {
1915 $news_set = new ilSetting("news");
1916 $rss_period = $news_set->get("rss_period");
1917 if ($rss_period == 0) // default to two weeks
1918 {
1919 $rss_period = 14;
1920 }
1921 return $rss_period;
1922 }

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 1611 of file class.ilNewsItem.php.

1612 {
1613 global $ilDB;
1614
1615 $query = "SELECT title FROM il_news_item WHERE id = ".
1616 $ilDB->quote($a_news_id, "integer");
1617 $set = $ilDB->query($query);
1618 $rec = $ilDB->fetchAssoc($set);
1619 return $rec["title"];
1620 }

References $ilDB, and $query.

◆ _lookupUserPDPeriod()

static ilNewsItem::_lookupUserPDPeriod (   $a_user_id)
static

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

1891 {
1892 $news_set = new ilSetting("news");
1893 $allow_shorter_periods = $news_set->get("allow_shorter_periods");
1894 $allow_longer_periods = $news_set->get("allow_longer_periods");
1895 $default_per = ilNewsItem::_lookupDefaultPDPeriod();
1896
1897 include_once("./Services/Block/classes/class.ilBlockSetting.php");
1898 $per = ilBlockSetting::_lookup("pdnews", "news_pd_period",
1899 $a_user_id, 0);
1900
1901 // news period information
1902 if ($per <= 0 ||
1903 (!$allow_shorter_periods && ($per < $default_per)) ||
1904 (!$allow_longer_periods && ($per > $default_per))
1905 )
1906 {
1907 $per = $default_per;
1908 }
1909
1910 return $per;
1911 }
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 1625 of file class.ilNewsItem.php.

1626 {
1627 global $ilDB;
1628
1629 $query = "SELECT visibility FROM il_news_item WHERE id = ".
1630 $ilDB->quote($a_news_id, "integer");
1631 $set = $ilDB->query($query);
1632 $rec = $ilDB->fetchAssoc($set);
1633
1634 return $rec["visibility"];
1635 }

References $ilDB, and $query.

◆ _setRead()

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

Set item read.

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

1447 {
1448 global $ilDB, $ilAppEventHandler;
1449
1450 $ilDB->replace("il_news_read",
1451 array(
1452 "user_id" => array("integer", $a_user_id),
1453 "news_id" => array("integer", $a_news_id)
1454 ),
1455 array()
1456 );
1457
1458 /*
1459 $ilDB->manipulate("DELETE FROM il_news_read WHERE ".
1460 "user_id = ".$ilDB->quote($a_user_id, "integer").
1461 " AND news_id = ".$ilDB->quote($a_news_id, "integer"));
1462 $ilDB->manipulate("INSERT INTO il_news_read (user_id, news_id) VALUES (".
1463 $ilDB->quote($a_user_id, "integer").",".
1464 $ilDB->quote($a_news_id, "integer").")");*/
1465
1466 $ilAppEventHandler->raise("Services/News", "readNews",
1467 array("user_id" => $a_user_id, "news_ids" => array($a_news_id)));
1468 }

References $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 1473 of file class.ilNewsItem.php.

1474 {
1475 global $ilDB, $ilAppEventHandler;
1476
1477 $ilDB->manipulate("DELETE FROM il_news_read (user_id, news_id) VALUES (".
1478 " WHERE user_id = ".$ilDB->quote($a_user_id, "integer").
1479 " AND news_id = ".$ilDB->quote($a_news_id, "integer"));
1480
1481 $ilAppEventHandler->raise("Services/News", "unreadNews",
1482 array("user_id" => $a_user_id, "news_ids" => array($a_news_id)));
1483 }

References $ilDB.

◆ aggregateFiles()

ilNewsItem::aggregateFiles (   $news,
  $a_ref_id 
)

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

1031 {
1032 $first_file = "";
1033 $to_del = array();
1034 foreach ($news as $k => $v)
1035 {
1036 // aggregate file related news
1037 if ($news[$k]["context_obj_type"] == "file")
1038 {
1039 if ($first_file == "")
1040 {
1041 $first_file = $k;
1042 }
1043 else
1044 {
1045 $to_del[] = $k;
1046 }
1047 $news[$first_file]["aggregation"][$k] = $news[$k];
1048 $news[$first_file]["agg_ref_id"] = $a_ref_id;
1049 $news[$first_file]["ref_id"] = $a_ref_id;
1050 }
1051 }
1052
1053 foreach($to_del as $v)
1054 {
1055 unset($news[$v]);
1056 }
1057
1058 return $news;
1059 }

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 980 of file class.ilNewsItem.php.

981 {
982 $to_del = array();
983 $forums = array();
984
985 // aggregate
986 foreach ($news as $k => $v)
987 {
988 if ($a_group_posting_sequence && $last_aggregation_forum > 0 &&
989 $last_aggregation_forum != $news[$k]["context_obj_id"])
990 {
991 $forums[$last_aggregation_forum] = "";
992 }
993
994 if ($news[$k]["context_obj_type"] == "frm")
995 {
996 if ($forums[$news[$k]["context_obj_id"]] == "")
997 {
998 // $forums[forum_id] = news_id;
999 $forums[$news[$k]["context_obj_id"]] = $k;
1000 $last_aggregation_forum = $news[$k]["context_obj_id"];
1001 }
1002 else
1003 {
1004 $to_del[] = $k;
1005 }
1006
1007 $news[$k]["no_context_title"] = true;
1008
1009 // aggregate every forum into it's "k" news
1010 $news[$forums[$news[$k]["context_obj_id"]]]["aggregation"][$k]
1011 = $news[$k];
1012 $news[$k]["agg_ref_id"]
1013 = $news[$k]["ref_id"];
1014 $news[$k]["content"] = "";
1015 $news[$k]["content_long"] = "";
1016 }
1017 }
1018
1019 // delete double entries
1020 foreach($to_del as $k)
1021 {
1022 unset($news[$k]);
1023 }
1024//var_dump($news[14]["aggregation"]);
1025
1026
1027 return $news;
1028 }

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 1287 of file class.ilNewsItem.php.

1288 {
1289 global $tree, $ilDB;
1290
1291 $all = array();
1292
1293 if(!$tree->isDeleted($a_ref_id))
1294 {
1295 // parse repository branch of group
1296 $nodes = array();
1297 $node = $tree->getNodeData($a_ref_id);
1298 foreach($tree->getSubTree($node) as $child)
1299 {
1300 if($child["type"] != "rolf")
1301 {
1302 $nodes[$child["obj_id"]] = $child["type"];
1303 }
1304 }
1305
1306 $limit_ts = self::handleTimePeriod($a_time_period);
1307
1308 // are there any news items for relevant objects and?
1309 $query = $ilDB->query("SELECT id,context_obj_id,context_obj_type".
1310 " FROM il_news_item".
1311 " WHERE ".$ilDB->in("context_obj_id", array_keys($nodes), false, "integer").
1312 " AND creation_date >= ".$ilDB->quote($limit_ts, "timestamp"));
1313 while($rec = $ilDB->fetchAssoc($query))
1314 {
1315 if ($nodes[$rec["context_obj_id"]] == $rec["context_obj_type"])
1316 {
1317 $all[] = $rec["id"];
1318 }
1319 }
1320 }
1321
1322 return $all;
1323 }
static handleTimePeriod($a_time_period)
Convert time period for DB-queries.

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

+ Here is the call graph for this function:

◆ create()

ilNewsItem::create ( )

Create.

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

575 {
576 global $ilDB;
577
578 // insert new record into db
579 $this->setId($ilDB->nextId("il_news_item"));
580 $ilDB->insert("il_news_item", array(
581 "id" => array("integer", $this->getId()),
582 "title" => array("text", $this->getTitle()),
583 "content" => array("clob", $this->getContent()),
584 "content_html" => array("integer", (int) $this->getContentHtml()),
585 "context_obj_id" => array("integer", (int) $this->getContextObjId()),
586 "context_obj_type" => array("text", $this->getContextObjType()),
587 "context_sub_obj_id" => array("integer", (int) $this->getContextSubObjId()),
588 "context_sub_obj_type" => array("text", $this->getContextSubObjType()),
589 "content_type" => array("text", $this->getContentType()),
590 "creation_date" => array("timestamp", ilUtil::now()),
591 "update_date" => array("timestamp", ilUtil::now()),
592 "user_id" => array("integer", $this->getUserId()),
593 "update_user_id" => array("integer", (int) $this->getUpdateUserId()),
594 "visibility" => array("text", $this->getVisibility()),
595 "content_long" => array("clob", $this->getContentLong()),
596 "priority" => array("integer", $this->getPriority()),
597 "content_is_lang_var" => array("integer", $this->getContentIsLangVar()),
598 "content_text_is_lang_var" => array("integer", (int) $this->getContentTextIsLangVar()),
599 "mob_id" => array("integer", $this->getMobId()),
600 "playtime" => array("text", $this->getPlaytime())
601 ));
602
603
604 $news_set = new ilSetting("news");
605 $max_items = $news_set->get("max_items");
606 if ($max_items <= 0)
607 {
608 $max_items = 50;
609 }
610
611 // limit number of news
612 if ($this->getLimitation())
613 {
614 // Determine how many rows should be deleted
615 $query = "SELECT count(*) cnt ".
616 "FROM il_news_item ".
617 "WHERE ".
618 "context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
619 " AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
620 " AND context_sub_obj_id = ".$ilDB->quote($this->getContextSubObjId(), "integer").
621 " AND ".$ilDB->equals("context_sub_obj_type", $this->getContextSubObjType(), "text", true)." ";
622
623 $set = $ilDB->query($query);
624 $rec = $ilDB->fetchAssoc($set);
625
626 // if we have more records than allowed, delete them
627 if (($rec["cnt"] > $max_items) && $this->getContextObjId() > 0)
628 {
629 $query = "SELECT * ".
630 "FROM il_news_item ".
631 "WHERE ".
632 "context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
633 " AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
634 " AND context_sub_obj_id = ".$ilDB->quote($this->getContextSubObjId(), "integer").
635 " AND ".$ilDB->equals("context_sub_obj_type", $this->getContextSubObjType(), "text", true).
636 " ORDER BY creation_date ASC";
637
638 $ilDB->setLimit($rec["cnt"] - $max_items);
639 $del_set = $ilDB->query($query);
640 while ($del_item = $ilDB->fetchAssoc($del_set))
641 {
642 $del_news = new ilNewsItem($del_item["id"]);
643 $del_news->delete();
644 }
645 }
646 }
647 }
getId()
Get Id.
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 $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 1548 of file class.ilNewsItem.php.

1549 {
1550 global $ilDB;
1551
1552 // delete il_news_read entries
1553 $ilDB->manipulate("DELETE FROM il_news_read ".
1554 " WHERE news_id = ".$ilDB->quote($this->getId(), "integer"));
1555
1556 // delete multimedia object
1557 $mob = $this->getMobId();
1558
1559 // delete
1560 $query = "DELETE FROM il_news_item".
1561 " WHERE id = ".$ilDB->quote($this->getId(), "integer");
1562 $ilDB->manipulate($query);
1563
1564 // delete mob after news, to have a "mob usage" of 0
1565 if ($mob > 0 and ilObject::_exists($mob))
1566 {
1567 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1568 $mob = new ilObjMediaObject($mob);
1569 $mob->delete();
1570 }
1571 }
Class ilObjMediaObject.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public

References $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 1577 of file class.ilNewsItem.php.

1579 {
1580 global $ilDB;
1581
1582 if ($a_context_obj_id == 0 || $a_context_obj_type == "")
1583 {
1584 return;
1585 }
1586
1587 if ($a_context_sub_obj_id > 0)
1588 {
1589 $and = " AND context_sub_obj_id = ".$ilDB->quote($a_context_sub_obj_id, "integer").
1590 " AND context_sub_obj_type = ".$ilDB->quote($a_context_sub_obj_type, "text");
1591 }
1592
1593 // get news records
1594 $query = "SELECT * FROM il_news_item".
1595 " WHERE context_obj_id = ".$ilDB->quote($a_context_obj_id, "integer").
1596 " AND context_obj_type = ".$ilDB->quote($a_context_obj_type, "text").
1597 $and;
1598
1599 $news_set = $ilDB->query($query);
1600
1601 while ($news = $ilDB->fetchAssoc($news_set))
1602 {
1603 $news_obj = new ilNewsItem($news["id"]);
1604 $news_obj->delete();
1605 }
1606 }

References $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 1939 of file class.ilNewsItem.php.

1940 {
1941 $mob = $this->getMobId();
1942 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1943 $mob = new ilObjMediaObject($mob);
1944 $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
1945
1946 // check purpose
1947 if (!$mob->hasPurposeItem($a_purpose))
1948 {
1949 return false;
1950 }
1951
1952 $m_item = $mob->getMediaItem($a_purpose);
1953 if ($m_item->getLocationType() != "Reference")
1954 {
1955 $file = $mob_dir."/".$m_item->getLocation();
1956 if (file_exists($file) && is_file($file))
1957 {
1958 if ($a_increase_download_cnt)
1959 {
1960 $this->increaseDownloadCounter();
1961 }
1962 ilUtil::deliverFile($file, $m_item->getLocation(), "", false, false, false);
1963 return true;
1964 }
1965 else
1966 {
1967 ilUtil::sendFailure("File not found!",true);
1968 return false;
1969 }
1970 }
1971 else
1972 {
1973 if ($a_increase_download_cnt)
1974 {
1975 $this->increaseDownloadCounter();
1976 }
1977 ilUtil::redirect($m_item->getLocation());
1978 }
1979 }
increaseDownloadCounter()
Increase download counter.
static _getDirectory($a_mob_id)
get directory for files of media object (static)
static redirect($a_script)
http redirect to other 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 1762 of file class.ilNewsItem.php.

1763 {
1764 global $lng;
1765
1766 if ($a_is_lang_var)
1767 {
1768 $lng->loadLanguageModule($a_context_obj_type);
1769 return $lng->txt($a_content);
1770 }
1771 else
1772 {
1773 return $a_content;
1774 }
1775 }
global $lng
Definition: privfeed.php:17
$a_content
Definition: workflow.php:94

References $a_content, 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 1687 of file class.ilNewsItem.php.

1689 {
1690 global $lng;
1691
1692 if ($a_agg_ref_id > 0)
1693 {
1694 $cnt = count($a_aggregation);
1695
1696 // forums
1697 if ($a_context_obj_type == "frm")
1698 {
1699 if ($cnt > 1)
1700 {
1701 return sprintf($lng->txt("news_x_postings"), $cnt);
1702 }
1703 else
1704 {
1705 return $lng->txt("news_1_postings");
1706 }
1707 }
1708 else // files
1709 {
1710 $up_cnt = $cr_cnt = 0;
1711 foreach($a_aggregation as $item)
1712 {
1713 if ($item["title"] == "file_updated")
1714 {
1715 $up_cnt++;
1716 }
1717 else
1718 {
1719 $cr_cnt++;
1720 }
1721 }
1722 $sep = "";
1723 if ($cr_cnt == 1)
1724 {
1725 $tit = $lng->txt("news_1_file_created");
1726 $sep = "<br />";
1727 }
1728 else if ($cr_cnt > 1)
1729 {
1730 $tit = sprintf($lng->txt("news_x_files_created"), $cr_cnt);
1731 $sep = "<br />";
1732 }
1733 if ($up_cnt == 1)
1734 {
1735 $tit .= $sep.$lng->txt("news_1_file_updated");
1736 }
1737 else if ($up_cnt > 1)
1738 {
1739 $tit .= $sep.sprintf($lng->txt("news_x_files_updated"), $up_cnt);
1740 }
1741 return $tit;
1742 }
1743 }
1744 else
1745 {
1746 if ($a_content_is_lang_var)
1747 {
1748 return $lng->txt($a_title);
1749 }
1750 else
1751 {
1752 return $a_title;
1753 }
1754 }
1755
1756 return "";
1757 }
sprintf('%.4f', $callTime)

References $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 1654 of file class.ilNewsItem.php.

1655 {
1656 global $ilDB;
1657
1658 $and = "";
1659 if ($a_time_period > 0)
1660 {
1661 $limit_ts = self::handleTimePeriod($a_time_period);
1662 $and = " AND creation_date >= ".$ilDB->quote($limit_ts, "timestamp")." ";
1663 }
1664
1665 if ($a_starting_date != "")
1666 {
1667 $and.= " AND creation_date >= ".$ilDB->quote($a_starting_date, "timestamp");
1668 }
1669
1670 $query = "SELECT DISTINCT(context_obj_id) AS obj_id FROM il_news_item".
1671 " WHERE ".$ilDB->in("context_obj_id", $a_obj_ids, false, "integer")." ".$and;
1672 //" WHERE context_obj_id IN (".implode(ilUtil::quoteArray($a_obj_ids),",").")".$and;
1673
1674 $set = $ilDB->query($query);
1675 $objs = array();
1676 while($rec = $ilDB->fetchAssoc($set))
1677 {
1678 $objs[] = $rec["obj_id"];
1679 }
1680
1681 return $objs;
1682 }

References $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 1065 of file class.ilNewsItem.php.

1068 {
1069 global $tree, $ilAccess;
1070
1071 // get news of parent object
1072 $data = $this->getNewsForRefId($a_ref_id, $a_only_public, true, $a_time_period,
1073 true, false, false, $a_no_auto_generated);
1074 foreach ($data as $k => $v)
1075 {
1076 $data[$k]["ref_id"] = $a_ref_id;
1077 }
1078
1079 // get childs
1080 $nodes = $tree->getChilds($a_ref_id);
1081
1082 // no check, for which of the objects any news are available
1083 $obj_ids = array();
1084 foreach($nodes as $node)
1085 {
1086 $obj_ids[] = $node["obj_id"];
1087 }
1088 $news_obj_ids = ilNewsItem::filterObjIdsPerNews($obj_ids, $a_time_period, $a_starting_date);
1089 //$news_obj_ids = $obj_ids;
1090
1091 // get news for all subtree nodes
1092 $contexts = array();
1093 foreach($nodes as $node)
1094 {
1095 // only go on, if news are available
1096 if (!in_array($node["obj_id"], $news_obj_ids))
1097 {
1098 continue;
1099 }
1100
1101 if (!$a_only_public && !$ilAccess->checkAccess("read", "", $node["child"]))
1102 {
1103 continue;
1104 }
1105 $ref_id[$node["obj_id"]] = $node["child"];
1106 $contexts[] = array("obj_id" => $node["obj_id"],
1107 "obj_type" => $node["type"]);
1108 }
1109
1110 $news = $this->queryNewsForMultipleContexts($contexts, $a_only_public, $a_time_period,
1111 $a_starting_date, $a_no_auto_generated);
1112 foreach ($news as $k => $v)
1113 {
1114 $news[$k]["ref_id"] = $ref_id[$v["context_obj_id"]];
1115 }
1117
1118 // sort and return
1119 $data = ilUtil::sortArray($data, "creation_date", "desc", false, true);
1120
1121 if (!$a_prevent_aggregation)
1122 {
1123 $data = $this->aggregateFiles($data, $a_ref_id);
1124 }
1125
1126 return $data;
1127 }
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.
queryNewsForMultipleContexts($a_contexts, $a_for_rss_use=false, $a_time_period=0, $a_starting_date="", $a_no_auto_generated=false, $a_user_id=null, $a_limit=0, $a_exclude=array())
Query News for multiple Contexts.
static filterObjIdsPerNews($a_obj_ids, $a_time_period=0, $a_starting_date="", $a_ending_date='', $ignore_period=false)
Checks whether news are available for.
aggregateFiles($news, $a_ref_id)

References $data, $ref_id, 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 884 of file class.ilNewsItem.php.

887 {
888 global $tree, $ilAccess, $ilObjDataCache;
889
890 // get news of parent object
891
892 $data = array();
893
894 // get subtree
895 $cur_node = $tree->getNodeData($a_ref_id);
896
897 // do not check for lft (materialized path)
898 if($cur_node)
899 {
900 $nodes = (array) $tree->getSubTree($cur_node,true);
901 }
902 else
903 {
904 $nodes = array();
905 }
906
907 // preload object data cache
908 $ref_ids = array();
909 $obj_ids = array();
910 foreach($nodes as $node)
911 {
912 $ref_ids[] = $node["child"];
913 $obj_ids[] = $node["obj_id"];
914 }
915
916 $ilObjDataCache->preloadReferenceCache($ref_ids);
917 if (!$a_only_public)
918 {
919 include_once "Services/Object/classes/class.ilObjectActivation.php";
921 }
922
923 // no check, for which of the objects any news are available
924 $news_obj_ids = ilNewsItem::filterObjIdsPerNews($obj_ids, $a_time_period, $a_starting_date);
925 //$news_obj_ids = $obj_ids;
926
927 // get news for all subtree nodes
928 $contexts = array();
929 foreach($nodes as $node)
930 {
931 // only go on, if news are available
932 if (!in_array($node["obj_id"], $news_obj_ids))
933 {
934 continue;
935 }
936
937 if (!$a_only_public)
938 {
939 if(!$a_user_id)
940 {
941 $acc = $ilAccess->checkAccess("read", "", $node["child"]);
942 }
943 else
944 {
945 $acc = $ilAccess->checkAccessOfUser($a_user_id, "read", "",
946 $node["child"]);
947 }
948 if (!$acc)
949 {
950 continue;
951 }
952 }
953
954 $ref_id[$node["obj_id"]] = $node["child"];
955 $contexts[] = array("obj_id" => $node["obj_id"],
956 "obj_type" => $node["type"]);
957 }
958
959 // sort and return
960 $news = $this->queryNewsForMultipleContexts($contexts, $a_only_public, $a_time_period,
961 $a_starting_date, $a_no_auto_generated, $a_user_id, $a_limit, $a_exclude);
962
963 $to_del = array();
964 foreach ($news as $k => $v)
965 {
966 $news[$k]["ref_id"] = $ref_id[$v["context_obj_id"]];
967 }
968
970 $data = ilUtil::sortArray($data, "creation_date", "desc", false, true);
971
972 if (!$a_prevent_aggregation)
973 {
974 $data = $this->aggregateFiles($data, $a_ref_id);
975 }
976
977 return $data;
978 }
static preloadData(array $a_ref_ids)
Preload data to internal cache.

References $data, $ref_id, 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 129 of file class.ilNewsItem.php.

130 {
131 return $this->content;
132 }

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 530 of file class.ilNewsItem.php.

531 {
532 return $this->content_html;
533 }

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 389 of file class.ilNewsItem.php.

390 {
392 }

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 349 of file class.ilNewsItem.php.

350 {
351 return $this->content_long;
352 }

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 470 of file class.ilNewsItem.php.

471 {
472 return $this->content_text_is_lang_var;
473 }

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 229 of file class.ilNewsItem.php.

230 {
231 return $this->content_type;
232 }

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 149 of file class.ilNewsItem.php.

150 {
152 }

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 169 of file class.ilNewsItem.php.

170 {
172 }

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 189 of file class.ilNewsItem.php.

190 {
192 }

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 209 of file class.ilNewsItem.php.

210 {
212 }

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 249 of file class.ilNewsItem.php.

250 {
252 }

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 1782 of file class.ilNewsItem.php.

1784 {
1785 global $ilDB;
1786
1787 // Determine how many rows should be deleted
1788 $query = "SELECT * ".
1789 "FROM il_news_item ".
1790 "WHERE ".
1791 "context_obj_id = ".$ilDB->quote($a_context_obj_id, "integer").
1792 " AND context_obj_type = ".$ilDB->quote($a_context_obj_type, "text").
1793 " AND context_sub_obj_id = ".$ilDB->quote($a_context_sub_obj_id, "integer").
1794 " AND ".$ilDB->equals("context_sub_obj_type", $a_context_sub_obj_type, "text", true);
1795
1796 $set = $ilDB->query($query);
1797 $rec = $ilDB->fetchAssoc($set);
1798
1799 return $rec["id"];
1800 }

References $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 89 of file class.ilNewsItem.php.

90 {
91 return $this->id;
92 }

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 1805 of file class.ilNewsItem.php.

1808 {
1809 global $ilDB;
1810
1811 // Determine how many rows should be deleted
1812 $query = "SELECT id, update_date ".
1813 "FROM il_news_item ".
1814 "WHERE ".
1815 "context_obj_id = ".$ilDB->quote($a_context_obj_id, "integer").
1816 " AND context_obj_type = ".$ilDB->quote($a_context_obj_type, "text").
1817 " AND context_sub_obj_id = ".$ilDB->quote($a_context_sub_obj_id, "integer").
1818 " AND ".$ilDB->equals("context_sub_obj_type", $a_context_sub_obj_type, "text", true).
1819 " ORDER BY update_date DESC";
1820
1821 $ilDB->setLimit(1);
1822 $set = $ilDB->query($query);
1823 $rec = $ilDB->fetchAssoc($set);
1824
1825 $id = (int) $rec["id"];
1826 if ($a_only_today)
1827 {
1828 $now = ilUtil::now();
1829 if (substr($now, 0, 10) != substr($rec["update_date"], 0, 10))
1830 {
1831 $id = 0;
1832 }
1833 }
1834
1835 return $id;
1836 }

References $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 450 of file class.ilNewsItem.php.

451 {
452 return $this->limitation;
453 }

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 510 of file class.ilNewsItem.php.

511 {
512 return $this->mob_cnt_download;
513 }

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 409 of file class.ilNewsItem.php.

410 {
411 return $this->mob_id;
412 }

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 490 of file class.ilNewsItem.php.

491 {
492 return $this->mob_cnt_play;
493 }

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 809 of file class.ilNewsItem.php.

812 {
813 $obj_id = ilObject::_lookupObjId($a_ref_id);
814 $obj_type = ilObject::_lookupType($obj_id);
815
816 // get starting date
817 $starting_date = "";
818 if ($obj_type == "grp" || $obj_type == "crs" || $obj_type == "cat")
819 {
820 include_once("./Services/Block/classes/class.ilBlockSetting.php");
821 $hide_news_per_date = ilBlockSetting::_lookup("news", "hide_news_per_date",
822 0, $obj_id);
823 if ($hide_news_per_date && !$a_ignore_date_filter)
824 {
825 $starting_date = ilBlockSetting::_lookup("news", "hide_news_date",
826 0, $obj_id);
827 }
828 }
829
830 if ($obj_type == "cat" && !$a_stopnesting)
831 {
832 $news = $this->getAggregatedChildNewsData($a_ref_id, $a_only_public, $a_time_period,
833 $a_prevent_aggregation, $starting_date, $a_no_auto_generated);
834 }
835 else if (($obj_type == "grp" || $obj_type == "crs") &&
836 !$a_stopnesting)
837 {
838 $news = $this->getAggregatedNewsData($a_ref_id, $a_only_public, $a_time_period,
839 $a_prevent_aggregation, $starting_date, $a_no_auto_generated, $a_user_id, $a_limit, $a_excluded);
840 }
841 else
842 {
843 $news_item = new ilNewsItem();
844 $news_item->setContextObjId($obj_id);
845 $news_item->setContextObjType($obj_type);
846 $news = $news_item->queryNewsForContext($a_only_public, $a_time_period,
847 $starting_date, $a_no_auto_generated);
848 $unset = array();
849 foreach ($news as $k => $v)
850 {
851 if (!$a_only_public || $v["visibility"] == NEWS_PUBLIC ||
852 ($v["priority"] == 0 &&
853 ilBlockSetting::_lookup("news", "public_notifications",
854 0, $obj_id)))
855 {
856 $news[$k]["ref_id"] = $a_ref_id;
857 }
858 else
859 {
860 $unset[] = $k;
861 }
862 }
863 foreach ($unset as $un)
864 {
865 unset($news[$un]);
866 }
867 }
868
869 if (!$a_prevent_aggregation)
870 {
871 $news = $this->aggregateForums($news);
872 }
873 else if ($a_forum_group_sequences)
874 {
875 $news = $this->aggregateForums($news, true);
876 }
877
878 return $news;
879 }
const NEWS_PUBLIC
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.
aggregateForums($news, $a_group_posting_sequence=false)
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.

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 429 of file class.ilNewsItem.php.

430 {
431 return $this->playtime;
432 }

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 369 of file class.ilNewsItem.php.

370 {
371 return $this->priority;
372 }

References $priority.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getPrivateFeedId()

static ilNewsItem::getPrivateFeedId ( )
static

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

1928 {
1929
1931 }
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 109 of file class.ilNewsItem.php.

110 {
111 return $this->title;
112 }

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 269 of file class.ilNewsItem.php.

270 {
271 return $this->update_date;
272 }

References $update_date.

◆ getUpdateUserId()

ilNewsItem::getUpdateUserId ( )

Get update user id.

Returns
int update user id

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

310 {
312 }

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 289 of file class.ilNewsItem.php.

290 {
291 return $this->user_id;
292 }

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 329 of file class.ilNewsItem.php.

330 {
331 return $this->visibility;
332 }

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 1146 of file class.ilNewsItem.php.

1147 {
1148 // time period is number of days
1149 if(is_numeric($a_time_period))
1150 {
1151 if($a_time_period > 0)
1152 {
1153 return date('Y-m-d H:i:s', time() - ($a_time_period * 24 * 60 * 60));
1154 }
1155 }
1156 // time period is datetime
1157 else if(preg_match("/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/", $a_time_period))
1158 {
1159 return $a_time_period;
1160 }
1161 // :TODO: what to return?
1162 }
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 1987 of file class.ilNewsItem.php.

1988 {
1989 global $ilDB;
1990
1991 $cnt = $this->getMobDownloadCounter();
1992 $cnt++;
1993 $this->setMobDownloadCounter($cnt);
1994 $ilDB->manipulate("UPDATE il_news_item SET ".
1995 " mob_cnt_download = ".$ilDB->quote($cnt, "integer").
1996 " WHERE id = ".$ilDB->quote($this->getId(), "integer")
1997 );
1998 }
getMobDownloadCounter()
Get mob download counter.
setMobDownloadCounter($a_val)
Set mob download counter.

References $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 2006 of file class.ilNewsItem.php.

2007 {
2008 global $ilDB;
2009
2010 $cnt = $this->getMobPlayCounter();
2011 $cnt++;
2012 $this->setMobPlayCounter($cnt);
2013 $ilDB->manipulate("UPDATE il_news_item SET ".
2014 " mob_cnt_play = ".$ilDB->quote($cnt, "integer").
2015 " WHERE id = ".$ilDB->quote($this->getId(), "integer")
2016 );
2017 }
setMobPlayCounter($a_val)
Set mob play counter.
getMobPlayCounter()
Get mob play counter.

References $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 1493 of file class.ilNewsItem.php.

1494 {
1495 foreach($n2 as $id => $news)
1496 {
1497 $n1[$id] = $news;
1498 }
1499
1500 return $n1;
1501 }

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 2025 of file class.ilNewsItem.php.

2026 {
2027 global $ilDB;
2028
2029 $data = $a_cres;
2030 $news_ids = array_keys($data);
2031 $set = $ilDB->query("SELECT id FROM il_news_item ".
2032 " WHERE ".$ilDB->in("id", $news_ids, false, "integer"));
2033 $existing_ids = array();
2034 while ($rec = $ilDB->fetchAssoc($set))
2035 {
2036 $existing_ids[] = $rec["id"];
2037 }
2038 //var_dump($existing_ids);
2039 $existing_news = array();
2040 foreach ($data as $k => $v)
2041 {
2042 if (in_array($k, $existing_ids))
2043 {
2044 $existing_news[$k] = $v;
2045 }
2046 }
2047
2048 //var_dump($data);
2049 //var_dump($existing_news);
2050
2051 return $existing_news;
2052 }

References $data, 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 1172 of file class.ilNewsItem.php.

1174 {
1175 global $ilDB, $ilUser, $lng;
1176
1177 $and = "";
1178 if ($a_time_period > 0)
1179 {
1180 $limit_ts = self::handleTimePeriod($a_time_period);
1181 $and = " AND creation_date >= ".$ilDB->quote($limit_ts, "timestamp")." ";
1182 }
1183
1184 if ($a_starting_date != "")
1185 {
1186 $and.= " AND creation_date > ".$ilDB->quote($a_starting_date, "timestamp")." ";
1187 }
1188
1189 if ($a_no_auto_generated)
1190 {
1191 $and.= " AND priority = 1 AND content_type = ".$ilDB->quote("text", "text")." ";
1192 }
1193
1194 // this is changed with 4.1 (news table for lm pages)
1195 if ($this->getContextSubObjId() > 0)
1196 {
1197 $and.= " AND context_sub_obj_id = ".$ilDB->quote($this->getContextSubObjId(), "integer").
1198 " AND context_sub_obj_type = ".$ilDB->quote($this->getContextSubObjType(), "text");
1199 }
1200
1201 $ordering = ($a_oldest_first)
1202 ? " creation_date ASC, id ASC "
1203 : " creation_date DESC, id DESC ";
1204
1205 if ($a_for_rss_use && ilNewsItem::getPrivateFeedId() == false)
1206 {
1207 $query = "SELECT * ".
1208 "FROM il_news_item ".
1209 " WHERE ".
1210 "context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
1211 " AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
1212 $and.
1213 " ORDER BY ".$ordering;
1214 }
1215 elseif (ilNewsItem::getPrivateFeedId() != false)
1216 {
1217 $query = "SELECT il_news_item.* ".
1218 ", il_news_read.user_id user_read ".
1219 "FROM il_news_item LEFT JOIN il_news_read ".
1220 "ON il_news_item.id = il_news_read.news_id AND ".
1221 " il_news_read.user_id = ".$ilDB->quote(ilNewsItem::getPrivateFeedId(), "integer").
1222 " WHERE ".
1223 "context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
1224 " AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
1225 $and.
1226 " ORDER BY ".$ordering;
1227 }
1228 else
1229 {
1230 $query = "SELECT il_news_item.* ".
1231 ", il_news_read.user_id as user_read ".
1232 "FROM il_news_item LEFT JOIN il_news_read ".
1233 "ON il_news_item.id = il_news_read.news_id AND ".
1234 " il_news_read.user_id = ".$ilDB->quote($ilUser->getId(), "integer").
1235 " WHERE ".
1236 "context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
1237 " AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
1238 $and.
1239 " ORDER BY ".$ordering;
1240 }
1241//echo $query;
1242 $set = $ilDB->query($query);
1243 $result = array();
1244 while($rec = $ilDB->fetchAssoc($set))
1245 {
1246 if ($a_limit > 0 && count($result) >= $a_limit)
1247 {
1248 continue;
1249 }
1250 if (!$a_for_rss_use || (ilNewsItem::getPrivateFeedId() != false) || ($rec["visibility"] == NEWS_PUBLIC ||
1251 ($rec["priority"] == 0 &&
1252 ilBlockSetting::_lookup("news", "public_notifications",
1253 0, $rec["context_obj_id"]))))
1254 {
1255 $result[$rec["id"]] = $rec;
1256 }
1257 }
1258
1259 // do we get data for rss and may the time limit by an issue?
1260 // do a second query without time limit.
1261 // this is not very performant, but I do not have a better
1262 // idea. The keep_rss_min setting is currently (Jul 2012) only set
1263 // by mediacasts
1264 if ($a_time_period != "" && $a_for_rss_use)
1265 {
1266 include_once("./Services/Block/classes/class.ilBlockSetting.php");
1267 $keep_rss_min = ilBlockSetting::_lookup("news", "keep_rss_min",
1268 0, $this->getContextObjId());
1269 if ($keep_rss_min > 0)
1270 {
1271 return $this->queryNewsForContext(true, 0,
1272 $a_starting_date, $a_no_auto_generated, $a_oldest_first, $keep_rss_min);
1273 }
1274 }
1275
1276 return $result;
1277
1278 }
$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)
$ilUser
Definition: imgupload.php:18

References $ilDB, $ilUser, $lng, $query, $result, 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 1338 of file class.ilNewsItem.php.

1341 {
1342 global $ilDB, $ilUser, $lng, $ilCtrl;
1343
1344 $and = "";
1345 if ($a_time_period > 0)
1346 {
1347 $limit_ts = self::handleTimePeriod($a_time_period);
1348 $and = " AND creation_date >= ".$ilDB->quote($limit_ts, "timestamp")." ";
1349 }
1350
1351 if ($a_starting_date != "")
1352 {
1353 $and.= " AND creation_date > ".$ilDB->quote($a_starting_date, "timestamp")." ";
1354 }
1355
1356 if ($a_no_auto_generated)
1357 {
1358 $and.= " AND priority = 1 AND content_type = ".$ilDB->quote("text", "text")." ";
1359 }
1360
1361 if ($a_limit > 0)
1362 {
1363 $ilDB->setLimit($a_limit, 0);
1364 }
1365
1366 if (is_array($a_exclude) && count($a_exclude) > 0)
1367 {
1368 $and.= " AND ".$ilDB->in("id", $a_exclude, true, "integer")." ";
1369 }
1370
1371 $ids = array();
1372 $type = array();
1373
1374 foreach($a_contexts as $cont)
1375 {
1376 $ids[] = $cont["obj_id"];
1377 $type[$cont["obj_id"]] = $cont["obj_type"];
1378 }
1379
1380 if ($a_for_rss_use && ilNewsItem::getPrivateFeedId() == false)
1381 {
1382 $query = "SELECT * ".
1383 "FROM il_news_item ".
1384 " WHERE ".
1385 $ilDB->in("context_obj_id", $ids, false, "integer")." ".
1386 $and.
1387 " ORDER BY creation_date DESC ";
1388 }
1389 elseif (ilNewsItem::getPrivateFeedId() != false)
1390 {
1391 $query = "SELECT il_news_item.* ".
1392 ", il_news_read.user_id as user_read ".
1393 "FROM il_news_item LEFT JOIN il_news_read ".
1394 "ON il_news_item.id = il_news_read.news_id AND ".
1395 " il_news_read.user_id = ".$ilDB->quote(ilNewsItem::getPrivateFeedId(), "integer").
1396 " WHERE ".
1397 $ilDB->in("context_obj_id", $ids, false, "integer")." ".
1398 $and.
1399 " ORDER BY creation_date DESC ";
1400 }
1401 else
1402 {
1403 if($a_user_id)
1404 {
1405 $user_id = $a_user_id;
1406 }
1407 else
1408 {
1409 $user_id = $ilUser->getId();
1410 }
1411 $query = "SELECT il_news_item.* ".
1412 ", il_news_read.user_id as user_read ".
1413 "FROM il_news_item LEFT JOIN il_news_read ".
1414 "ON il_news_item.id = il_news_read.news_id AND ".
1415 " il_news_read.user_id = ".$ilDB->quote($user_id, "integer").
1416 " WHERE ".
1417 $ilDB->in("context_obj_id", $ids, false, "integer")." ".
1418 $and.
1419 " ORDER BY creation_date DESC ";
1420 }
1421
1422 $set = $ilDB->query($query);
1423 $result = array();
1424 while($rec = $ilDB->fetchAssoc($set))
1425 {
1426 if ($type[$rec["context_obj_id"]] == $rec["context_obj_type"])
1427 {
1428 if (!$a_for_rss_use || ilNewsItem::getPrivateFeedId() != false || ($rec["visibility"] == NEWS_PUBLIC ||
1429 ($rec["priority"] == 0 &&
1430 ilBlockSetting::_lookup("news", "public_notifications",
1431 0, $rec["context_obj_id"]))))
1432 {
1433 $result[$rec["id"]] = $rec;
1434 }
1435 }
1436 }
1437
1438 return $result;
1439
1440 }
global $ilCtrl
Definition: ilias.php:18

References $ilCtrl, $ilDB, $ilUser, $lng, $query, $result, $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 538 of file class.ilNewsItem.php.

539 {
540 global $ilDB;
541
542 $query = "SELECT * FROM il_news_item WHERE id = ".
543 $ilDB->quote($this->getId(), "integer");
544 $set = $ilDB->query($query);
545 $rec = $ilDB->fetchAssoc($set);
546
547 $this->setTitle($rec["title"]);
548 $this->setContent($rec["content"]);
549 $this->setContextObjId((int) $rec["context_obj_id"]);
550 $this->setContextObjType($rec["context_obj_type"]);
551 $this->setContextSubObjId((int) $rec["context_sub_obj_id"]);
552 $this->setContextSubObjType($rec["context_sub_obj_type"]);
553 $this->setContentType($rec["content_type"]);
554 $this->setCreationDate($rec["creation_date"]);
555 $this->setUpdateDate($rec["update_date"]);
556 $this->setUserId($rec["user_id"]);
557 $this->setUpdateUserId($rec["update_user_id"]);
558 $this->setVisibility($rec["visibility"]);
559 $this->setContentLong($rec["content_long"]);
560 $this->setPriority($rec["priority"]);
561 $this->setContentIsLangVar($rec["content_is_lang_var"]);
562 $this->setContentTextIsLangVar((int) $rec["content_text_is_lang_var"]);
563 $this->setMobId($rec["mob_id"]);
564 $this->setPlaytime($rec["playtime"]);
565 $this->setMobPlayCounter($rec["mob_cnt_play"]);
566 $this->setMobDownloadCounter($rec["mob_cnt_download"]);
567 $this->setContentHtml($rec["content_html"]);
568
569 }
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 $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 119 of file class.ilNewsItem.php.

120 {
121 $this->content = $a_content;
122 }

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 520 of file class.ilNewsItem.php.

521 {
522 $this->content_html = $a_val;
523 }

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 379 of file class.ilNewsItem.php.

380 {
381 $this->content_is_lang_var = $a_content_is_lang_var;
382 }

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 339 of file class.ilNewsItem.php.

340 {
341 $this->content_long = $a_content_long;
342 }

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 460 of file class.ilNewsItem.php.

461 {
462 $this->content_text_is_lang_var = $a_val;
463 }

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 219 of file class.ilNewsItem.php.

220 {
221 $this->content_type = $a_content_type;
222 }

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 1132 of file class.ilNewsItem.php.

1133 {
1134 $this->setContextObjId($a_obj_id);
1135 $this->setContextObjType($a_obj_type);
1136 $this->setContextSubObjId($a_sub_obj_id);
1137 $this->setContextSubObjType($a_sub_obj_type);
1138 }

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 139 of file class.ilNewsItem.php.

140 {
141 $this->context_obj_id = $a_context_obj_id;
142 }

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 159 of file class.ilNewsItem.php.

160 {
161 $this->context_obj_type = $a_context_obj_type;
162 }

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 179 of file class.ilNewsItem.php.

180 {
181 $this->context_sub_obj_id = $a_context_sub_obj_id;
182 }

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 199 of file class.ilNewsItem.php.

200 {
201 $this->context_sub_obj_type = $a_context_sub_obj_type;
202 }

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 239 of file class.ilNewsItem.php.

240 {
241 $this->creation_date = $a_creation_date;
242 }

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 79 of file class.ilNewsItem.php.

80 {
81 $this->id = $a_id;
82 }

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 440 of file class.ilNewsItem.php.

441 {
442 $this->limitation = $a_limitation;
443 }

◆ setMobDownloadCounter()

ilNewsItem::setMobDownloadCounter (   $a_val)

Set mob download counter.

Parameters
int$a_valcounter

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

501 {
502 $this->mob_cnt_download = $a_val;
503 }

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 399 of file class.ilNewsItem.php.

400 {
401 $this->mob_id = $a_mob_id;
402 }

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 480 of file class.ilNewsItem.php.

481 {
482 $this->mob_cnt_play = $a_val;
483 }

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 419 of file class.ilNewsItem.php.

420 {
421 $this->playtime = $a_playtime;
422 }

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 359 of file class.ilNewsItem.php.

360 {
361 $this->priority = $a_priority;
362 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setPrivateFeedId()

static ilNewsItem::setPrivateFeedId (   $a_userId)
static

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

1924 {
1925 ilNewsItem::$privFeedId = $a_userId;
1926 }

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 99 of file class.ilNewsItem.php.

100 {
101 $this->title = $a_title;
102 }

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 259 of file class.ilNewsItem.php.

260 {
261 $this->update_date = $a_update_date;
262 }

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 299 of file class.ilNewsItem.php.

300 {
301 $this->update_user_id = $a_val;
302 }

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 279 of file class.ilNewsItem.php.

280 {
281 $this->user_id = $a_user_id;
282 }

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 319 of file class.ilNewsItem.php.

320 {
321 $this->visibility = $a_visibility;
322 }

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 654 of file class.ilNewsItem.php.

655 {
656 global $ilDB;
657
658 $fields = array(
659 "title" => array("text", $this->getTitle()),
660 "content" => array("clob", $this->getContent()),
661 "content_html" => array("integer", (int) $this->getContentHtml()),
662 "context_obj_id" => array("integer", $this->getContextObjId()),
663 "context_obj_type" => array("text", $this->getContextObjType()),
664 "context_sub_obj_id" => array("integer", $this->getContextSubObjId()),
665 "context_sub_obj_type" => array("text", $this->getContextSubObjType()),
666 "content_type" => array("text", $this->getContentType()),
667 "user_id" => array("integer", $this->getUserId()),
668 "update_user_id" => array("integer", (int) $this->getUpdateUserId()),
669 "visibility" => array("text", $this->getVisibility()),
670 "content_long" => array("clob", $this->getContentLong()),
671 "priority" => array("integer", $this->getPriority()),
672 "content_is_lang_var" => array("integer", $this->getContentIsLangVar()),
673 "content_text_is_lang_var" => array("integer", (int) $this->getContentTextIsLangVar()),
674 "mob_id" => array("integer", $this->getMobId()),
675 "mob_cnt_play" => array("integer", $this->getMobPlayCounter()),
676 "mob_cnt_download" => array("integer", $this->getMobDownloadCounter()),
677 "playtime" => array("text", $this->getPlaytime())
678 );
679
680 $now = ilUtil::now();
681 if ($a_as_new)
682 {
683 $fields["creation_date"] = array("timestamp", $now);
684 $fields["update_date"] = array("timestamp", $now);
685 }
686 else
687 {
688 $fields["update_date"] = array("timestamp", $now);
689 }
690
691 $ilDB->update("il_news_item", $fields, array(
692 "id" => array("integer", $this->getId())
693 ));
694
695 }

References $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

◆ $content

ilNewsItem::$content
protected

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

Referenced by getContent().

◆ $content_html

ilNewsItem::$content_html
protected

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

Referenced by getContentHtml().

◆ $content_is_lang_var

ilNewsItem::$content_is_lang_var = 0
protected

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

Referenced by getContentIsLangVar().

◆ $content_long

ilNewsItem::$content_long
protected

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

Referenced by getContentLong().

◆ $content_type

ilNewsItem::$content_type = "text"
protected

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

Referenced by getContentType().

◆ $context_obj_id

ilNewsItem::$context_obj_id
protected

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

Referenced by getContextObjId().

◆ $context_obj_type

ilNewsItem::$context_obj_type
protected

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

Referenced by getContextObjType().

◆ $context_sub_obj_id

ilNewsItem::$context_sub_obj_id
protected

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

Referenced by getContextSubObjId().

◆ $context_sub_obj_type

ilNewsItem::$context_sub_obj_type
protected

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

Referenced by getContextSubObjType().

◆ $creation_date

ilNewsItem::$creation_date
protected

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

Referenced by getCreationDate().

◆ $id

ilNewsItem::$id
protected

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

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

◆ $limitation

ilNewsItem::$limitation
private

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

Referenced by getLimitation().

◆ $mob_id

ilNewsItem::$mob_id
protected

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

Referenced by getMobId().

◆ $playtime

ilNewsItem::$playtime
protected

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

Referenced by getPlaytime().

◆ $priority

ilNewsItem::$priority = 1
protected

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

Referenced by getPriority().

◆ $privFeedId

ilNewsItem::$privFeedId = false
staticprivate

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

Referenced by getPrivateFeedId(), and setPrivateFeedId().

◆ $title

ilNewsItem::$title
protected

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

Referenced by getTitle().

◆ $update_date

ilNewsItem::$update_date
protected

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

Referenced by getUpdateDate().

◆ $update_user_id

ilNewsItem::$update_user_id
protected

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

Referenced by getUpdateUserId().

◆ $user_id

ilNewsItem::$user_id
protected

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

Referenced by getUserId(), and queryNewsForMultipleContexts().

◆ $visibility

ilNewsItem::$visibility = "users"
protected

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

Referenced by _getDefaultVisibilityForRefId(), and getVisibility().


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