ILIAS  Release_4_0_x_branch Revision 61816
 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)
 Get News For Ref Id.
 getAggregatedNewsData ($a_ref_id, $a_only_public=false, $a_time_period=0, $a_prevent_aggregation=false, $a_starting_date="")
 Get news aggregation (e.g.
 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="")
 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="")
 Query NewsForContext.
 queryNewsForMultipleContexts ($a_contexts, $a_for_rss_use=false, $a_time_period=0, $a_starting_date="")
 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.
 deleteNewsOfContext ($a_context_obj_id, $a_context_obj_type)
 Delete all news of a context.
 _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 _lookupTitle ($a_news_id)
 Lookup News Title.
static _lookupVisibility ($a_news_id)
 Lookup News Visibility.
static filterObjIdsPerNews ($a_obj_ids, $a_time_period=0, $a_starting_date="")
 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 22 of file class.ilNewsItem.php.

Constructor & Destructor Documentation

ilNewsItem::__construct (   $a_id = 0)

Constructor.

Parameters
int$a_id

Reimplemented from ilNewsItemGen.

Definition at line 33 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 766 of file class.ilNewsItem.php.

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

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

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

References $data, $ilBench, $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, $ilBench;
$ilBench->start("News", "getNewsItemsOfUser");
$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
$ilBench->start("News", "getNewsItemsOfUser_getRefIds");
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"];
}
}
}
$ilBench->stop("News", "getNewsItemsOfUser_getRefIds");
$data = array();
foreach($ref_ids as $ref_id)
{
$ilBench->start("News", "getNewsForRefId");
if (!$a_only_public)
{
// this loop should not cost too much performance
$ilBench->start("News", "getAggregatedNewsData_getContexts_checkAccess");
$acc = $ilAccess->checkAccess("read", "", $ref_id);
$ilBench->stop("News", "getAggregatedNewsData_getContexts_checkAccess");
if (!$acc)
{
continue;
}
}
if (ilNewsItem::getPrivateFeedId() != false) {
global $rbacsystem;
$acc = $rbacsystem->checkAccessOfUser(ilNewsItem::getPrivateFeedId(),"read", $ref_id);
if (!$acc)
{
continue;
}
}
$ilBench->start("News", "getNewsForRefId_getNews");
$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);
$ilBench->stop("News", "getNewsForRefId_getNews");
// counter
if (!is_null($a_cnt))
{
$a_cnt[$ref_id] = count($news);
}
$ilBench->start("News", "getNewsForRefId_mergeNews");
$ilBench->stop("News", "getNewsForRefId_mergeNews");
$ilBench->stop("News", "getNewsForRefId");
}
$data = ilUtil::sortArray($data, "creation_date", "desc", false, true);
$ilBench->stop("News", "getNewsItemsOfUser");
//var_dump($data);
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 1043 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 1057 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 1021 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:

ilNewsItem::_lookupRSSPeriod ( )

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

Referenced by ilObjNewsSettingsGUI\editSettings(), 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 860 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 1069 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 874 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 713 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 731 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 435 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::aggregateForums (   $news,
  $a_group_posting_sequence = false 
)

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

Referenced by getNewsForRefId().

{
$to_del = array();
$forums = array();
// aggregate
foreach ($news as $k => $v)
{
if ($a_group_posting_sequence && $last_aggregation_forum > 0 &&
$last_aggregation_forum != $news[$k]["context_obj_id"])
{
$forums[$last_aggregation_forum] = "";
}
if ($news[$k]["context_obj_type"] == "frm")
{
if ($forums[$news[$k]["context_obj_id"]] == "")
{
// $forums[forum_id] = news_id;
$forums[$news[$k]["context_obj_id"]] = $k;
$last_aggregation_forum = $news[$k]["context_obj_id"];
}
else
{
$to_del[] = $k;
}
$news[$k]["no_context_title"] = true;
// aggregate every forum into it's "k" news
$news[$forums[$news[$k]["context_obj_id"]]]["aggregation"][$k]
= $news[$k];
$news[$k]["agg_ref_id"]
= $news[$k]["ref_id"];
$news[$k]["content"] = "";
$news[$k]["content_long"] = "";
}
}
// delete double entries
foreach($to_del as $k)
{
unset($news[$k]);
}
//var_dump($news[14]["aggregation"]);
return $news;
}

+ Here is the caller graph for this function:

ilNewsItem::create ( )

Create.

Reimplemented from ilNewsItemGen.

Definition at line 63 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 806 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:

ilNewsItem::deleteNewsOfContext (   $a_context_obj_id,
  $a_context_obj_type 
)

Delete all news of a context.

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

References $ilDB, and $query.

{
global $ilDB;
if ($a_context_obj_id == 0 || $a_context_obj_type == "")
{
return;
}
// 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");
$news_set = $ilDB->query($query);
while ($news = $ilDB->fetchAssoc($news_set))
{
$news_obj = new ilNewsItem($news["id"]);
$news_obj->delete();
}
}
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 922 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);
// forums
if ($a_context_obj_type == "frm")
{
if ($cnt > 1)
{
return sprintf($lng->txt("news_x_postings"), $cnt);
}
else
{
return $lng->txt("news_1_postings");
}
}
else // files
{
$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 = "" 
)
static

Checks whether news are available for.

Definition at line 889 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 = "" 
)

Get news aggregation for child objects (e.g.

for categories)

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

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

Referenced by getNewsForRefId().

{
global $tree, $ilAccess, $ilBench;
$ilBench->start("News", "getAggregatedChildNewsData");
// get news of parent object
$data = $this->getNewsForRefId($a_ref_id, $a_only_public, true, $a_time_period);
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);
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);
}
$ilBench->stop("News", "getAggregatedChildNewsData");
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 = "" 
)

Get news aggregation (e.g.

for courses, groups)

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

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

Referenced by getNewsForRefId().

{
global $tree, $ilAccess, $ilBench, $ilObjDataCache;
$ilBench->start("News", "getAggregatedNewsData");
// get news of parent object
$data = array();
// get subtree
$ilBench->start("News", "getAggregatedNewsData_getSubTree");
$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"];
}
$ilBench->stop("News", "getAggregatedNewsData_getSubTree");
$ilBench->start("News", "getAggregatedNewsData_preloadActivationTimes");
$ilObjDataCache->preloadReferenceCache($ref_ids);
if (!$a_only_public)
{
$ilAccess->preloadActivationTimes($ref_ids);
}
$ilBench->stop("News", "getAggregatedNewsData_preloadActivationTimes");
// 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
$ilBench->start("News", "getAggregatedNewsData_getContexts");
$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)
{
$ilBench->start("News", "getAggregatedNewsData_getContexts_checkAccess");
$acc = $ilAccess->checkAccess("read", "", $node["child"]);
$ilBench->stop("News", "getAggregatedNewsData_getContexts_checkAccess");
if (!$acc)
{
continue;
}
}
$ref_id[$node["obj_id"]] = $node["child"];
$contexts[] = array("obj_id" => $node["obj_id"],
"obj_type" => $node["type"]);
}
$ilBench->stop("News", "getAggregatedNewsData_getContexts");
// sort and return
$news = $this->queryNewsForMultipleContexts($contexts, $a_only_public, $a_time_period,
$a_starting_date);
$ilBench->start("News", "getAggregatedNewsData_mergeAndSort");
$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);
}
//var_dump($data);
$ilBench->stop("News", "getAggregatedNewsData_mergeAndSort");
$ilBench->stop("News", "getAggregatedNewsData");
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 998 of file class.ilNewsItem.php.

References $ilDB, and $query.

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

{
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"];
}

+ Here is the caller graph for this function:

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

{
}

+ 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 
)

Get News For Ref Id.

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

References ilBlockSetting\_lookup(), ilObject\_lookupObjId(), ilObject\_lookupType(), aggregateForums(), 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)
{
$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);
}
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);
}
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);
$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]);
}
}
if (!$a_prevent_aggregation)
{
$news = $this->aggregateForums($news);
}
else if ($a_forum_group_sequences)
{
$news = $this->aggregateForums($news, true);
}
return $news;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilNewsItem::getPrivateFeedId ( )

Definition at line 1109 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 751 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 = "" 
)

Query NewsForContext.

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

References $ilDB, $lng, $query, $result, ilBlockSetting\_lookup(), elseif(), ilNewsItemGen\getContextObjId(), ilNewsItemGen\getContextObjType(), 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_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 creation_date DESC ";
}
{
$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 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 ".
"context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
" AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
$and.
" ORDER BY creation_date DESC ";
}
$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 = "" 
)

Query News for multiple Contexts.

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

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

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

Referenced by getAggregatedChildNewsData(), and getAggregatedNewsData().

{
global $ilDB, $ilUser, $ilBench, $lng, $ilCtrl;
$ilBench->start("News", "queryNewsForMultipleContexts");
$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")." ";
}
$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 ";
}
{
$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;
}
}
}
$ilBench->stop("News", "queryNewsForMultipleContexts");
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 539 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 45 of file class.ilNewsItem.php.

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

Definition at line 1104 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 26 of file class.ilNewsItem.php.

Referenced by getLimitation().

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: