ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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  }
read()
Read item from database.
user()
Definition: user.php:4
$DIC
Definition: xapitoken.php:46
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 1649 of file class.ilNewsItem.php.

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

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

1650  {
1651  global $DIC;
1652 
1653  $tree = $DIC->repositoryTree();
1654  $ilSetting = $DIC->settings();
1655 
1656  include_once("./Services/Block/classes/class.ilBlockSetting.php");
1657 
1658  $news_set = new ilSetting("news");
1659  $default_visibility = ($news_set->get("default_visibility") != "")
1660  ? $news_set->get("default_visibility")
1661  : "users";
1662 
1663  if ($tree->isInTree($a_ref_id)) {
1664  $path = $tree->getPathFull($a_ref_id);
1665 
1666  foreach ($path as $key => $row) {
1667  if (!in_array($row["type"], array("root", "cat","crs", "fold", "grp"))) {
1668  continue;
1669  }
1670 
1672  "news",
1673  "default_visibility",
1674  0,
1675  $row["obj_id"]
1676  );
1677 
1678  if ($visibility != "") {
1679  $default_visibility = $visibility;
1680  }
1681  }
1682  }
1683 
1684  return $default_visibility;
1685  }
static _lookup($a_type, $a_setting, $a_user=0, $a_block_id=0)
Lookup setting from database.
global $ilSetting
Definition: privfeed.php:17
$DIC
Definition: xapitoken.php:46
+ 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(), 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  $fav_rep = new ilFavouritesDBRepository();
755 
756  $news_item = new ilNewsItem();
757  $news_set = new ilSetting("news");
758 
759  $per = $a_per;
760 
761  include_once("./Services/News/classes/class.ilNewsSubscription.php");
762  include_once("./Services/Block/classes/class.ilBlockSetting.php");
763 
764  // this is currently not used
765  $ref_ids = ilNewsSubscription::_getSubscriptionsOfUser($a_user_id);
766 
767  if (ilObjUser::_lookupPref($a_user_id, "pd_items_news") != "n") {
768  // get all items of the personal desktop
769  $pd_items = $fav_rep->getFavouritesOfUser($a_user_id);
770  foreach ($pd_items as $item) {
771  if (!in_array($item["ref_id"], $ref_ids)) {
772  $ref_ids[] = $item["ref_id"];
773  }
774  }
775 
776  // get all memberships
777  include_once 'Services/Membership/classes/class.ilParticipants.php';
778  $crs_mbs = ilParticipants::_getMembershipByType($a_user_id, 'crs');
779  $grp_mbs = ilParticipants::_getMembershipByType($a_user_id, 'grp');
780  $items = array_merge($crs_mbs, $grp_mbs);
781  foreach ($items as $i) {
782  $item_references = ilObject::_getAllReferences($i);
783  if (is_array($item_references) && count($item_references)) {
784  foreach ($item_references as $ref_id) {
785  if (!in_array($ref_id, $ref_ids)) {
786  $ref_ids[] = $ref_id;
787  }
788  }
789  }
790  }
791  }
792 
793  $data = array();
794 
795  foreach ($ref_ids as $ref_id) {
796  if (!$a_only_public) {
797  // this loop should not cost too much performance
798  $acc = $ilAccess->checkAccessOfUser($a_user_id, "read", "", $ref_id);
799 
800  if (!$acc) {
801  continue;
802  }
803  }
804  if (ilNewsItem::getPrivateFeedId() != false) {
805  global $DIC;
806 
807  $rbacsystem = $DIC->rbac()->system();
808  $acc = $rbacsystem->checkAccessOfUser(ilNewsItem::getPrivateFeedId(), "read", $ref_id);
809 
810  if (!$acc) {
811  continue;
812  }
813  }
814 
815  $obj_id = ilObject::_lookupObjId($ref_id);
816  $obj_type = ilObject::_lookupType($obj_id);
817  $news = $news_item->getNewsForRefId(
818  $ref_id,
819  $a_only_public,
820  false,
821  $per,
822  $a_prevent_aggregation,
823  false,
824  false,
825  false,
826  $a_user_id
827  );
828 
829  // counter
830  if (!is_null($a_cnt)) {
831  $a_cnt[$ref_id] = count($news);
832  }
833 
835  }
836 
837  $data = ilUtil::sortArray($data, "creation_date", "desc", false, true);
838 
839  return $data;
840  }
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
$data
Definition: storeScorm.php:23
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 getPrivateFeedId()
static _lookupPref($a_usr_id, $a_keyword)
$DIC
Definition: xapitoken.php:46
$i
Definition: metadata.php:24
+ 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 2068 of file class.ilNewsItem.php.

References $DIC, $ilDB, and $query.

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

2069  {
2070  global $DIC;
2071 
2072  $ilDB = $DIC->database();
2073 
2074  $query = "SELECT * " .
2075  "FROM il_news_item " .
2076  "WHERE " .
2077  " id = " . $ilDB->quote($a_news_id, "integer");
2078  $set = $ilDB->query($query);
2079  $rec = $ilDB->fetchAssoc($set);
2080 
2081  return $rec["context_obj_id"];
2082  }
$query
global $ilDB
$DIC
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

◆ _lookupDefaultPDPeriod()

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

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

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

2088  {
2089  $news_set = new ilSetting("news");
2090  $per = $news_set->get("pd_period");
2091  if ($per == 0) {
2092  $per = 30;
2093  }
2094 
2095  return $per;
2096  }
+ 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 2044 of file class.ilNewsItem.php.

References $DIC, $ilDB, and $query.

Referenced by ilObjMediaObject\lookupUsages().

2045  {
2046  global $DIC;
2047 
2048  $ilDB = $DIC->database();
2049 
2050  $query = "SELECT * " .
2051  "FROM il_news_item " .
2052  "WHERE " .
2053  " mob_id = " . $ilDB->quote($a_mob_id, "integer");
2054 
2055  $usages = array();
2056  $set = $ilDB->query($query);
2057  while ($rec = $ilDB->fetchAssoc($set)) {
2058  $usages[$rec["id"]] = array("type" => "news", "id" => $rec["id"]);
2059  }
2060 
2061  return $usages;
2062  }
$query
global $ilDB
$DIC
Definition: xapitoken.php:46
+ 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 1813 of file class.ilNewsItem.php.

References $DIC, $ilDB, and $query.

Referenced by ilNewsExporter\getXmlExportHeadDependencies().

1814  {
1815  global $DIC;
1816 
1817  $ilDB = $DIC->database();
1818 
1819  $query = "SELECT mob_id FROM il_news_item WHERE id = " .
1820  $ilDB->quote($a_news_id, "integer");
1821  $set = $ilDB->query($query);
1822  $rec = $ilDB->fetchAssoc($set);
1823  return $rec["mob_id"];
1824  }
$query
global $ilDB
$DIC
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

◆ _lookupRSSPeriod()

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

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

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

2131  {
2132  $news_set = new ilSetting("news");
2133  $rss_period = $news_set->get("rss_period");
2134  if ($rss_period == 0) { // default to two weeks
2135  $rss_period = 14;
2136  }
2137  return $rss_period;
2138  }
+ 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 1778 of file class.ilNewsItem.php.

References $DIC, $ilDB, and $query.

1779  {
1780  global $DIC;
1781 
1782  $ilDB = $DIC->database();
1783 
1784  $query = "SELECT title FROM il_news_item WHERE id = " .
1785  $ilDB->quote($a_news_id, "integer");
1786  $set = $ilDB->query($query);
1787  $rec = $ilDB->fetchAssoc($set);
1788  return $rec["title"];
1789  }
$query
global $ilDB
$DIC
Definition: xapitoken.php:46

◆ _lookupUserPDPeriod()

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

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

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

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

2102  {
2103  $news_set = new ilSetting("news");
2104  $allow_shorter_periods = $news_set->get("allow_shorter_periods");
2105  $allow_longer_periods = $news_set->get("allow_longer_periods");
2106  $default_per = ilNewsItem::_lookupDefaultPDPeriod();
2107 
2108  include_once("./Services/Block/classes/class.ilBlockSetting.php");
2109  $per = ilBlockSetting::_lookup(
2110  "pdnews",
2111  "news_pd_period",
2112  $a_user_id,
2113  0
2114  );
2115 
2116  // news period information
2117  if ($per <= 0 ||
2118  (!$allow_shorter_periods && ($per < $default_per)) ||
2119  (!$allow_longer_periods && ($per > $default_per))
2120  ) {
2121  $per = $default_per;
2122  }
2123 
2124  return $per;
2125  }
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 1795 of file class.ilNewsItem.php.

References $DIC, $ilDB, and $query.

Referenced by ilObjMediaObjectAccess\checkAccessMob().

1796  {
1797  global $DIC;
1798 
1799  $ilDB = $DIC->database();
1800 
1801  $query = "SELECT visibility FROM il_news_item WHERE id = " .
1802  $ilDB->quote($a_news_id, "integer");
1803  $set = $ilDB->query($query);
1804  $rec = $ilDB->fetchAssoc($set);
1805 
1806  return $rec["visibility"];
1807  }
$query
global $ilDB
$DIC
Definition: xapitoken.php:46
+ 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 1574 of file class.ilNewsItem.php.

References $DIC, and $ilDB.

Referenced by ilNewsForContextBlockGUI\showNews().

1575  {
1576  global $DIC;
1577 
1578  $ilDB = $DIC->database();
1579  $ilAppEventHandler = $DIC["ilAppEventHandler"];
1580 
1581  $ilDB->replace(
1582  "il_news_read",
1583  array(
1584  "user_id" => array("integer", $a_user_id),
1585  "news_id" => array("integer", $a_news_id)
1586  ),
1587  array()
1588  );
1589 
1590  /*
1591  $ilDB->manipulate("DELETE FROM il_news_read WHERE ".
1592  "user_id = ".$ilDB->quote($a_user_id, "integer").
1593  " AND news_id = ".$ilDB->quote($a_news_id, "integer"));
1594  $ilDB->manipulate("INSERT INTO il_news_read (user_id, news_id) VALUES (".
1595  $ilDB->quote($a_user_id, "integer").",".
1596  $ilDB->quote($a_news_id, "integer").")");*/
1597 
1598  $ilAppEventHandler->raise(
1599  "Services/News",
1600  "readNews",
1601  array("user_id" => $a_user_id, "news_ids" => array($a_news_id))
1602  );
1603  }
global $ilDB
$DIC
Definition: xapitoken.php:46
+ 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 1609 of file class.ilNewsItem.php.

References $DIC, and $ilDB.

1610  {
1611  global $DIC;
1612 
1613  $ilDB = $DIC->database();
1614  $ilAppEventHandler = $DIC["ilAppEventHandler"];
1615 
1616  $ilDB->manipulate("DELETE FROM il_news_read (user_id, news_id) VALUES (" .
1617  " WHERE user_id = " . $ilDB->quote($a_user_id, "integer") .
1618  " AND news_id = " . $ilDB->quote($a_news_id, "integer"));
1619 
1620  $ilAppEventHandler->raise(
1621  "Services/News",
1622  "unreadNews",
1623  array("user_id" => $a_user_id, "news_ids" => array($a_news_id))
1624  );
1625  }
global $ilDB
$DIC
Definition: xapitoken.php:46

◆ aggregateFiles()

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

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

Referenced by getAggregatedChildNewsData(), and getAggregatedNewsData().

1138  {
1139  $first_file = "";
1140  $to_del = array();
1141  foreach ($news as $k => $v) {
1142  // aggregate file related news
1143  if ($news[$k]["context_obj_type"] == "file") {
1144  if ($first_file == "") {
1145  $first_file = $k;
1146  } else {
1147  $to_del[] = $k;
1148  }
1149  $news[$first_file]["aggregation"][$k] = $news[$k];
1150  $news[$first_file]["agg_ref_id"] = $a_ref_id;
1151  $news[$first_file]["ref_id"] = $a_ref_id;
1152  }
1153  }
1154 
1155  foreach ($to_del as $v) {
1156  unset($news[$v]);
1157  }
1158 
1159  return $news;
1160  }
+ 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 1088 of file class.ilNewsItem.php.

Referenced by getNewsForRefId().

1089  {
1090  $to_del = array();
1091  $forums = array();
1092 
1093  // aggregate
1094  foreach ($news as $k => $v) {
1095  if ($a_group_posting_sequence && $last_aggregation_forum > 0 &&
1096  $last_aggregation_forum != $news[$k]["context_obj_id"]) {
1097  $forums[$last_aggregation_forum] = "";
1098  }
1099 
1100  if ($news[$k]["context_obj_type"] == "frm") {
1101  if ($forums[$news[$k]["context_obj_id"]] == "") {
1102  // $forums[forum_id] = news_id;
1103  $forums[$news[$k]["context_obj_id"]] = $k;
1104  $last_aggregation_forum = $news[$k]["context_obj_id"];
1105  } else {
1106  $to_del[] = $k;
1107  }
1108 
1109  $news[$k]["no_context_title"] = true;
1110 
1111  // aggregate every forum into it's "k" news
1112  $news[$forums[$news[$k]["context_obj_id"]]]["aggregation"][$k]
1113  = $news[$k];
1114  $news[$k]["agg_ref_id"]
1115  = $news[$k]["ref_id"];
1116  $news[$k]["content"] = "";
1117  $news[$k]["content_long"] = "";
1118  }
1119  }
1120 
1121  // delete double entries
1122  foreach ($to_del as $k) {
1123  unset($news[$k]);
1124  }
1125  //var_dump($news[14]["aggregation"]);
1126 
1127 
1128  return $news;
1129  }
+ 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 1435 of file class.ilNewsItem.php.

References $db, $ilDB, and $query.

1436  {
1437  $ilDB = $this->db;
1438 
1439  $all = array();
1440 
1441  $limit_ts = self::handleTimePeriod($a_time_period);
1442 
1443  // are there any news items for relevant objects and?
1444  $query = $ilDB->query("SELECT id,context_obj_id,context_obj_type" .
1445  " FROM il_news_item" .
1446  " WHERE " . $ilDB->in("context_obj_id", array_keys($objects), false, "integer") .
1447  " AND creation_date >= " . $ilDB->quote($limit_ts, "timestamp"));
1448  while ($rec = $ilDB->fetchAssoc($query)) {
1449  if ($objects[$rec["context_obj_id"]]["type"] == $rec["context_obj_type"]) {
1450  $all[] = $rec["id"];
1451  }
1452  }
1453 
1454  return $all;
1455  }
$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 1692 of file class.ilNewsItem.php.

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

1693  {
1694  $ilDB = $this->db;
1695 
1696  // delete il_news_read entries
1697  $ilDB->manipulate("DELETE FROM il_news_read " .
1698  " WHERE news_id = " . $ilDB->quote($this->getId(), "integer"));
1699 
1700  // delete multimedia object
1701  $mob = $this->getMobId();
1702 
1703  // delete
1704  $query = "DELETE FROM il_news_item" .
1705  " WHERE id = " . $ilDB->quote($this->getId(), "integer");
1706  $ilDB->manipulate($query);
1707 
1708  // delete mob after news, to have a "mob usage" of 0
1709  if ($mob > 0 and ilObject::_exists($mob)) {
1710  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1711  $mob = new ilObjMediaObject($mob);
1712  $mob->delete();
1713  }
1714  }
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 1758 of file class.ilNewsItem.php.

References $n.

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

1763  {
1764  foreach (self::getNewsOfContext(
1765  $a_context_obj_id,
1766  $a_context_obj_type,
1767  $a_context_sub_obj_id,
1768  $a_context_sub_obj_type
1769  ) as $n) {
1770  $n->delete();
1771  }
1772  }
$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 2164 of file class.ilNewsItem.php.

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

2165  {
2166  $mob = $this->getMobId();
2167  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2168  $mob = new ilObjMediaObject($mob);
2169  $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
2170 
2171  // check purpose
2172  if (!$mob->hasPurposeItem($a_purpose)) {
2173  return false;
2174  }
2175 
2176  $m_item = $mob->getMediaItem($a_purpose);
2177  if ($m_item->getLocationType() != "Reference") {
2178  $file = $mob_dir . "/" . $m_item->getLocation();
2179  if (file_exists($file) && is_file($file)) {
2180  if ($a_increase_download_cnt) {
2181  $this->increaseDownloadCounter();
2182  }
2183  ilUtil::deliverFile($file, $m_item->getLocation(), "", false, false, false);
2184  return true;
2185  } else {
2186  ilUtil::sendFailure("File not found!", true);
2187  return false;
2188  }
2189  } else {
2190  if ($a_increase_download_cnt) {
2191  $this->increaseDownloadCounter();
2192  }
2193  ilUtil::redirect($m_item->getLocation());
2194  }
2195  }
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 1950 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().

1951  {
1952  global $DIC;
1953 
1954  $lng = $DIC->language();
1955  $obj_definition = $DIC["objDefinition"];
1956 
1957  if ($a_is_lang_var) {
1958  if ($obj_definition->isPlugin($a_context_obj_type)) {
1959  return ilObjectPlugin::lookupTxtById($a_context_obj_type, $a_content);
1960  }
1961  $lng->loadLanguageModule($a_context_obj_type);
1962  return $lng->txt($a_content);
1963  } else {
1964  return $a_content;
1965  }
1966  }
static lookupTxtById($plugin_id, $lang_var)
$a_content
Definition: workflow.php:93
$DIC
Definition: xapitoken.php:46
+ 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 1886 of file class.ilNewsItem.php.

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

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

1892  {
1893  global $DIC;
1894 
1895  $lng = $DIC->language();
1896  $obj_definition = $DIC["objDefinition"];
1897 
1898  if ($a_agg_ref_id > 0) {
1899  $cnt = count($a_aggregation);
1900 
1901  // forums
1902  if ($a_context_obj_type == "frm") {
1903  if ($cnt > 1) {
1904  return sprintf($lng->txt("news_x_postings"), $cnt);
1905  } else {
1906  return $lng->txt("news_1_postings");
1907  }
1908  } else { // files
1909  $up_cnt = $cr_cnt = 0;
1910  foreach ($a_aggregation as $item) {
1911  if ($item["title"] == "file_updated") {
1912  $up_cnt++;
1913  } else {
1914  $cr_cnt++;
1915  }
1916  }
1917  $sep = "";
1918  if ($cr_cnt == 1) {
1919  $tit = $lng->txt("news_1_file_created");
1920  $sep = "<br />";
1921  } elseif ($cr_cnt > 1) {
1922  $tit = sprintf($lng->txt("news_x_files_created"), $cr_cnt);
1923  $sep = "<br />";
1924  }
1925  if ($up_cnt == 1) {
1926  $tit .= $sep . $lng->txt("news_1_file_updated");
1927  } elseif ($up_cnt > 1) {
1928  $tit .= $sep . sprintf($lng->txt("news_x_files_updated"), $up_cnt);
1929  }
1930  return $tit;
1931  }
1932  } else {
1933  if ($a_content_is_lang_var) {
1934  if ($obj_definition->isPlugin($a_context_obj_type)) {
1935  return ilObjectPlugin::lookupTxtById($a_context_obj_type, $a_title);
1936  }
1937  return $lng->txt($a_title);
1938  } else {
1939  return $a_title;
1940  }
1941  }
1942 
1943  return "";
1944  }
static lookupTxtById($plugin_id, $lang_var)
$DIC
Definition: xapitoken.php:46
+ 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 1862 of file class.ilNewsItem.php.

References $DIC, $ilDB, and $query.

1863  {
1864  global $DIC;
1865 
1866  $ilDB = $DIC->database();
1867 
1868  $query = "SELECT context_obj_type, content_is_lang_var, title FROM il_news_item WHERE id = " .
1869  $ilDB->quote($a_news_id, "integer");
1870  $set = $ilDB->query($query);
1871  $rec = $ilDB->fetchAssoc($set);
1872 
1873  return self::determineNewsTitle(
1874  $rec["context_obj_type"],
1875  $rec["title"],
1876  $rec["content_is_lang_var"],
1877  $a_agg_ref_id,
1878  $a_aggregation
1879  );
1880  }
$query
global $ilDB
$DIC
Definition: xapitoken.php:46

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

References $DIC, $ilDB, and $query.

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

1831  {
1832  global $DIC;
1833 
1834  $ilDB = $DIC->database();
1835 
1836  $and = "";
1837  if ($a_time_period > 0) {
1838  $limit_ts = self::handleTimePeriod($a_time_period);
1839  $and = " AND creation_date >= " . $ilDB->quote($limit_ts, "timestamp") . " ";
1840  }
1841 
1842  if ($a_starting_date != "") {
1843  $and .= " AND creation_date >= " . $ilDB->quote($a_starting_date, "timestamp");
1844  }
1845 
1846  $query = "SELECT DISTINCT(context_obj_id) AS obj_id FROM il_news_item" .
1847  " WHERE " . $ilDB->in("context_obj_id", $a_obj_ids, false, "integer") . " " . $and;
1848  //" WHERE context_obj_id IN (".implode(ilUtil::quoteArray($a_obj_ids),",").")".$and;
1849 
1850  $set = $ilDB->query($query);
1851  $objs = array();
1852  while ($rec = $ilDB->fetchAssoc($set)) {
1853  $objs[] = $rec["obj_id"];
1854  }
1855 
1856  return $objs;
1857  }
$query
global $ilDB
$DIC
Definition: xapitoken.php:46
+ 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 1174 of file class.ilNewsItem.php.

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

Referenced by getNewsForRefId().

1181  {
1182  $tree = $this->tree;
1183  $ilAccess = $this->access;
1184 
1185  // get news of parent object
1186  $data = $this->getNewsForRefId(
1187  $a_ref_id,
1188  $a_only_public,
1189  true,
1190  $a_time_period,
1191  true,
1192  false,
1193  false,
1194  $a_no_auto_generated
1195  );
1196  foreach ($data as $k => $v) {
1197  $data[$k]["ref_id"] = $a_ref_id;
1198  }
1199 
1200  // get childs
1201  $nodes = $tree->getChilds($a_ref_id);
1202 
1203  // no check, for which of the objects any news are available
1204  $obj_ids = array();
1205  foreach ($nodes as $node) {
1206  $obj_ids[] = $node["obj_id"];
1207  }
1208  $news_obj_ids = ilNewsItem::filterObjIdsPerNews($obj_ids, $a_time_period, $a_starting_date);
1209  //$news_obj_ids = $obj_ids;
1210 
1211  // get news for all subtree nodes
1212  $contexts = array();
1213  foreach ($nodes as $node) {
1214  // only go on, if news are available
1215  if (!in_array($node["obj_id"], $news_obj_ids)) {
1216  continue;
1217  }
1218 
1219  if (!$a_only_public && !$ilAccess->checkAccess("read", "", $node["child"])) {
1220  continue;
1221  }
1222  $ref_id[$node["obj_id"]] = $node["child"];
1223  $contexts[] = array("obj_id" => $node["obj_id"],
1224  "obj_type" => $node["type"]);
1225  }
1226 
1227  $news = $this->queryNewsForMultipleContexts(
1228  $contexts,
1229  $a_only_public,
1230  $a_time_period,
1231  $a_starting_date,
1232  $a_no_auto_generated
1233  );
1234  foreach ($news as $k => $v) {
1235  $news[$k]["ref_id"] = $ref_id[$v["context_obj_id"]];
1236  }
1237  $data = ilNewsItem::mergeNews($data, $news);
1238 
1239  // sort and return
1240  $data = ilUtil::sortArray($data, "creation_date", "desc", false, true);
1241 
1242  if (!$a_prevent_aggregation) {
1243  $data = $this->aggregateFiles($data, $a_ref_id);
1244  }
1245 
1246  return $data;
1247  }
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
$data
Definition: storeScorm.php:23
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.
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 979 of file class.ilNewsItem.php.

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

Referenced by getNewsForRefId().

989  {
990  $tree = $this->tree;
991  $ilAccess = $this->access;
992  $ilObjDataCache = $this->obj_data_cache;
993 
994  // get news of parent object
995 
996  $data = array();
997 
998  // get subtree
999  $cur_node = $tree->getNodeData($a_ref_id);
1000 
1001  // do not check for lft (materialized path)
1002  if ($cur_node) {
1003  $nodes = (array) $tree->getSubTree($cur_node, true);
1004  } else {
1005  $nodes = array();
1006  }
1007 
1008  // preload object data cache
1009  $ref_ids = array();
1010  $obj_ids = array();
1011  foreach ($nodes as $node) {
1012  $ref_ids[] = $node["child"];
1013  $obj_ids[] = $node["obj_id"];
1014  }
1015 
1016  $ilObjDataCache->preloadReferenceCache($ref_ids);
1017  if (!$a_only_public) {
1018  include_once "Services/Object/classes/class.ilObjectActivation.php";
1020  }
1021 
1022  // no check, for which of the objects any news are available
1023  $news_obj_ids = ilNewsItem::filterObjIdsPerNews($obj_ids, $a_time_period, $a_starting_date);
1024  //$news_obj_ids = $obj_ids;
1025 
1026  // get news for all subtree nodes
1027  $contexts = array();
1028  foreach ($nodes as $node) {
1029  // only go on, if news are available
1030  if (!in_array($node["obj_id"], $news_obj_ids)) {
1031  continue;
1032  }
1033 
1034  if (!$a_only_public) {
1035  if (!$a_user_id) {
1036  $acc = $ilAccess->checkAccess("read", "", $node["child"]);
1037  } else {
1038  $acc = $ilAccess->checkAccessOfUser(
1039  $a_user_id,
1040  "read",
1041  "",
1042  $node["child"]
1043  );
1044  }
1045  if (!$acc) {
1046  continue;
1047  }
1048  }
1049 
1050  $ref_id[$node["obj_id"]] = $node["child"];
1051  $contexts[] = array("obj_id" => $node["obj_id"],
1052  "obj_type" => $node["type"]);
1053  }
1054 
1055  // sort and return
1056  $news = $this->queryNewsForMultipleContexts(
1057  $contexts,
1058  $a_only_public,
1059  $a_time_period,
1060  $a_starting_date,
1061  $a_no_auto_generated,
1062  $a_user_id,
1063  $a_limit,
1064  $a_exclude
1065  );
1066 
1067  $to_del = array();
1068  foreach ($news as $k => $v) {
1069  $news[$k]["ref_id"] = $ref_id[$v["context_obj_id"]];
1070  }
1071 
1072  $data = ilNewsItem::mergeNews($data, $news);
1073  $data = ilUtil::sortArray($data, "creation_date", "desc", false, true);
1074 
1075  if (!$a_prevent_aggregation) {
1076  $data = $this->aggregateFiles($data, $a_ref_id);
1077  }
1078 
1079  return $data;
1080  }
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
$data
Definition: storeScorm.php:23
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.
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 1974 of file class.ilNewsItem.php.

References $DIC, $ilDB, and $query.

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

1979  {
1980  global $DIC;
1981 
1982  $ilDB = $DIC->database();
1983 
1984  // Determine how many rows should be deleted
1985  $query = "SELECT * " .
1986  "FROM il_news_item " .
1987  "WHERE " .
1988  "context_obj_id = " . $ilDB->quote($a_context_obj_id, "integer") .
1989  " AND context_obj_type = " . $ilDB->quote($a_context_obj_type, "text") .
1990  " AND context_sub_obj_id = " . $ilDB->quote($a_context_sub_obj_id, "integer") .
1991  " AND " . $ilDB->equals("context_sub_obj_type", $a_context_sub_obj_type, "text", true);
1992 
1993  $set = $ilDB->query($query);
1994  $rec = $ilDB->fetchAssoc($set);
1995 
1996  return $rec["id"];
1997  }
$query
global $ilDB
$DIC
Definition: xapitoken.php:46
+ 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 2003 of file class.ilNewsItem.php.

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

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

2009  {
2010  global $DIC;
2011 
2012  $ilDB = $DIC->database();
2013 
2014  // Determine how many rows should be deleted
2015  $query = "SELECT id, update_date " .
2016  "FROM il_news_item " .
2017  "WHERE " .
2018  "context_obj_id = " . $ilDB->quote($a_context_obj_id, "integer") .
2019  " AND context_obj_type = " . $ilDB->quote($a_context_obj_type, "text") .
2020  " AND context_sub_obj_id = " . $ilDB->quote($a_context_sub_obj_id, "integer") .
2021  " AND " . $ilDB->equals("context_sub_obj_type", $a_context_sub_obj_type, "text", true) .
2022  " ORDER BY update_date DESC";
2023 
2024  $ilDB->setLimit(1);
2025  $set = $ilDB->query($query);
2026  $rec = $ilDB->fetchAssoc($set);
2027 
2028  $id = (int) $rec["id"];
2029  if ($a_only_today) {
2030  $now = ilUtil::now();
2031  if (substr($now, 0, 10) != substr($rec["update_date"], 0, 10)) {
2032  $id = 0;
2033  }
2034  }
2035 
2036  return $id;
2037  }
static now()
Return current timestamp in Y-m-d H:i:s format.
$query
global $ilDB
$DIC
Definition: xapitoken.php:46
+ 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 860 of file class.ilNewsItem.php.

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

Referenced by getAggregatedChildNewsData().

872  {
873  $obj_id = ilObject::_lookupObjId($a_ref_id);
874  $obj_type = ilObject::_lookupType($obj_id);
875 
876  // get starting date
877  $starting_date = "";
878  if ($obj_type == "grp" || $obj_type == "crs") {
879  // see #31471, #30687, and ilMembershipNotification
881  $obj_id,
882  'cont_use_news',
883  true
884  ) || (
886  $obj_id,
887  'cont_show_news',
888  true
890  $obj_id,
891  'news_timeline'
892  )
893  )) {
894  return [];
895  }
896 
897  include_once("./Services/Block/classes/class.ilBlockSetting.php");
898  $hide_news_per_date = ilBlockSetting::_lookup(
899  "news",
900  "hide_news_per_date",
901  0,
902  $obj_id
903  );
904  if ($hide_news_per_date && !$a_ignore_date_filter) {
905  $starting_date = ilBlockSetting::_lookup(
906  "news",
907  "hide_news_date",
908  0,
909  $obj_id
910  );
911  }
912  }
913 
914  if ($obj_type == "cat" && !$a_stopnesting) {
915  $news = $this->getAggregatedChildNewsData(
916  $a_ref_id,
917  $a_only_public,
918  $a_time_period,
919  $a_prevent_aggregation,
920  $starting_date,
921  $a_no_auto_generated
922  );
923  } elseif (($obj_type == "grp" || $obj_type == "crs") &&
924  !$a_stopnesting) {
925  $news = $this->getAggregatedNewsData(
926  $a_ref_id,
927  $a_only_public,
928  $a_time_period,
929  $a_prevent_aggregation,
930  $starting_date,
931  $a_no_auto_generated,
932  $a_user_id,
933  $a_limit,
934  $a_excluded
935  );
936  } else {
937  $news_item = new ilNewsItem();
938  $news_item->setContextObjId($obj_id);
939  $news_item->setContextObjType($obj_type);
940  $news = $news_item->queryNewsForContext(
941  $a_only_public,
942  $a_time_period,
943  $starting_date,
944  $a_no_auto_generated
945  );
946  $unset = array();
947  foreach ($news as $k => $v) {
948  if (!$a_only_public || $v["visibility"] == NEWS_PUBLIC ||
949  ($v["priority"] == 0 &&
951  "news",
952  "public_notifications",
953  0,
954  $obj_id
955  ))) {
956  $news[$k]["ref_id"] = $a_ref_id;
957  } else {
958  $unset[] = $k;
959  }
960  }
961  foreach ($unset as $un) {
962  unset($news[$un]);
963  }
964  }
965 
966  if (!$a_prevent_aggregation) {
967  $news = $this->aggregateForums($news);
968  } elseif ($a_forum_group_sequences) {
969  $news = $this->aggregateForums($news, true);
970  }
971 
972  return $news;
973  }
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.
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
+ 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 1720 of file class.ilNewsItem.php.

References $DIC, $ilDB, and $query.

Referenced by ilNewsData\getNewsOfContext().

1725  {
1726  global $DIC;
1727 
1728  $ilDB = $DIC->database();
1729 
1730  if ($a_context_obj_id == 0 || $a_context_obj_type == "") {
1731  return [];
1732  }
1733 
1734  if ($a_context_sub_obj_id > 0) {
1735  $and = " AND context_sub_obj_id = " . $ilDB->quote($a_context_sub_obj_id, "integer") .
1736  " AND context_sub_obj_type = " . $ilDB->quote($a_context_sub_obj_type, "text");
1737  }
1738 
1739  // get news records
1740  $query = "SELECT * FROM il_news_item" .
1741  " WHERE context_obj_id = " . $ilDB->quote($a_context_obj_id, "integer") .
1742  " AND context_obj_type = " . $ilDB->quote($a_context_obj_type, "text") .
1743  $and;
1744 
1745  $news_set = $ilDB->query($query);
1746 
1747  $news_arr = [];
1748  while ($news = $ilDB->fetchAssoc($news_set)) {
1749  $news_arr[] = new ilNewsItem($news["id"]);
1750  }
1751  return $news_arr;
1752  }
$query
global $ilDB
$DIC
Definition: xapitoken.php:46
+ 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 2151 of file class.ilNewsItem.php.

References $privFeedId.

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

2152  {
2153  return ilNewsItem::$privFeedId;
2154  }
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 1271 of file class.ilNewsItem.php.

1272  {
1273  // time period is number of days
1274  if (is_numeric($a_time_period)) {
1275  if ($a_time_period > 0) {
1276  return date('Y-m-d H:i:s', time() - ($a_time_period * 24 * 60 * 60));
1277  }
1278  }
1279  // time period is datetime
1280  elseif (preg_match("/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/", $a_time_period)) {
1281  return $a_time_period;
1282  }
1283  // :TODO: what to return?
1284  }

◆ increaseDownloadCounter()

ilNewsItem::increaseDownloadCounter ( )

Increase download counter.

Deprecated:
will move to data

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

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

Referenced by deliverMobFile().

2202  {
2203  $ilDB = $this->db;
2204 
2205  $cnt = $this->getMobDownloadCounter();
2206  $cnt++;
2207  $this->setMobDownloadCounter($cnt);
2208  $ilDB->manipulate(
2209  "UPDATE il_news_item SET " .
2210  " mob_cnt_download = " . $ilDB->quote($cnt, "integer") .
2211  " WHERE id = " . $ilDB->quote($this->getId(), "integer")
2212  );
2213  }
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 2220 of file class.ilNewsItem.php.

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

2221  {
2222  $ilDB = $this->db;
2223 
2224  $cnt = $this->getMobPlayCounter();
2225  $cnt++;
2226  $this->setMobPlayCounter($cnt);
2227  $ilDB->manipulate(
2228  "UPDATE il_news_item SET " .
2229  " mob_cnt_play = " . $ilDB->quote($cnt, "integer") .
2230  " WHERE id = " . $ilDB->quote($this->getId(), "integer")
2231  );
2232  }
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 1635 of file class.ilNewsItem.php.

References $id.

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

1636  {
1637  foreach ($n2 as $id => $news) {
1638  $n1[$id] = $news;
1639  }
1640 
1641  return $n1;
1642  }
+ 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 2240 of file class.ilNewsItem.php.

References $data, $DIC, and $ilDB.

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

2241  {
2242  global $DIC;
2243 
2244  $ilDB = $DIC->database();
2245 
2246  $data = $a_cres;
2247  $news_ids = array_keys($data);
2248  $set = $ilDB->query("SELECT id FROM il_news_item " .
2249  " WHERE " . $ilDB->in("id", $news_ids, false, "integer"));
2250  $existing_ids = array();
2251  while ($rec = $ilDB->fetchAssoc($set)) {
2252  $existing_ids[] = $rec["id"];
2253  }
2254  //var_dump($existing_ids);
2255  $existing_news = array();
2256  foreach ($data as $k => $v) {
2257  if (in_array($k, $existing_ids)) {
2258  $existing_news[$k] = $v;
2259  }
2260  }
2261 
2262  //var_dump($data);
2263  //var_dump($existing_news);
2264 
2265  return $existing_news;
2266  }
$data
Definition: storeScorm.php:23
global $ilDB
$DIC
Definition: xapitoken.php:46
+ 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 1415 of file class.ilNewsItem.php.

References $DIC, and $ilDB.

Referenced by ilMembershipCronNotificationsData\loadMissingNews().

1416  {
1417  global $DIC;
1418  $ilDB = $DIC->database();
1419  $news = array();
1420  $set = $ilDB->query("SELECT * FROM il_news_item " .
1421  " WHERE " . $ilDB->in("id", $a_news_ids, false, "integer"));
1422  while ($rec = $ilDB->fetchAssoc($set)) {
1423  $news[$rec["id"]] = $rec;
1424  }
1425  return $news;
1426  }
global $ilDB
$DIC
Definition: xapitoken.php:46
+ 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 1295 of file class.ilNewsItem.php.

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

1302  {
1303  $ilDB = $this->db;
1304  $ilUser = $this->user;
1305  $lng = $this->lng;
1306 
1307  $and = "";
1308  if ($a_time_period > 0) {
1309  $limit_ts = self::handleTimePeriod($a_time_period);
1310  $and = " AND creation_date >= " . $ilDB->quote($limit_ts, "timestamp") . " ";
1311  }
1312 
1313  if ($a_starting_date != "") {
1314  $and .= " AND creation_date > " . $ilDB->quote($a_starting_date, "timestamp") . " ";
1315  }
1316 
1317  if ($a_no_auto_generated) {
1318  $and .= " AND priority = 1 AND content_type = " . $ilDB->quote("text", "text") . " ";
1319  }
1320 
1321  // this is changed with 4.1 (news table for lm pages)
1322  if ($this->getContextSubObjId() > 0) {
1323  $and .= " AND context_sub_obj_id = " . $ilDB->quote($this->getContextSubObjId(), "integer") .
1324  " AND context_sub_obj_type = " . $ilDB->quote($this->getContextSubObjType(), "text");
1325  }
1326 
1327  $ordering = ($a_oldest_first)
1328  ? " creation_date ASC, id ASC "
1329  : " creation_date DESC, id DESC ";
1330 
1331  if ($a_for_rss_use && ilNewsItem::getPrivateFeedId() == false) {
1332  $query = "SELECT * " .
1333  "FROM il_news_item " .
1334  " WHERE " .
1335  "context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
1336  " AND context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text") .
1337  $and .
1338  " ORDER BY " . $ordering;
1339  } elseif (ilNewsItem::getPrivateFeedId() != false) {
1340  $query = "SELECT il_news_item.* " .
1341  ", il_news_read.user_id user_read " .
1342  "FROM il_news_item LEFT JOIN il_news_read " .
1343  "ON il_news_item.id = il_news_read.news_id AND " .
1344  " il_news_read.user_id = " . $ilDB->quote(ilNewsItem::getPrivateFeedId(), "integer") .
1345  " WHERE " .
1346  "context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
1347  " AND context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text") .
1348  $and .
1349  " ORDER BY " . $ordering;
1350  } else {
1351  $query = "SELECT il_news_item.* " .
1352  ", il_news_read.user_id as user_read " .
1353  "FROM il_news_item LEFT JOIN il_news_read " .
1354  "ON il_news_item.id = il_news_read.news_id AND " .
1355  " il_news_read.user_id = " . $ilDB->quote($ilUser->getId(), "integer") .
1356  " WHERE " .
1357  "context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
1358  " AND context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text") .
1359  $and .
1360  " ORDER BY " . $ordering;
1361  }
1362  //echo $query;
1363  $set = $ilDB->query($query);
1364  $result = array();
1365  while ($rec = $ilDB->fetchAssoc($set)) {
1366  if ($a_limit > 0 && count($result) >= $a_limit) {
1367  continue;
1368  }
1369  if (!$a_for_rss_use || (ilNewsItem::getPrivateFeedId() != false) || ($rec["visibility"] == NEWS_PUBLIC ||
1370  ($rec["priority"] == 0 &&
1372  "news",
1373  "public_notifications",
1374  0,
1375  $rec["context_obj_id"]
1376  )))) {
1377  $result[$rec["id"]] = $rec;
1378  }
1379  }
1380 
1381  // do we get data for rss and may the time limit by an issue?
1382  // do a second query without time limit.
1383  // this is not very performant, but I do not have a better
1384  // idea. The keep_rss_min setting is currently (Jul 2012) only set
1385  // by mediacasts
1386  if ($a_time_period != "" && $a_for_rss_use) {
1387  include_once("./Services/Block/classes/class.ilBlockSetting.php");
1388  $keep_rss_min = ilBlockSetting::_lookup(
1389  "news",
1390  "keep_rss_min",
1391  0,
1392  $this->getContextObjId()
1393  );
1394  if ($keep_rss_min > 0) {
1395  return $this->queryNewsForContext(
1396  true,
1397  0,
1398  $a_starting_date,
1399  $a_no_auto_generated,
1400  $a_oldest_first,
1401  $keep_rss_min
1402  );
1403  }
1404  }
1405 
1406  return $result;
1407  }
$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 1470 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().

1479  {
1480  $ilDB = $this->db;
1481  $ilUser = $this->user;
1482  $lng = $this->lng;
1483  $ilCtrl = $this->ctrl;
1484 
1485  $and = "";
1486  if ($a_time_period > 0) {
1487  $limit_ts = self::handleTimePeriod($a_time_period);
1488  $and = " AND creation_date >= " . $ilDB->quote($limit_ts, "timestamp") . " ";
1489  }
1490 
1491  if ($a_starting_date != "") {
1492  $and .= " AND creation_date > " . $ilDB->quote($a_starting_date, "timestamp") . " ";
1493  }
1494 
1495  if ($a_no_auto_generated) {
1496  $and .= " AND priority = 1 AND content_type = " . $ilDB->quote("text", "text") . " ";
1497  }
1498 
1499  if ($a_limit > 0) {
1500  $ilDB->setLimit($a_limit, 0);
1501  }
1502 
1503  if (is_array($a_exclude) && count($a_exclude) > 0) {
1504  $and .= " AND " . $ilDB->in("id", $a_exclude, true, "integer") . " ";
1505  }
1506 
1507  $ids = array();
1508  $type = array();
1509 
1510  foreach ($a_contexts as $cont) {
1511  $ids[] = $cont["obj_id"];
1512  $type[$cont["obj_id"]] = $cont["obj_type"];
1513  }
1514 
1515  if ($a_for_rss_use && ilNewsItem::getPrivateFeedId() == false) {
1516  $query = "SELECT * " .
1517  "FROM il_news_item " .
1518  " WHERE " .
1519  $ilDB->in("context_obj_id", $ids, false, "integer") . " " .
1520  $and .
1521  " ORDER BY creation_date DESC ";
1522  } elseif (ilNewsItem::getPrivateFeedId() != false) {
1523  $query = "SELECT il_news_item.* " .
1524  ", il_news_read.user_id as user_read " .
1525  "FROM il_news_item LEFT JOIN il_news_read " .
1526  "ON il_news_item.id = il_news_read.news_id AND " .
1527  " il_news_read.user_id = " . $ilDB->quote(ilNewsItem::getPrivateFeedId(), "integer") .
1528  " WHERE " .
1529  $ilDB->in("context_obj_id", $ids, false, "integer") . " " .
1530  $and .
1531  " ORDER BY creation_date DESC ";
1532  } else {
1533  if ($a_user_id) {
1534  $user_id = $a_user_id;
1535  } else {
1536  $user_id = $ilUser->getId();
1537  }
1538  $query = "SELECT il_news_item.* " .
1539  ", il_news_read.user_id as user_read " .
1540  "FROM il_news_item LEFT JOIN il_news_read " .
1541  "ON il_news_item.id = il_news_read.news_id AND " .
1542  " il_news_read.user_id = " . $ilDB->quote($user_id, "integer") .
1543  " WHERE " .
1544  $ilDB->in("context_obj_id", $ids, false, "integer") . " " .
1545  $and .
1546  " ORDER BY creation_date DESC ";
1547  }
1548 
1549  $set = $ilDB->query($query);
1550  $result = array();
1551  while ($rec = $ilDB->fetchAssoc($set)) {
1552  if ($type[$rec["context_obj_id"]] == $rec["context_obj_type"]) {
1553  if (!$a_for_rss_use || ilNewsItem::getPrivateFeedId() != false || ($rec["visibility"] == NEWS_PUBLIC ||
1554  ($rec["priority"] == 0 &&
1556  "news",
1557  "public_notifications",
1558  0,
1559  $rec["context_obj_id"]
1560  )))) {
1561  $result[$rec["id"]] = $rec;
1562  }
1563  }
1564  }
1565 
1566  return $result;
1567  }
$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 1257 of file class.ilNewsItem.php.

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

1258  {
1259  $this->setContextObjId($a_obj_id);
1260  $this->setContextObjType($a_obj_type);
1261  $this->setContextSubObjId($a_sub_obj_id);
1262  $this->setContextSubObjType($a_sub_obj_type);
1263  }
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 2143 of file class.ilNewsItem.php.

References $privFeedId.

Referenced by ilObjectFeedWriter\__construct().

2144  {
2145  ilNewsItem::$privFeedId = $a_userId;
2146  }
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: