ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilNewsItem Class Reference
+ Inheritance diagram for ilNewsItem:
+ Collaboration diagram for ilNewsItem:

Public Member Functions

 __construct ($a_id=0)
 Constructor. More...
 
 setLimitation ($a_limitation)
 Set Limitation for number of items. More...
 
 getLimitation ()
 Get Limitation for number of items. More...
 
 setContentTextIsLangVar ($a_val=0)
 Set content text ist lang var. More...
 
 getContentTextIsLangVar ()
 Get content text ist lang var. More...
 
 setMobPlayCounter ($a_val)
 Set mob play counter. More...
 
 getMobPlayCounter ()
 Get mob play counter. More...
 
 setMobDownloadCounter ($a_val)
 Set mob download counter. More...
 
 getMobDownloadCounter ()
 Get mob download counter. More...
 
 read ()
 Read item from database. More...
 
 create ()
 Create. More...
 
 update ($a_as_new=false)
 Update item in database. More...
 
 getNewsForRefId ($a_ref_id, $a_only_public=false, $a_stopnesting=false, $a_time_period=0, $a_prevent_aggregation=true, $a_forum_group_sequences=false, $a_no_auto_generated=false, $a_ignore_date_filter=false, $a_user_id=null)
 Get News For Ref Id. More...
 
 getAggregatedNewsData ($a_ref_id, $a_only_public=false, $a_time_period=0, $a_prevent_aggregation=false, $a_starting_date="", $a_no_auto_generated=false, $a_user_id=null)
 Get news aggregation (e.g. More...
 
 aggregateForums ($news, $a_group_posting_sequence=false)
 
 aggregateFiles ($news, $a_ref_id)
 
 getAggregatedChildNewsData ($a_ref_id, $a_only_public=false, $a_time_period=0, $a_prevent_aggregation=false, $a_starting_date="", $a_no_auto_generated=false)
 Get news aggregation for child objects (e.g. More...
 
 setContext ($a_obj_id, $a_obj_type, $a_sub_obj_id=0, $a_sub_obj_type="")
 Convenient function to set the whole context information. More...
 
 queryNewsForContext ($a_for_rss_use=false, $a_time_period=0, $a_starting_date="", $a_no_auto_generated=false, $a_oldest_first=false, $a_limit=0)
 Query news for a context. More...
 
 checkNewsExistsForGroupCourse ($a_ref_id, $a_time_period=1)
 
 queryNewsForMultipleContexts ($a_contexts, $a_for_rss_use=false, $a_time_period=0, $a_starting_date="", $a_no_auto_generated=false, $a_user_id=null)
 Query News for multiple Contexts. More...
 
 _setRead ($a_user_id, $a_news_id)
 Set item read. More...
 
 _setUnread ($a_user_id, $a_news_id)
 Set item unread. More...
 
 mergeNews ($n1, $n2)
 Merges two sets of news. More...
 
 delete ()
 Delete news item. More...
 
 _lookupDefaultPDPeriod ()
 
 _lookupUserPDPeriod ($a_user_id)
 
 _lookupRSSPeriod ()
 
 setPrivateFeedId ($a_userId)
 
 getPrivateFeedId ()
 
 deliverMobFile ($a_purpose="Standard", $a_increase_download_cnt=false)
 Deliver mob file. More...
 
 increaseDownloadCounter ()
 Increase download counter. More...
 
 increasePlayCounter ()
 Increase play counter. More...
 
- Public Member Functions inherited from ilNewsItemGen
 __construct ($a_id=0)
 Constructor. More...
 
 setId ($a_id)
 Set Id. More...
 
 getId ()
 Get Id. More...
 
 setTitle ($a_title)
 Set Title. More...
 
 getTitle ()
 Get Title. More...
 
 setContent ($a_content)
 Set Content. More...
 
 getContent ()
 Get Content. More...
 
 setContextObjId ($a_context_obj_id)
 Set ContextObjId. More...
 
 getContextObjId ()
 Get ContextObjId. More...
 
 setContextObjType ($a_context_obj_type)
 Set ContextObjType. More...
 
 getContextObjType ()
 Get ContextObjType. More...
 
 setContextSubObjId ($a_context_sub_obj_id)
 Set ContextSubObjId. More...
 
 getContextSubObjId ()
 Get ContextSubObjId. More...
 
 setContextSubObjType ($a_context_sub_obj_type)
 Set ContextSubObjType. More...
 
 getContextSubObjType ()
 Get ContextSubObjType. More...
 
 setContentType ($a_content_type="text")
 Set ContentType. More...
 
 getContentType ()
 Get ContentType. More...
 
 setCreationDate ($a_creation_date)
 Set CreationDate. More...
 
 getCreationDate ()
 Get CreationDate. More...
 
 setUpdateDate ($a_update_date)
 Set UpdateDate. More...
 
 getUpdateDate ()
 Get UpdateDate. More...
 
 setUserId ($a_user_id)
 Set UserId. More...
 
 getUserId ()
 Get UserId. More...
 
 setVisibility ($a_visibility="users")
 Set Visibility. More...
 
 getVisibility ()
 Get Visibility. More...
 
 setContentLong ($a_content_long)
 Set ContentLong. More...
 
 getContentLong ()
 Get ContentLong. More...
 
 setPriority ($a_priority=1)
 Set Priority. More...
 
 getPriority ()
 Get Priority. More...
 
 setContentIsLangVar ($a_content_is_lang_var=0)
 Set ContentIsLangVar. More...
 
 getContentIsLangVar ()
 Get ContentIsLangVar. More...
 
 setMobId ($a_mob_id)
 Set MobId. More...
 
 getMobId ()
 Get MobId. More...
 
 setPlaytime ($a_playtime)
 Set Playtime. More...
 
 getPlaytime ()
 Get Playtime. More...
 
 create ()
 Create new item. More...
 
 delete ()
 Delete item from database. More...
 
 queryNewsForContext ()
 Query NewsForContext. More...
 
 queryNewsForVisibility ()
 Query NewsForVisibility. More...
 

Static Public Member Functions

static _getNewsItemsOfUser ($a_user_id, $a_only_public=false, $a_prevent_aggregation=false, $a_per=0, &$a_cnt=NULL)
 Get all news items for a user. More...
 
static _getDefaultVisibilityForRefId ($a_ref_id)
 Get default visibility for reference id. More...
 
static deleteNewsOfContext ($a_context_obj_id, $a_context_obj_type, $a_context_sub_obj_id=0, $a_context_sub_obj_type="")
 Delete all news of a context. More...
 
static _lookupTitle ($a_news_id)
 Lookup News Title. More...
 
static _lookupVisibility ($a_news_id)
 Lookup News Visibility. More...
 
static _lookupMobId ($a_news_id)
 Lookup mob id. More...
 
static filterObjIdsPerNews ($a_obj_ids, $a_time_period=0, $a_starting_date="", $a_ending_date='', $ignore_period=false)
 Checks whether news are available for. More...
 
static determineNewsTitle ($a_context_obj_type, $a_title, $a_content_is_lang_var, $a_agg_ref_id=0, $a_aggregation="")
 Determine title for news item entry. More...
 
static determineNewsContent ($a_context_obj_type, $a_content, $a_is_lang_var)
 Determine new content. More...
 
static getFirstNewsIdForContext ($a_context_obj_id, $a_context_obj_type, $a_context_sub_obj_id="", $a_context_sub_obj_type="")
 Get first new id of news set related to a certain context. More...
 
static getLastNewsIdForContext ($a_context_obj_id, $a_context_obj_type, $a_context_sub_obj_id="", $a_context_sub_obj_type="", $a_only_today=false)
 Get last news id of news set related to a certain context. More...
 
static _lookupMediaObjectUsages ($a_mob_id)
 Lookup media object usage(s) More...
 
static _lookupContextObjId ($a_news_id)
 Context Object ID. More...
 
static prepareNewsDataFromCache ($a_cres)
 Prepare news data from cache. More...
 

Static Protected Member Functions

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

Private Attributes

 $limitation
 

Static Private Attributes

static $privFeedId = false
 

Additional Inherited Members

- Protected Attributes inherited from ilNewsItemGen
 $id
 
 $title
 
 $content
 
 $context_obj_id
 
 $context_obj_type
 
 $context_sub_obj_id
 
 $context_sub_obj_type
 
 $content_type = "text"
 
 $creation_date
 
 $update_date
 
 $user_id
 
 $visibility = "users"
 
 $content_long
 
 $priority = 1
 
 $content_is_lang_var = 0
 
 $mob_id
 
 $playtime
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilNewsItem::__construct (   $a_id = 0)

Constructor.

Parameters
int$a_id

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

34  {
35  parent::__construct($a_id);
36  $this->limitation = true;
37  }

Member Function Documentation

◆ _getDefaultVisibilityForRefId()

static ilNewsItem::_getDefaultVisibilityForRefId (   $a_ref_id)
static

Get default visibility for reference id.

Parameters
$a_ref_idreference id

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

References $ilSetting, $path, $row, ilNewsItemGen\$visibility, and ilBlockSetting\_lookup().

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

1058  {
1059  global $tree, $ilSetting;
1060 
1061  include_once("./Services/Block/classes/class.ilBlockSetting.php");
1062 
1063  $news_set = new ilSetting("news");
1064  $default_visibility = ($news_set->get("default_visibility") != "")
1065  ? $news_set->get("default_visibility")
1066  : "users";
1067 
1068  if ($tree->isInTree($a_ref_id))
1069  {
1070  $path = $tree->getPathFull($a_ref_id);
1071 
1072  foreach ($path as $key => $row)
1073  {
1074  if (!in_array($row["type"], array("root", "cat","crs", "fold", "grp")))
1075  {
1076  continue;
1077  }
1078 
1079  $visibility = ilBlockSetting::_lookup("news", "default_visibility",
1080  0, $row["obj_id"]);
1081 
1082  if ($visibility != "")
1083  {
1084  $default_visibility = $visibility;
1085  }
1086  }
1087  }
1088 
1089  return $default_visibility;
1090  }
ILIAS Setting Class.
static _lookup($a_type, $a_setting, $a_user=0, $a_block_id=0)
Lookup setting from database.
global $ilSetting
Definition: privfeed.php:40
$path
Definition: index.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getNewsItemsOfUser()

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

Get all news items for a user.

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

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

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

282  {
283  global $ilAccess;
284 
285  $news_item = new ilNewsItem();
286  $news_set = new ilSetting("news");
287 
288  $per = $a_per;
289 
290  include_once("./Services/News/classes/class.ilNewsSubscription.php");
291  include_once("./Services/Block/classes/class.ilBlockSetting.php");
292 
293  // this is currently not used
294  $ref_ids = ilNewsSubscription::_getSubscriptionsOfUser($a_user_id);
295 
296  if (ilObjUser::_lookupPref($a_user_id, "pd_items_news") != "n")
297  {
298  // get all items of the personal desktop
299  $pd_items = ilObjUser::_lookupDesktopItems($a_user_id);
300  foreach($pd_items as $item)
301  {
302  if (!in_array($item["ref_id"], $ref_ids))
303  {
304  $ref_ids[] = $item["ref_id"];
305  }
306  }
307 
308  // get all memberships
309  include_once 'Services/Membership/classes/class.ilParticipants.php';
310  $crs_mbs = ilParticipants::_getMembershipByType($a_user_id, 'crs');
311  $grp_mbs = ilParticipants::_getMembershipByType($a_user_id, 'grp');
312  $items = array_merge($crs_mbs, $grp_mbs);
313  foreach($items as $i)
314  {
315  $item_references = ilObject::_getAllReferences($i);
316  if(is_array($item_references) && count($item_references))
317  {
318  foreach($item_references as $ref_id)
319  {
320  if (!in_array($ref_id, $ref_ids))
321  {
322  $ref_ids[] = $ref_id;
323  }
324  }
325  }
326  }
327  }
328 
329  $data = array();
330 
331  foreach($ref_ids as $ref_id)
332  {
333  if (!$a_only_public)
334  {
335  // this loop should not cost too much performance
336  $acc = $ilAccess->checkAccessOfUser($a_user_id, "read", "", $ref_id);
337 
338  if (!$acc)
339  {
340  continue;
341  }
342  }
343  if (ilNewsItem::getPrivateFeedId() != false) {
344  global $rbacsystem;
345  $acc = $rbacsystem->checkAccessOfUser(ilNewsItem::getPrivateFeedId(),"read", $ref_id);
346 
347  if (!$acc)
348  {
349  continue;
350  }
351  }
352 
353  $obj_id = ilObject::_lookupObjId($ref_id);
354  $obj_type = ilObject::_lookupType($obj_id);
355  $news = $news_item->getNewsForRefId($ref_id, $a_only_public, false,
356  $per, $a_prevent_aggregation, false, false, false, $a_user_id);
357 
358  // counter
359  if (!is_null($a_cnt))
360  {
361  $a_cnt[$ref_id] = count($news);
362  }
363 
365  }
366 
367  $data = ilUtil::sortArray($data, "creation_date", "desc", false, true);
368 
369  return $data;
370  }
ILIAS Setting Class.
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
_lookupPref($a_usr_id, $a_keyword)
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static _getAllReferences($a_id)
get all reference ids of object
static _getSubscriptionsOfUser($a_user_id)
Get subscriptions of user.
$data
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
mergeNews($n1, $n2)
Merges two sets of news.
static _lookupDesktopItems($user_id, $a_types="")
get all desktop items of user and specified type
$ref_id
Definition: sahs_server.php:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupContextObjId()

static ilNewsItem::_lookupContextObjId (   $a_news_id)
static

Context Object ID.

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

References $ilDB, and $query.

Referenced by ilObjMediaObject\getParentObjectIdForUsage().

1412  {
1413  global $ilDB;
1414 
1415  $query = "SELECT * ".
1416  "FROM il_news_item ".
1417  "WHERE ".
1418  " id = ".$ilDB->quote($a_news_id, "integer");
1419  $set = $ilDB->query($query);
1420  $rec = $ilDB->fetchAssoc($set);
1421 
1422  return $rec["context_obj_id"];
1423  }
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupDefaultPDPeriod()

ilNewsItem::_lookupDefaultPDPeriod ( )

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

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

1426  {
1427  $news_set = new ilSetting("news");
1428  $per = $news_set->get("pd_period");
1429  if ($per == 0)
1430  {
1431  $per = 30;
1432  }
1433 
1434  return $per;
1435  }
ILIAS Setting Class.
+ Here is the caller graph for this function:

◆ _lookupMediaObjectUsages()

static ilNewsItem::_lookupMediaObjectUsages (   $a_mob_id)
static

Lookup media object usage(s)

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

References $ilDB, and $query.

Referenced by ilObjMediaObject\lookupUsages().

1390  {
1391  global $ilDB;
1392 
1393  $query = "SELECT * ".
1394  "FROM il_news_item ".
1395  "WHERE ".
1396  " mob_id = ".$ilDB->quote($a_mob_id, "integer");
1397 
1398  $usages = array();
1399  $set = $ilDB->query($query);
1400  while ($rec = $ilDB->fetchAssoc($set))
1401  {
1402  $usages[$rec["id"]] = array("type" => "news", "id" => $rec["id"]);
1403  }
1404 
1405  return $usages;
1406  }
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupMobId()

static ilNewsItem::_lookupMobId (   $a_news_id)
static

Lookup mob id.

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

References $ilDB, and $query.

Referenced by ilNewsExporter\getXmlExportHeadDependencies().

1188  {
1189  global $ilDB;
1190 
1191  $query = "SELECT mob_id FROM il_news_item WHERE id = ".
1192  $ilDB->quote($a_news_id, "integer");
1193  $set = $ilDB->query($query);
1194  $rec = $ilDB->fetchAssoc($set);
1195  return $rec["mob_id"];
1196  }
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupRSSPeriod()

ilNewsItem::_lookupRSSPeriod ( )

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

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

1463  {
1464  $news_set = new ilSetting("news");
1465  $rss_period = $news_set->get("rss_period");
1466  if ($rss_period == 0) // default to two weeks
1467  {
1468  $rss_period = 14;
1469  }
1470  return $rss_period;
1471  }
ILIAS Setting Class.
+ Here is the caller graph for this function:

◆ _lookupTitle()

static ilNewsItem::_lookupTitle (   $a_news_id)
static

Lookup News Title.

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

References $ilDB, and $query.

1159  {
1160  global $ilDB;
1161 
1162  $query = "SELECT title FROM il_news_item WHERE id = ".
1163  $ilDB->quote($a_news_id, "integer");
1164  $set = $ilDB->query($query);
1165  $rec = $ilDB->fetchAssoc($set);
1166  return $rec["title"];
1167  }
global $ilDB

◆ _lookupUserPDPeriod()

ilNewsItem::_lookupUserPDPeriod (   $a_user_id)

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

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

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

1438  {
1439  global $ilSetting;
1440 
1441  $news_set = new ilSetting("news");
1442  $allow_shorter_periods = $news_set->get("allow_shorter_periods");
1443  $allow_longer_periods = $news_set->get("allow_longer_periods");
1444  $default_per = ilNewsItem::_lookupDefaultPDPeriod();
1445 
1446  include_once("./Services/Block/classes/class.ilBlockSetting.php");
1447  $per = ilBlockSetting::_lookup("pdnews", "news_pd_period",
1448  $a_user_id, 0);
1449 
1450  // news period information
1451  if ($per <= 0 ||
1452  (!$allow_shorter_periods && ($per < $default_per)) ||
1453  (!$allow_longer_periods && ($per > $default_per))
1454  )
1455  {
1456  $per = $default_per;
1457  }
1458 
1459  return $per;
1460  }
ILIAS Setting Class.
static _lookup($a_type, $a_setting, $a_user=0, $a_block_id=0)
Lookup setting from database.
global $ilSetting
Definition: privfeed.php:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupVisibility()

static ilNewsItem::_lookupVisibility (   $a_news_id)
static

Lookup News Visibility.

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

References $ilDB, and $query.

Referenced by ilObjMediaObjectAccess\checkAccessMob().

1173  {
1174  global $ilDB;
1175 
1176  $query = "SELECT visibility FROM il_news_item WHERE id = ".
1177  $ilDB->quote($a_news_id, "integer");
1178  $set = $ilDB->query($query);
1179  $rec = $ilDB->fetchAssoc($set);
1180 
1181  return $rec["visibility"];
1182  }
global $ilDB
+ Here is the caller graph for this function:

◆ _setRead()

ilNewsItem::_setRead (   $a_user_id,
  $a_news_id 
)

Set item read.

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

References $ilDB.

Referenced by ilNewsForContextBlockGUI\showNews().

996  {
997  global $ilDB, $ilAppEventHandler;
998 
999  $ilDB->replace("il_news_read",
1000  array(
1001  "user_id" => array("integer", $a_user_id),
1002  "news_id" => array("integer", $a_news_id)
1003  ),
1004  array()
1005  );
1006 
1007  /*
1008  $ilDB->manipulate("DELETE FROM il_news_read WHERE ".
1009  "user_id = ".$ilDB->quote($a_user_id, "integer").
1010  " AND news_id = ".$ilDB->quote($a_news_id, "integer"));
1011  $ilDB->manipulate("INSERT INTO il_news_read (user_id, news_id) VALUES (".
1012  $ilDB->quote($a_user_id, "integer").",".
1013  $ilDB->quote($a_news_id, "integer").")");*/
1014 
1015  $ilAppEventHandler->raise("Services/News", "readNews",
1016  array("user_id" => $a_user_id, "news_ids" => array($a_news_id)));
1017  }
global $ilDB
+ Here is the caller graph for this function:

◆ _setUnread()

ilNewsItem::_setUnread (   $a_user_id,
  $a_news_id 
)

Set item unread.

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

References $ilDB.

1023  {
1024  global $ilDB, $ilAppEventHandler;
1025 
1026  $ilDB->manipulate("DELETE FROM il_news_read (user_id, news_id) VALUES (".
1027  " WHERE user_id = ".$ilDB->quote($a_user_id, "integer").
1028  " AND news_id = ".$ilDB->quote($a_news_id, "integer"));
1029 
1030  $ilAppEventHandler->raise("Services/News", "unreadNews",
1031  array("user_id" => $a_user_id, "news_ids" => array($a_news_id)));
1032  }
global $ilDB

◆ aggregateFiles()

ilNewsItem::aggregateFiles (   $news,
  $a_ref_id 
)

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

Referenced by getAggregatedChildNewsData(), and getAggregatedNewsData().

599  {
600  $first_file = "";
601  $to_del = array();
602  foreach ($news as $k => $v)
603  {
604  // aggregate file related news
605  if ($news[$k]["context_obj_type"] == "file")
606  {
607  if ($first_file == "")
608  {
609  $first_file = $k;
610  }
611  else
612  {
613  $to_del[] = $k;
614  }
615  $news[$first_file]["aggregation"][$k] = $news[$k];
616  $news[$first_file]["agg_ref_id"] = $a_ref_id;
617  $news[$first_file]["ref_id"] = $a_ref_id;
618  }
619  }
620 
621  foreach($to_del as $v)
622  {
623  unset($news[$v]);
624  }
625 
626  return $news;
627  }
+ Here is the caller graph for this function:

◆ aggregateForums()

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

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

Referenced by getNewsForRefId().

549  {
550  $to_del = array();
551  $forums = array();
552 
553  // aggregate
554  foreach ($news as $k => $v)
555  {
556  if ($a_group_posting_sequence && $last_aggregation_forum > 0 &&
557  $last_aggregation_forum != $news[$k]["context_obj_id"])
558  {
559  $forums[$last_aggregation_forum] = "";
560  }
561 
562  if ($news[$k]["context_obj_type"] == "frm")
563  {
564  if ($forums[$news[$k]["context_obj_id"]] == "")
565  {
566  // $forums[forum_id] = news_id;
567  $forums[$news[$k]["context_obj_id"]] = $k;
568  $last_aggregation_forum = $news[$k]["context_obj_id"];
569  }
570  else
571  {
572  $to_del[] = $k;
573  }
574 
575  $news[$k]["no_context_title"] = true;
576 
577  // aggregate every forum into it's "k" news
578  $news[$forums[$news[$k]["context_obj_id"]]]["aggregation"][$k]
579  = $news[$k];
580  $news[$k]["agg_ref_id"]
581  = $news[$k]["ref_id"];
582  $news[$k]["content"] = "";
583  $news[$k]["content_long"] = "";
584  }
585  }
586 
587  // delete double entries
588  foreach($to_del as $k)
589  {
590  unset($news[$k]);
591  }
592 //var_dump($news[14]["aggregation"]);
593 
594 
595  return $news;
596  }
+ Here is the caller graph for this function:

◆ checkNewsExistsForGroupCourse()

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

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

References $ilDB, and $query.

856  {
857  global $tree, $ilDB;
858 
859  $all = array();
860 
861  if(!$tree->isDeleted($a_ref_id))
862  {
863  // parse repository branch of group
864  $nodes = array();
865  $node = $tree->getNodeData($a_ref_id);
866  foreach($tree->getSubTree($node) as $child)
867  {
868  if($child["type"] != "rolf")
869  {
870  $nodes[$child["obj_id"]] = $child["type"];
871  }
872  }
873 
874  $limit_ts = self::handleTimePeriod($a_time_period);
875 
876  // are there any news items for relevant objects and?
877  $query = $ilDB->query("SELECT id,context_obj_id,context_obj_type".
878  " FROM il_news_item".
879  " WHERE ".$ilDB->in("context_obj_id", array_keys($nodes), false, "integer").
880  " AND creation_date >= ".$ilDB->quote($limit_ts, "timestamp"));
881  while($rec = $ilDB->fetchAssoc($query))
882  {
883  if ($nodes[$rec["context_obj_id"]] == $rec["context_obj_type"])
884  {
885  $all[] = $rec["id"];
886  }
887  }
888  }
889 
890  return $all;
891  }
global $ilDB

◆ create()

ilNewsItem::create ( )

Create.

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

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

158  {
159  global $ilDB;
160 
161  // insert new record into db
162  $this->setId($ilDB->nextId("il_news_item"));
163  $ilDB->insert("il_news_item", array(
164  "id" => array("integer", $this->getId()),
165  "title" => array("text", $this->getTitle()),
166  "content" => array("clob", $this->getContent()),
167  "context_obj_id" => array("integer", (int) $this->getContextObjId()),
168  "context_obj_type" => array("text", $this->getContextObjType()),
169  "context_sub_obj_id" => array("integer", (int) $this->getContextSubObjId()),
170  "context_sub_obj_type" => array("text", $this->getContextSubObjType()),
171  "content_type" => array("text", $this->getContentType()),
172  "creation_date" => array("timestamp", ilUtil::now()),
173  "update_date" => array("timestamp", ilUtil::now()),
174  "user_id" => array("integer", $this->getUserId()),
175  "visibility" => array("text", $this->getVisibility()),
176  "content_long" => array("clob", $this->getContentLong()),
177  "priority" => array("integer", $this->getPriority()),
178  "content_is_lang_var" => array("integer", $this->getContentIsLangVar()),
179  "content_text_is_lang_var" => array("integer", (int) $this->getContentTextIsLangVar()),
180  "mob_id" => array("integer", $this->getMobId()),
181  "playtime" => array("text", $this->getPlaytime())
182  ));
183 
184 
185  $news_set = new ilSetting("news");
186  $max_items = $news_set->get("max_items");
187  if ($max_items <= 0)
188  {
189  $max_items = 50;
190  }
191 
192  // limit number of news
193  if ($this->getLimitation())
194  {
195  // Determine how many rows should be deleted
196  $query = "SELECT count(*) cnt ".
197  "FROM il_news_item ".
198  "WHERE ".
199  "context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
200  " AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
201  " AND context_sub_obj_id = ".$ilDB->quote($this->getContextSubObjId(), "integer").
202  " AND ".$ilDB->equals("context_sub_obj_type", $this->getContextSubObjType(), "text", true)." ";
203 
204  $set = $ilDB->query($query);
205  $rec = $ilDB->fetchAssoc($set);
206 
207  // if we have more records than allowed, delete them
208  if (($rec["cnt"] > $max_items) && $this->getContextObjId() > 0)
209  {
210  $query = "SELECT * ".
211  "FROM il_news_item ".
212  "WHERE ".
213  "context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
214  " AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
215  " AND context_sub_obj_id = ".$ilDB->quote($this->getContextSubObjId(), "integer").
216  " AND ".$ilDB->equals("context_sub_obj_type", $this->getContextSubObjType(), "text", true).
217  " ORDER BY creation_date ASC";
218 
219  $ilDB->setLimit($rec["cnt"] - $max_items);
220  $del_set = $ilDB->query($query);
221  while ($del_item = $ilDB->fetchAssoc($del_set))
222  {
223  $del_news = new ilNewsItem($del_item["id"]);
224  $del_news->delete();
225  }
226  }
227  }
228  }
getContextSubObjType()
Get ContextSubObjType.
getPriority()
Get Priority.
ILIAS Setting Class.
getContentIsLangVar()
Get ContentIsLangVar.
getUserId()
Get UserId.
getContentTextIsLangVar()
Get content text ist lang var.
static now()
Return current timestamp in Y-m-d H:i:s format.
getContextSubObjId()
Get ContextSubObjId.
getContextObjId()
Get ContextObjId.
getContent()
Get Content.
getContextObjType()
Get ContextObjType.
getContentType()
Get ContentType.
getContentLong()
Get ContentLong.
getTitle()
Get Title.
getLimitation()
Get Limitation for number of items.
getVisibility()
Get Visibility.
setId($a_id)
Set Id.
global $ilDB
getPlaytime()
Get Playtime.
getMobId()
Get MobId.
+ Here is the call graph for this function:

◆ delete()

ilNewsItem::delete ( )

Delete news item.

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

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

1098  {
1099  global $ilDB;
1100 
1101  // delete il_news_read entries
1102  $ilDB->manipulate("DELETE FROM il_news_read ".
1103  " WHERE news_id = ".$ilDB->quote($this->getId(), "integer"));
1104 
1105  // delete multimedia object
1106  $mob = $this->getMobId();
1107 
1108  // delete
1109  parent::delete();
1110 
1111  // delete mob after news, to have a "mob usage" of 0
1112  if ($mob > 0 and ilObject::_exists($mob))
1113  {
1114  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1115  $mob = new ilObjMediaObject($mob);
1116  $mob->delete();
1117  }
1118  }
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
Class ilObjMediaObject.
global $ilDB
getMobId()
Get MobId.
+ Here is the call graph for this function:

◆ deleteNewsOfContext()

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

Delete all news of a context.

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

References $ilDB, and $query.

Referenced by ilPageObject\delete().

1126  {
1127  global $ilDB;
1128 
1129  if ($a_context_obj_id == 0 || $a_context_obj_type == "")
1130  {
1131  return;
1132  }
1133 
1134  if ($a_context_sub_obj_id > 0)
1135  {
1136  $and = " AND context_sub_obj_id = ".$ilDB->quote($a_context_sub_obj_id, "integer").
1137  " AND context_sub_obj_type = ".$ilDB->quote($a_context_sub_obj_type, "text");
1138  }
1139 
1140  // get news records
1141  $query = "SELECT * FROM il_news_item".
1142  " WHERE context_obj_id = ".$ilDB->quote($a_context_obj_id, "integer").
1143  " AND context_obj_type = ".$ilDB->quote($a_context_obj_type, "text").
1144  $and;
1145 
1146  $news_set = $ilDB->query($query);
1147 
1148  while ($news = $ilDB->fetchAssoc($news_set))
1149  {
1150  $news_obj = new ilNewsItem($news["id"]);
1151  $news_obj->delete();
1152  }
1153  }
global $ilDB
+ Here is the caller graph for this function:

◆ deliverMobFile()

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

Deliver mob file.

Parameters

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

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

1489  {
1490  $mob = $this->getMobId();
1491  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1492  $mob = new ilObjMediaObject($mob);
1493  $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
1494 
1495  // check purpose
1496  if (!$mob->hasPurposeItem($a_purpose))
1497  {
1498  return false;
1499  }
1500 
1501  $m_item = $mob->getMediaItem($a_purpose);
1502  if ($m_item->getLocationType() != "Reference")
1503  {
1504  $file = $mob_dir."/".$m_item->getLocation();
1505  if (file_exists($file) && is_file($file))
1506  {
1507  if ($a_increase_download_cnt)
1508  {
1509  $this->increaseDownloadCounter();
1510  }
1511  ilUtil::deliverFile($file, $m_item->getLocation(), "", false, false, false);
1512  return true;
1513  }
1514  else
1515  {
1516  ilUtil::sendFailure("File not found!",true);
1517  return false;
1518  }
1519  }
1520  else
1521  {
1522  if ($a_increase_download_cnt)
1523  {
1524  $this->increaseDownloadCounter();
1525  }
1526  ilUtil::redirect($m_item->getLocation());
1527  }
1528  }
print $file
increaseDownloadCounter()
Increase download counter.
Class ilObjMediaObject.
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static redirect($a_script)
http redirect to other script
getMobId()
Get MobId.
_getDirectory($a_mob_id)
get directory for files of media object (static)
+ Here is the call graph for this function:

◆ determineNewsContent()

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

Determine new content.

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

References $lng.

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

1310  {
1311  global $lng;
1312 
1313  if ($a_is_lang_var)
1314  {
1315  $lng->loadLanguageModule($a_context_obj_type);
1316  return $lng->txt($a_content);
1317  }
1318  else
1319  {
1320  return $a_content;
1321  }
1322  }
global $lng
Definition: privfeed.php:40
+ Here is the caller graph for this function:

◆ determineNewsTitle()

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

Determine title for news item entry.

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

References $lng.

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

1236  {
1237  global $lng;
1238 
1239  if ($a_agg_ref_id > 0)
1240  {
1241  $cnt = count($a_aggregation);
1242 
1243  // forums
1244  if ($a_context_obj_type == "frm")
1245  {
1246  if ($cnt > 1)
1247  {
1248  return sprintf($lng->txt("news_x_postings"), $cnt);
1249  }
1250  else
1251  {
1252  return $lng->txt("news_1_postings");
1253  }
1254  }
1255  else // files
1256  {
1257  $up_cnt = $cr_cnt = 0;
1258  foreach($a_aggregation as $item)
1259  {
1260  if ($item["title"] == "file_updated")
1261  {
1262  $up_cnt++;
1263  }
1264  else
1265  {
1266  $cr_cnt++;
1267  }
1268  }
1269  $sep = "";
1270  if ($cr_cnt == 1)
1271  {
1272  $tit = $lng->txt("news_1_file_created");
1273  $sep = "<br />";
1274  }
1275  else if ($cr_cnt > 1)
1276  {
1277  $tit = sprintf($lng->txt("news_x_files_created"), $cr_cnt);
1278  $sep = "<br />";
1279  }
1280  if ($up_cnt == 1)
1281  {
1282  $tit .= $sep.$lng->txt("news_1_file_updated");
1283  }
1284  else if ($up_cnt > 1)
1285  {
1286  $tit .= $sep.sprintf($lng->txt("news_x_files_updated"), $up_cnt);
1287  }
1288  return $tit;
1289  }
1290  }
1291  else
1292  {
1293  if ($a_content_is_lang_var)
1294  {
1295  return $lng->txt($a_title);
1296  }
1297  else
1298  {
1299  return $a_title;
1300  }
1301  }
1302 
1303  return "";
1304  }
global $lng
Definition: privfeed.php:40
+ Here is the caller graph for this function:

◆ filterObjIdsPerNews()

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

Checks whether news are available for.

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

References $ilDB, and $query.

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

1202  {
1203  global $ilDB;
1204 
1205  $and = "";
1206  if ($a_time_period > 0)
1207  {
1208  $limit_ts = self::handleTimePeriod($a_time_period);
1209  $and = " AND creation_date >= ".$ilDB->quote($limit_ts, "timestamp")." ";
1210  }
1211 
1212  if ($a_starting_date != "")
1213  {
1214  $and.= " AND creation_date >= ".$ilDB->quote($a_starting_date, "timestamp");
1215  }
1216 
1217  $query = "SELECT DISTINCT(context_obj_id) AS obj_id FROM il_news_item".
1218  " WHERE ".$ilDB->in("context_obj_id", $a_obj_ids, false, "integer")." ".$and;
1219  //" WHERE context_obj_id IN (".implode(ilUtil::quoteArray($a_obj_ids),",").")".$and;
1220 
1221  $set = $ilDB->query($query);
1222  $objs = array();
1223  while($rec = $ilDB->fetchAssoc($set))
1224  {
1225  $objs[] = $rec["obj_id"];
1226  }
1227 
1228  return $objs;
1229  }
global $ilDB
+ Here is the caller graph for this function:

◆ getAggregatedChildNewsData()

ilNewsItem::getAggregatedChildNewsData (   $a_ref_id,
  $a_only_public = false,
  $a_time_period = 0,
  $a_prevent_aggregation = false,
  $a_starting_date = "",
  $a_no_auto_generated = false 
)

Get news aggregation for child objects (e.g.

for categories)

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

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

Referenced by getNewsForRefId().

636  {
637  global $tree, $ilAccess;
638 
639  // get news of parent object
640  $data = $this->getNewsForRefId($a_ref_id, $a_only_public, true, $a_time_period,
641  true, false, false, $a_no_auto_generated);
642  foreach ($data as $k => $v)
643  {
644  $data[$k]["ref_id"] = $a_ref_id;
645  }
646 
647  // get childs
648  $nodes = $tree->getChilds($a_ref_id);
649 
650  // no check, for which of the objects any news are available
651  $obj_ids = array();
652  foreach($nodes as $node)
653  {
654  $obj_ids[] = $node["obj_id"];
655  }
656  $news_obj_ids = ilNewsItem::filterObjIdsPerNews($obj_ids, $a_time_period, $a_starting_date);
657  //$news_obj_ids = $obj_ids;
658 
659  // get news for all subtree nodes
660  $contexts = array();
661  foreach($nodes as $node)
662  {
663  // only go on, if news are available
664  if (!in_array($node["obj_id"], $news_obj_ids))
665  {
666  continue;
667  }
668 
669  if (!$a_only_public && !$ilAccess->checkAccess("read", "", $node["child"]))
670  {
671  continue;
672  }
673  $ref_id[$node["obj_id"]] = $node["child"];
674  $contexts[] = array("obj_id" => $node["obj_id"],
675  "obj_type" => $node["type"]);
676  }
677 
678  $news = $this->queryNewsForMultipleContexts($contexts, $a_only_public, $a_time_period,
679  $a_starting_date, $a_no_auto_generated);
680  foreach ($news as $k => $v)
681  {
682  $news[$k]["ref_id"] = $ref_id[$v["context_obj_id"]];
683  }
685 
686  // sort and return
687  $data = ilUtil::sortArray($data, "creation_date", "desc", false, true);
688 
689  if (!$a_prevent_aggregation)
690  {
691  $data = $this->aggregateFiles($data, $a_ref_id);
692  }
693 
694  return $data;
695  }
queryNewsForMultipleContexts($a_contexts, $a_for_rss_use=false, $a_time_period=0, $a_starting_date="", $a_no_auto_generated=false, $a_user_id=null)
Query News for multiple Contexts.
getNewsForRefId($a_ref_id, $a_only_public=false, $a_stopnesting=false, $a_time_period=0, $a_prevent_aggregation=true, $a_forum_group_sequences=false, $a_no_auto_generated=false, $a_ignore_date_filter=false, $a_user_id=null)
Get News For Ref Id.
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
$data
mergeNews($n1, $n2)
Merges two sets of news.
$ref_id
Definition: sahs_server.php:39
static filterObjIdsPerNews($a_obj_ids, $a_time_period=0, $a_starting_date="", $a_ending_date='', $ignore_period=false)
Checks whether news are available for.
aggregateFiles($news, $a_ref_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAggregatedNewsData()

ilNewsItem::getAggregatedNewsData (   $a_ref_id,
  $a_only_public = false,
  $a_time_period = 0,
  $a_prevent_aggregation = false,
  $a_starting_date = "",
  $a_no_auto_generated = false,
  $a_user_id = null 
)

Get news aggregation (e.g.

for courses, groups)

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

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

Referenced by getNewsForRefId().

455  {
456  global $tree, $ilAccess, $ilObjDataCache;
457 
458  // get news of parent object
459 
460  $data = array();
461 
462  // get subtree
463  $cur_node = $tree->getNodeData($a_ref_id);
464 
465  // do not check for lft (materialized path)
466  if($cur_node)
467  {
468  $nodes = (array) $tree->getSubTree($cur_node,true);
469  }
470  else
471  {
472  $nodes = array();
473  }
474 
475  // preload object data cache
476  $ref_ids = array();
477  $obj_ids = array();
478  foreach($nodes as $node)
479  {
480  $ref_ids[] = $node["child"];
481  $obj_ids[] = $node["obj_id"];
482  }
483 
484  $ilObjDataCache->preloadReferenceCache($ref_ids);
485  if (!$a_only_public)
486  {
487  include_once "Services/Object/classes/class.ilObjectActivation.php";
489  }
490 
491  // no check, for which of the objects any news are available
492  $news_obj_ids = ilNewsItem::filterObjIdsPerNews($obj_ids, $a_time_period, $a_starting_date);
493  //$news_obj_ids = $obj_ids;
494 
495  // get news for all subtree nodes
496  $contexts = array();
497  foreach($nodes as $node)
498  {
499  // only go on, if news are available
500  if (!in_array($node["obj_id"], $news_obj_ids))
501  {
502  continue;
503  }
504 
505  if (!$a_only_public)
506  {
507  if(!$a_user_id)
508  {
509  $acc = $ilAccess->checkAccess("read", "", $node["child"]);
510  }
511  else
512  {
513  $acc = $ilAccess->checkAccessOfUser($a_user_id, "read", "",
514  $node["child"]);
515  }
516  if (!$acc)
517  {
518  continue;
519  }
520  }
521 
522  $ref_id[$node["obj_id"]] = $node["child"];
523  $contexts[] = array("obj_id" => $node["obj_id"],
524  "obj_type" => $node["type"]);
525  }
526 
527  // sort and return
528  $news = $this->queryNewsForMultipleContexts($contexts, $a_only_public, $a_time_period,
529  $a_starting_date, $a_no_auto_generated, $a_user_id);
530 
531  $to_del = array();
532  foreach ($news as $k => $v)
533  {
534  $news[$k]["ref_id"] = $ref_id[$v["context_obj_id"]];
535  }
536 
538  $data = ilUtil::sortArray($data, "creation_date", "desc", false, true);
539 
540  if (!$a_prevent_aggregation)
541  {
542  $data = $this->aggregateFiles($data, $a_ref_id);
543  }
544 
545  return $data;
546  }
queryNewsForMultipleContexts($a_contexts, $a_for_rss_use=false, $a_time_period=0, $a_starting_date="", $a_no_auto_generated=false, $a_user_id=null)
Query News for multiple Contexts.
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
$data
static preloadData(array $a_ref_ids)
Preload data to internal cache.
mergeNews($n1, $n2)
Merges two sets of news.
$ref_id
Definition: sahs_server.php:39
static filterObjIdsPerNews($a_obj_ids, $a_time_period=0, $a_starting_date="", $a_ending_date='', $ignore_period=false)
Checks whether news are available for.
aggregateFiles($news, $a_ref_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getContentTextIsLangVar()

ilNewsItem::getContentTextIsLangVar ( )

Get content text ist lang var.

Returns
boolean

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

Referenced by create(), and update().

76  {
77  return $this->content_text_is_lang_var;
78  }
+ Here is the caller graph for this function:

◆ getFirstNewsIdForContext()

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

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

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

References $ilDB, and $query.

Referenced by ilForum\deletePost(), ilForumTopic\movePosts(), ilForum\postCensorship(), and ilObjForumGUI\quoteTopLevelPostObject().

1331  {
1332  global $ilDB;
1333 
1334  // Determine how many rows should be deleted
1335  $query = "SELECT * ".
1336  "FROM il_news_item ".
1337  "WHERE ".
1338  "context_obj_id = ".$ilDB->quote($a_context_obj_id, "integer").
1339  " AND context_obj_type = ".$ilDB->quote($a_context_obj_type, "text").
1340  " AND context_sub_obj_id = ".$ilDB->quote($a_context_sub_obj_id, "integer").
1341  " AND ".$ilDB->equals("context_sub_obj_type", $a_context_sub_obj_type, "text", true);
1342 
1343  $set = $ilDB->query($query);
1344  $rec = $ilDB->fetchAssoc($set);
1345 
1346  return $rec["id"];
1347  }
global $ilDB
+ Here is the caller graph for this function:

◆ getLastNewsIdForContext()

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

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

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

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

Referenced by ilWikiPage\updateNews().

1355  {
1356  global $ilDB;
1357 
1358  // Determine how many rows should be deleted
1359  $query = "SELECT id, update_date ".
1360  "FROM il_news_item ".
1361  "WHERE ".
1362  "context_obj_id = ".$ilDB->quote($a_context_obj_id, "integer").
1363  " AND context_obj_type = ".$ilDB->quote($a_context_obj_type, "text").
1364  " AND context_sub_obj_id = ".$ilDB->quote($a_context_sub_obj_id, "integer").
1365  " AND ".$ilDB->equals("context_sub_obj_type", $a_context_sub_obj_type, "text", true).
1366  " ORDER BY update_date DESC";
1367 
1368  $ilDB->setLimit(1);
1369  $set = $ilDB->query($query);
1370  $rec = $ilDB->fetchAssoc($set);
1371 
1372  $id = (int) $rec["id"];
1373  if ($a_only_today)
1374  {
1375  $now = ilUtil::now();
1376  if (substr($now, 0, 10) != substr($rec["update_date"], 0, 10))
1377  {
1378  $id = 0;
1379  }
1380  }
1381 
1382  return $id;
1383  }
static now()
Return current timestamp in Y-m-d H:i:s format.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLimitation()

ilNewsItem::getLimitation ( )

Get Limitation for number of items.

Returns
boolean Limitation for number of items

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

References $limitation.

Referenced by create().

56  {
57  return $this->limitation;
58  }
+ Here is the caller graph for this function:

◆ getMobDownloadCounter()

ilNewsItem::getMobDownloadCounter ( )

Get mob download counter.

Returns
int counter

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

Referenced by increaseDownloadCounter(), and update().

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

◆ getMobPlayCounter()

ilNewsItem::getMobPlayCounter ( )

Get mob play counter.

Returns
int counter

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

Referenced by increasePlayCounter(), and update().

96  {
97  return $this->mob_cnt_play;
98  }
+ Here is the caller graph for this function:

◆ getNewsForRefId()

ilNewsItem::getNewsForRefId (   $a_ref_id,
  $a_only_public = false,
  $a_stopnesting = false,
  $a_time_period = 0,
  $a_prevent_aggregation = true,
  $a_forum_group_sequences = false,
  $a_no_auto_generated = false,
  $a_ignore_date_filter = false,
  $a_user_id = null 
)

Get News For Ref Id.

$a_user_id does only work for groups and courses so far

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

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

Referenced by getAggregatedChildNewsData().

380  {
381  $obj_id = ilObject::_lookupObjId($a_ref_id);
382  $obj_type = ilObject::_lookupType($obj_id);
383 
384  // get starting date
385  $starting_date = "";
386  if ($obj_type == "grp" || $obj_type == "crs" || $obj_type == "cat")
387  {
388  include_once("./Services/Block/classes/class.ilBlockSetting.php");
389  $hide_news_per_date = ilBlockSetting::_lookup("news", "hide_news_per_date",
390  0, $obj_id);
391  if ($hide_news_per_date && !$a_ignore_date_filter)
392  {
393  $starting_date = ilBlockSetting::_lookup("news", "hide_news_date",
394  0, $obj_id);
395  }
396  }
397 
398  if ($obj_type == "cat" && !$a_stopnesting)
399  {
400  $news = $this->getAggregatedChildNewsData($a_ref_id, $a_only_public, $a_time_period,
401  $a_prevent_aggregation, $starting_date, $a_no_auto_generated);
402  }
403  else if (($obj_type == "grp" || $obj_type == "crs") &&
404  !$a_stopnesting)
405  {
406  $news = $this->getAggregatedNewsData($a_ref_id, $a_only_public, $a_time_period,
407  $a_prevent_aggregation, $starting_date, $a_no_auto_generated, $a_user_id);
408  }
409  else
410  {
411  $news_item = new ilNewsItem();
412  $news_item->setContextObjId($obj_id);
413  $news_item->setContextObjType($obj_type);
414  $news = $news_item->queryNewsForContext($a_only_public, $a_time_period,
415  $starting_date, $a_no_auto_generated);
416  $unset = array();
417  foreach ($news as $k => $v)
418  {
419  if (!$a_only_public || $v["visibility"] == NEWS_PUBLIC ||
420  ($v["priority"] == 0 &&
421  ilBlockSetting::_lookup("news", "public_notifications",
422  0, $obj_id)))
423  {
424  $news[$k]["ref_id"] = $a_ref_id;
425  }
426  else
427  {
428  $unset[] = $k;
429  }
430  }
431  foreach ($unset as $un)
432  {
433  unset($news[$un]);
434  }
435  }
436 
437  if (!$a_prevent_aggregation)
438  {
439  $news = $this->aggregateForums($news);
440  }
441  else if ($a_forum_group_sequences)
442  {
443  $news = $this->aggregateForums($news, true);
444  }
445 
446  return $news;
447  }
getAggregatedChildNewsData($a_ref_id, $a_only_public=false, $a_time_period=0, $a_prevent_aggregation=false, $a_starting_date="", $a_no_auto_generated=false)
Get news aggregation for child objects (e.g.
getAggregatedNewsData($a_ref_id, $a_only_public=false, $a_time_period=0, $a_prevent_aggregation=false, $a_starting_date="", $a_no_auto_generated=false, $a_user_id=null)
Get news aggregation (e.g.
const NEWS_PUBLIC
aggregateForums($news, $a_group_posting_sequence=false)
static _lookupObjId($a_id)
static _lookup($a_type, $a_setting, $a_user=0, $a_block_id=0)
Lookup setting from database.
static _lookupType($a_id, $a_reference=false)
lookup object type
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPrivateFeedId()

ilNewsItem::getPrivateFeedId ( )

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

References $privFeedId.

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

1477  {
1478 
1479  return ilNewsItem::$privFeedId;
1480  }
static $privFeedId
+ Here is the caller graph for this function:

◆ handleTimePeriod()

static ilNewsItem::handleTimePeriod (   $a_time_period)
staticprotected

Convert time period for DB-queries.

Parameters
mixed$a_time_period
Returns
string

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

715  {
716  // time period is number of days
717  if(is_numeric($a_time_period))
718  {
719  if($a_time_period > 0)
720  {
721  return date('Y-m-d H:i:s', time() - ($a_time_period * 24 * 60 * 60));
722  }
723  }
724  // time period is datetime
725  else if(preg_match("/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/", $a_time_period))
726  {
727  return $a_time_period;
728  }
729  // :TODO: what to return?
730  }

◆ increaseDownloadCounter()

ilNewsItem::increaseDownloadCounter ( )

Increase download counter.

Parameters

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

References $ilDB, ilNewsItemGen\getId(), getMobDownloadCounter(), and setMobDownloadCounter().

Referenced by deliverMobFile().

1537  {
1538  global $ilDB;
1539 
1540  $cnt = $this->getMobDownloadCounter();
1541  $cnt++;
1542  $this->setMobDownloadCounter($cnt);
1543  $ilDB->manipulate("UPDATE il_news_item SET ".
1544  " mob_cnt_download = ".$ilDB->quote($cnt, "integer").
1545  " WHERE id = ".$ilDB->quote($this->getId(), "integer")
1546  );
1547  }
getMobDownloadCounter()
Get mob download counter.
setMobDownloadCounter($a_val)
Set mob download counter.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ increasePlayCounter()

ilNewsItem::increasePlayCounter ( )

Increase play counter.

Parameters

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

References $ilDB, ilNewsItemGen\getId(), getMobPlayCounter(), and setMobPlayCounter().

1556  {
1557  global $ilDB;
1558 
1559  $cnt = $this->getMobPlayCounter();
1560  $cnt++;
1561  $this->setMobPlayCounter($cnt);
1562  $ilDB->manipulate("UPDATE il_news_item SET ".
1563  " mob_cnt_play = ".$ilDB->quote($cnt, "integer").
1564  " WHERE id = ".$ilDB->quote($this->getId(), "integer")
1565  );
1566  }
getMobPlayCounter()
Get mob play counter.
global $ilDB
setMobPlayCounter($a_val)
Set mob play counter.
+ Here is the call graph for this function:

◆ mergeNews()

ilNewsItem::mergeNews (   $n1,
  $n2 
)

Merges two sets of news.

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

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

References ilNewsItemGen\$id.

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

1043  {
1044  foreach($n2 as $id => $news)
1045  {
1046  $n1[$id] = $news;
1047  }
1048 
1049  return $n1;
1050  }
+ Here is the caller graph for this function:

◆ prepareNewsDataFromCache()

static ilNewsItem::prepareNewsDataFromCache (   $a_cres)
static

Prepare news data from cache.

Parameters
string$a_crescache string
Returns
array news array

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

References $data, and $ilDB.

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

1575  {
1576  global $ilDB;
1577 
1578  $data = unserialize($a_cres);
1579  $news_ids = array_keys($data);
1580  $set = $ilDB->query("SELECT id FROM il_news_item ".
1581  " WHERE ".$ilDB->in("id", $news_ids, false, "integer"));
1582  $existing_ids = array();
1583  while ($rec = $ilDB->fetchAssoc($set))
1584  {
1585  $existing_ids[] = $rec["id"];
1586  }
1587  //var_dump($existing_ids);
1588  $existing_news = array();
1589  foreach ($data as $k => $v)
1590  {
1591  if (in_array($k, $existing_ids))
1592  {
1593  $existing_news[$k] = $v;
1594  }
1595  }
1596 
1597  //var_dump($data);
1598  //var_dump($existing_news);
1599 
1600  return $existing_news;
1601  }
$data
global $ilDB
+ Here is the caller graph for this function:

◆ queryNewsForContext()

ilNewsItem::queryNewsForContext (   $a_for_rss_use = false,
  $a_time_period = 0,
  $a_starting_date = "",
  $a_no_auto_generated = false,
  $a_oldest_first = false,
  $a_limit = 0 
)

Query news for a context.

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

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

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

742  {
743  global $ilDB, $ilUser, $lng;
744 
745  $and = "";
746  if ($a_time_period > 0)
747  {
748  $limit_ts = self::handleTimePeriod($a_time_period);
749  $and = " AND creation_date >= ".$ilDB->quote($limit_ts, "timestamp")." ";
750  }
751 
752  if ($a_starting_date != "")
753  {
754  $and.= " AND creation_date > ".$ilDB->quote($a_starting_date, "timestamp")." ";
755  }
756 
757  if ($a_no_auto_generated)
758  {
759  $and.= " AND priority = 1 AND content_type = ".$ilDB->quote("text", "text")." ";
760  }
761 
762  // this is changed with 4.1 (news table for lm pages)
763  if ($this->getContextSubObjId() > 0)
764  {
765  $and.= " AND context_sub_obj_id = ".$ilDB->quote($this->getContextSubObjId(), "integer").
766  " AND context_sub_obj_type = ".$ilDB->quote($this->getContextSubObjType(), "text");
767  }
768 
769  $ordering = ($a_oldest_first)
770  ? " creation_date ASC, id ASC "
771  : " creation_date DESC, id DESC ";
772 
773  if ($a_for_rss_use && ilNewsItem::getPrivateFeedId() == false)
774  {
775  $query = "SELECT * ".
776  "FROM il_news_item ".
777  " WHERE ".
778  "context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
779  " AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
780  $and.
781  " ORDER BY ".$ordering;
782  }
783  elseif (ilNewsItem::getPrivateFeedId() != false)
784  {
785  $query = "SELECT il_news_item.* ".
786  ", il_news_read.user_id user_read ".
787  "FROM il_news_item LEFT JOIN il_news_read ".
788  "ON il_news_item.id = il_news_read.news_id AND ".
789  " il_news_read.user_id = ".$ilDB->quote(ilNewsItem::getPrivateFeedId(), "integer").
790  " WHERE ".
791  "context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
792  " AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
793  $and.
794  " ORDER BY ".$ordering;
795  }
796  else
797  {
798  $query = "SELECT il_news_item.* ".
799  ", il_news_read.user_id as user_read ".
800  "FROM il_news_item LEFT JOIN il_news_read ".
801  "ON il_news_item.id = il_news_read.news_id AND ".
802  " il_news_read.user_id = ".$ilDB->quote($ilUser->getId(), "integer").
803  " WHERE ".
804  "context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
805  " AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
806  $and.
807  " ORDER BY ".$ordering;
808  }
809 //echo $query;
810  $set = $ilDB->query($query);
811  $result = array();
812  while($rec = $ilDB->fetchAssoc($set))
813  {
814  if ($a_limit > 0 && count($result) >= $a_limit)
815  {
816  continue;
817  }
818  if (!$a_for_rss_use || (ilNewsItem::getPrivateFeedId() != false) || ($rec["visibility"] == NEWS_PUBLIC ||
819  ($rec["priority"] == 0 &&
820  ilBlockSetting::_lookup("news", "public_notifications",
821  0, $rec["context_obj_id"]))))
822  {
823  $result[$rec["id"]] = $rec;
824  }
825  }
826 
827  // do we get data for rss and may the time limit by an issue?
828  // do a second query without time limit.
829  // this is not very performant, but I do not have a better
830  // idea. The keep_rss_min setting is currently (Jul 2012) only set
831  // by mediacasts
832  if ($a_time_period != "" && $a_for_rss_use)
833  {
834  include_once("./Services/Block/classes/class.ilBlockSetting.php");
835  $keep_rss_min = ilBlockSetting::_lookup("news", "keep_rss_min",
836  0, $this->getContextObjId());
837  if ($keep_rss_min > 0)
838  {
839  return $this->queryNewsForContext(true, 0,
840  $a_starting_date, $a_no_auto_generated, $a_oldest_first, $keep_rss_min);
841  }
842  }
843 
844  return $result;
845 
846  }
getContextSubObjType()
Get ContextSubObjType.
$result
const NEWS_PUBLIC
getContextSubObjId()
Get ContextSubObjId.
getContextObjId()
Get ContextObjId.
getContextObjType()
Get ContextObjType.
static _lookup($a_type, $a_setting, $a_user=0, $a_block_id=0)
Lookup setting from database.
global $ilUser
Definition: imgupload.php:15
global $lng
Definition: privfeed.php:40
global $ilDB
queryNewsForContext()
Query NewsForContext.
+ Here is the call graph for this function:

◆ queryNewsForMultipleContexts()

ilNewsItem::queryNewsForMultipleContexts (   $a_contexts,
  $a_for_rss_use = false,
  $a_time_period = 0,
  $a_starting_date = "",
  $a_no_auto_generated = false,
  $a_user_id = null 
)

Query News for multiple Contexts.

Parameters
array$a_contextsarray of array("obj_id", "obj_type")

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

References $ilCtrl, $ilDB, $ilUser, $lng, $query, $result, ilNewsItemGen\$user_id, ilBlockSetting\_lookup(), getPrivateFeedId(), and NEWS_PUBLIC.

Referenced by getAggregatedChildNewsData(), and getAggregatedNewsData().

901  {
902  global $ilDB, $ilUser, $lng, $ilCtrl;
903 
904  $and = "";
905  if ($a_time_period > 0)
906  {
907  $limit_ts = self::handleTimePeriod($a_time_period);
908  $and = " AND creation_date >= ".$ilDB->quote($limit_ts, "timestamp")." ";
909  }
910 
911  if ($a_starting_date != "")
912  {
913  $and.= " AND creation_date > ".$ilDB->quote($a_starting_date, "timestamp")." ";
914  }
915 
916  if ($a_no_auto_generated)
917  {
918  $and.= " AND priority = 1 AND content_type = ".$ilDB->quote("text", "text")." ";
919  }
920 
921  $ids = array();
922  $type = array();
923  foreach($a_contexts as $cont)
924  {
925  $ids[] = $cont["obj_id"];
926  $type[$cont["obj_id"]] = $cont["obj_type"];
927  }
928 
929  if ($a_for_rss_use && ilNewsItem::getPrivateFeedId() == false)
930  {
931  $query = "SELECT * ".
932  "FROM il_news_item ".
933  " WHERE ".
934  $ilDB->in("context_obj_id", $ids, false, "integer")." ".
935  $and.
936  " ORDER BY creation_date DESC ";
937  }
938  elseif (ilNewsItem::getPrivateFeedId() != false)
939  {
940  $query = "SELECT il_news_item.* ".
941  ", il_news_read.user_id as user_read ".
942  "FROM il_news_item LEFT JOIN il_news_read ".
943  "ON il_news_item.id = il_news_read.news_id AND ".
944  " il_news_read.user_id = ".$ilDB->quote(ilNewsItem::getPrivateFeedId(), "integer").
945  " WHERE ".
946  $ilDB->in("context_obj_id", $ids, false, "integer")." ".
947  $and.
948  " ORDER BY creation_date DESC ";
949  }
950  else
951  {
952  if($a_user_id)
953  {
954  $user_id = $a_user_id;
955  }
956  else
957  {
958  $user_id = $ilUser->getId();
959  }
960  $query = "SELECT il_news_item.* ".
961  ", il_news_read.user_id as user_read ".
962  "FROM il_news_item LEFT JOIN il_news_read ".
963  "ON il_news_item.id = il_news_read.news_id AND ".
964  " il_news_read.user_id = ".$ilDB->quote($user_id, "integer").
965  " WHERE ".
966  $ilDB->in("context_obj_id", $ids, false, "integer")." ".
967  $and.
968  " ORDER BY creation_date DESC ";
969  }
970 
971  $set = $ilDB->query($query);
972  $result = array();
973  while($rec = $ilDB->fetchAssoc($set))
974  {
975  if ($type[$rec["context_obj_id"]] == $rec["context_obj_type"])
976  {
977  if (!$a_for_rss_use || ilNewsItem::getPrivateFeedId() != false || ($rec["visibility"] == NEWS_PUBLIC ||
978  ($rec["priority"] == 0 &&
979  ilBlockSetting::_lookup("news", "public_notifications",
980  0, $rec["context_obj_id"]))))
981  {
982  $result[$rec["id"]] = $rec;
983  }
984  }
985  }
986 
987  return $result;
988 
989  }
$result
global $ilCtrl
Definition: ilias.php:18
const NEWS_PUBLIC
static _lookup($a_type, $a_setting, $a_user=0, $a_block_id=0)
Lookup setting from database.
global $ilUser
Definition: imgupload.php:15
global $lng
Definition: privfeed.php:40
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilNewsItem::read ( )

Read item from database.

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

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

124  {
125  global $ilDB;
126 
127  $query = "SELECT * FROM il_news_item WHERE id = ".
128  $ilDB->quote($this->getId(), "integer");
129  $set = $ilDB->query($query);
130  $rec = $ilDB->fetchAssoc($set);
131 
132  $this->setTitle($rec["title"]);
133  $this->setContent($rec["content"]);
134  $this->setContextObjId((int) $rec["context_obj_id"]);
135  $this->setContextObjType($rec["context_obj_type"]);
136  $this->setContextSubObjId((int) $rec["context_sub_obj_id"]);
137  $this->setContextSubObjType($rec["context_sub_obj_type"]);
138  $this->setContentType($rec["content_type"]);
139  $this->setCreationDate($rec["creation_date"]);
140  $this->setUpdateDate($rec["update_date"]);
141  $this->setUserId($rec["user_id"]);
142  $this->setVisibility($rec["visibility"]);
143  $this->setContentLong($rec["content_long"]);
144  $this->setPriority($rec["priority"]);
145  $this->setContentIsLangVar($rec["content_is_lang_var"]);
146  $this->setContentTextIsLangVar((int) $rec["content_text_is_lang_var"]);
147  $this->setMobId($rec["mob_id"]);
148  $this->setPlaytime($rec["playtime"]);
149  $this->setMobPlayCounter($rec["mob_cnt_play"]);
150  $this->setMobDownloadCounter($rec["mob_cnt_download"]);
151 
152  }
setContentTextIsLangVar($a_val=0)
Set content text ist lang var.
setContextObjId($a_context_obj_id)
Set ContextObjId.
setPlaytime($a_playtime)
Set Playtime.
setContentLong($a_content_long)
Set ContentLong.
setPriority($a_priority=1)
Set Priority.
setContent($a_content)
Set Content.
setUserId($a_user_id)
Set UserId.
setContextSubObjId($a_context_sub_obj_id)
Set ContextSubObjId.
setMobId($a_mob_id)
Set MobId.
setCreationDate($a_creation_date)
Set CreationDate.
setContextObjType($a_context_obj_type)
Set ContextObjType.
setUpdateDate($a_update_date)
Set UpdateDate.
setMobDownloadCounter($a_val)
Set mob download counter.
setVisibility($a_visibility="users")
Set Visibility.
setTitle($a_title)
Set Title.
setContentIsLangVar($a_content_is_lang_var=0)
Set ContentIsLangVar.
global $ilDB
setContextSubObjType($a_context_sub_obj_type)
Set ContextSubObjType.
setContentType($a_content_type="text")
Set ContentType.
setMobPlayCounter($a_val)
Set mob play counter.
+ Here is the call graph for this function:

◆ setContentTextIsLangVar()

ilNewsItem::setContentTextIsLangVar (   $a_val = 0)

Set content text ist lang var.

Parameters
boolean$a_content_is_lang_var

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

Referenced by read().

66  {
67  $this->content_text_is_lang_var = $a_val;
68  }
+ Here is the caller graph for this function:

◆ setContext()

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

Convenient function to set the whole context information.

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

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

701  {
702  $this->setContextObjId($a_obj_id);
703  $this->setContextObjType($a_obj_type);
704  $this->setContextSubObjId($a_sub_obj_id);
705  $this->setContextSubObjType($a_sub_obj_type);
706  }
setContextObjId($a_context_obj_id)
Set ContextObjId.
setContextSubObjId($a_context_sub_obj_id)
Set ContextSubObjId.
setContextObjType($a_context_obj_type)
Set ContextObjType.
setContextSubObjType($a_context_sub_obj_type)
Set ContextSubObjType.
+ Here is the call graph for this function:

◆ setLimitation()

ilNewsItem::setLimitation (   $a_limitation)

Set Limitation for number of items.

Parameters
boolean$a_limitationLimitation for number of items

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

46  {
47  $this->limitation = $a_limitation;
48  }

◆ setMobDownloadCounter()

ilNewsItem::setMobDownloadCounter (   $a_val)

Set mob download counter.

Parameters
int$a_valcounter

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

Referenced by increaseDownloadCounter(), and read().

106  {
107  $this->mob_cnt_download = $a_val;
108  }
+ Here is the caller graph for this function:

◆ setMobPlayCounter()

ilNewsItem::setMobPlayCounter (   $a_val)

Set mob play counter.

Parameters
int$a_valcounter

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

Referenced by increasePlayCounter(), and read().

86  {
87  $this->mob_cnt_play = $a_val;
88  }
+ Here is the caller graph for this function:

◆ setPrivateFeedId()

ilNewsItem::setPrivateFeedId (   $a_userId)

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

References $privFeedId.

Referenced by ilObjectFeedWriter\ilObjectFeedWriter().

1473  {
1474  ilNewsItem::$privFeedId = $a_userId;
1475  }
static $privFeedId
+ Here is the caller graph for this function:

◆ update()

ilNewsItem::update (   $a_as_new = false)

Update item in database.

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

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

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

236  {
237  global $ilDB;
238 
239  $fields = array(
240  "title" => array("text", $this->getTitle()),
241  "content" => array("clob", $this->getContent()),
242  "context_obj_id" => array("integer", $this->getContextObjId()),
243  "context_obj_type" => array("text", $this->getContextObjType()),
244  "context_sub_obj_id" => array("integer", $this->getContextSubObjId()),
245  "context_sub_obj_type" => array("text", $this->getContextSubObjType()),
246  "content_type" => array("text", $this->getContentType()),
247  "user_id" => array("integer", $this->getUserId()),
248  "visibility" => array("text", $this->getVisibility()),
249  "content_long" => array("clob", $this->getContentLong()),
250  "priority" => array("integer", $this->getPriority()),
251  "content_is_lang_var" => array("integer", $this->getContentIsLangVar()),
252  "content_text_is_lang_var" => array("integer", (int) $this->getContentTextIsLangVar()),
253  "mob_id" => array("integer", $this->getMobId()),
254  "mob_cnt_play" => array("integer", $this->getMobPlayCounter()),
255  "mob_cnt_download" => array("integer", $this->getMobDownloadCounter()),
256  "playtime" => array("text", $this->getPlaytime())
257  );
258 
259  $now = ilUtil::now();
260  if ($a_as_new)
261  {
262  $fields["creation_date"] = array("timestamp", $now);
263  $fields["update_date"] = array("timestamp", $now);
264  }
265  else
266  {
267  $fields["update_date"] = array("timestamp", $now);
268  }
269 
270  $ilDB->update("il_news_item", $fields, array(
271  "id" => array("integer", $this->getId())
272  ));
273 
274  }
getContextSubObjType()
Get ContextSubObjType.
getPriority()
Get Priority.
getContentIsLangVar()
Get ContentIsLangVar.
getUserId()
Get UserId.
getContentTextIsLangVar()
Get content text ist lang var.
static now()
Return current timestamp in Y-m-d H:i:s format.
getMobDownloadCounter()
Get mob download counter.
getContextSubObjId()
Get ContextSubObjId.
getContextObjId()
Get ContextObjId.
getContent()
Get Content.
getContextObjType()
Get ContextObjType.
getContentType()
Get ContentType.
getContentLong()
Get ContentLong.
getTitle()
Get Title.
getVisibility()
Get Visibility.
getMobPlayCounter()
Get mob play counter.
global $ilDB
getPlaytime()
Get Playtime.
getMobId()
Get MobId.
+ Here is the call graph for this function:

Field Documentation

◆ $limitation

ilNewsItem::$limitation
private

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

Referenced by getLimitation().

◆ $privFeedId

ilNewsItem::$privFeedId = false
staticprivate

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

Referenced by getPrivateFeedId(), and setPrivateFeedId().


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