ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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...
 
 setContext (int $a_obj_id, string $a_obj_type, int $a_sub_obj_id=0, string $a_sub_obj_type="")
 Set context for news. More...
 
 queryNewsForContext ( $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...
 
 checkNewsExistsForObjects ($objects, $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 queryNewsByIds (array $a_news_ids)
 Query news data by news ids. 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 getNewsOfContext ( $a_context_obj_id, $a_context_obj_type, $a_context_sub_obj_id=0, $a_context_sub_obj_type="")
 Get all news of a context. 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 determineNewsTitleByNewsId ($a_news_id, $a_agg_ref_id=0, $a_aggregation="")
 Determine title for news item entry. 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...
 

Protected Member Functions

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

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

Constructor & Destructor Documentation

◆ __construct()

ilNewsItem::__construct (   $a_id = 0)

Constructor.

Parameters
int$a_id

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

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

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

Deprecated:
will move to ilNewsData
Parameters
$a_ref_idreference id

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

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

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

1630  {
1631  global $DIC;
1632 
1633  $tree = $DIC->repositoryTree();
1634  $ilSetting = $DIC->settings();
1635 
1636  include_once("./Services/Block/classes/class.ilBlockSetting.php");
1637 
1638  $news_set = new ilSetting("news");
1639  $default_visibility = ($news_set->get("default_visibility") != "")
1640  ? $news_set->get("default_visibility")
1641  : "users";
1642 
1643  if ($tree->isInTree($a_ref_id)) {
1644  $path = $tree->getPathFull($a_ref_id);
1645 
1646  foreach ($path as $key => $row) {
1647  if (!in_array($row["type"], array("root", "cat","crs", "fold", "grp"))) {
1648  continue;
1649  }
1650 
1652  "news",
1653  "default_visibility",
1654  0,
1655  $row["obj_id"]
1656  );
1657 
1658  if ($visibility != "") {
1659  $default_visibility = $visibility;
1660  }
1661  }
1662  }
1663 
1664  return $default_visibility;
1665  }
$path
Definition: aliased.php:25
global $DIC
Definition: saml.php:7
static _lookup($a_type, $a_setting, $a_user=0, $a_block_id=0)
Lookup setting from database.
$row
global $ilSetting
Definition: privfeed.php:17
$key
Definition: croninfo.php:18
+ 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.

Deprecated:
(will migrate to ilNewsData)

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

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().

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

Deprecated:
will move to ilNewsData

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

References $DIC, $ilDB, and $query.

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

2049  {
2050  global $DIC;
2051 
2052  $ilDB = $DIC->database();
2053 
2054  $query = "SELECT * " .
2055  "FROM il_news_item " .
2056  "WHERE " .
2057  " id = " . $ilDB->quote($a_news_id, "integer");
2058  $set = $ilDB->query($query);
2059  $rec = $ilDB->fetchAssoc($set);
2060 
2061  return $rec["context_obj_id"];
2062  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupDefaultPDPeriod()

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

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

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

2068  {
2069  $news_set = new ilSetting("news");
2070  $per = $news_set->get("pd_period");
2071  if ($per == 0) {
2072  $per = 30;
2073  }
2074 
2075  return $per;
2076  }
+ Here is the caller graph for this function:

◆ _lookupMediaObjectUsages()

static ilNewsItem::_lookupMediaObjectUsages (   $a_mob_id)
static

Lookup media object usage(s)

Deprecated:
will move to ilNewsData

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

References $DIC, $ilDB, and $query.

Referenced by ilObjMediaObject\lookupUsages().

2025  {
2026  global $DIC;
2027 
2028  $ilDB = $DIC->database();
2029 
2030  $query = "SELECT * " .
2031  "FROM il_news_item " .
2032  "WHERE " .
2033  " mob_id = " . $ilDB->quote($a_mob_id, "integer");
2034 
2035  $usages = array();
2036  $set = $ilDB->query($query);
2037  while ($rec = $ilDB->fetchAssoc($set)) {
2038  $usages[$rec["id"]] = array("type" => "news", "id" => $rec["id"]);
2039  }
2040 
2041  return $usages;
2042  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupMobId()

static ilNewsItem::_lookupMobId (   $a_news_id)
static

Lookup mob id.

Deprecated:
will move to ilNewsData

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

References $DIC, $ilDB, and $query.

Referenced by ilNewsExporter\getXmlExportHeadDependencies().

1794  {
1795  global $DIC;
1796 
1797  $ilDB = $DIC->database();
1798 
1799  $query = "SELECT mob_id FROM il_news_item WHERE id = " .
1800  $ilDB->quote($a_news_id, "integer");
1801  $set = $ilDB->query($query);
1802  $rec = $ilDB->fetchAssoc($set);
1803  return $rec["mob_id"];
1804  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupRSSPeriod()

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

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

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

2111  {
2112  $news_set = new ilSetting("news");
2113  $rss_period = $news_set->get("rss_period");
2114  if ($rss_period == 0) { // default to two weeks
2115  $rss_period = 14;
2116  }
2117  return $rss_period;
2118  }
+ Here is the caller graph for this function:

◆ _lookupTitle()

static ilNewsItem::_lookupTitle (   $a_news_id)
static

Lookup News Title.

Deprecated:
will move to ilNewsData

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

References $DIC, $ilDB, and $query.

1759  {
1760  global $DIC;
1761 
1762  $ilDB = $DIC->database();
1763 
1764  $query = "SELECT title FROM il_news_item WHERE id = " .
1765  $ilDB->quote($a_news_id, "integer");
1766  $set = $ilDB->query($query);
1767  $rec = $ilDB->fetchAssoc($set);
1768  return $rec["title"];
1769  }
global $DIC
Definition: saml.php:7
$query
global $ilDB

◆ _lookupUserPDPeriod()

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

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

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

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

2082  {
2083  $news_set = new ilSetting("news");
2084  $allow_shorter_periods = $news_set->get("allow_shorter_periods");
2085  $allow_longer_periods = $news_set->get("allow_longer_periods");
2086  $default_per = ilNewsItem::_lookupDefaultPDPeriod();
2087 
2088  include_once("./Services/Block/classes/class.ilBlockSetting.php");
2089  $per = ilBlockSetting::_lookup(
2090  "pdnews",
2091  "news_pd_period",
2092  $a_user_id,
2093  0
2094  );
2095 
2096  // news period information
2097  if ($per <= 0 ||
2098  (!$allow_shorter_periods && ($per < $default_per)) ||
2099  (!$allow_longer_periods && ($per > $default_per))
2100  ) {
2101  $per = $default_per;
2102  }
2103 
2104  return $per;
2105  }
static _lookup($a_type, $a_setting, $a_user=0, $a_block_id=0)
Lookup setting from database.
static _lookupDefaultPDPeriod()
+ 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.

Deprecated:
will move to ilNewsData

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

References $DIC, $ilDB, and $query.

Referenced by ilObjMediaObjectAccess\checkAccessMob().

1776  {
1777  global $DIC;
1778 
1779  $ilDB = $DIC->database();
1780 
1781  $query = "SELECT visibility FROM il_news_item WHERE id = " .
1782  $ilDB->quote($a_news_id, "integer");
1783  $set = $ilDB->query($query);
1784  $rec = $ilDB->fetchAssoc($set);
1785 
1786  return $rec["visibility"];
1787  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _setRead()

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

Set item read.

Deprecated:
will move to ilNewsData

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

References $DIC, and $ilDB.

Referenced by ilNewsForContextBlockGUI\showNews().

1555  {
1556  global $DIC;
1557 
1558  $ilDB = $DIC->database();
1559  $ilAppEventHandler = $DIC["ilAppEventHandler"];
1560 
1561  $ilDB->replace(
1562  "il_news_read",
1563  array(
1564  "user_id" => array("integer", $a_user_id),
1565  "news_id" => array("integer", $a_news_id)
1566  ),
1567  array()
1568  );
1569 
1570  /*
1571  $ilDB->manipulate("DELETE FROM il_news_read WHERE ".
1572  "user_id = ".$ilDB->quote($a_user_id, "integer").
1573  " AND news_id = ".$ilDB->quote($a_news_id, "integer"));
1574  $ilDB->manipulate("INSERT INTO il_news_read (user_id, news_id) VALUES (".
1575  $ilDB->quote($a_user_id, "integer").",".
1576  $ilDB->quote($a_news_id, "integer").")");*/
1577 
1578  $ilAppEventHandler->raise(
1579  "Services/News",
1580  "readNews",
1581  array("user_id" => $a_user_id, "news_ids" => array($a_news_id))
1582  );
1583  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ _setUnread()

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

Set item unread.

Deprecated:
will move to ilNewsData

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

References $DIC, and $ilDB.

1590  {
1591  global $DIC;
1592 
1593  $ilDB = $DIC->database();
1594  $ilAppEventHandler = $DIC["ilAppEventHandler"];
1595 
1596  $ilDB->manipulate("DELETE FROM il_news_read (user_id, news_id) VALUES (" .
1597  " WHERE user_id = " . $ilDB->quote($a_user_id, "integer") .
1598  " AND news_id = " . $ilDB->quote($a_news_id, "integer"));
1599 
1600  $ilAppEventHandler->raise(
1601  "Services/News",
1602  "unreadNews",
1603  array("user_id" => $a_user_id, "news_ids" => array($a_news_id))
1604  );
1605  }
global $DIC
Definition: saml.php:7
global $ilDB

◆ aggregateFiles()

ilNewsItem::aggregateFiles (   $news,
  $a_ref_id 
)
protected
Deprecated:
will move to ilNewsData
Parameters
$news
$a_ref_id
Returns
mixed

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

Referenced by getAggregatedChildNewsData(), and getAggregatedNewsData().

1118  {
1119  $first_file = "";
1120  $to_del = array();
1121  foreach ($news as $k => $v) {
1122  // aggregate file related news
1123  if ($news[$k]["context_obj_type"] == "file") {
1124  if ($first_file == "") {
1125  $first_file = $k;
1126  } else {
1127  $to_del[] = $k;
1128  }
1129  $news[$first_file]["aggregation"][$k] = $news[$k];
1130  $news[$first_file]["agg_ref_id"] = $a_ref_id;
1131  $news[$first_file]["ref_id"] = $a_ref_id;
1132  }
1133  }
1134 
1135  foreach ($to_del as $v) {
1136  unset($news[$v]);
1137  }
1138 
1139  return $news;
1140  }
+ Here is the caller graph for this function:

◆ aggregateForums()

ilNewsItem::aggregateForums (   $news,
  $a_group_posting_sequence = false 
)
protected
Deprecated:
will move to ilNewsData
Parameters
$news
bool$a_group_posting_sequence
Returns
mixed

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

Referenced by getNewsForRefId().

1069  {
1070  $to_del = array();
1071  $forums = array();
1072 
1073  // aggregate
1074  foreach ($news as $k => $v) {
1075  if ($a_group_posting_sequence && $last_aggregation_forum > 0 &&
1076  $last_aggregation_forum != $news[$k]["context_obj_id"]) {
1077  $forums[$last_aggregation_forum] = "";
1078  }
1079 
1080  if ($news[$k]["context_obj_type"] == "frm") {
1081  if ($forums[$news[$k]["context_obj_id"]] == "") {
1082  // $forums[forum_id] = news_id;
1083  $forums[$news[$k]["context_obj_id"]] = $k;
1084  $last_aggregation_forum = $news[$k]["context_obj_id"];
1085  } else {
1086  $to_del[] = $k;
1087  }
1088 
1089  $news[$k]["no_context_title"] = true;
1090 
1091  // aggregate every forum into it's "k" news
1092  $news[$forums[$news[$k]["context_obj_id"]]]["aggregation"][$k]
1093  = $news[$k];
1094  $news[$k]["agg_ref_id"]
1095  = $news[$k]["ref_id"];
1096  $news[$k]["content"] = "";
1097  $news[$k]["content_long"] = "";
1098  }
1099  }
1100 
1101  // delete double entries
1102  foreach ($to_del as $k) {
1103  unset($news[$k]);
1104  }
1105  //var_dump($news[14]["aggregation"]);
1106 
1107 
1108  return $news;
1109  }
+ Here is the caller graph for this function:

◆ checkNewsExistsForObjects()

ilNewsItem::checkNewsExistsForObjects (   $objects,
  $a_time_period = 1 
)
Deprecated:
will move to ilNewsData
Parameters
int$a_ref_id
int$a_time_periodhours
Returns
array news item ids

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

References $db, $ilDB, and $query.

1416  {
1417  $ilDB = $this->db;
1418 
1419  $all = array();
1420 
1421  $limit_ts = self::handleTimePeriod($a_time_period);
1422 
1423  // are there any news items for relevant objects and?
1424  $query = $ilDB->query("SELECT id,context_obj_id,context_obj_type" .
1425  " FROM il_news_item" .
1426  " WHERE " . $ilDB->in("context_obj_id", array_keys($objects), false, "integer") .
1427  " AND creation_date >= " . $ilDB->quote($limit_ts, "timestamp"));
1428  while ($rec = $ilDB->fetchAssoc($query)) {
1429  if ($objects[$rec["context_obj_id"]]["type"] == $rec["context_obj_type"]) {
1430  $all[] = $rec["id"];
1431  }
1432  }
1433 
1434  return $all;
1435  }
$query
global $ilDB

◆ create()

ilNewsItem::create ( )

Create.

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

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

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().

Referenced by ilNewsData\save().

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

◆ delete()

ilNewsItem::delete ( )

Delete news item.

Deprecated:
will move to ilNewsData

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

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

1673  {
1674  $ilDB = $this->db;
1675 
1676  // delete il_news_read entries
1677  $ilDB->manipulate("DELETE FROM il_news_read " .
1678  " WHERE news_id = " . $ilDB->quote($this->getId(), "integer"));
1679 
1680  // delete multimedia object
1681  $mob = $this->getMobId();
1682 
1683  // delete
1684  $query = "DELETE FROM il_news_item" .
1685  " WHERE id = " . $ilDB->quote($this->getId(), "integer");
1686  $ilDB->manipulate($query);
1687 
1688  // delete mob after news, to have a "mob usage" of 0
1689  if ($mob > 0 and ilObject::_exists($mob)) {
1690  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1691  $mob = new ilObjMediaObject($mob);
1692  $mob->delete();
1693  }
1694  }
getMobId()
Get MobId.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
getId()
Get Id.
Class ilObjMediaObject.
$query
global $ilDB
+ 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.

Deprecated:
will move to ilNewsData

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

References $n.

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

1743  {
1744  foreach (self::getNewsOfContext(
1745  $a_context_obj_id,
1746  $a_context_obj_type,
1747  $a_context_sub_obj_id,
1748  $a_context_sub_obj_type
1749  ) as $n) {
1750  $n->delete();
1751  }
1752  }
$n
Definition: RandomTest.php:85
+ Here is the caller graph for this function:

◆ deliverMobFile()

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

Deliver mob file.

Deprecated:
will move to ?
Parameters
string$a_purpose
bool$a_increase_download_cnt
Returns
bool

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

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

2145  {
2146  $mob = $this->getMobId();
2147  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2148  $mob = new ilObjMediaObject($mob);
2149  $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
2150 
2151  // check purpose
2152  if (!$mob->hasPurposeItem($a_purpose)) {
2153  return false;
2154  }
2155 
2156  $m_item = $mob->getMediaItem($a_purpose);
2157  if ($m_item->getLocationType() != "Reference") {
2158  $file = $mob_dir . "/" . $m_item->getLocation();
2159  if (file_exists($file) && is_file($file)) {
2160  if ($a_increase_download_cnt) {
2161  $this->increaseDownloadCounter();
2162  }
2163  ilUtil::deliverFile($file, $m_item->getLocation(), "", false, false, false);
2164  return true;
2165  } else {
2166  ilUtil::sendFailure("File not found!", true);
2167  return false;
2168  }
2169  } else {
2170  if ($a_increase_download_cnt) {
2171  $this->increaseDownloadCounter();
2172  }
2173  ilUtil::redirect($m_item->getLocation());
2174  }
2175  }
getMobId()
Get MobId.
increaseDownloadCounter()
Increase download counter.
static _getDirectory($a_mob_id)
Get absolute directory.
Class ilObjMediaObject.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static redirect($a_script)
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
+ 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.

Deprecated:
will move to util?

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

References $a_content, $DIC, $lng, and ilObjectPlugin\lookupTxtById().

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

1931  {
1932  global $DIC;
1933 
1934  $lng = $DIC->language();
1935  $obj_definition = $DIC["objDefinition"];
1936 
1937  if ($a_is_lang_var) {
1938  if ($obj_definition->isPlugin($a_context_obj_type)) {
1939  return ilObjectPlugin::lookupTxtById($a_context_obj_type, $a_content);
1940  }
1941  $lng->loadLanguageModule($a_context_obj_type);
1942  return $lng->txt($a_content);
1943  } else {
1944  return $a_content;
1945  }
1946  }
static lookupTxtById($plugin_id, $lang_var)
global $DIC
Definition: saml.php:7
$a_content
Definition: workflow.php:93
+ Here is the call graph for this function:
+ 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.

Deprecated:
will move to util?

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

References $DIC, $lng, and ilObjectPlugin\lookupTxtById().

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

1872  {
1873  global $DIC;
1874 
1875  $lng = $DIC->language();
1876  $obj_definition = $DIC["objDefinition"];
1877 
1878  if ($a_agg_ref_id > 0) {
1879  $cnt = count($a_aggregation);
1880 
1881  // forums
1882  if ($a_context_obj_type == "frm") {
1883  if ($cnt > 1) {
1884  return sprintf($lng->txt("news_x_postings"), $cnt);
1885  } else {
1886  return $lng->txt("news_1_postings");
1887  }
1888  } else { // files
1889  $up_cnt = $cr_cnt = 0;
1890  foreach ($a_aggregation as $item) {
1891  if ($item["title"] == "file_updated") {
1892  $up_cnt++;
1893  } else {
1894  $cr_cnt++;
1895  }
1896  }
1897  $sep = "";
1898  if ($cr_cnt == 1) {
1899  $tit = $lng->txt("news_1_file_created");
1900  $sep = "<br />";
1901  } elseif ($cr_cnt > 1) {
1902  $tit = sprintf($lng->txt("news_x_files_created"), $cr_cnt);
1903  $sep = "<br />";
1904  }
1905  if ($up_cnt == 1) {
1906  $tit .= $sep . $lng->txt("news_1_file_updated");
1907  } elseif ($up_cnt > 1) {
1908  $tit .= $sep . sprintf($lng->txt("news_x_files_updated"), $up_cnt);
1909  }
1910  return $tit;
1911  }
1912  } else {
1913  if ($a_content_is_lang_var) {
1914  if ($obj_definition->isPlugin($a_context_obj_type)) {
1915  return ilObjectPlugin::lookupTxtById($a_context_obj_type, $a_title);
1916  }
1917  return $lng->txt($a_title);
1918  } else {
1919  return $a_title;
1920  }
1921  }
1922 
1923  return "";
1924  }
static lookupTxtById($plugin_id, $lang_var)
global $DIC
Definition: saml.php:7
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ determineNewsTitleByNewsId()

static ilNewsItem::determineNewsTitleByNewsId (   $a_news_id,
  $a_agg_ref_id = 0,
  $a_aggregation = "" 
)
static

Determine title for news item entry.

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

References $DIC, $ilDB, and $query.

1843  {
1844  global $DIC;
1845 
1846  $ilDB = $DIC->database();
1847 
1848  $query = "SELECT context_obj_type, content_is_lang_var, title FROM il_news_item WHERE id = " .
1849  $ilDB->quote($a_news_id, "integer");
1850  $set = $ilDB->query($query);
1851  $rec = $ilDB->fetchAssoc($set);
1852 
1853  return self::determineNewsTitle(
1854  $rec["context_obj_type"],
1855  $rec["title"],
1856  $rec["content_is_lang_var"],
1857  $a_agg_ref_id,
1858  $a_aggregation
1859  );
1860  }
global $DIC
Definition: saml.php:7
$query
global $ilDB

◆ 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.

Deprecated:
will move to ilNewsData

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

References $DIC, $ilDB, and $query.

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

1811  {
1812  global $DIC;
1813 
1814  $ilDB = $DIC->database();
1815 
1816  $and = "";
1817  if ($a_time_period > 0) {
1818  $limit_ts = self::handleTimePeriod($a_time_period);
1819  $and = " AND creation_date >= " . $ilDB->quote($limit_ts, "timestamp") . " ";
1820  }
1821 
1822  if ($a_starting_date != "") {
1823  $and .= " AND creation_date >= " . $ilDB->quote($a_starting_date, "timestamp");
1824  }
1825 
1826  $query = "SELECT DISTINCT(context_obj_id) AS obj_id FROM il_news_item" .
1827  " WHERE " . $ilDB->in("context_obj_id", $a_obj_ids, false, "integer") . " " . $and;
1828  //" WHERE context_obj_id IN (".implode(ilUtil::quoteArray($a_obj_ids),",").")".$and;
1829 
1830  $set = $ilDB->query($query);
1831  $objs = array();
1832  while ($rec = $ilDB->fetchAssoc($set)) {
1833  $objs[] = $rec["obj_id"];
1834  }
1835 
1836  return $objs;
1837  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ 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 
)
protected

Get news aggregation for child objects (e.g.

for categories)

Deprecated:
will move to ilNewsData
Parameters
$a_ref_id
bool$a_only_public
int$a_time_period
bool$a_prevent_aggregation
string$a_starting_date
bool$a_no_auto_generated
Returns
array|mixed

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

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

Referenced by getNewsForRefId().

1161  {
1162  $tree = $this->tree;
1163  $ilAccess = $this->access;
1164 
1165  // get news of parent object
1166  $data = $this->getNewsForRefId(
1167  $a_ref_id,
1168  $a_only_public,
1169  true,
1170  $a_time_period,
1171  true,
1172  false,
1173  false,
1174  $a_no_auto_generated
1175  );
1176  foreach ($data as $k => $v) {
1177  $data[$k]["ref_id"] = $a_ref_id;
1178  }
1179 
1180  // get childs
1181  $nodes = $tree->getChilds($a_ref_id);
1182 
1183  // no check, for which of the objects any news are available
1184  $obj_ids = array();
1185  foreach ($nodes as $node) {
1186  $obj_ids[] = $node["obj_id"];
1187  }
1188  $news_obj_ids = ilNewsItem::filterObjIdsPerNews($obj_ids, $a_time_period, $a_starting_date);
1189  //$news_obj_ids = $obj_ids;
1190 
1191  // get news for all subtree nodes
1192  $contexts = array();
1193  foreach ($nodes as $node) {
1194  // only go on, if news are available
1195  if (!in_array($node["obj_id"], $news_obj_ids)) {
1196  continue;
1197  }
1198 
1199  if (!$a_only_public && !$ilAccess->checkAccess("read", "", $node["child"])) {
1200  continue;
1201  }
1202  $ref_id[$node["obj_id"]] = $node["child"];
1203  $contexts[] = array("obj_id" => $node["obj_id"],
1204  "obj_type" => $node["type"]);
1205  }
1206 
1207  $news = $this->queryNewsForMultipleContexts(
1208  $contexts,
1209  $a_only_public,
1210  $a_time_period,
1211  $a_starting_date,
1212  $a_no_auto_generated
1213  );
1214  foreach ($news as $k => $v) {
1215  $news[$k]["ref_id"] = $ref_id[$v["context_obj_id"]];
1216  }
1217  $data = ilNewsItem::mergeNews($data, $news);
1218 
1219  // sort and return
1220  $data = ilUtil::sortArray($data, "creation_date", "desc", false, true);
1221 
1222  if (!$a_prevent_aggregation) {
1223  $data = $this->aggregateFiles($data, $a_ref_id);
1224  }
1225 
1226  return $data;
1227  }
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static mergeNews($n1, $n2)
Merges two sets of news.
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.
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.
$data
Definition: bench.php:6
aggregateFiles($news, $a_ref_id)
+ 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)

Deprecated:
(will migrate to ilNewsData)

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

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

Referenced by getNewsForRefId().

969  {
970  $tree = $this->tree;
971  $ilAccess = $this->access;
972  $ilObjDataCache = $this->obj_data_cache;
973 
974  // get news of parent object
975 
976  $data = array();
977 
978  // get subtree
979  $cur_node = $tree->getNodeData($a_ref_id);
980 
981  // do not check for lft (materialized path)
982  if ($cur_node) {
983  $nodes = (array) $tree->getSubTree($cur_node, true);
984  } else {
985  $nodes = array();
986  }
987 
988  // preload object data cache
989  $ref_ids = array();
990  $obj_ids = array();
991  foreach ($nodes as $node) {
992  $ref_ids[] = $node["child"];
993  $obj_ids[] = $node["obj_id"];
994  }
995 
996  $ilObjDataCache->preloadReferenceCache($ref_ids);
997  if (!$a_only_public) {
998  include_once "Services/Object/classes/class.ilObjectActivation.php";
1000  }
1001 
1002  // no check, for which of the objects any news are available
1003  $news_obj_ids = ilNewsItem::filterObjIdsPerNews($obj_ids, $a_time_period, $a_starting_date);
1004  //$news_obj_ids = $obj_ids;
1005 
1006  // get news for all subtree nodes
1007  $contexts = array();
1008  foreach ($nodes as $node) {
1009  // only go on, if news are available
1010  if (!in_array($node["obj_id"], $news_obj_ids)) {
1011  continue;
1012  }
1013 
1014  if (!$a_only_public) {
1015  if (!$a_user_id) {
1016  $acc = $ilAccess->checkAccess("read", "", $node["child"]);
1017  } else {
1018  $acc = $ilAccess->checkAccessOfUser(
1019  $a_user_id,
1020  "read",
1021  "",
1022  $node["child"]
1023  );
1024  }
1025  if (!$acc) {
1026  continue;
1027  }
1028  }
1029 
1030  $ref_id[$node["obj_id"]] = $node["child"];
1031  $contexts[] = array("obj_id" => $node["obj_id"],
1032  "obj_type" => $node["type"]);
1033  }
1034 
1035  // sort and return
1036  $news = $this->queryNewsForMultipleContexts(
1037  $contexts,
1038  $a_only_public,
1039  $a_time_period,
1040  $a_starting_date,
1041  $a_no_auto_generated,
1042  $a_user_id,
1043  $a_limit,
1044  $a_exclude
1045  );
1046 
1047  $to_del = array();
1048  foreach ($news as $k => $v) {
1049  $news[$k]["ref_id"] = $ref_id[$v["context_obj_id"]];
1050  }
1051 
1052  $data = ilNewsItem::mergeNews($data, $news);
1053  $data = ilUtil::sortArray($data, "creation_date", "desc", false, true);
1054 
1055  if (!$a_prevent_aggregation) {
1056  $data = $this->aggregateFiles($data, $a_ref_id);
1057  }
1058 
1059  return $data;
1060  }
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static mergeNews($n1, $n2)
Merges two sets of news.
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 preloadData(array $a_ref_ids)
Preload data to internal cache.
static filterObjIdsPerNews($a_obj_ids, $a_time_period=0, $a_starting_date="", $a_ending_date='', $ignore_period=false)
Checks whether news are available for.
$data
Definition: bench.php:6
aggregateFiles($news, $a_ref_id)
+ 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 176 of file class.ilNewsItem.php.

References $content.

Referenced by create(), and update().

177  {
178  return $this->content;
179  }
+ Here is the caller graph for this function:

◆ getContentHtml()

ilNewsItem::getContentHtml ( )

Get content as html.

Returns
bool

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

References $content_html.

Referenced by create(), and update().

578  {
579  return $this->content_html;
580  }
+ Here is the caller graph for this function:

◆ getContentIsLangVar()

ilNewsItem::getContentIsLangVar ( )

Get ContentIsLangVar.

Returns
boolean

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

References $content_is_lang_var.

Referenced by create(), and update().

437  {
439  }
+ Here is the caller graph for this function:

◆ getContentLong()

ilNewsItem::getContentLong ( )

Get ContentLong.

Returns
string Long content of news

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

References $content_long.

Referenced by create(), and update().

397  {
398  return $this->content_long;
399  }
+ Here is the caller graph for this function:

◆ getContentTextIsLangVar()

ilNewsItem::getContentTextIsLangVar ( )

Get content text ist lang var.

Returns
boolean

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

Referenced by create(), and update().

518  {
519  return $this->content_text_is_lang_var;
520  }
+ Here is the caller graph for this function:

◆ getContentType()

ilNewsItem::getContentType ( )

Get ContentType.

Returns
string Content type.

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

References $content_type.

Referenced by create(), and update().

277  {
278  return $this->content_type;
279  }
+ Here is the caller graph for this function:

◆ getContextObjId()

ilNewsItem::getContextObjId ( )

Get ContextObjId.

Returns
int

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

References $context_obj_id.

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

197  {
198  return $this->context_obj_id;
199  }
+ Here is the caller graph for this function:

◆ getContextObjType()

ilNewsItem::getContextObjType ( )

Get ContextObjType.

Returns
int

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

References $context_obj_type.

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

217  {
219  }
+ Here is the caller graph for this function:

◆ getContextSubObjId()

ilNewsItem::getContextSubObjId ( )

Get ContextSubObjId.

Returns
int

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

References $context_sub_obj_id.

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

237  {
239  }
+ Here is the caller graph for this function:

◆ getContextSubObjType()

ilNewsItem::getContextSubObjType ( )

Get ContextSubObjType.

Returns
int

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

References $context_sub_obj_type.

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

257  {
259  }
+ Here is the caller graph for this function:

◆ getCreationDate()

ilNewsItem::getCreationDate ( )

Get CreationDate.

Returns
string Date of creation.

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

References $creation_date.

297  {
298  return $this->creation_date;
299  }

◆ 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.

Deprecated:
will move to ilNewsData

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

References $DIC, $ilDB, and $query.

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

1959  {
1960  global $DIC;
1961 
1962  $ilDB = $DIC->database();
1963 
1964  // Determine how many rows should be deleted
1965  $query = "SELECT * " .
1966  "FROM il_news_item " .
1967  "WHERE " .
1968  "context_obj_id = " . $ilDB->quote($a_context_obj_id, "integer") .
1969  " AND context_obj_type = " . $ilDB->quote($a_context_obj_type, "text") .
1970  " AND context_sub_obj_id = " . $ilDB->quote($a_context_sub_obj_id, "integer") .
1971  " AND " . $ilDB->equals("context_sub_obj_type", $a_context_sub_obj_type, "text", true);
1972 
1973  $set = $ilDB->query($query);
1974  $rec = $ilDB->fetchAssoc($set);
1975 
1976  return $rec["id"];
1977  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ Here is the caller graph for this function:

◆ getId()

ilNewsItem::getId ( )

Get Id.

Returns
int

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

References $id.

Referenced by create(), delete(), increaseDownloadCounter(), increasePlayCounter(), read(), ilNewsTimelineItemGUI\renderMedia(), ilNewsTimelineItemGUI\renderMediaModal(), ilNewsData\save(), and update().

137  {
138  return $this->id;
139  }
+ 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.

Deprecated:
will move to ilNewsData

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

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

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

1989  {
1990  global $DIC;
1991 
1992  $ilDB = $DIC->database();
1993 
1994  // Determine how many rows should be deleted
1995  $query = "SELECT id, update_date " .
1996  "FROM il_news_item " .
1997  "WHERE " .
1998  "context_obj_id = " . $ilDB->quote($a_context_obj_id, "integer") .
1999  " AND context_obj_type = " . $ilDB->quote($a_context_obj_type, "text") .
2000  " AND context_sub_obj_id = " . $ilDB->quote($a_context_sub_obj_id, "integer") .
2001  " AND " . $ilDB->equals("context_sub_obj_type", $a_context_sub_obj_type, "text", true) .
2002  " ORDER BY update_date DESC";
2003 
2004  $ilDB->setLimit(1);
2005  $set = $ilDB->query($query);
2006  $rec = $ilDB->fetchAssoc($set);
2007 
2008  $id = (int) $rec["id"];
2009  if ($a_only_today) {
2010  $now = ilUtil::now();
2011  if (substr($now, 0, 10) != substr($rec["update_date"], 0, 10)) {
2012  $id = 0;
2013  }
2014  }
2015 
2016  return $id;
2017  }
global $DIC
Definition: saml.php:7
static now()
Return current timestamp in Y-m-d H:i:s format.
$query
global $ilDB
+ 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 497 of file class.ilNewsItem.php.

References $limitation.

Referenced by create().

498  {
499  return $this->limitation;
500  }
+ Here is the caller graph for this function:

◆ getMobDownloadCounter()

ilNewsItem::getMobDownloadCounter ( )

Get mob download counter.

Returns
int counter

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

Referenced by increaseDownloadCounter(), and update().

558  {
559  return $this->mob_cnt_download;
560  }
+ 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 456 of file class.ilNewsItem.php.

References $mob_id.

Referenced by create(), delete(), deliverMobFile(), ilNewsTimelineItemGUI\getMediaPath(), and update().

457  {
458  return $this->mob_id;
459  }
+ Here is the caller graph for this function:

◆ getMobPlayCounter()

ilNewsItem::getMobPlayCounter ( )

Get mob play counter.

Returns
int counter

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

Referenced by increasePlayCounter(), and update().

538  {
539  return $this->mob_cnt_play;
540  }
+ 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.

Deprecated:
(will migrate to ilNewsData)
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_excluded currently only supported for groups and courses (news ids)
Returns
array|mixed

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

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

Referenced by getAggregatedChildNewsData().

870  {
871  $obj_id = ilObject::_lookupObjId($a_ref_id);
872  $obj_type = ilObject::_lookupType($obj_id);
873 
874  // get starting date
875  $starting_date = "";
876  if ($obj_type == "grp" || $obj_type == "crs" || $obj_type == "cat") {
877  include_once("./Services/Block/classes/class.ilBlockSetting.php");
878  $hide_news_per_date = ilBlockSetting::_lookup(
879  "news",
880  "hide_news_per_date",
881  0,
882  $obj_id
883  );
884  if ($hide_news_per_date && !$a_ignore_date_filter) {
885  $starting_date = ilBlockSetting::_lookup(
886  "news",
887  "hide_news_date",
888  0,
889  $obj_id
890  );
891  }
892  }
893 
894  if ($obj_type == "cat" && !$a_stopnesting) {
895  $news = $this->getAggregatedChildNewsData(
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  );
903  } elseif (($obj_type == "grp" || $obj_type == "crs") &&
904  !$a_stopnesting) {
905  $news = $this->getAggregatedNewsData(
906  $a_ref_id,
907  $a_only_public,
908  $a_time_period,
909  $a_prevent_aggregation,
910  $starting_date,
911  $a_no_auto_generated,
912  $a_user_id,
913  $a_limit,
914  $a_excluded
915  );
916  } else {
917  $news_item = new ilNewsItem();
918  $news_item->setContextObjId($obj_id);
919  $news_item->setContextObjType($obj_type);
920  $news = $news_item->queryNewsForContext(
921  $a_only_public,
922  $a_time_period,
923  $starting_date,
924  $a_no_auto_generated
925  );
926  $unset = array();
927  foreach ($news as $k => $v) {
928  if (!$a_only_public || $v["visibility"] == NEWS_PUBLIC ||
929  ($v["priority"] == 0 &&
931  "news",
932  "public_notifications",
933  0,
934  $obj_id
935  ))) {
936  $news[$k]["ref_id"] = $a_ref_id;
937  } else {
938  $unset[] = $k;
939  }
940  }
941  foreach ($unset as $un) {
942  unset($news[$un]);
943  }
944  }
945 
946  if (!$a_prevent_aggregation) {
947  $news = $this->aggregateForums($news);
948  } elseif ($a_forum_group_sequences) {
949  $news = $this->aggregateForums($news, true);
950  }
951 
952  return $news;
953  }
const NEWS_PUBLIC
aggregateForums($news, $a_group_posting_sequence=false)
static _lookupObjId($a_id)
static _lookup($a_type, $a_setting, $a_user=0, $a_block_id=0)
Lookup setting from database.
static _lookupType($a_id, $a_reference=false)
lookup object type
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.
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.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNewsOfContext()

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

Get all news of a context.

Deprecated:
will move to ilNewsData

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

References $DIC, $ilDB, and $query.

Referenced by ilNewsData\getNewsOfContext().

1705  {
1706  global $DIC;
1707 
1708  $ilDB = $DIC->database();
1709 
1710  if ($a_context_obj_id == 0 || $a_context_obj_type == "") {
1711  return [];
1712  }
1713 
1714  if ($a_context_sub_obj_id > 0) {
1715  $and = " AND context_sub_obj_id = " . $ilDB->quote($a_context_sub_obj_id, "integer") .
1716  " AND context_sub_obj_type = " . $ilDB->quote($a_context_sub_obj_type, "text");
1717  }
1718 
1719  // get news records
1720  $query = "SELECT * FROM il_news_item" .
1721  " WHERE context_obj_id = " . $ilDB->quote($a_context_obj_id, "integer") .
1722  " AND context_obj_type = " . $ilDB->quote($a_context_obj_type, "text") .
1723  $and;
1724 
1725  $news_set = $ilDB->query($query);
1726 
1727  $news_arr = [];
1728  while ($news = $ilDB->fetchAssoc($news_set)) {
1729  $news_arr[] = new ilNewsItem($news["id"]);
1730  }
1731  return $news_arr;
1732  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ 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 476 of file class.ilNewsItem.php.

References $playtime.

Referenced by create(), and update().

477  {
478  return $this->playtime;
479  }
+ Here is the caller graph for this function:

◆ getPriority()

ilNewsItem::getPriority ( )

Get Priority.

Returns
int News Priority

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

References $priority.

Referenced by create(), and update().

417  {
418  return $this->priority;
419  }
+ Here is the caller graph for this function:

◆ getPrivateFeedId()

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

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

References $privFeedId.

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

2132  {
2133  return ilNewsItem::$privFeedId;
2134  }
static $privFeedId
+ Here is the caller graph for this function:

◆ getTitle()

ilNewsItem::getTitle ( )

Get Title.

Returns
string Title of news item.

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

References $title.

Referenced by create(), and update().

157  {
158  return $this->title;
159  }
+ Here is the caller graph for this function:

◆ getUpdateDate()

ilNewsItem::getUpdateDate ( )

Get UpdateDate.

Returns
string Date of last update.

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

References $update_date.

317  {
318  return $this->update_date;
319  }

◆ getUpdateUserId()

ilNewsItem::getUpdateUserId ( )

Get update user id.

Returns
int update user id

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

References $update_user_id.

Referenced by create(), and update().

357  {
358  return $this->update_user_id;
359  }
+ Here is the caller graph for this function:

◆ getUserId()

ilNewsItem::getUserId ( )

Get UserId.

Returns
int User Id of last update.

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

References $user_id.

Referenced by create(), and update().

337  {
338  return $this->user_id;
339  }
+ Here is the caller graph for this function:

◆ getVisibility()

ilNewsItem::getVisibility ( )

Get Visibility.

Returns
string Access level of news.

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

References $visibility.

Referenced by create(), and update().

377  {
378  return $this->visibility;
379  }
+ 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 1251 of file class.ilNewsItem.php.

1252  {
1253  // time period is number of days
1254  if (is_numeric($a_time_period)) {
1255  if ($a_time_period > 0) {
1256  return date('Y-m-d H:i:s', time() - ($a_time_period * 24 * 60 * 60));
1257  }
1258  }
1259  // time period is datetime
1260  elseif (preg_match("/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/", $a_time_period)) {
1261  return $a_time_period;
1262  }
1263  // :TODO: what to return?
1264  }

◆ increaseDownloadCounter()

ilNewsItem::increaseDownloadCounter ( )

Increase download counter.

Deprecated:
will move to data

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

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

Referenced by deliverMobFile().

2182  {
2183  $ilDB = $this->db;
2184 
2185  $cnt = $this->getMobDownloadCounter();
2186  $cnt++;
2187  $this->setMobDownloadCounter($cnt);
2188  $ilDB->manipulate(
2189  "UPDATE il_news_item SET " .
2190  " mob_cnt_download = " . $ilDB->quote($cnt, "integer") .
2191  " WHERE id = " . $ilDB->quote($this->getId(), "integer")
2192  );
2193  }
getMobDownloadCounter()
Get mob download counter.
getId()
Get Id.
setMobDownloadCounter($a_val)
Set mob download counter.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ increasePlayCounter()

ilNewsItem::increasePlayCounter ( )

Increase play counter.

Deprecated:
will move to data

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

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

2201  {
2202  $ilDB = $this->db;
2203 
2204  $cnt = $this->getMobPlayCounter();
2205  $cnt++;
2206  $this->setMobPlayCounter($cnt);
2207  $ilDB->manipulate(
2208  "UPDATE il_news_item SET " .
2209  " mob_cnt_play = " . $ilDB->quote($cnt, "integer") .
2210  " WHERE id = " . $ilDB->quote($this->getId(), "integer")
2211  );
2212  }
getId()
Get Id.
getMobPlayCounter()
Get mob play counter.
global $ilDB
setMobPlayCounter($a_val)
Set mob play counter.
+ Here is the call graph for this function:

◆ mergeNews()

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

Merges two sets of news.

Deprecated:
will move to ilNewsData
Parameters
array$n1Array of news
array$n2Array of news
Returns
array Array of news

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

References $id.

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

1616  {
1617  foreach ($n2 as $id => $news) {
1618  $n1[$id] = $news;
1619  }
1620 
1621  return $n1;
1622  }
+ Here is the caller graph for this function:

◆ prepareNewsDataFromCache()

static ilNewsItem::prepareNewsDataFromCache (   $a_cres)
static

Prepare news data from cache.

Deprecated:
will move to data
Parameters
string$a_crescache string
Returns
array news array

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

References $data, $DIC, and $ilDB.

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

2221  {
2222  global $DIC;
2223 
2224  $ilDB = $DIC->database();
2225 
2226  $data = $a_cres;
2227  $news_ids = array_keys($data);
2228  $set = $ilDB->query("SELECT id FROM il_news_item " .
2229  " WHERE " . $ilDB->in("id", $news_ids, false, "integer"));
2230  $existing_ids = array();
2231  while ($rec = $ilDB->fetchAssoc($set)) {
2232  $existing_ids[] = $rec["id"];
2233  }
2234  //var_dump($existing_ids);
2235  $existing_news = array();
2236  foreach ($data as $k => $v) {
2237  if (in_array($k, $existing_ids)) {
2238  $existing_news[$k] = $v;
2239  }
2240  }
2241 
2242  //var_dump($data);
2243  //var_dump($existing_news);
2244 
2245  return $existing_news;
2246  }
global $DIC
Definition: saml.php:7
global $ilDB
$data
Definition: bench.php:6
+ Here is the caller graph for this function:

◆ queryNewsByIds()

static ilNewsItem::queryNewsByIds ( array  $a_news_ids)
static

Query news data by news ids.

Parameters
int[]$a_news_ids
Returns
array[]

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

References $DIC, and $ilDB.

Referenced by ilMembershipCronNotificationsData\loadMissingNews().

1396  {
1397  global $DIC;
1398  $ilDB = $DIC->database();
1399  $news = array();
1400  $set = $ilDB->query("SELECT * FROM il_news_item " .
1401  " WHERE " . $ilDB->in("id", $a_news_ids, false, "integer"));
1402  while ($rec = $ilDB->fetchAssoc($set)) {
1403  $news[$rec["id"]] = $rec;
1404  }
1405  return $news;
1406  }
global $DIC
Definition: saml.php:7
global $ilDB
+ 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.

Deprecated:
will move to ilNewsData
Parameters
booleanquery for outgoing rss feed
inttime period in seconds
stringstartind date
booleando not include auto generated news items

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

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

1282  {
1283  $ilDB = $this->db;
1284  $ilUser = $this->user;
1285  $lng = $this->lng;
1286 
1287  $and = "";
1288  if ($a_time_period > 0) {
1289  $limit_ts = self::handleTimePeriod($a_time_period);
1290  $and = " AND creation_date >= " . $ilDB->quote($limit_ts, "timestamp") . " ";
1291  }
1292 
1293  if ($a_starting_date != "") {
1294  $and .= " AND creation_date > " . $ilDB->quote($a_starting_date, "timestamp") . " ";
1295  }
1296 
1297  if ($a_no_auto_generated) {
1298  $and .= " AND priority = 1 AND content_type = " . $ilDB->quote("text", "text") . " ";
1299  }
1300 
1301  // this is changed with 4.1 (news table for lm pages)
1302  if ($this->getContextSubObjId() > 0) {
1303  $and .= " AND context_sub_obj_id = " . $ilDB->quote($this->getContextSubObjId(), "integer") .
1304  " AND context_sub_obj_type = " . $ilDB->quote($this->getContextSubObjType(), "text");
1305  }
1306 
1307  $ordering = ($a_oldest_first)
1308  ? " creation_date ASC, id ASC "
1309  : " creation_date DESC, id DESC ";
1310 
1311  if ($a_for_rss_use && ilNewsItem::getPrivateFeedId() == false) {
1312  $query = "SELECT * " .
1313  "FROM il_news_item " .
1314  " WHERE " .
1315  "context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
1316  " AND context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text") .
1317  $and .
1318  " ORDER BY " . $ordering;
1319  } elseif (ilNewsItem::getPrivateFeedId() != false) {
1320  $query = "SELECT il_news_item.* " .
1321  ", il_news_read.user_id user_read " .
1322  "FROM il_news_item LEFT JOIN il_news_read " .
1323  "ON il_news_item.id = il_news_read.news_id AND " .
1324  " il_news_read.user_id = " . $ilDB->quote(ilNewsItem::getPrivateFeedId(), "integer") .
1325  " WHERE " .
1326  "context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
1327  " AND context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text") .
1328  $and .
1329  " ORDER BY " . $ordering;
1330  } else {
1331  $query = "SELECT il_news_item.* " .
1332  ", il_news_read.user_id as user_read " .
1333  "FROM il_news_item LEFT JOIN il_news_read " .
1334  "ON il_news_item.id = il_news_read.news_id AND " .
1335  " il_news_read.user_id = " . $ilDB->quote($ilUser->getId(), "integer") .
1336  " WHERE " .
1337  "context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
1338  " AND context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text") .
1339  $and .
1340  " ORDER BY " . $ordering;
1341  }
1342  //echo $query;
1343  $set = $ilDB->query($query);
1344  $result = array();
1345  while ($rec = $ilDB->fetchAssoc($set)) {
1346  if ($a_limit > 0 && count($result) >= $a_limit) {
1347  continue;
1348  }
1349  if (!$a_for_rss_use || (ilNewsItem::getPrivateFeedId() != false) || ($rec["visibility"] == NEWS_PUBLIC ||
1350  ($rec["priority"] == 0 &&
1352  "news",
1353  "public_notifications",
1354  0,
1355  $rec["context_obj_id"]
1356  )))) {
1357  $result[$rec["id"]] = $rec;
1358  }
1359  }
1360 
1361  // do we get data for rss and may the time limit by an issue?
1362  // do a second query without time limit.
1363  // this is not very performant, but I do not have a better
1364  // idea. The keep_rss_min setting is currently (Jul 2012) only set
1365  // by mediacasts
1366  if ($a_time_period != "" && $a_for_rss_use) {
1367  include_once("./Services/Block/classes/class.ilBlockSetting.php");
1368  $keep_rss_min = ilBlockSetting::_lookup(
1369  "news",
1370  "keep_rss_min",
1371  0,
1372  $this->getContextObjId()
1373  );
1374  if ($keep_rss_min > 0) {
1375  return $this->queryNewsForContext(
1376  true,
1377  0,
1378  $a_starting_date,
1379  $a_no_auto_generated,
1380  $a_oldest_first,
1381  $keep_rss_min
1382  );
1383  }
1384  }
1385 
1386  return $result;
1387  }
$result
getContextObjType()
Get ContextObjType.
getContextSubObjType()
Get ContextSubObjType.
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.
const NEWS_PUBLIC
static _lookup($a_type, $a_setting, $a_user=0, $a_block_id=0)
Lookup setting from database.
$ilUser
Definition: imgupload.php:18
$query
getContextSubObjId()
Get ContextSubObjId.
static getPrivateFeedId()
global $ilDB
getContextObjId()
Get ContextObjId.
+ Here is the call 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.

Deprecated:
will move to ilNewsData
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 1450 of file class.ilNewsItem.php.

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

Referenced by getAggregatedChildNewsData(), and getAggregatedNewsData().

1459  {
1460  $ilDB = $this->db;
1461  $ilUser = $this->user;
1462  $lng = $this->lng;
1463  $ilCtrl = $this->ctrl;
1464 
1465  $and = "";
1466  if ($a_time_period > 0) {
1467  $limit_ts = self::handleTimePeriod($a_time_period);
1468  $and = " AND creation_date >= " . $ilDB->quote($limit_ts, "timestamp") . " ";
1469  }
1470 
1471  if ($a_starting_date != "") {
1472  $and .= " AND creation_date > " . $ilDB->quote($a_starting_date, "timestamp") . " ";
1473  }
1474 
1475  if ($a_no_auto_generated) {
1476  $and .= " AND priority = 1 AND content_type = " . $ilDB->quote("text", "text") . " ";
1477  }
1478 
1479  if ($a_limit > 0) {
1480  $ilDB->setLimit($a_limit, 0);
1481  }
1482 
1483  if (is_array($a_exclude) && count($a_exclude) > 0) {
1484  $and .= " AND " . $ilDB->in("id", $a_exclude, true, "integer") . " ";
1485  }
1486 
1487  $ids = array();
1488  $type = array();
1489 
1490  foreach ($a_contexts as $cont) {
1491  $ids[] = $cont["obj_id"];
1492  $type[$cont["obj_id"]] = $cont["obj_type"];
1493  }
1494 
1495  if ($a_for_rss_use && ilNewsItem::getPrivateFeedId() == false) {
1496  $query = "SELECT * " .
1497  "FROM il_news_item " .
1498  " WHERE " .
1499  $ilDB->in("context_obj_id", $ids, false, "integer") . " " .
1500  $and .
1501  " ORDER BY creation_date DESC ";
1502  } elseif (ilNewsItem::getPrivateFeedId() != false) {
1503  $query = "SELECT il_news_item.* " .
1504  ", il_news_read.user_id as user_read " .
1505  "FROM il_news_item LEFT JOIN il_news_read " .
1506  "ON il_news_item.id = il_news_read.news_id AND " .
1507  " il_news_read.user_id = " . $ilDB->quote(ilNewsItem::getPrivateFeedId(), "integer") .
1508  " WHERE " .
1509  $ilDB->in("context_obj_id", $ids, false, "integer") . " " .
1510  $and .
1511  " ORDER BY creation_date DESC ";
1512  } else {
1513  if ($a_user_id) {
1514  $user_id = $a_user_id;
1515  } else {
1516  $user_id = $ilUser->getId();
1517  }
1518  $query = "SELECT il_news_item.* " .
1519  ", il_news_read.user_id as user_read " .
1520  "FROM il_news_item LEFT JOIN il_news_read " .
1521  "ON il_news_item.id = il_news_read.news_id AND " .
1522  " il_news_read.user_id = " . $ilDB->quote($user_id, "integer") .
1523  " WHERE " .
1524  $ilDB->in("context_obj_id", $ids, false, "integer") . " " .
1525  $and .
1526  " ORDER BY creation_date DESC ";
1527  }
1528 
1529  $set = $ilDB->query($query);
1530  $result = array();
1531  while ($rec = $ilDB->fetchAssoc($set)) {
1532  if ($type[$rec["context_obj_id"]] == $rec["context_obj_type"]) {
1533  if (!$a_for_rss_use || ilNewsItem::getPrivateFeedId() != false || ($rec["visibility"] == NEWS_PUBLIC ||
1534  ($rec["priority"] == 0 &&
1536  "news",
1537  "public_notifications",
1538  0,
1539  $rec["context_obj_id"]
1540  )))) {
1541  $result[$rec["id"]] = $rec;
1542  }
1543  }
1544  }
1545 
1546  return $result;
1547  }
$result
$type
global $ilCtrl
Definition: ilias.php:18
const NEWS_PUBLIC
static _lookup($a_type, $a_setting, $a_user=0, $a_block_id=0)
Lookup setting from database.
$ilUser
Definition: imgupload.php:18
$query
static getPrivateFeedId()
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilNewsItem::read ( )

Read item from database.

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

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

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().

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

References $a_content.

Referenced by read().

167  {
168  $this->content = $a_content;
169  }
$a_content
Definition: workflow.php:93
+ 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 567 of file class.ilNewsItem.php.

Referenced by read().

568  {
569  $this->content_html = $a_val;
570  }
+ 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 426 of file class.ilNewsItem.php.

Referenced by read().

427  {
428  $this->content_is_lang_var = $a_content_is_lang_var;
429  }
+ 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 386 of file class.ilNewsItem.php.

Referenced by read().

387  {
388  $this->content_long = $a_content_long;
389  }
+ 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 507 of file class.ilNewsItem.php.

Referenced by read().

508  {
509  $this->content_text_is_lang_var = $a_val;
510  }
+ 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 266 of file class.ilNewsItem.php.

Referenced by read().

267  {
268  $this->content_type = $a_content_type;
269  }
+ Here is the caller graph for this function:

◆ setContext()

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

Set context for news.

Parameters
int$a_obj_id
int$a_obj_type
int$a_sub_obj_id
string$a_sub_obj_type

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

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

1238  {
1239  $this->setContextObjId($a_obj_id);
1240  $this->setContextObjType($a_obj_type);
1241  $this->setContextSubObjId($a_sub_obj_id);
1242  $this->setContextSubObjType($a_sub_obj_type);
1243  }
setContextSubObjId($a_context_sub_obj_id)
Set ContextSubObjId.
setContextSubObjType($a_context_sub_obj_type)
Set ContextSubObjType.
setContextObjId($a_context_obj_id)
Set ContextObjId.
setContextObjType($a_context_obj_type)
Set ContextObjType.
+ 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 186 of file class.ilNewsItem.php.

Referenced by read(), and setContext().

187  {
188  $this->context_obj_id = $a_context_obj_id;
189  }
+ 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 206 of file class.ilNewsItem.php.

Referenced by read(), and setContext().

207  {
208  $this->context_obj_type = $a_context_obj_type;
209  }
+ 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 226 of file class.ilNewsItem.php.

Referenced by read(), and setContext().

227  {
228  $this->context_sub_obj_id = $a_context_sub_obj_id;
229  }
+ 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 246 of file class.ilNewsItem.php.

Referenced by read(), and setContext().

247  {
248  $this->context_sub_obj_type = $a_context_sub_obj_type;
249  }
+ 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 286 of file class.ilNewsItem.php.

Referenced by read().

287  {
288  $this->creation_date = $a_creation_date;
289  }
+ Here is the caller graph for this function:

◆ setId()

ilNewsItem::setId (   $a_id)

Set Id.

Parameters
int$a_id

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

Referenced by __construct(), and create().

127  {
128  $this->id = $a_id;
129  }
+ 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 487 of file class.ilNewsItem.php.

488  {
489  $this->limitation = $a_limitation;
490  }

◆ setMobDownloadCounter()

ilNewsItem::setMobDownloadCounter (   $a_val)

Set mob download counter.

Parameters
int$a_valcounter

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

Referenced by increaseDownloadCounter(), and read().

548  {
549  $this->mob_cnt_download = $a_val;
550  }
+ 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 446 of file class.ilNewsItem.php.

Referenced by read().

447  {
448  $this->mob_id = $a_mob_id;
449  }
+ Here is the caller graph for this function:

◆ setMobPlayCounter()

ilNewsItem::setMobPlayCounter (   $a_val)

Set mob play counter.

Parameters
int$a_valcounter

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

Referenced by increasePlayCounter(), and read().

528  {
529  $this->mob_cnt_play = $a_val;
530  }
+ 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 466 of file class.ilNewsItem.php.

Referenced by read().

467  {
468  $this->playtime = $a_playtime;
469  }
+ Here is the caller graph for this function:

◆ setPriority()

ilNewsItem::setPriority (   $a_priority = 1)

Set Priority.

Parameters
int$a_priorityNews Priority

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

Referenced by read().

407  {
408  $this->priority = $a_priority;
409  }
+ Here is the caller graph for this function:

◆ setPrivateFeedId()

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

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

References $privFeedId.

Referenced by ilObjectFeedWriter\__construct().

2124  {
2125  ilNewsItem::$privFeedId = $a_userId;
2126  }
static $privFeedId
+ 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 146 of file class.ilNewsItem.php.

Referenced by read().

147  {
148  $this->title = $a_title;
149  }
+ 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 306 of file class.ilNewsItem.php.

Referenced by read().

307  {
308  $this->update_date = $a_update_date;
309  }
+ 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 346 of file class.ilNewsItem.php.

Referenced by read().

347  {
348  $this->update_user_id = $a_val;
349  }
+ 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 326 of file class.ilNewsItem.php.

Referenced by read().

327  {
328  $this->user_id = $a_user_id;
329  }
+ 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 366 of file class.ilNewsItem.php.

Referenced by read().

367  {
368  $this->visibility = $a_visibility;
369  }
+ Here is the caller graph for this function:

◆ update()

ilNewsItem::update (   $a_as_new = false)

Update item in database.

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

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

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().

Referenced by ilNewsData\save().

700  {
701  $ilDB = $this->db;
702 
703  $fields = array(
704  "title" => array("text", $this->getTitle()),
705  "content" => array("clob", $this->getContent()),
706  "content_html" => array("integer", (int) $this->getContentHtml()),
707  "context_obj_id" => array("integer", $this->getContextObjId()),
708  "context_obj_type" => array("text", $this->getContextObjType()),
709  "context_sub_obj_id" => array("integer", $this->getContextSubObjId()),
710  "context_sub_obj_type" => array("text", $this->getContextSubObjType()),
711  "content_type" => array("text", $this->getContentType()),
712  "user_id" => array("integer", $this->getUserId()),
713  "update_user_id" => array("integer", (int) $this->getUpdateUserId()),
714  "visibility" => array("text", $this->getVisibility()),
715  "content_long" => array("clob", $this->getContentLong()),
716  "priority" => array("integer", $this->getPriority()),
717  "content_is_lang_var" => array("integer", $this->getContentIsLangVar()),
718  "content_text_is_lang_var" => array("integer", (int) $this->getContentTextIsLangVar()),
719  "mob_id" => array("integer", $this->getMobId()),
720  "mob_cnt_play" => array("integer", $this->getMobPlayCounter()),
721  "mob_cnt_download" => array("integer", $this->getMobDownloadCounter()),
722  "playtime" => array("text", $this->getPlaytime())
723  );
724 
725  $now = ilUtil::now();
726  if ($a_as_new) {
727  $fields["creation_date"] = array("timestamp", $now);
728  $fields["update_date"] = array("timestamp", $now);
729  } else {
730  $fields["update_date"] = array("timestamp", $now);
731  }
732 
733  $ilDB->update("il_news_item", $fields, array(
734  "id" => array("integer", $this->getId())
735  ));
736  }
getContentHtml()
Get content as html.
getUserId()
Get UserId.
getMobId()
Get MobId.
getContentType()
Get ContentType.
getPriority()
Get Priority.
getPlaytime()
Get Playtime.
getContentTextIsLangVar()
Get content text ist lang var.
getContentLong()
Get ContentLong.
getContextObjType()
Get ContextObjType.
static now()
Return current timestamp in Y-m-d H:i:s format.
getContextSubObjType()
Get ContextSubObjType.
getMobDownloadCounter()
Get mob download counter.
getContent()
Get Content.
getContentIsLangVar()
Get ContentIsLangVar.
getId()
Get Id.
getContextSubObjId()
Get ContextSubObjId.
getVisibility()
Get Visibility.
getMobPlayCounter()
Get mob play counter.
global $ilDB
getTitle()
Get Title.
getUpdateUserId()
Get update user id.
getContextObjId()
Get ContextObjId.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilNewsItem::$access
protected

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

Referenced by getAggregatedChildNewsData(), and getAggregatedNewsData().

◆ $content

ilNewsItem::$content
protected

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

Referenced by getContent().

◆ $content_html

ilNewsItem::$content_html
protected

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

Referenced by getContentHtml().

◆ $content_is_lang_var

ilNewsItem::$content_is_lang_var = 0
protected

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

Referenced by getContentIsLangVar().

◆ $content_long

ilNewsItem::$content_long
protected

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

Referenced by getContentLong().

◆ $content_type

ilNewsItem::$content_type = "text"
protected

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

Referenced by getContentType().

◆ $context_obj_id

ilNewsItem::$context_obj_id
protected

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

Referenced by getContextObjId().

◆ $context_obj_type

ilNewsItem::$context_obj_type
protected

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

Referenced by getContextObjType().

◆ $context_sub_obj_id

ilNewsItem::$context_sub_obj_id
protected

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

Referenced by getContextSubObjId().

◆ $context_sub_obj_type

ilNewsItem::$context_sub_obj_type
protected

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

Referenced by getContextSubObjType().

◆ $creation_date

ilNewsItem::$creation_date
protected

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

Referenced by getCreationDate().

◆ $ctrl

ilNewsItem::$ctrl
protected

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

Referenced by queryNewsForMultipleContexts().

◆ $db

◆ $id

ilNewsItem::$id
protected

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

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

◆ $limitation

ilNewsItem::$limitation
private

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

Referenced by getLimitation().

◆ $lng

ilNewsItem::$lng
protected

◆ $mob_id

ilNewsItem::$mob_id
protected

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

Referenced by getMobId().

◆ $obj_data_cache

ilNewsItem::$obj_data_cache
protected

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

Referenced by getAggregatedNewsData().

◆ $playtime

ilNewsItem::$playtime
protected

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

Referenced by getPlaytime().

◆ $priority

ilNewsItem::$priority = 1
protected

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

Referenced by getPriority().

◆ $privFeedId

ilNewsItem::$privFeedId = false
staticprivate

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

Referenced by getPrivateFeedId(), and setPrivateFeedId().

◆ $title

ilNewsItem::$title
protected

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

Referenced by getTitle().

◆ $tree

ilNewsItem::$tree
protected

◆ $update_date

ilNewsItem::$update_date
protected

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

Referenced by getUpdateDate().

◆ $update_user_id

ilNewsItem::$update_user_id
protected

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

Referenced by getUpdateUserId().

◆ $user

ilNewsItem::$user
protected

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

Referenced by queryNewsForContext(), and queryNewsForMultipleContexts().

◆ $user_id

ilNewsItem::$user_id
protected

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

Referenced by getUserId(), and queryNewsForMultipleContexts().

◆ $visibility

ilNewsItem::$visibility = "users"
protected

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

Referenced by _getDefaultVisibilityForRefId(), and getVisibility().


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