ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilNewsItem Class Reference

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

+ Collaboration diagram for ilNewsItem:

Public Member Functions

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

Static Public Member Functions

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

Protected Member Functions

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

Static Protected Member Functions

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

Protected Attributes

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

Private Attributes

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

Static Private Attributes

static int $privFeedId = 0
 

Detailed Description

A news item can be created by different sources.

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

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

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

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

Constructor & Destructor Documentation

◆ __construct()

ilNewsItem::__construct ( int  $a_id = 0)

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

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

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

Member Function Documentation

◆ _getDefaultVisibilityForRefId()

static ilNewsItem::_getDefaultVisibilityForRefId ( int  $a_ref_id)
static

Get default visibility for reference id.

Deprecated:
will move to ilNewsData

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

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

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

1386  : string
1387  {
1388  global $DIC;
1389 
1390  $tree = $DIC->repositoryTree();
1391 
1392  $news_set = new ilSetting("news");
1393  $default_visibility = ($news_set->get("default_visibility") != "")
1394  ? $news_set->get("default_visibility")
1395  : "users";
1396 
1397  if ($tree->isInTree($a_ref_id)) {
1398  $path = $tree->getPathFull($a_ref_id);
1399 
1400  foreach ($path as $key => $row) {
1401  if (!in_array($row["type"], ["root", "cat", "crs", "fold", "grp"], true)) {
1402  continue;
1403  }
1404 
1406  "news",
1407  "default_visibility",
1408  0,
1409  (int) $row["obj_id"]
1410  );
1411 
1412  if ($visibility != "") {
1413  $default_visibility = $visibility;
1414  }
1415  }
1416  }
1417 
1418  return $default_visibility;
1419  }
isInTree(?int $a_node_id)
get all information of a node.
getPathFull(int $a_endnode_id, int $a_startnode_id=0)
get path from a given startnode to a given endnode if startnode is not given the rootnode is startnod...
$path
Definition: ltiservices.php:29
static _lookup(string $a_type, string $a_setting, int $a_user=0, int $a_block_id=0)
Lookup setting from database.
global $DIC
Definition: shib_login.php:26
string $visibility
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getNewsItemsOfUser()

static ilNewsItem::_getNewsItemsOfUser ( int  $a_user_id,
bool  $a_only_public = false,
bool  $a_prevent_aggregation = false,
int  $a_per = 0,
array &  $a_cnt = [],
bool  $no_auto_generated = false,
array  $excluded = [],
int  $a_limit = 0 
)
static

Get all news items for a user.

Deprecated:
(will migrate to ilNewsData)

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

References $data, $DIC, $ref_id, ilObject\_getAllReferences(), ilParticipants\_getMembershipByType(), ilObject\_lookupObjId(), ilObjUser\_lookupPref(), ilObject\_lookupType(), ILIAS\Repository\int(), and ilArrayUtil\sortArray().

Referenced by ilUserFeedWriter\__construct(), ILIAS\News\Dashboard\DashboardNewsManager\getContextOptions(), ILIAS\News\Timeline\TimelineManager\getNewsData(), ilPDNewsBlockGUI\getNewsData(), and ILIAS\News\Dashboard\DashboardNewsManager\getNewsForOverview().

512  : array {
513  global $DIC;
514 
515  $ilAccess = $DIC->access();
516  $fav_rep = new ilFavouritesDBRepository();
517 
518  $news_item = new ilNewsItem();
519 
520  $per = $a_per;
521 
522  // this is currently not used
523  $ref_ids = [];
524 
525  if (ilObjUser::_lookupPref($a_user_id, "pd_items_news") !== "n") {
526  // get all items of the personal desktop
527  $pd_items = $fav_rep->getFavouritesOfUser($a_user_id);
528  foreach ($pd_items as $item) {
529  if (!in_array($item["ref_id"], $ref_ids)) {
530  $ref_ids[] = (int) $item["ref_id"];
531  }
532  }
533 
534  // get all memberships
535  $crs_mbs = ilParticipants::_getMembershipByType($a_user_id, ['crs']);
536  $grp_mbs = ilParticipants::_getMembershipByType($a_user_id, ['grp']);
537  $items = array_merge($crs_mbs, $grp_mbs);
538  foreach ($items as $i) {
539  $item_references = ilObject::_getAllReferences($i);
540  if (is_array($item_references) && count($item_references)) {
541  foreach ($item_references as $ref_id) {
542  if (!in_array($ref_id, $ref_ids)) {
543  $ref_ids[] = $ref_id;
544  }
545  }
546  }
547  }
548  }
549 
550  $data = [];
551 
552  foreach ($ref_ids as $ref_id) {
553  if (!$a_only_public) {
554  // this loop should not cost too much performance
555  $acc = $ilAccess->checkAccessOfUser($a_user_id, "read", "", $ref_id);
556 
557  if (!$acc) {
558  continue;
559  }
560  }
561  if (self::getPrivateFeedId() > 0) {
562  global $DIC;
563 
564  $rbacsystem = $DIC->rbac()->system();
565  $acc = $rbacsystem->checkAccessOfUser(self::getPrivateFeedId(), "read", $ref_id);
566 
567  if (!$acc) {
568  continue;
569  }
570  }
571 
572  $obj_id = ilObject::_lookupObjId($ref_id);
573  $obj_type = ilObject::_lookupType($obj_id);
574  $news = $news_item->getNewsForRefId(
575  $ref_id,
576  $a_only_public,
577  false,
578  $per,
579  $a_prevent_aggregation,
580  false,
581  $no_auto_generated,
582  false,
583  $a_user_id,
584  0,
585  $excluded
586  );
587 
588  // counter
589  if (!is_null($a_cnt)) {
590  $a_cnt[$ref_id] = count($news);
591  }
592 
593  $data = self::mergeNews($data, $news);
594  }
595 
596  $data = ilArrayUtil::sortArray($data, "creation_date", "desc", false, true);
597 
598  if ($a_limit > 0) {
599  array_splice($data, $a_limit);
600  }
601  return $data;
602  }
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupPref(int $a_usr_id, string $a_keyword)
static _lookupObjId(int $ref_id)
$ref_id
Definition: ltiauth.php:65
global $DIC
Definition: shib_login.php:26
A news item can be created by different sources.
static _getMembershipByType(int $a_usr_id, array $a_type, bool $a_only_member_role=false)
get membership by type Get course or group membership
static _lookupType(int $id, bool $reference=false)
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupContextObjId()

static ilNewsItem::_lookupContextObjId ( int  $a_news_id)
static

Context Object ID.

Deprecated:
will move to ilNewsData

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

References $DIC, and $ilDB.

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

1821  : int
1822  {
1823  global $DIC;
1824 
1825  $ilDB = $DIC->database();
1826 
1827  $query = "SELECT context_obj_id " .
1828  "FROM il_news_item " .
1829  "WHERE " .
1830  " id = " . $ilDB->quote($a_news_id, "integer");
1831  $set = $ilDB->query($query);
1832  $rec = $ilDB->fetchAssoc($set);
1833 
1834  return $rec["context_obj_id"];
1835  }
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ _lookupDefaultPDPeriod()

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

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

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

1840  : int
1841  {
1842  $news_set = new ilSetting("news");
1843  $per = $news_set->get("pd_period");
1844  if ((int) $per === 0) {
1845  $per = 30;
1846  }
1847 
1848  return $per;
1849  }
+ Here is the caller graph for this function:

◆ _lookupMediaObjectUsages()

static ilNewsItem::_lookupMediaObjectUsages ( int  $a_mob_id)
static

Lookup media object usage(s)

Deprecated:
will move to ilNewsData

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

References $DIC, and $ilDB.

Referenced by ilObjMediaObject\lookupUsages().

1797  : array
1798  {
1799  global $DIC;
1800 
1801  $ilDB = $DIC->database();
1802 
1803  $query = "SELECT id " .
1804  "FROM il_news_item " .
1805  "WHERE " .
1806  " mob_id = " . $ilDB->quote($a_mob_id, "integer");
1807 
1808  $usages = [];
1809  $set = $ilDB->query($query);
1810  while ($rec = $ilDB->fetchAssoc($set)) {
1811  $usages[$rec["id"]] = ["type" => "news", "id" => $rec["id"]];
1812  }
1813 
1814  return $usages;
1815  }
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ _lookupMobId()

static ilNewsItem::_lookupMobId ( int  $a_news_id)
static

Lookup mob id.

Deprecated:
will move to ilNewsData

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

References $DIC, and $ilDB.

Referenced by ilNewsExporter\getXmlExportHeadDependencies().

1548  : int
1549  {
1550  global $DIC;
1551 
1552  $ilDB = $DIC->database();
1553 
1554  $query = "SELECT mob_id FROM il_news_item WHERE id = " .
1555  $ilDB->quote($a_news_id, "integer");
1556  $set = $ilDB->query($query);
1557  $rec = $ilDB->fetchAssoc($set);
1558  return (int) ($rec["mob_id"] ?? 0);
1559  }
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ _lookupRSSPeriod()

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

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

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

1882  : int
1883  {
1884  $news_set = new ilSetting("news");
1885  $rss_period = $news_set->get("rss_period");
1886  if ((int) $rss_period === 0) { // default to two weeks
1887  $rss_period = 14;
1888  }
1889  return $rss_period;
1890  }
+ Here is the caller graph for this function:

◆ _lookupTitle()

static ilNewsItem::_lookupTitle ( int  $a_news_id)
static

Lookup News Title.

Deprecated:
will move to ilNewsData

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

References $DIC, and $ilDB.

1513  : string
1514  {
1515  global $DIC;
1516 
1517  $ilDB = $DIC->database();
1518 
1519  $query = "SELECT title FROM il_news_item WHERE id = " .
1520  $ilDB->quote($a_news_id, "integer");
1521  $set = $ilDB->query($query);
1522  $rec = $ilDB->fetchAssoc($set);
1523  return $rec["title"] ?? '';
1524  }
global $DIC
Definition: shib_login.php:26

◆ _lookupUserPDPeriod()

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

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

References ilBlockSetting\_lookup().

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

1854  : int
1855  {
1856  $news_set = new ilSetting("news");
1857  $allow_shorter_periods = $news_set->get("allow_shorter_periods");
1858  $allow_longer_periods = $news_set->get("allow_longer_periods");
1859  $default_per = self::_lookupDefaultPDPeriod();
1860 
1861  $per = ilBlockSetting::_lookup(
1862  "pdnews",
1863  "news_pd_period",
1864  $a_user_id,
1865  0
1866  );
1867 
1868  // news period information
1869  if ($per <= 0 ||
1870  (!$allow_shorter_periods && ($per < $default_per)) ||
1871  (!$allow_longer_periods && ($per > $default_per))
1872  ) {
1873  $per = $default_per;
1874  }
1875 
1876  return (int) $per;
1877  }
static _lookup(string $a_type, string $a_setting, int $a_user=0, int $a_block_id=0)
Lookup setting from database.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupVisibility()

static ilNewsItem::_lookupVisibility ( int  $a_news_id)
static

Lookup News Visibility.

Deprecated:
will move to ilNewsData

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

References $DIC, $ilDB, and NEWS_USERS.

Referenced by ilObjMediaObjectAccess\checkAccessMob(), and ilMobStakeholder\checkAccessMobUsage().

1530  : string
1531  {
1532  global $DIC;
1533 
1534  $ilDB = $DIC->database();
1535 
1536  $query = "SELECT visibility FROM il_news_item WHERE id = " .
1537  $ilDB->quote($a_news_id, "integer");
1538  $set = $ilDB->query($query);
1539  $rec = $ilDB->fetchAssoc($set);
1540 
1541  return $rec["visibility"] ?? NEWS_USERS;
1542  }
global $DIC
Definition: shib_login.php:26
const NEWS_USERS
+ Here is the caller graph for this function:

◆ _setRead()

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

Set item read.

Deprecated:
will move to ilNewsData

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

References $DIC, and $ilDB.

Referenced by ilNewsForContextBlockGUI\showNews().

1321  : void {
1322  global $DIC;
1323 
1324  $ilDB = $DIC->database();
1325  $ilAppEventHandler = $DIC["ilAppEventHandler"];
1326 
1327  $ilDB->replace(
1328  "il_news_read",
1329  [
1330  "user_id" => ["integer", $a_user_id],
1331  "news_id" => ["integer", $a_news_id]
1332  ],
1333  []
1334  );
1335 
1336  $ilAppEventHandler->raise(
1337  "components/ILIAS/News",
1338  "readNews",
1339  ["user_id" => $a_user_id, "news_ids" => [$a_news_id]]
1340  );
1341  }
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ _setUnread()

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

Set item unread.

Deprecated:
will move to ilNewsData

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

References $DIC, and $ilDB.

1350  : void {
1351  global $DIC;
1352 
1353  $ilDB = $DIC->database();
1354  $ilAppEventHandler = $DIC["ilAppEventHandler"];
1355 
1356  $ilDB->manipulate("DELETE FROM il_news_read (user_id, news_id) VALUES (" .
1357  " WHERE user_id = " . $ilDB->quote($a_user_id, "integer") .
1358  " AND news_id = " . $ilDB->quote($a_news_id, "integer"));
1359 
1360  $ilAppEventHandler->raise(
1361  "components/ILIAS/News",
1362  "unreadNews",
1363  ["user_id" => $a_user_id, "news_ids" => [$a_news_id]]
1364  );
1365  }
global $DIC
Definition: shib_login.php:26

◆ aggregateFiles()

ilNewsItem::aggregateFiles ( array  $news,
int  $a_ref_id 
)
protected
Deprecated:
will move to ilNewsData

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

Referenced by getAggregatedChildNewsData(), and getAggregatedNewsData().

893  : array {
894  $first_file = "";
895  $to_del = [];
896  foreach ($news as $k => $v) {
897  // aggregate file related news
898  if ($v["context_obj_type"] === "file") {
899  if ($first_file === "") {
900  $first_file = $k;
901  } else {
902  $to_del[] = $k;
903  }
904  $news[$first_file]["aggregation"][$k] = $v;
905  $news[$first_file]["agg_ref_id"] = $a_ref_id;
906  $news[$first_file]["ref_id"] = $a_ref_id;
907  }
908  }
909 
910  foreach ($to_del as $v) {
911  unset($news[$v]);
912  }
913 
914  return $news;
915  }
+ Here is the caller graph for this function:

◆ aggregateForums()

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

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

References null.

Referenced by getNewsForRefId().

845  : array {
846  $to_del = [];
847  $forums = [];
848  $last_aggregation_forum = 0;
849 
850  // aggregate
851  foreach ($news as $k => $v) {
852  if ($a_group_posting_sequence && $last_aggregation_forum > 0 &&
853  $last_aggregation_forum != $v["context_obj_id"]) {
854  $forums[$last_aggregation_forum] = null;
855  }
856 
857  if ($v["context_obj_type"] === "frm") {
858  if (!isset($forums[$v["context_obj_id"]])) {
859  // $forums[forum_id] = news_id;
860  $forums[$v["context_obj_id"]] = $k;
861  $last_aggregation_forum = $v["context_obj_id"];
862  } else {
863  $to_del[] = $k;
864  }
865 
866  $news[$k]["no_context_title"] = true;
867 
868  // aggregate every forum into it's "k" news
869  $news[$forums[$news[$k]["context_obj_id"]]]["aggregation"][$k]
870  = $news[$k];
871  $news[$k]["agg_ref_id"]
872  = $news[$k]["ref_id"];
873  $news[$k]["content"] = "";
874  $news[$k]["content_long"] = "";
875  }
876  }
877 
878  // delete double entries
879  foreach ($to_del as $k) {
880  unset($news[$k]);
881  }
882  //var_dump($news[14]["aggregation"]);
883 
884  return $news;
885  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ checkNewsExistsForObjects()

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

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

References $db, $ilDB, $q, and ILIAS\Repository\int().

1189  : array {
1190  $ilDB = $this->db;
1191 
1192  $all = [];
1193 
1194  $this->log->debug("time period: " . $a_time_period);
1195  $limit_ts = self::handleTimePeriod($a_time_period);
1196 
1197  // are there any news items for relevant objects and?
1198  $query = $ilDB->query($q = "SELECT id,context_obj_id,context_obj_type" .
1199  " FROM il_news_item" .
1200  " WHERE " . $ilDB->in("context_obj_id", array_keys($objects), false, "integer") .
1201  " AND creation_date >= " . $ilDB->quote($limit_ts, "timestamp"));
1202  $this->log->debug($q);
1203  while ($rec = $ilDB->fetchAssoc($query)) {
1204  if ($objects[$rec["context_obj_id"]]["type"] == $rec["context_obj_type"]) {
1205  $all[] = (int) $rec["id"];
1206  }
1207  }
1208 
1209  return $all;
1210  }
$q
Definition: shib_logout.php:23
ilDBInterface $db
+ Here is the call graph for this function:

◆ create()

ilNewsItem::create ( )

Create.

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

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

References $db, $ilDB, 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 ILIAS\News\Items\NewsItemManager\save().

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

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

Referenced by ilNewsTimelineGUI\remove().

1426  : void
1427  {
1428  $ilDB = $this->db;
1429 
1430  // delete il_news_read entries
1431  $ilDB->manipulate("DELETE FROM il_news_read " .
1432  " WHERE news_id = " . $ilDB->quote($this->getId(), "integer"));
1433 
1434  // delete multimedia object
1435  $mob = $this->getMobId();
1436 
1437  // delete
1438  $query = "DELETE FROM il_news_item" .
1439  " WHERE id = " . $ilDB->quote($this->getId(), "integer");
1440  $ilDB->manipulate($query);
1441 
1442  // delete mob after news, to have a "mob usage" of 0
1443  if ($mob > 0 && ilObject::_exists($mob)) {
1444  $mob = new ilObjMediaObject($mob);
1445  $mob->delete();
1446  }
1447  }
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
ilDBInterface $db
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteNewsOfContext()

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

Delete all news of a context.

Deprecated:
will move to ilNewsData

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

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

1498  : void {
1499  foreach (self::getNewsOfContext(
1500  $a_context_obj_id,
1501  $a_context_obj_type,
1502  $a_context_sub_obj_id,
1503  $a_context_sub_obj_type
1504  ) as $n) {
1505  $n->delete();
1506  }
1507  }
+ Here is the caller graph for this function:

◆ deliverMobFile()

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

Deliver mob file.

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

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

1915  : bool {
1916  $mob = $this->getMobId();
1917  $mob = new ilObjMediaObject($mob);
1918  $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
1919 
1920  // check purpose
1921  if (!$mob->hasPurposeItem($a_purpose)) {
1922  return false;
1923  }
1924 
1925  $m_item = $mob->getMediaItem($a_purpose);
1926  if ($m_item->getLocationType() !== "Reference") {
1927  $this->media_manager->deliverEntry($mob->getId(), "/" . $m_item->getLocation());
1928  if ($a_increase_download_cnt) {
1929  $this->increaseDownloadCounter();
1930  }
1931  $this->main_tpl->setOnScreenMessage('failure', "File not found!", true);
1932  return false;
1933  }
1934 
1935  if ($a_increase_download_cnt) {
1936  $this->increaseDownloadCounter();
1937  }
1938 
1939  ilUtil::redirect($m_item->getLocation());
1940  return true;
1941  }
increaseDownloadCounter()
Increase download counter.
static _getDirectory(int $a_mob_id)
Get absolute directory.
static redirect(string $a_script)
+ Here is the call graph for this function:

◆ determineNewsContent()

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

Determine new content.

Deprecated:
will move to util?

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

References $DIC, ilLanguage\loadLanguageModule(), ilObjectPlugin\lookupTxtById(), and ilLanguage\txt().

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

1703  : string {
1704  global $DIC;
1705 
1706  if (is_null($lng)) {
1707  $lng = $DIC->language();
1708  }
1709  $obj_definition = $DIC["objDefinition"];
1710 
1711  if ($a_is_lang_var) {
1712  if ($obj_definition->isPlugin($a_context_obj_type)) {
1713  return ilObjectPlugin::lookupTxtById($a_context_obj_type, $a_content);
1714  }
1715  $lng->loadLanguageModule($a_context_obj_type);
1716  return $lng->txt($a_content);
1717  }
1718 
1719  return $a_content;
1720  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
loadLanguageModule(string $a_module)
Load language module.
ilLanguage $lng
global $DIC
Definition: shib_login.php:26
static lookupTxtById(string $plugin_id, string $lang_var)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ determineNewsTitle()

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

Determine title for news item entry.

Deprecated:
will move to util?

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

References $DIC, ilObjectPlugin\lookupTxtById(), and ilLanguage\txt().

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

1638  : string {
1639  global $DIC;
1640 
1641  if (is_null($lng)) {
1642  $lng = $DIC->language();
1643  }
1644  $obj_definition = $DIC["objDefinition"];
1645  $tit = "";
1646 
1647  if ($a_agg_ref_id > 0) {
1648  $cnt = count($a_aggregation);
1649 
1650  // forums
1651  if ($a_context_obj_type === "frm") {
1652  if ($cnt > 1) {
1653  return sprintf($lng->txt("news_x_postings"), $cnt);
1654  }
1655 
1656  return $lng->txt("news_1_postings");
1657  }
1658 
1659  // files
1660  $up_cnt = $cr_cnt = 0;
1661  foreach ($a_aggregation as $item) {
1662  if ($item["title"] === "file_updated") {
1663  $up_cnt++;
1664  } else {
1665  $cr_cnt++;
1666  }
1667  }
1668  $sep = "";
1669  if ($cr_cnt === 1) {
1670  $tit = $lng->txt("news_1_file_created");
1671  $sep = "<br />";
1672  } elseif ($cr_cnt > 1) {
1673  $tit = sprintf($lng->txt("news_x_files_created"), $cr_cnt);
1674  $sep = "<br />";
1675  }
1676  if ($up_cnt === 1) {
1677  $tit .= $sep . $lng->txt("news_1_file_updated");
1678  } elseif ($up_cnt > 1) {
1679  $tit .= $sep . sprintf($lng->txt("news_x_files_updated"), $up_cnt);
1680  }
1681  return $tit;
1682  }
1683 
1684  if ($a_content_is_lang_var) {
1685  if ($obj_definition->isPlugin($a_context_obj_type)) {
1686  return ilObjectPlugin::lookupTxtById($a_context_obj_type, $a_title);
1687  }
1688  return $lng->txt($a_title);
1689  }
1690 
1691  return $a_title;
1692  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
ilLanguage $lng
global $DIC
Definition: shib_login.php:26
static lookupTxtById(string $plugin_id, string $lang_var)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ determineNewsTitleByNewsId()

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

Determine title for news item entry.

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

References $DIC, and $ilDB.

1608  : string {
1609  global $DIC;
1610 
1611  $ilDB = $DIC->database();
1612 
1613  $query = "SELECT context_obj_type, content_is_lang_var, title FROM il_news_item WHERE id = " .
1614  $ilDB->quote($a_news_id, "integer");
1615  $set = $ilDB->query($query);
1616  $rec = $ilDB->fetchAssoc($set);
1617 
1618  return self::determineNewsTitle(
1619  $rec["context_obj_type"],
1620  $rec["title"],
1621  $rec["content_is_lang_var"],
1622  $a_agg_ref_id,
1623  $a_aggregation
1624  );
1625  }
global $DIC
Definition: shib_login.php:26

◆ filterObjIdsPerNews()

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

Checks whether news are available for.

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

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

References $DIC, and $ilDB.

1573  : array {
1574  global $DIC;
1575 
1576  $ilDB = $DIC->database();
1577 
1578  $and = "";
1579  if ($a_time_period > 0) {
1580  $limit_ts = self::handleTimePeriod($a_time_period);
1581  $and = " AND creation_date >= " . $ilDB->quote($limit_ts, "timestamp") . " ";
1582  }
1583 
1584  if ($a_starting_date !== "") {
1585  $and .= " AND creation_date >= " . $ilDB->quote($a_starting_date, "timestamp");
1586  }
1587 
1588  $query = "SELECT DISTINCT(context_obj_id) AS obj_id FROM il_news_item" .
1589  " WHERE " . $ilDB->in("context_obj_id", $a_obj_ids, false, "integer") . " " . $and;
1590  //" WHERE context_obj_id IN (".implode(ilUtil::quoteArray($a_obj_ids),",").")".$and;
1591 
1592  $set = $ilDB->query($query);
1593  $objs = [];
1594  while ($rec = $ilDB->fetchAssoc($set)) {
1595  $objs[] = $rec["obj_id"];
1596  }
1597 
1598  return $objs;
1599  }
global $DIC
Definition: shib_login.php:26

◆ getAggregatedChildNewsData()

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

Get news aggregation for child objects (e.g.

for categories)

Deprecated:
will move to ilNewsData

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

References $access, $data, $ref_id, $tree, aggregateFiles(), ilTree\getChilds(), getNewsForRefId(), null, queryNewsForMultipleContexts(), and ilArrayUtil\sortArray().

Referenced by getNewsForRefId().

930  : array {
931  $tree = $this->tree;
932  $ilAccess = $this->access;
933  $ref_id = [];
934  // get news of parent object
935  $data = $this->getNewsForRefId(
936  $a_ref_id,
937  $a_only_public,
938  true,
939  $a_time_period,
940  true,
941  false,
942  $a_no_auto_generated,
943  false,
944  null,
945  0,
946  $a_excluded
947  );
948  foreach ($data as $k => $v) {
949  $data[$k]["ref_id"] = $a_ref_id;
950  }
951 
952  // get childs
953  $nodes = $tree->getChilds($a_ref_id);
954 
955  // no check, for which of the objects any news are available
956  $obj_ids = [];
957  foreach ($nodes as $node) {
958  $obj_ids[] = $node["obj_id"];
959  }
960  $news_obj_ids = self::filterObjIdsPerNews($obj_ids, $a_time_period, $a_starting_date);
961  //$news_obj_ids = $obj_ids;
962 
963  // get news for all subtree nodes
964  $contexts = [];
965  foreach ($nodes as $node) {
966  // only go on, if news are available
967  if (!in_array($node["obj_id"], $news_obj_ids)) {
968  continue;
969  }
970 
971  if (!$a_only_public && !$ilAccess->checkAccess("read", "", (int) $node["child"])) {
972  continue;
973  }
974  $ref_id[$node["obj_id"]] = $node["child"];
975  $contexts[] = [
976  "obj_id" => $node["obj_id"],
977  "obj_type" => $node["type"]
978  ];
979  }
980 
981  $news = $this->queryNewsForMultipleContexts(
982  $contexts,
983  $a_only_public,
984  $a_time_period,
985  $a_starting_date,
986  $a_no_auto_generated,
987  null,
988  0,
989  $a_excluded
990  );
991  foreach ($news as $k => $v) {
992  $news[$k]["ref_id"] = $ref_id[$v["context_obj_id"]];
993  }
994  $data = self::mergeNews($data, $news);
995 
996  // sort and return
997  $data = ilArrayUtil::sortArray($data, "creation_date", "desc", false, true);
998 
999  if (!$a_prevent_aggregation) {
1000  $data = $this->aggregateFiles($data, $a_ref_id);
1001  }
1002 
1003  return $data;
1004  }
getChilds(int $a_node_id, string $a_order="", string $a_direction="ASC")
get child nodes of given node
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$ref_id
Definition: ltiauth.php:65
queryNewsForMultipleContexts(array $a_contexts, bool $a_for_rss_use=false, $a_time_period=0, string $a_starting_date="", bool $a_no_auto_generated=false, ?int $a_user_id=null, int $a_limit=0, array $a_exclude=[])
aggregateFiles(array $news, int $a_ref_id)
getNewsForRefId(int $a_ref_id, bool $a_only_public=false, bool $a_stopnesting=false, $a_time_period=0, bool $a_prevent_aggregation=true, bool $a_forum_group_sequences=false, bool $a_no_auto_generated=false, bool $a_ignore_date_filter=false, ?int $a_user_id=null, int $a_limit=0, array $a_excluded=[])
Get News For Ref Id.
ilAccessHandler $access
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAggregatedNewsData()

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

Get news aggregation (e.g.

for courses, groups)

Deprecated:
(will migrate to ilNewsData)
Parameters
string | int$a_time_period

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

References $access, $data, $obj_data_cache, $ref_id, $tree, aggregateFiles(), ilTree\getNodeData(), ilTree\getSubTree(), ILIAS\Repository\int(), ilObjectActivation\preloadData(), queryNewsForMultipleContexts(), and ilArrayUtil\sortArray().

Referenced by getNewsForRefId().

745  : array {
746  $tree = $this->tree;
747  $ilAccess = $this->access;
748  $ilObjDataCache = $this->obj_data_cache;
749 
750  // get news of parent object
751  $data = [];
752 
753  // get subtree
754  $cur_node = $tree->getNodeData($a_ref_id);
755 
756  // do not check for lft (materialized path)
757  if ($cur_node) {
758  $nodes = $tree->getSubTree($cur_node, true);
759  } else {
760  $nodes = [];
761  }
762 
763  // preload object data cache
764  $ref_ids = [];
765  $obj_ids = [];
766  $ref_id = [];
767  foreach ($nodes as $node) {
768  $ref_ids[] = (int) $node["child"];
769  $obj_ids[] = (int) $node["obj_id"];
770  }
771 
772  $ilObjDataCache->preloadReferenceCache($ref_ids);
773  if (!$a_only_public) {
775  }
776 
777  // no check, for which of the objects any news are available
778  $news_obj_ids = self::filterObjIdsPerNews($obj_ids, $a_time_period, $a_starting_date);
779  //$news_obj_ids = $obj_ids;
780 
781  // get news for all subtree nodes
782  $contexts = [];
783  foreach ($nodes as $node) {
784  // only go on, if news are available
785  if (!in_array($node["obj_id"], $news_obj_ids)) {
786  continue;
787  }
788 
789  if (!$a_only_public) {
790  if (!$a_user_id) {
791  $acc = $ilAccess->checkAccess("read", "", (int) $node["child"]);
792  } else {
793  $acc = $ilAccess->checkAccessOfUser(
794  $a_user_id,
795  "read",
796  "",
797  (int) $node["child"]
798  );
799  }
800  if (!$acc) {
801  continue;
802  }
803  }
804 
805  $ref_id[$node["obj_id"]] = $node["child"];
806  $contexts[] = [
807  "obj_id" => $node["obj_id"],
808  "obj_type" => $node["type"]
809  ];
810  }
811 
812  // sort and return
813  $news = $this->queryNewsForMultipleContexts(
814  $contexts,
815  $a_only_public,
816  $a_time_period,
817  $a_starting_date,
818  $a_no_auto_generated,
819  $a_user_id,
820  $a_limit,
821  $a_exclude
822  );
823 
824  $to_del = [];
825  foreach ($news as $k => $v) {
826  $news[$k]["ref_id"] = $ref_id[$v["context_obj_id"]];
827  }
828 
829  $data = self::mergeNews($data, $news);
830  $data = ilArrayUtil::sortArray($data, "creation_date", "desc", false, true);
831 
832  if (!$a_prevent_aggregation) {
833  $data = $this->aggregateFiles($data, $a_ref_id);
834  }
835 
836  return $data;
837  }
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
$ref_id
Definition: ltiauth.php:65
queryNewsForMultipleContexts(array $a_contexts, bool $a_for_rss_use=false, $a_time_period=0, string $a_starting_date="", bool $a_no_auto_generated=false, ?int $a_user_id=null, int $a_limit=0, array $a_exclude=[])
static preloadData(array $ref_ids)
Preload data to internal cache.
aggregateFiles(array $news, int $a_ref_id)
ilAccessHandler $access
getSubTree(array $a_node, bool $a_with_data=true, array $a_type=[])
get all nodes in the subtree under specified node
ilObjectDataCache $obj_data_cache
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getContent()

ilNewsItem::getContent ( )

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

References $content.

Referenced by create(), and update().

125  : string
126  {
127  return $this->content;
128  }
+ Here is the caller graph for this function:

◆ getContentHtml()

ilNewsItem::getContentHtml ( )

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

References $content_html.

Referenced by create(), and update().

339  : bool
340  {
341  return $this->content_html;
342  }
+ Here is the caller graph for this function:

◆ getContentIsLangVar()

ilNewsItem::getContentIsLangVar ( )

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

References $content_is_lang_var.

Referenced by create(), and update().

263  : bool
264  {
266  }
bool $content_is_lang_var
+ Here is the caller graph for this function:

◆ getContentLong()

ilNewsItem::getContentLong ( )

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

References $content_long.

Referenced by create(), and update().

242  : string
243  {
244  return $this->content_long;
245  }
string $content_long
+ Here is the caller graph for this function:

◆ getContentTextIsLangVar()

ilNewsItem::getContentTextIsLangVar ( )

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

References $content_text_is_lang_var.

Referenced by create(), and update().

309  : bool
310  {
312  }
bool $content_text_is_lang_var
+ Here is the caller graph for this function:

◆ getContentType()

ilNewsItem::getContentType ( )

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

References $content_type.

Referenced by create(), and update().

175  : string
176  {
177  return $this->content_type;
178  }
string $content_type
+ Here is the caller graph for this function:

◆ getContextObjId()

ilNewsItem::getContextObjId ( )

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

References $context_obj_id.

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

135  : int
136  {
137  return $this->context_obj_id;
138  }
+ Here is the caller graph for this function:

◆ getContextObjType()

ilNewsItem::getContextObjType ( )

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

References $context_obj_type.

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

145  : string
146  {
148  }
string $context_obj_type
+ Here is the caller graph for this function:

◆ getContextSubObjId()

ilNewsItem::getContextSubObjId ( )

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

References $context_sub_obj_id.

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

155  : int
156  {
158  }
+ Here is the caller graph for this function:

◆ getContextSubObjType()

ilNewsItem::getContextSubObjType ( )

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

References $context_sub_obj_type.

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

165  : ?string
166  {
168  }
string $context_sub_obj_type
+ Here is the caller graph for this function:

◆ getCreationDate()

ilNewsItem::getCreationDate ( )

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

References $creation_date.

185  : string
186  {
187  return $this->creation_date;
188  }
string $creation_date

◆ getFirstNewsIdForContext()

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

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

Deprecated:
will move to ilNewsData

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

References $DIC, and $ilDB.

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

1731  : int {
1732  global $DIC;
1733 
1734  $ilDB = $DIC->database();
1735 
1736  // Determine how many rows should be deleted
1737  $query = "SELECT id " .
1738  "FROM il_news_item " .
1739  "WHERE " .
1740  "context_obj_id = " . $ilDB->quote($a_context_obj_id, "integer") .
1741  " AND context_obj_type = " . $ilDB->quote($a_context_obj_type, "text") .
1742  " AND context_sub_obj_id = " . $ilDB->quote($a_context_sub_obj_id, "integer") .
1743  " AND " . $ilDB->equals("context_sub_obj_type", $a_context_sub_obj_type, "text", true);
1744 
1745  $set = $ilDB->query($query);
1746  $rec = $ilDB->fetchAssoc($set);
1747 
1748  return (int) ($rec["id"] ?? 0);
1749  }
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ getId()

ilNewsItem::getId ( )

◆ getLastNewsIdForContext()

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

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

Deprecated:
will move to ilNewsData

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

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

Referenced by ILIAS\Blog\News\NewsManager\handle(), and ilWikiPage\updateNews().

1761  : int {
1762  global $DIC;
1763 
1764  $ilDB = $DIC->database();
1765 
1766  // Determine how many rows should be deleted
1767  $query = "SELECT id, update_date " .
1768  "FROM il_news_item " .
1769  "WHERE " .
1770  "context_obj_id = " . $ilDB->quote($a_context_obj_id, "integer") .
1771  " AND context_obj_type = " . $ilDB->quote($a_context_obj_type, "text") .
1772  " AND context_sub_obj_id = " . $ilDB->quote($a_context_sub_obj_id, "integer") .
1773  " AND " . $ilDB->equals("context_sub_obj_type", $a_context_sub_obj_type, "text", true) .
1774  " ORDER BY update_date DESC";
1775 
1776  $ilDB->setLimit(1, 0);
1777  $set = $ilDB->query($query);
1778  $id = 0;
1779  if ($rec = $ilDB->fetchAssoc($set)) {
1780  $id = (int) $rec["id"];
1781  if ($a_only_today) {
1782  $now = ilUtil::now();
1783  if (strpos($rec["update_date"], substr($now, 0, 10)) !== 0) {
1784  $id = 0;
1785  }
1786  }
1787  }
1788 
1789  return $id;
1790  }
static now()
Return current timestamp in Y-m-d H:i:s format.
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLimitation()

ilNewsItem::getLimitation ( )

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

References $limitation.

Referenced by create().

299  : bool
300  {
301  return $this->limitation;
302  }
+ Here is the caller graph for this function:

◆ getMobDownloadCounter()

ilNewsItem::getMobDownloadCounter ( )

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

References $mob_cnt_download.

Referenced by increaseDownloadCounter(), and update().

329  : int
330  {
332  }
+ Here is the caller graph for this function:

◆ getMobId()

ilNewsItem::getMobId ( )

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

References $mob_id.

Referenced by create(), delete(), deliverMobFile(), ilObjMediaCastGUI\determinePlaytimeObject(), ilNewsTimelineItemGUI\getMediaPath(), ilObjMediaCastGUI\initAddCastItemForm(), update(), and ilObjMediaCastGUI\updateCastItemObject().

273  : int
274  {
275  return $this->mob_id;
276  }
+ Here is the caller graph for this function:

◆ getMobPlayCounter()

ilNewsItem::getMobPlayCounter ( )

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

References $mob_cnt_play.

Referenced by increasePlayCounter(), and update().

319  : int
320  {
321  return $this->mob_cnt_play;
322  }
+ Here is the caller graph for this function:

◆ getNewsForRefId()

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

Get News For Ref Id.

Deprecated:
(will migrate to ilNewsData)
Parameters
string | int$a_time_period
int$a_limitcurrently only supported for groups and courses
int[]$a_excluded currently only supported for groups and courses (news ids)

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

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

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

624  : array {
625  $obj_id = ilObject::_lookupObjId($a_ref_id);
626  $obj_type = ilObject::_lookupType($obj_id);
627 
628  // get starting date
629  $starting_date = "";
630  if ($obj_type === "grp" || $obj_type === "crs") {
631  // see #31471, #30687, and ilMembershipNotification
633  $obj_id,
634  'cont_use_news',
635  '1'
636  ) || (
638  $obj_id,
639  'cont_show_news',
640  '1'
642  $obj_id,
643  'news_timeline'
644  )
645  )) {
646  return [];
647  }
648 
649  $hide_news_per_date = ilBlockSetting::_lookup(
650  "news",
651  "hide_news_per_date",
652  0,
653  $obj_id
654  );
655  if ($hide_news_per_date && !$a_ignore_date_filter) {
656  $starting_date = ilBlockSetting::_lookup(
657  "news",
658  "hide_news_date",
659  0,
660  $obj_id
661  );
662  }
663  }
664 
665  if ($obj_type === "cat" && !$a_stopnesting) {
666  $news = $this->getAggregatedChildNewsData(
667  $a_ref_id,
668  $a_only_public,
669  $a_time_period,
670  $a_prevent_aggregation,
671  $starting_date,
672  $a_no_auto_generated,
673  $a_excluded
674  );
675  } elseif (($obj_type === "grp" || $obj_type === "crs") &&
676  !$a_stopnesting) {
677  $news = $this->getAggregatedNewsData(
678  $a_ref_id,
679  $a_only_public,
680  $a_time_period,
681  $a_prevent_aggregation,
682  $starting_date,
683  $a_no_auto_generated,
684  $a_user_id,
685  $a_limit,
686  $a_excluded
687  );
688  } else {
689  $news_item = new ilNewsItem();
690  $news_item->setContextObjId($obj_id);
691  $news_item->setContextObjType($obj_type);
692  $news = $news_item->queryNewsForContext(
693  $a_only_public,
694  $a_time_period,
695  $starting_date,
696  $a_no_auto_generated,
697  false,
698  0,
699  $a_excluded
700  );
701  $unset = [];
702  foreach ($news as $k => $v) {
703  if (!$a_only_public || $v["visibility"] == NEWS_PUBLIC ||
704  ($v["priority"] == 0 &&
706  "news",
707  "public_notifications",
708  0,
709  $obj_id
710  ))) {
711  $news[$k]["ref_id"] = $a_ref_id;
712  } else {
713  $unset[] = $k;
714  }
715  }
716  foreach ($unset as $un) {
717  unset($news[$un]);
718  }
719  }
720 
721  if (!$a_prevent_aggregation) {
722  $news = $this->aggregateForums($news);
723  } elseif ($a_forum_group_sequences) {
724  $news = $this->aggregateForums($news, true);
725  }
726 
727  return $news;
728  }
getAggregatedChildNewsData(int $a_ref_id, bool $a_only_public=false, int $a_time_period=0, bool $a_prevent_aggregation=false, string $a_starting_date="", bool $a_no_auto_generated=false, array $a_excluded=[])
Get news aggregation for child objects (e.g.
getAggregatedNewsData(int $a_ref_id, bool $a_only_public=false, $a_time_period=0, bool $a_prevent_aggregation=false, string $a_starting_date="", bool $a_no_auto_generated=false, ?int $a_user_id=null, int $a_limit=0, array $a_exclude=[])
Get news aggregation (e.g.
static _lookupObjId(int $ref_id)
const NEWS_PUBLIC
static _lookup(string $a_type, string $a_setting, int $a_user=0, int $a_block_id=0)
Lookup setting from database.
A news item can be created by different sources.
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
static _lookupType(int $id, bool $reference=false)
aggregateForums(array $news, bool $a_group_posting_sequence=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNewsOfContext()

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

Get all news of a context.

Deprecated:
will move to ilNewsData
Returns
ilNewsItem[]

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

References $DIC, and $ilDB.

1459  : array {
1460  global $DIC;
1461 
1462  $ilDB = $DIC->database();
1463  $and = "";
1464 
1465  if ($a_context_obj_id === 0 || $a_context_obj_type === "") {
1466  return [];
1467  }
1468 
1469  if ($a_context_sub_obj_id > 0) {
1470  $and = " AND context_sub_obj_id = " . $ilDB->quote($a_context_sub_obj_id, "integer") .
1471  " AND context_sub_obj_type = " . $ilDB->quote($a_context_sub_obj_type, "text");
1472  }
1473 
1474  // get news records
1475  $query = "SELECT id FROM il_news_item" .
1476  " WHERE context_obj_id = " . $ilDB->quote($a_context_obj_id, "integer") .
1477  " AND context_obj_type = " . $ilDB->quote($a_context_obj_type, "text") .
1478  $and;
1479 
1480  $news_set = $ilDB->query($query);
1481 
1482  $news_arr = [];
1483  while ($news = $ilDB->fetchAssoc($news_set)) {
1484  $news_arr[] = new ilNewsItem((int) $news["id"]);
1485  }
1486  return $news_arr;
1487  }
global $DIC
Definition: shib_login.php:26
A news item can be created by different sources.

◆ getPlaytime()

ilNewsItem::getPlaytime ( )

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

References $playtime.

Referenced by create(), and update().

286  : string
287  {
288  return $this->playtime;
289  }
+ Here is the caller graph for this function:

◆ getPriority()

ilNewsItem::getPriority ( )

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

References $priority.

Referenced by ILIAS\News\Access\NewsAccess\canEdit(), create(), and update().

252  : int
253  {
254  return $this->priority;
255  }
+ Here is the caller graph for this function:

◆ getPrivateFeedId()

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

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

1903  : int
1904  {
1905  return self::$privFeedId;
1906  }

◆ getTitle()

ilNewsItem::getTitle ( )

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

References $title.

Referenced by create(), and update().

115  : string
116  {
117  return $this->title;
118  }
+ Here is the caller graph for this function:

◆ getUpdateDate()

ilNewsItem::getUpdateDate ( )

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

References $update_date.

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

◆ getUpdateUserId()

ilNewsItem::getUpdateUserId ( )

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

References $update_user_id.

Referenced by create(), and update().

215  : int
216  {
217  return $this->update_user_id;
218  }
+ Here is the caller graph for this function:

◆ getUserId()

ilNewsItem::getUserId ( )

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

References $user_id.

Referenced by ILIAS\News\Access\NewsAccess\canEdit(), create(), and update().

205  : int
206  {
207  return $this->user_id;
208  }
+ Here is the caller graph for this function:

◆ getVisibility()

ilNewsItem::getVisibility ( )

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

References $visibility.

Referenced by create(), and update().

229  : string
230  {
231  return $this->visibility;
232  }
string $visibility
+ Here is the caller graph for this function:

◆ handleTimePeriod()

static ilNewsItem::handleTimePeriod (   $a_time_period)
staticprotected

Convert time period for DB-queries.

Parameters
string | int$a_time_period

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

1025  : string
1026  {
1027  // time period is number of days
1028  if (is_numeric($a_time_period)) {
1029  if ($a_time_period > 0) {
1030  return date('Y-m-d H:i:s', time() - ($a_time_period * 24 * 60 * 60));
1031  }
1032  }
1033  // time period is datetime
1034  elseif (preg_match("/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/", $a_time_period)) {
1035  return $a_time_period;
1036  }
1037  return "";
1038  }

◆ increaseDownloadCounter()

ilNewsItem::increaseDownloadCounter ( )

Increase download counter.

Deprecated:
will move to data

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

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

Referenced by deliverMobFile().

1947  : void
1948  {
1949  $ilDB = $this->db;
1950 
1951  $cnt = $this->getMobDownloadCounter();
1952  $cnt++;
1953  $this->setMobDownloadCounter($cnt);
1954  $ilDB->manipulate(
1955  "UPDATE il_news_item SET " .
1956  " mob_cnt_download = " . $ilDB->quote($cnt, "integer") .
1957  " WHERE id = " . $ilDB->quote($this->getId(), "integer")
1958  );
1959  }
setMobDownloadCounter(int $a_val)
ilDBInterface $db
+ 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 1966 of file class.ilNewsItem.php.

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

1966  : void
1967  {
1968  $ilDB = $this->db;
1969 
1970  $cnt = $this->getMobPlayCounter();
1971  $cnt++;
1972  $this->setMobPlayCounter($cnt);
1973  $ilDB->manipulate(
1974  "UPDATE il_news_item SET " .
1975  " mob_cnt_play = " . $ilDB->quote($cnt, "integer") .
1976  " WHERE id = " . $ilDB->quote($this->getId(), "integer")
1977  );
1978  }
setMobPlayCounter(int $a_val)
ilDBInterface $db
+ Here is the call graph for this function:

◆ mergeNews()

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

Merges two sets of news.

Deprecated:
will move to ilNewsData

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

References $id.

1374  : array {
1375  foreach ($n2 as $id => $news) {
1376  $n1[$id] = $news;
1377  }
1378 
1379  return $n1;
1380  }

◆ prepareNewsDataFromCache()

static ilNewsItem::prepareNewsDataFromCache ( array  $a_cres)
static

Prepare news data from cache.

Deprecated:
will move to data

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

References $data, $DIC, $ilDB, and ILIAS\Repository\int().

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

1984  : array
1985  {
1986  global $DIC;
1987 
1988  $ilDB = $DIC->database();
1989 
1990  $data = $a_cres;
1991  $news_ids = array_keys($data);
1992  $set = $ilDB->query("SELECT id FROM il_news_item " .
1993  " WHERE " . $ilDB->in("id", $news_ids, false, "integer"));
1994  $existing_ids = [];
1995  while ($rec = $ilDB->fetchAssoc($set)) {
1996  $existing_ids[] = (int) $rec["id"];
1997  }
1998  //var_dump($existing_ids);
1999  $existing_news = [];
2000  foreach ($data as $k => $v) {
2001  if (in_array($k, $existing_ids)) {
2002  $existing_news[$k] = $v;
2003  }
2004  }
2005 
2006  return $existing_news;
2007  }
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function:
+ 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 1168 of file class.ilNewsItem.php.

References $DIC, and $ilDB.

Referenced by ilMembershipCronNotificationsData\loadMissingNews().

1168  : array
1169  {
1170  global $DIC;
1171  $ilDB = $DIC->database();
1172  $news = [];
1173  $set = $ilDB->query("SELECT * FROM il_news_item " .
1174  " WHERE " . $ilDB->in("id", $a_news_ids, false, "integer"));
1175  while ($rec = $ilDB->fetchAssoc($set)) {
1176  $news[$rec["id"]] = $rec;
1177  }
1178  return $news;
1179  }
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ queryNewsForContext()

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

Query news for a context.

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

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

References $db, $ilDB, $user, ilBlockSetting\_lookup(), getContextObjId(), getContextObjType(), getContextSubObjId(), getContextSubObjType(), ILIAS\Repository\int(), and NEWS_PUBLIC.

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

1053  : array {
1054  $ilDB = $this->db;
1055  $ilUser = $this->user;
1056 
1057  $and = "";
1058  if ($a_time_period > 0) {
1059  $limit_ts = self::handleTimePeriod($a_time_period);
1060  $and = " AND creation_date >= " . $ilDB->quote($limit_ts, "timestamp") . " ";
1061  }
1062 
1063  if ($a_starting_date !== "") {
1064  $and .= " AND creation_date > " . $ilDB->quote($a_starting_date, "timestamp") . " ";
1065  }
1066 
1067  if ($a_no_auto_generated) {
1068  $and .= " AND priority = 1 AND content_type = " . $ilDB->quote("text", "text") . " ";
1069  }
1070 
1071  // this is changed with 4.1 (news table for lm pages)
1072  if ($this->getContextSubObjId() > 0) {
1073  $and .= " AND context_sub_obj_id = " . $ilDB->quote($this->getContextSubObjId(), "integer") .
1074  " AND context_sub_obj_type = " . $ilDB->quote($this->getContextSubObjType(), "text");
1075  }
1076 
1077  if (count($a_exclude) > 0) {
1078  $and .= " AND " . $ilDB->in("id", $a_exclude, true, "integer") . " ";
1079  }
1080 
1081  $ordering = ($a_oldest_first)
1082  ? " creation_date ASC, id ASC "
1083  : " creation_date DESC, id DESC ";
1084 
1085  if ($a_for_rss_use && self::getPrivateFeedId() === 0) {
1086  $query = "SELECT * " .
1087  "FROM il_news_item " .
1088  " WHERE " .
1089  "context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
1090  " AND context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text") .
1091  $and .
1092  " ORDER BY " . $ordering;
1093  } elseif (self::getPrivateFeedId() > 0) {
1094  $query = "SELECT il_news_item.* " .
1095  ", il_news_read.user_id user_read " .
1096  "FROM il_news_item LEFT JOIN il_news_read " .
1097  "ON il_news_item.id = il_news_read.news_id AND " .
1098  " il_news_read.user_id = " . $ilDB->quote(self::getPrivateFeedId(), "integer") .
1099  " WHERE " .
1100  "context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
1101  " AND context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text") .
1102  $and .
1103  " ORDER BY " . $ordering;
1104  } else {
1105  $query = "SELECT il_news_item.* " .
1106  ", il_news_read.user_id as user_read " .
1107  "FROM il_news_item LEFT JOIN il_news_read " .
1108  "ON il_news_item.id = il_news_read.news_id AND " .
1109  " il_news_read.user_id = " . $ilDB->quote($ilUser->getId(), "integer") .
1110  " WHERE " .
1111  "context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
1112  " AND context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text") .
1113  $and .
1114  " ORDER BY " . $ordering;
1115  }
1116  //echo $query;
1117  $set = $ilDB->query($query);
1118  $result = [];
1119  while ($rec = $ilDB->fetchAssoc($set)) {
1120  if ($a_limit > 0 && count($result) >= $a_limit) {
1121  continue;
1122  }
1123  if (!$a_for_rss_use || (self::getPrivateFeedId() > 0) || ($rec["visibility"] === NEWS_PUBLIC ||
1124  ((int) $rec["priority"] === 0 &&
1126  "news",
1127  "public_notifications",
1128  0,
1129  (int) $rec["context_obj_id"]
1130  )))) {
1131  $result[$rec["id"]] = $rec;
1132  }
1133  }
1134 
1135  // do we get data for rss and may the time limit by an issue?
1136  // do a second query without time limit.
1137  // this is not very performant, but I do not have a better
1138  // idea. The keep_rss_min setting is currently (Jul 2012) only set
1139  // by mediacasts
1140  if ($a_time_period && $a_for_rss_use) {
1141  $keep_rss_min = ilBlockSetting::_lookup(
1142  "news",
1143  "keep_rss_min",
1144  0,
1145  $this->getContextObjId()
1146  );
1147  if ($keep_rss_min > 0) {
1148  return $this->queryNewsForContext(
1149  true,
1150  0,
1151  $a_starting_date,
1152  $a_no_auto_generated,
1153  $a_oldest_first,
1154  (int) $keep_rss_min,
1155  $a_exclude
1156  );
1157  }
1158  }
1159 
1160  return $result;
1161  }
const NEWS_PUBLIC
static _lookup(string $a_type, string $a_setting, int $a_user=0, int $a_block_id=0)
Lookup setting from database.
queryNewsForContext(bool $a_for_rss_use=false, $a_time_period=0, string $a_starting_date="", bool $a_no_auto_generated=false, bool $a_oldest_first=false, int $a_limit=0, array $a_exclude=[])
Query news for a context.
ilObjUser $user
ilDBInterface $db
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ queryNewsForMultipleContexts()

ilNewsItem::queryNewsForMultipleContexts ( array  $a_contexts,
bool  $a_for_rss_use = false,
  $a_time_period = 0,
string  $a_starting_date = "",
bool  $a_no_auto_generated = false,
?int  $a_user_id = null,
int  $a_limit = 0,
array  $a_exclude = [] 
)
Deprecated:
will move to ilNewsData
Parameters
string | int$a_time_period

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

References $db, $ilDB, $user, ilBlockSetting\_lookup(), ILIAS\Repository\int(), and NEWS_PUBLIC.

Referenced by getAggregatedChildNewsData(), and getAggregatedNewsData().

1225  : array {
1226  $ilDB = $this->db;
1227  $ilUser = $this->user;
1228 
1229  $and = "";
1230  if ($a_time_period > 0) {
1231  $limit_ts = self::handleTimePeriod($a_time_period);
1232  $and = " AND creation_date >= " . $ilDB->quote($limit_ts, "timestamp") . " ";
1233  }
1234 
1235  if ($a_starting_date !== "") {
1236  $and .= " AND creation_date > " . $ilDB->quote($a_starting_date, "timestamp") . " ";
1237  }
1238 
1239  if ($a_no_auto_generated) {
1240  $and .= " AND priority = 1 AND content_type = " . $ilDB->quote("text", "text") . " ";
1241  }
1242 
1243  if ($a_limit > 0) {
1244  $ilDB->setLimit($a_limit, 0);
1245  }
1246 
1247  if (is_array($a_exclude) && count($a_exclude) > 0) {
1248  $and .= " AND " . $ilDB->in("id", $a_exclude, true, "integer") . " ";
1249  }
1250 
1251  $ids = [];
1252  $type = [];
1253 
1254  foreach ($a_contexts as $cont) {
1255  $ids[] = $cont["obj_id"];
1256  $type[$cont["obj_id"]] = $cont["obj_type"];
1257  }
1258 
1259  if ($a_for_rss_use && self::getPrivateFeedId() === 0) {
1260  $query = "SELECT * " .
1261  "FROM il_news_item " .
1262  " WHERE " .
1263  $ilDB->in("context_obj_id", $ids, false, "integer") . " " .
1264  $and .
1265  " ORDER BY creation_date DESC ";
1266  } elseif (self::getPrivateFeedId() > 0) {
1267  $query = "SELECT il_news_item.* " .
1268  ", il_news_read.user_id as user_read " .
1269  "FROM il_news_item LEFT JOIN il_news_read " .
1270  "ON il_news_item.id = il_news_read.news_id AND " .
1271  " il_news_read.user_id = " . $ilDB->quote(self::getPrivateFeedId(), "integer") .
1272  " WHERE " .
1273  $ilDB->in("context_obj_id", $ids, false, "integer") . " " .
1274  $and .
1275  " ORDER BY creation_date DESC ";
1276  } else {
1277  if ($a_user_id) {
1278  $user_id = $a_user_id;
1279  } else {
1280  $user_id = $ilUser->getId();
1281  }
1282  $query = "SELECT il_news_item.* " .
1283  ", il_news_read.user_id as user_read " .
1284  "FROM il_news_item LEFT JOIN il_news_read " .
1285  "ON il_news_item.id = il_news_read.news_id AND " .
1286  " il_news_read.user_id = " . $ilDB->quote($user_id, "integer") .
1287  " WHERE " .
1288  $ilDB->in("context_obj_id", $ids, false, "integer") . " " .
1289  $and .
1290  " ORDER BY creation_date DESC ";
1291  }
1292 
1293  $set = $ilDB->query($query);
1294  $result = [];
1295  while ($rec = $ilDB->fetchAssoc($set)) {
1296  if ($type[$rec["context_obj_id"]] == $rec["context_obj_type"]) {
1297  if (!$a_for_rss_use || self::getPrivateFeedId() > 0 || ($rec["visibility"] === NEWS_PUBLIC ||
1298  ((int) $rec["priority"] === 0 &&
1300  "news",
1301  "public_notifications",
1302  0,
1303  (int) $rec["context_obj_id"]
1304  )))) {
1305  $result[$rec["id"]] = $rec;
1306  }
1307  }
1308  }
1309 
1310  return $result;
1311  }
const NEWS_PUBLIC
static _lookup(string $a_type, string $a_setting, int $a_user=0, int $a_block_id=0)
Lookup setting from database.
ilObjUser $user
ilDBInterface $db
+ 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 348 of file class.ilNewsItem.php.

References $db, $ilDB, 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().

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

◆ setContent()

ilNewsItem::setContent ( string  $a_content)

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

Referenced by read().

120  : void
121  {
122  $this->content = $a_content;
123  }
+ Here is the caller graph for this function:

◆ setContentHtml()

ilNewsItem::setContentHtml ( bool  $a_val)

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

Referenced by read().

334  : void
335  {
336  $this->content_html = $a_val;
337  }
+ Here is the caller graph for this function:

◆ setContentIsLangVar()

ilNewsItem::setContentIsLangVar ( bool  $a_content_is_lang_var = false)

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

Referenced by read().

259  : void {
260  $this->content_is_lang_var = $a_content_is_lang_var;
261  }
+ Here is the caller graph for this function:

◆ setContentLong()

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

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

Referenced by read().

237  : void
238  {
239  $this->content_long = $a_content_long;
240  }
+ Here is the caller graph for this function:

◆ setContentTextIsLangVar()

ilNewsItem::setContentTextIsLangVar ( bool  $a_val = false)

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

Referenced by read().

304  : void
305  {
306  $this->content_text_is_lang_var = $a_val;
307  }
+ Here is the caller graph for this function:

◆ setContentType()

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

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

Referenced by read().

170  : void
171  {
172  $this->content_type = $a_content_type;
173  }
+ 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.

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

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

1014  : void {
1015  $this->setContextObjId($a_obj_id);
1016  $this->setContextObjType($a_obj_type);
1017  $this->setContextSubObjId($a_sub_obj_id);
1018  $this->setContextSubObjType($a_sub_obj_type);
1019  }
setContextSubObjId(int $a_context_sub_obj_id)
setContextObjType(string $a_context_obj_type)
setContextSubObjType(?string $a_context_sub_obj_type)
setContextObjId(int $a_context_obj_id)
+ Here is the call graph for this function:

◆ setContextObjId()

ilNewsItem::setContextObjId ( int  $a_context_obj_id)

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

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

130  : void
131  {
132  $this->context_obj_id = $a_context_obj_id;
133  }
+ Here is the caller graph for this function:

◆ setContextObjType()

ilNewsItem::setContextObjType ( string  $a_context_obj_type)

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

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

140  : void
141  {
142  $this->context_obj_type = $a_context_obj_type;
143  }
+ Here is the caller graph for this function:

◆ setContextSubObjId()

ilNewsItem::setContextSubObjId ( int  $a_context_sub_obj_id)

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

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

150  : void
151  {
152  $this->context_sub_obj_id = $a_context_sub_obj_id;
153  }
+ Here is the caller graph for this function:

◆ setContextSubObjType()

ilNewsItem::setContextSubObjType ( ?string  $a_context_sub_obj_type)

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

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

160  : void
161  {
162  $this->context_sub_obj_type = $a_context_sub_obj_type;
163  }
+ Here is the caller graph for this function:

◆ setCreationDate()

ilNewsItem::setCreationDate ( string  $a_creation_date)

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

Referenced by read().

180  : void
181  {
182  $this->creation_date = $a_creation_date;
183  }
+ Here is the caller graph for this function:

◆ setId()

ilNewsItem::setId ( int  $a_id)

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

Referenced by __construct(), and create().

100  : void
101  {
102  $this->id = $a_id;
103  }
+ Here is the caller graph for this function:

◆ setLimitation()

ilNewsItem::setLimitation ( bool  $a_limitation)

Set Limitation for number of items.

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

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

◆ setMobDownloadCounter()

ilNewsItem::setMobDownloadCounter ( int  $a_val)

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

Referenced by increaseDownloadCounter(), and read().

324  : void
325  {
326  $this->mob_cnt_download = $a_val;
327  }
+ Here is the caller graph for this function:

◆ setMobId()

ilNewsItem::setMobId ( int  $a_mob_id)

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

Referenced by read().

268  : void
269  {
270  $this->mob_id = $a_mob_id;
271  }
+ Here is the caller graph for this function:

◆ setMobPlayCounter()

ilNewsItem::setMobPlayCounter ( int  $a_val)

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

Referenced by increasePlayCounter(), and read().

314  : void
315  {
316  $this->mob_cnt_play = $a_val;
317  }
+ Here is the caller graph for this function:

◆ setPlaytime()

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

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

Referenced by ilObjMediaCastGUI\determinePlaytimeObject(), and read().

281  : void
282  {
283  $this->playtime = $a_playtime;
284  }
+ Here is the caller graph for this function:

◆ setPriority()

ilNewsItem::setPriority ( int  $a_priority = 1)

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

Referenced by read().

247  : void
248  {
249  $this->priority = $a_priority;
250  }
+ Here is the caller graph for this function:

◆ setPrivateFeedId()

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

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

Referenced by ilObjectFeedWriter\__construct().

1895  : void
1896  {
1897  self::$privFeedId = $a_userId;
1898  }
+ Here is the caller graph for this function:

◆ setTitle()

ilNewsItem::setTitle ( string  $a_title)

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

Referenced by read(), and ilNewsTimelineGUI\update().

110  : void
111  {
112  $this->title = $a_title;
113  }
+ Here is the caller graph for this function:

◆ setUpdateDate()

ilNewsItem::setUpdateDate ( string  $a_update_date)

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

Referenced by read().

190  : void
191  {
192  $this->update_date = $a_update_date;
193  }
+ Here is the caller graph for this function:

◆ setUpdateUserId()

ilNewsItem::setUpdateUserId ( int  $a_val)

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

Referenced by read().

210  : void
211  {
212  $this->update_user_id = $a_val;
213  }
+ Here is the caller graph for this function:

◆ setUserId()

ilNewsItem::setUserId ( int  $a_user_id)

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

Referenced by read().

200  : void
201  {
202  $this->user_id = $a_user_id;
203  }
+ Here is the caller graph for this function:

◆ setVisibility()

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

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

Referenced by read().

225  : void {
226  $this->visibility = $a_visibility;
227  }
+ Here is the caller graph for this function:

◆ update()

ilNewsItem::update ( bool  $a_as_new = false)

Update item in database.

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

Definition at line 461 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(), ILIAS\Repository\int(), and ilUtil\now().

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

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

Field Documentation

◆ $access

ilAccessHandler ilNewsItem::$access
protected

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

Referenced by getAggregatedChildNewsData(), and getAggregatedNewsData().

◆ $content

string ilNewsItem::$content = ""
protected

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

Referenced by getContent().

◆ $content_html

bool ilNewsItem::$content_html = false
protected

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

Referenced by getContentHtml().

◆ $content_is_lang_var

bool ilNewsItem::$content_is_lang_var = false
protected

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

Referenced by getContentIsLangVar().

◆ $content_long

string ilNewsItem::$content_long = ""
protected

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

Referenced by getContentLong().

◆ $content_text_is_lang_var

bool ilNewsItem::$content_text_is_lang_var = false
protected

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

Referenced by getContentTextIsLangVar().

◆ $content_type

string ilNewsItem::$content_type = "text"
protected

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

Referenced by getContentType().

◆ $context_obj_id

int ilNewsItem::$context_obj_id = 0
protected

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

Referenced by getContextObjId().

◆ $context_obj_type

string ilNewsItem::$context_obj_type = ""
protected

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

Referenced by getContextObjType().

◆ $context_sub_obj_id

int ilNewsItem::$context_sub_obj_id = 0
protected

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

Referenced by getContextSubObjId().

◆ $context_sub_obj_type

string ilNewsItem::$context_sub_obj_type = null
protected

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

Referenced by getContextSubObjType().

◆ $creation_date

string ilNewsItem::$creation_date = ""
protected

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

Referenced by getCreationDate().

◆ $ctrl

ilCtrl ilNewsItem::$ctrl
protected

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

◆ $db

◆ $id

int ilNewsItem::$id = 0
protected

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

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

◆ $limitation

bool ilNewsItem::$limitation = false
private

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

Referenced by getLimitation().

◆ $lng

ilLanguage ilNewsItem::$lng
protected

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

◆ $log

ilLogger ilNewsItem::$log
protected

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

◆ $main_tpl

ilGlobalTemplateInterface ilNewsItem::$main_tpl
private

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

◆ $media_manager

MediaObjectManager ilNewsItem::$media_manager
protected

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

◆ $mob_cnt_download

int ilNewsItem::$mob_cnt_download = 0
private

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

Referenced by getMobDownloadCounter().

◆ $mob_cnt_play

int ilNewsItem::$mob_cnt_play = 0
protected

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

Referenced by getMobPlayCounter().

◆ $mob_id

int ilNewsItem::$mob_id = 0
protected

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

Referenced by getMobId().

◆ $obj_data_cache

ilObjectDataCache ilNewsItem::$obj_data_cache
protected

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

Referenced by getAggregatedNewsData().

◆ $playtime

string ilNewsItem::$playtime = ""
protected

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

Referenced by getPlaytime().

◆ $priority

int ilNewsItem::$priority = 1
protected

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

Referenced by getPriority().

◆ $privFeedId

int ilNewsItem::$privFeedId = 0
staticprivate

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

◆ $title

string ilNewsItem::$title = ""
protected

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

Referenced by getTitle().

◆ $tree

ilTree ilNewsItem::$tree
protected

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

Referenced by getAggregatedChildNewsData(), and getAggregatedNewsData().

◆ $update_date

string ilNewsItem::$update_date = ""
protected

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

Referenced by getUpdateDate().

◆ $update_user_id

int ilNewsItem::$update_user_id = 0
protected

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

Referenced by getUpdateUserId().

◆ $user

ilObjUser ilNewsItem::$user
protected

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

Referenced by queryNewsForContext(), and queryNewsForMultipleContexts().

◆ $user_id

int ilNewsItem::$user_id = 0
protected

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

Referenced by getUserId().

◆ $visibility

string ilNewsItem::$visibility = "users"
protected

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

Referenced by _getDefaultVisibilityForRefId(), and getVisibility().


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