ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilNewsItem Class Reference
+ Inheritance diagram for ilNewsItem:
+ Collaboration diagram for ilNewsItem:

Public Member Functions

 __construct ($a_id=0)
 Constructor.
 setLimitation ($a_limitation)
 Set Limitation for number of items.
 getLimitation ()
 Get Limitation for number of items.
 create ()
 Create.
 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)
 Get News For Ref Id.
 getAggregatedNewsData ($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 (e.g.
 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.
 setContext ($a_obj_id, $a_obj_type, $a_sub_obj_id=0, $a_sub_obj_type="")
 Convenient function to set the whole context information.
 queryNewsForContext ($a_for_rss_use=false, $a_time_period=0, $a_starting_date="", $a_no_auto_generated=false, $a_oldest_first=false)
 Query news for a context.
 queryNewsForMultipleContexts ($a_contexts, $a_for_rss_use=false, $a_time_period=0, $a_starting_date="", $a_no_auto_generated=false)
 Query News for multiple Contexts.
 _setRead ($a_user_id, $a_news_id)
 Set item read.
 _setUnread ($a_user_id, $a_news_id)
 Set item unread.
 mergeNews ($n1, $n2)
 Merges two sets of news.
 delete ()
 Delete news item.
 _lookupDefaultPDPeriod ()
 _lookupUserPDPeriod ($a_user_id)
 _lookupRSSPeriod ()
 setPrivateFeedId ($a_userId)
 getPrivateFeedId ()
- Public Member Functions inherited from ilNewsItemGen
 setId ($a_id)
 Set Id.
 getId ()
 Get Id.
 setTitle ($a_title)
 Set Title.
 getTitle ()
 Get Title.
 setContent ($a_content)
 Set Content.
 getContent ()
 Get Content.
 setContextObjId ($a_context_obj_id)
 Set ContextObjId.
 getContextObjId ()
 Get ContextObjId.
 setContextObjType ($a_context_obj_type)
 Set ContextObjType.
 getContextObjType ()
 Get ContextObjType.
 setContextSubObjId ($a_context_sub_obj_id)
 Set ContextSubObjId.
 getContextSubObjId ()
 Get ContextSubObjId.
 setContextSubObjType ($a_context_sub_obj_type)
 Set ContextSubObjType.
 getContextSubObjType ()
 Get ContextSubObjType.
 setContentType ($a_content_type="text")
 Set ContentType.
 getContentType ()
 Get ContentType.
 setCreationDate ($a_creation_date)
 Set CreationDate.
 getCreationDate ()
 Get CreationDate.
 setUpdateDate ($a_update_date)
 Set UpdateDate.
 getUpdateDate ()
 Get UpdateDate.
 setUserId ($a_user_id)
 Set UserId.
 getUserId ()
 Get UserId.
 setVisibility ($a_visibility="users")
 Set Visibility.
 getVisibility ()
 Get Visibility.
 setContentLong ($a_content_long)
 Set ContentLong.
 getContentLong ()
 Get ContentLong.
 setPriority ($a_priority=1)
 Set Priority.
 getPriority ()
 Get Priority.
 setContentIsLangVar ($a_content_is_lang_var=0)
 Set ContentIsLangVar.
 getContentIsLangVar ()
 Get ContentIsLangVar.
 setMobId ($a_mob_id)
 Set MobId.
 getMobId ()
 Get MobId.
 setPlaytime ($a_playtime)
 Set Playtime.
 getPlaytime ()
 Get Playtime.
 read ()
 Read item from database.
 update ()
 Update item in database.
 queryNewsForContext ()
 Query NewsForContext.
 queryNewsForVisibility ()
 Query NewsForVisibility.

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.
static _getDefaultVisibilityForRefId ($a_ref_id)
 Get default visibility for reference id.
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.
static _lookupTitle ($a_news_id)
 Lookup News Title.
static _lookupVisibility ($a_news_id)
 Lookup News Visibility.
static _lookupMobId ($a_news_id)
 Lookup mob id.
static filterObjIdsPerNews ($a_obj_ids, $a_time_period=0, $a_starting_date="", $a_ending_date= '', $ignore_period=false)
 Checks whether news are available for.
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.
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.
static _lookupMediaObjectUsages ($a_mob_id)
 Lookup media object usage(s)
static _lookupContextObjId ($a_news_id)
 Context Object ID.

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

Constructor & Destructor Documentation

ilNewsItem::__construct (   $a_id = 0)

Constructor.

Parameters
int$a_id

Reimplemented from ilNewsItemGen.

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

{
$this->limitation = true;
}

Member Function Documentation

static ilNewsItem::_getDefaultVisibilityForRefId (   $a_ref_id)
static

Get default visibility for reference id.

Parameters
$a_ref_idreference id

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

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

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

{
global $tree, $ilSetting;
include_once("./Services/Block/classes/class.ilBlockSetting.php");
$news_set = new ilSetting("news");
$default_visibility = ($news_set->get("default_visibility") != "")
? $news_set->get("default_visibility")
: "users";
if ($tree->isInTree($a_ref_id))
{
$path = $tree->getPathFull($a_ref_id);
foreach ($path as $key => $row)
{
if (!in_array($row["type"], array("root", "cat","crs", "fold", "grp", "icrs")))
{
continue;
}
$visibility = ilBlockSetting::_lookup("news", "default_visibility",
0, $row["obj_id"]);
if ($visibility != "")
{
$default_visibility = $visibility;
}
}
}
return $default_visibility;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

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

{
global $ilAccess, $ilUser;
$news_item = new ilNewsItem();
$news_set = new ilSetting("news");
$per = $a_per;
include_once("./Services/News/classes/class.ilNewsSubscription.php");
include_once("./Services/Block/classes/class.ilBlockSetting.php");
// this is currently not used
if (ilObjUser::_lookupPref($a_user_id, "pd_items_news") != "n")
{
// this should be the case for all users
$pd_items = ilObjUser::_lookupDesktopItems($a_user_id);
foreach($pd_items as $item)
{
if (!in_array($item["ref_id"], $ref_ids))
{
$ref_ids[] = $item["ref_id"];
}
}
}
$data = array();
foreach($ref_ids as $ref_id)
{
if (!$a_only_public)
{
// this loop should not cost too much performance
$acc = $ilAccess->checkAccess("read", "", $ref_id);
if (!$acc)
{
continue;
}
}
if (ilNewsItem::getPrivateFeedId() != false) {
global $rbacsystem;
$acc = $rbacsystem->checkAccessOfUser(ilNewsItem::getPrivateFeedId(),"read", $ref_id);
if (!$acc)
{
continue;
}
}
$obj_id = ilObject::_lookupObjId($ref_id);
$obj_type = ilObject::_lookupType($obj_id);
$news = $news_item->getNewsForRefId($ref_id, $a_only_public, false,
$per, $a_prevent_aggregation);
// counter
if (!is_null($a_cnt))
{
$a_cnt[$ref_id] = count($news);
}
}
$data = ilUtil::sortArray($data, "creation_date", "desc", false, true);
return $data;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilNewsItem::_lookupContextObjId (   $a_news_id)
static

Context Object ID.

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

References $ilDB, and $query.

Referenced by ilObjMediaObject\getParentObjectIdForUsage().

{
global $ilDB;
$query = "SELECT * ".
"FROM il_news_item ".
"WHERE ".
" id = ".$ilDB->quote($a_news_id, "integer");
$set = $ilDB->query($query);
$rec = $ilDB->fetchAssoc($set);
return $rec["context_obj_id"];
}

+ Here is the caller graph for this function:

ilNewsItem::_lookupDefaultPDPeriod ( )

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

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

{
$news_set = new ilSetting("news");
$per = $news_set->get("pd_period");
if ($per == 0)
{
$per = 30;
}
return $per;
}

+ Here is the caller graph for this function:

static ilNewsItem::_lookupMediaObjectUsages (   $a_mob_id)
static

Lookup media object usage(s)

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

References $ilDB, and $query.

Referenced by ilObjMediaObject\lookupUsages().

{
global $ilDB;
$query = "SELECT * ".
"FROM il_news_item ".
"WHERE ".
" mob_id = ".$ilDB->quote($a_mob_id, "integer");
$usages = array();
$set = $ilDB->query($query);
while ($rec = $ilDB->fetchAssoc($set))
{
$usages[$rec["id"]] = array("type" => "news", "id" => $rec["id"]);
}
return $usages;
}

+ Here is the caller graph for this function:

static ilNewsItem::_lookupMobId (   $a_news_id)
static

Lookup mob id.

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

References $ilDB, and $query.

Referenced by ilNewsExporter\getXmlExportHeadDependencies().

{
global $ilDB;
$query = "SELECT mob_id FROM il_news_item WHERE id = ".
$ilDB->quote($a_news_id, "integer");
$set = $ilDB->query($query);
$rec = $ilDB->fetchAssoc($set);
return $rec["mob_id"];
}

+ Here is the caller graph for this function:

ilNewsItem::_lookupRSSPeriod ( )

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

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

{
$news_set = new ilSetting("news");
$rss_period = $news_set->get("rss_period");
if ($rss_period == 0) // default to two weeks
{
$rss_period = 14;
}
return $rss_period;
}

+ Here is the caller graph for this function:

static ilNewsItem::_lookupTitle (   $a_news_id)
static

Lookup News Title.

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

References $ilDB, and $query.

Referenced by ilShopResultPresentationGUI\__appendChildLinks().

{
global $ilDB;
$query = "SELECT title FROM il_news_item WHERE id = ".
$ilDB->quote($a_news_id, "integer");
$set = $ilDB->query($query);
$rec = $ilDB->fetchAssoc($set);
return $rec["title"];
}

+ Here is the caller graph for this function:

ilNewsItem::_lookupUserPDPeriod (   $a_user_id)

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

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

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

{
global $ilSetting;
$news_set = new ilSetting("news");
$allow_shorter_periods = $news_set->get("allow_shorter_periods");
$allow_longer_periods = $news_set->get("allow_longer_periods");
include_once("./Services/Block/classes/class.ilBlockSetting.php");
$per = ilBlockSetting::_lookup("pdnews", "news_pd_period",
$a_user_id, 0);
// news period information
if ($per <= 0 ||
(!$allow_shorter_periods && ($per < $default_per)) ||
(!$allow_longer_periods && ($per > $default_per))
)
{
$per = $default_per;
}
return $per;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilNewsItem::_lookupVisibility (   $a_news_id)
static

Lookup News Visibility.

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

References $ilDB, and $query.

Referenced by ilWebAccessChecker\checkAccess().

{
global $ilDB;
$query = "SELECT visibility FROM il_news_item WHERE id = ".
$ilDB->quote($a_news_id, "integer");
$set = $ilDB->query($query);
$rec = $ilDB->fetchAssoc($set);
return $rec["visibility"];
}

+ Here is the caller graph for this function:

ilNewsItem::_setRead (   $a_user_id,
  $a_news_id 
)

Set item read.

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

References $ilDB.

Referenced by ilNewsForContextBlockGUI\showNews().

{
global $ilDB, $ilAppEventHandler;
$ilDB->manipulate("DELETE FROM il_news_read WHERE ".
"user_id = ".$ilDB->quote($a_user_id, "integer").
" AND news_id = ".$ilDB->quote($a_news_id, "integer"));
$ilDB->manipulate("INSERT INTO il_news_read (user_id, news_id) VALUES (".
$ilDB->quote($a_user_id, "integer").",".
$ilDB->quote($a_news_id, "integer").")");
$ilAppEventHandler->raise("Services/News", "readNews",
array("user_id" => $a_user_id, "news_ids" => array($a_news_id)));
}

+ Here is the caller graph for this function:

ilNewsItem::_setUnread (   $a_user_id,
  $a_news_id 
)

Set item unread.

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

References $ilDB.

{
global $ilDB, $ilAppEventHandler;
$ilDB->manipulate("DELETE FROM il_news_read (user_id, news_id) VALUES (".
" WHERE user_id = ".$ilDB->quote($a_user_id, "integer").
" AND news_id = ".$ilDB->quote($a_news_id, "integer"));
$ilAppEventHandler->raise("Services/News", "unreadNews",
array("user_id" => $a_user_id, "news_ids" => array($a_news_id)));
}
ilNewsItem::aggregateFiles (   $news,
  $a_ref_id 
)

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

Referenced by getAggregatedChildNewsData(), and getAggregatedNewsData().

{
$first_file = "";
$to_del = array();
foreach ($news as $k => $v)
{
// aggregate file related news
if ($news[$k]["context_obj_type"] == "file")
{
if ($first_file == "")
{
$first_file = $k;
}
else
{
$to_del[] = $k;
}
$news[$first_file]["aggregation"][$k] = $news[$k];
$news[$first_file]["agg_ref_id"] = $a_ref_id;
$news[$first_file]["ref_id"] = $a_ref_id;
}
}
foreach($to_del as $v)
{
unset($news[$v]);
}
return $news;
}

+ Here is the caller graph for this function:

ilNewsItem::create ( )

Create.

Reimplemented from ilNewsItemGen.

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

References $ilDB, $query, ilNewsItemGen\getContextObjId(), ilNewsItemGen\getContextObjType(), ilNewsItemGen\getContextSubObjId(), ilNewsItemGen\getContextSubObjType(), and getLimitation().

{
global $ilDB;
$news_set = new ilSetting("news");
$max_items = $news_set->get("max_items");
if ($max_items <= 0)
{
$max_items = 50;
}
// limit number of news
if ($this->getLimitation())
{
// Determine how many rows should be deleted
$query = "SELECT count(*) cnt ".
"FROM il_news_item ".
"WHERE ".
"context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
" AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
" AND context_sub_obj_id = ".$ilDB->quote($this->getContextSubObjId(), "integer").
" AND ".$ilDB->equals("context_sub_obj_type", $this->getContextSubObjType(), "text", true)." ";
$set = $ilDB->query($query);
$rec = $ilDB->fetchAssoc($set);
// if we have more records than allowed, delete them
if (($rec["cnt"] > $max_items) && $this->getContextObjId() > 0)
{
$query = "SELECT * ".
"FROM il_news_item ".
"WHERE ".
"context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
" AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
" AND context_sub_obj_id = ".$ilDB->quote($this->getContextSubObjId(), "integer").
" AND ".$ilDB->equals("context_sub_obj_type", $this->getContextSubObjType(), "text", true).
" ORDER BY creation_date ASC";
$ilDB->setLimit($rec["cnt"] - $max_items);
$del_set = $ilDB->query($query);
while ($del_item = $ilDB->fetchAssoc($del_set))
{
$del_news = new ilNewsItem($del_item["id"]);
$del_news->delete();
}
}
}
}

+ Here is the call graph for this function:

ilNewsItem::delete ( )

Delete news item.

Reimplemented from ilNewsItemGen.

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

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

{
global $ilDB;
// delete il_news_read entries
$ilDB->manipulate("DELETE FROM il_news_read ".
" WHERE news_id = ".$ilDB->quote($this->getId(), "integer"));
// delete multimedia object
$mob = $this->getMobId();
// delete
// delete mob after news, to have a "mob usage" of 0
if ($mob > 0 and ilObject::_exists($mob))
{
include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
$mob = new ilObjMediaObject($mob);
$mob->delete();
}
}

+ Here is the call graph for this function:

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

References $ilDB, and $query.

Referenced by ilPageObject\delete().

{
global $ilDB;
if ($a_context_obj_id == 0 || $a_context_obj_type == "")
{
return;
}
if ($a_context_sub_obj_id > 0)
{
$and = " AND context_sub_obj_id = ".$ilDB->quote($a_context_sub_obj_id, "integer").
" AND context_sub_obj_type = ".$ilDB->quote($a_context_sub_obj_type, "text");
}
// get news records
$query = "SELECT * FROM il_news_item".
" WHERE context_obj_id = ".$ilDB->quote($a_context_obj_id, "integer").
" AND context_obj_type = ".$ilDB->quote($a_context_obj_type, "text").
$and;
$news_set = $ilDB->query($query);
while ($news = $ilDB->fetchAssoc($news_set))
{
$news_obj = new ilNewsItem($news["id"]);
$news_obj->delete();
}
}

+ Here is the caller graph for this function:

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

References $lng.

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

{
global $lng;
if ($a_agg_ref_id > 0)
{
$cnt = count($a_aggregation);
$up_cnt = $cr_cnt = 0;
foreach($a_aggregation as $item)
{
if ($item["title"] == "file_updated")
{
$up_cnt++;
}
else
{
$cr_cnt++;
}
}
$sep = "";
if ($cr_cnt == 1)
{
$tit = $lng->txt("news_1_file_created");
$sep = "<br />";
}
else if ($cr_cnt > 1)
{
$tit = sprintf($lng->txt("news_x_files_created"), $cr_cnt);
$sep = "<br />";
}
if ($up_cnt == 1)
{
$tit .= $sep.$lng->txt("news_1_file_updated");
}
else if ($up_cnt > 1)
{
$tit .= $sep.sprintf($lng->txt("news_x_files_updated"), $up_cnt);
}
return $tit;
}
else
{
if ($a_content_is_lang_var)
{
return $lng->txt($a_title);
}
else
{
return $a_title;
}
}
return "";
}

+ Here is the caller graph for this function:

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

References $ilDB, and $query.

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

{
global $ilDB;
$and = "";
if ($a_time_period > 0)
{
$limit_ts = date('Y-m-d H:i:s', time() - ($a_time_period * 24 * 60 * 60));
$and = " AND creation_date >= ".$ilDB->quote($limit_ts, "timestamp")." ";
}
if ($a_starting_date != "")
{
$and.= " AND creation_date >= ".$ilDB->quote($a_starting_date, "timestamp");
}
$query = "SELECT DISTINCT(context_obj_id) AS obj_id FROM il_news_item".
" WHERE ".$ilDB->in("context_obj_id", $a_obj_ids, false, "integer")." ".$and;
//" WHERE context_obj_id IN (".implode(ilUtil::quoteArray($a_obj_ids),",").")".$and;
$set = $ilDB->query($query);
$objs = array();
while($rec = $ilDB->fetchAssoc($set))
{
$objs[] = $rec["obj_id"];
}
return $objs;
}

+ Here is the caller graph for this function:

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

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

Referenced by getNewsForRefId().

{
global $tree, $ilAccess;
// get news of parent object
$data = $this->getNewsForRefId($a_ref_id, $a_only_public, true, $a_time_period,
true, false, false, $a_no_auto_generated);
foreach ($data as $k => $v)
{
$data[$k]["ref_id"] = $a_ref_id;
}
// get childs
$nodes = $tree->getChilds($a_ref_id);
// no check, for which of the objects any news are available
$obj_ids = array();
foreach($nodes as $node)
{
$obj_ids[] = $node["obj_id"];
}
$news_obj_ids = ilNewsItem::filterObjIdsPerNews($obj_ids, $a_time_period, $a_starting_date);
//$news_obj_ids = $obj_ids;
// get news for all subtree nodes
$contexts = array();
foreach($nodes as $node)
{
// only go on, if news are available
if (!in_array($node["obj_id"], $news_obj_ids))
{
continue;
}
if (!$a_only_public && !$ilAccess->checkAccess("read", "", $node["child"]))
{
continue;
}
$ref_id[$node["obj_id"]] = $node["child"];
$contexts[] = array("obj_id" => $node["obj_id"],
"obj_type" => $node["type"]);
}
$news = $this->queryNewsForMultipleContexts($contexts, $a_only_public, $a_time_period,
$a_starting_date, $a_no_auto_generated);
foreach ($news as $k => $v)
{
$news[$k]["ref_id"] = $ref_id[$v["context_obj_id"]];
}
// sort and return
$data = ilUtil::sortArray($data, "creation_date", "desc", false, true);
if (!$a_prevent_aggregation)
{
$data = $this->aggregateFiles($data, $a_ref_id);
}
return $data;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Get news aggregation (e.g.

for courses, groups)

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

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

Referenced by getNewsForRefId().

{
global $tree, $ilAccess, $ilObjDataCache;
// get news of parent object
$data = array();
// get subtree
$cur_node = $tree->getNodeData($a_ref_id);
if ($cur_node["lft"] != "") // should never be empty
{
$nodes = $tree->getSubTree($cur_node, true);
}
else
{
$nodes = array();
}
// preload object data cache
$ref_ids = array();
$obj_ids = array();
foreach($nodes as $node)
{
$ref_ids[] = $node["child"];
$obj_ids[] = $node["obj_id"];
}
$ilObjDataCache->preloadReferenceCache($ref_ids);
if (!$a_only_public)
{
$ilAccess->preloadActivationTimes($ref_ids);
}
// no check, for which of the objects any news are available
$news_obj_ids = ilNewsItem::filterObjIdsPerNews($obj_ids, $a_time_period, $a_starting_date);
//$news_obj_ids = $obj_ids;
// get news for all subtree nodes
$contexts = array();
foreach($nodes as $node)
{
// only go on, if news are available
if (!in_array($node["obj_id"], $news_obj_ids))
{
continue;
}
if (!$a_only_public)
{
$acc = $ilAccess->checkAccess("read", "", $node["child"]);
if (!$acc)
{
continue;
}
}
$ref_id[$node["obj_id"]] = $node["child"];
$contexts[] = array("obj_id" => $node["obj_id"],
"obj_type" => $node["type"]);
}
// sort and return
$news = $this->queryNewsForMultipleContexts($contexts, $a_only_public, $a_time_period,
$a_starting_date, $a_no_auto_generated);
$to_del = array();
foreach ($news as $k => $v)
{
$news[$k]["ref_id"] = $ref_id[$v["context_obj_id"]];
}
$data = ilUtil::sortArray($data, "creation_date", "desc", false, true);
if (!$a_prevent_aggregation)
{
$data = $this->aggregateFiles($data, $a_ref_id);
}
return $data;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References $ilDB, and $query.

{
global $ilDB;
// Determine how many rows should be deleted
$query = "SELECT * ".
"FROM il_news_item ".
"WHERE ".
"context_obj_id = ".$ilDB->quote($a_context_obj_id, "integer").
" AND context_obj_type = ".$ilDB->quote($a_context_obj_type, "text").
" AND context_sub_obj_id = ".$ilDB->quote($a_context_sub_obj_id, "integer").
" AND ".$ilDB->equals("context_sub_obj_type", $a_context_sub_obj_type, "text", true);
$set = $ilDB->query($query);
$rec = $ilDB->fetchAssoc($set);
return $rec["id"];
}
ilNewsItem::getLimitation ( )

Get Limitation for number of items.

Returns
boolean Limitation for number of items

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

References $limitation.

Referenced by create().

{
}

+ Here is the caller graph for this function:

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 
)

Get News For Ref Id.

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

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

Referenced by getAggregatedChildNewsData().

{
$obj_id = ilObject::_lookupObjId($a_ref_id);
$obj_type = ilObject::_lookupType($obj_id);
// get starting date
$starting_date = "";
if ($obj_type == "grp" || $obj_type == "crs" || $obj_type == "cat")
{
include_once("./Services/Block/classes/class.ilBlockSetting.php");
$hide_news_per_date = ilBlockSetting::_lookup("news", "hide_news_per_date",
0, $obj_id);
if ($hide_news_per_date && !$a_ignore_date_filter)
{
$starting_date = ilBlockSetting::_lookup("news", "hide_news_date",
0, $obj_id);
}
}
if ($obj_type == "cat" && !$a_stopnesting)
{
$news = $this->getAggregatedChildNewsData($a_ref_id, $a_only_public, $a_time_period,
$a_prevent_aggregation, $starting_date, $a_no_auto_generated);
}
else if (($obj_type == "grp" || $obj_type == "crs") &&
!$a_stopnesting)
{
$news = $this->getAggregatedNewsData($a_ref_id, $a_only_public, $a_time_period,
$a_prevent_aggregation, $starting_date, $a_no_auto_generated);
}
else
{
$news_item = new ilNewsItem();
$news_item->setContextObjId($obj_id);
$news_item->setContextObjType($obj_type);
$news = $news_item->queryNewsForContext($a_only_public, $a_time_period,
$starting_date, $a_no_auto_generated);
$unset = array();
foreach ($news as $k => $v)
{
if (!$a_only_public || $v["visibility"] == NEWS_PUBLIC ||
($v["priority"] == 0 &&
ilBlockSetting::_lookup("news", "public_notifications",
0, $obj_id)))
{
$news[$k]["ref_id"] = $a_ref_id;
}
else
{
$unset[] = $k;
}
}
foreach ($unset as $un)
{
unset($news[$un]);
}
}
return $news;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilNewsItem::getPrivateFeedId ( )

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

References $privFeedId.

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

+ Here is the caller graph for this function:

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

References ilNewsItemGen\$id.

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

{
foreach($n2 as $id => $news)
{
$n1[$id] = $news;
}
return $n1;
}

+ Here is the caller graph for this function:

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

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

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

{
global $ilDB, $ilUser, $lng;
$and = "";
if ($a_time_period > 0)
{
$limit_ts = date('Y-m-d H:i:s', time() - ($a_time_period * 24 * 60 * 60));
$and = " AND creation_date >= ".$ilDB->quote($limit_ts, "timestamp")." ";
}
if ($a_starting_date != "")
{
$and.= " AND creation_date > ".$ilDB->quote($a_starting_date, "timestamp")." ";
}
if ($a_no_auto_generated)
{
$and.= " AND priority = 1 AND content_type = ".$ilDB->quote("text", "text")." ";
}
// this is changed with 4.1 (news table for lm pages)
if ($this->getContextSubObjId() > 0)
{
$and.= " AND context_sub_obj_id = ".$ilDB->quote($this->getContextSubObjId(), "integer").
" AND context_sub_obj_type = ".$ilDB->quote($this->getContextSubObjType(), "text");
}
$ordering = ($a_oldest_first)
? " creation_date ASC, id ASC "
: " creation_date DESC, id DESC ";
if ($a_for_rss_use && ilNewsItem::getPrivateFeedId() == false)
{
$query = "SELECT * ".
"FROM il_news_item ".
" WHERE ".
"context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
" AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
$and.
" ORDER BY ".$ordering;
}
elseif (ilNewsItem::getPrivateFeedId() != false)
{
$query = "SELECT il_news_item.* ".
", il_news_read.user_id user_read ".
"FROM il_news_item LEFT JOIN il_news_read ".
"ON il_news_item.id = il_news_read.news_id AND ".
" il_news_read.user_id = ".$ilDB->quote(ilNewsItem::getPrivateFeedId(), "integer").
" WHERE ".
"context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
" AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
$and.
" ORDER BY ".$ordering;
}
else
{
$query = "SELECT il_news_item.* ".
", il_news_read.user_id as user_read ".
"FROM il_news_item LEFT JOIN il_news_read ".
"ON il_news_item.id = il_news_read.news_id AND ".
" il_news_read.user_id = ".$ilDB->quote($ilUser->getId(), "integer").
" WHERE ".
"context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
" AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
$and.
" ORDER BY ".$ordering;
}
//echo $query;
$set = $ilDB->query($query);
$result = array();
while($rec = $ilDB->fetchAssoc($set))
{
if (!$a_for_rss_use || (ilNewsItem::getPrivateFeedId() != false) || ($rec["visibility"] == NEWS_PUBLIC ||
($rec["priority"] == 0 &&
ilBlockSetting::_lookup("news", "public_notifications",
0, $rec["context_obj_id"]))))
{
$result[$rec["id"]] = $rec;
}
}
return $result;
}

+ Here is the call graph for this function:

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

Query News for multiple Contexts.

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

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

References $ilCtrl, $ilDB, $lng, $query, $type, ilBlockSetting\_lookup(), getPrivateFeedId(), and NEWS_PUBLIC.

Referenced by getAggregatedChildNewsData(), and getAggregatedNewsData().

{
global $ilDB, $ilUser, $lng, $ilCtrl;
$and = "";
if ($a_time_period > 0)
{
$limit_ts = date('Y-m-d H:i:s', time() - ($a_time_period * 24 * 60 * 60));
$and = " AND creation_date >= ".$ilDB->quote($limit_ts, "timestamp")." ";
}
if ($a_starting_date != "")
{
$and.= " AND creation_date > ".$ilDB->quote($a_starting_date, "timestamp")." ";
}
if ($a_no_auto_generated)
{
$and.= " AND priority = 1 AND content_type = ".$ilDB->quote("text", "text")." ";
}
$ids = array();
$type = array();
foreach($a_contexts as $cont)
{
$ids[] = $cont["obj_id"];
$type[$cont["obj_id"]] = $cont["obj_type"];
}
if ($a_for_rss_use && ilNewsItem::getPrivateFeedId() == false)
{
$query = "SELECT * ".
"FROM il_news_item ".
" WHERE ".
$ilDB->in("context_obj_id", $ids, false, "integer")." ".
$and.
" ORDER BY creation_date DESC ";
}
elseif (ilNewsItem::getPrivateFeedId() != false)
{
$query = "SELECT il_news_item.* ".
", il_news_read.user_id as user_read ".
"FROM il_news_item LEFT JOIN il_news_read ".
"ON il_news_item.id = il_news_read.news_id AND ".
" il_news_read.user_id = ".$ilDB->quote(ilNewsItem::getPrivateFeedId(), "integer").
" WHERE ".
$ilDB->in("context_obj_id", $ids, false, "integer")." ".
$and.
" ORDER BY creation_date DESC ";
}
else
{
$query = "SELECT il_news_item.* ".
", il_news_read.user_id as user_read ".
"FROM il_news_item LEFT JOIN il_news_read ".
"ON il_news_item.id = il_news_read.news_id AND ".
" il_news_read.user_id = ".$ilDB->quote($ilUser->getId(), "integer").
" WHERE ".
$ilDB->in("context_obj_id", $ids, false, "integer")." ".
$and.
" ORDER BY creation_date DESC ";
}
$set = $ilDB->query($query);
$result = array();
while($rec = $ilDB->fetchAssoc($set))
{
if ($type[$rec["context_obj_id"]] == $rec["context_obj_type"])
{
if (!$a_for_rss_use || ilNewsItem::getPrivateFeedId() != false || ($rec["visibility"] == NEWS_PUBLIC ||
($rec["priority"] == 0 &&
ilBlockSetting::_lookup("news", "public_notifications",
0, $rec["context_obj_id"]))))
{
$result[$rec["id"]] = $rec;
}
}
}
return $result;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

{
$this->setContextObjId($a_obj_id);
$this->setContextObjType($a_obj_type);
$this->setContextSubObjId($a_sub_obj_id);
$this->setContextSubObjType($a_sub_obj_type);
}

+ Here is the call graph for this function:

ilNewsItem::setLimitation (   $a_limitation)

Set Limitation for number of items.

Parameters
boolean$a_limitationLimitation for number of items

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

{
$this->limitation = $a_limitation;
}
ilNewsItem::setPrivateFeedId (   $a_userId)

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

References $privFeedId.

Referenced by ilObjectFeedWriter\ilObjectFeedWriter(), and ilUserFeedWriter\ilUserFeedWriter().

{
}

+ Here is the caller graph for this function:

Field Documentation

ilNewsItem::$limitation
private

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

Referenced by getLimitation().

ilNewsItem::$privFeedId = false
staticprivate

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

Referenced by getPrivateFeedId(), and setPrivateFeedId().


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