ILIAS  Release_4_4_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.
 setContentTextIsLangVar ($a_val=0)
 Set content text ist lang var.
 getContentTextIsLangVar ()
 Get content text ist lang var.
 setMobPlayCounter ($a_val)
 Set mob play counter.
 getMobPlayCounter ()
 Get mob play counter.
 setMobDownloadCounter ($a_val)
 Set mob download counter.
 getMobDownloadCounter ()
 Get mob download counter.
 read ()
 Read item from database.
 create ()
 Create.
 update ($a_as_new=false)
 Update item in database.
 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.
 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.
 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.
 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, $a_limit=0)
 Query news for a context.
 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.
 _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 ()
 deliverMobFile ($a_purpose="Standard", $a_increase_download_cnt=false)
 Deliver mob file.
 increaseDownloadCounter ()
 Increase download counter.
 increasePlayCounter ()
 Increase play counter.
- 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.
 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 determineNewsContent ($a_context_obj_type, $a_content, $a_is_lang_var)
 Determine new content.
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 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.
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 1033 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().

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

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

{
global $ilAccess;
$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")
{
// get all items of the personal desktop
$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"];
}
}
// get all memberships
include_once 'Services/Membership/classes/class.ilParticipants.php';
$crs_mbs = ilParticipants::_getMembershipByType($a_user_id, 'crs');
$grp_mbs = ilParticipants::_getMembershipByType($a_user_id, 'grp');
$items = array_merge($crs_mbs, $grp_mbs);
foreach($items as $i)
{
$item_references = ilObject::_getAllReferences($i);
if(is_array($item_references) && count($item_references))
{
foreach($item_references as $ref_id)
{
if (!in_array($ref_id, $ref_ids))
{
$ref_ids[] = $ref_id;
}
}
}
}
}
$data = array();
foreach($ref_ids as $ref_id)
{
if (!$a_only_public)
{
// this loop should not cost too much performance
$acc = $ilAccess->checkAccessOfUser($a_user_id, "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, false, false, false, $a_user_id);
// counter
if (!is_null($a_cnt))
{
$a_cnt[$ref_id] = count($news);
}
$data = ilNewsItem::mergeNews($data, $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 1387 of file class.ilNewsItem.php.

References $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 1401 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 1365 of file class.ilNewsItem.php.

References $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 1163 of file class.ilNewsItem.php.

References $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 1438 of file class.ilNewsItem.php.

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

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

References $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 1413 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 1148 of file class.ilNewsItem.php.

References $query.

{
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"];
}
ilNewsItem::_setRead (   $a_user_id,
  $a_news_id 
)

Set item read.

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

Referenced by ilNewsForContextBlockGUI\showNews().

{
global $ilDB, $ilAppEventHandler;
$ilDB->replace("il_news_read",
array(
"user_id" => array("integer", $a_user_id),
"news_id" => array("integer", $a_news_id)
),
array()
);
/*
$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 998 of file class.ilNewsItem.php.

{
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 598 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 548 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::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 831 of file class.ilNewsItem.php.

References $query.

{
global $tree, $ilDB;
$all = array();
if(!$tree->isDeleted($a_ref_id))
{
// parse repository branch of group
$nodes = array();
$node = $tree->getNodeData($a_ref_id);
foreach($tree->getSubTree($node) as $child)
{
if($child["type"] != "rolf")
{
$nodes[$child["obj_id"]] = $child["type"];
}
}
$limit_ts = date('Y-m-d H:i:s', time() - ($a_time_period * 24 * 60 * 60));
// are there any news items for relevant objects and?
$query = $ilDB->query("SELECT id,context_obj_id,context_obj_type".
" FROM il_news_item".
" WHERE ".$ilDB->in("context_obj_id", array_keys($nodes), false, "integer").
" AND creation_date >= ".$ilDB->quote($limit_ts, "timestamp"));
while($rec = $ilDB->fetchAssoc($query))
{
if ($nodes[$rec["context_obj_id"]] == $rec["context_obj_type"])
{
$all[] = $rec["id"];
}
}
}
return $all;
}
ilNewsItem::create ( )

Create.

Reimplemented from ilNewsItemGen.

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

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

{
global $ilDB;
// insert new record into db
$this->setId($ilDB->nextId("il_news_item"));
$ilDB->insert("il_news_item", array(
"id" => array("integer", $this->getId()),
"title" => array("text", $this->getTitle()),
"content" => array("clob", $this->getContent()),
"context_obj_id" => array("integer", (int) $this->getContextObjId()),
"context_obj_type" => array("text", $this->getContextObjType()),
"context_sub_obj_id" => array("integer", (int) $this->getContextSubObjId()),
"context_sub_obj_type" => array("text", $this->getContextSubObjType()),
"content_type" => array("text", $this->getContentType()),
"creation_date" => array("timestamp", ilUtil::now()),
"update_date" => array("timestamp", ilUtil::now()),
"user_id" => array("integer", $this->getUserId()),
"visibility" => array("text", $this->getVisibility()),
"content_long" => array("clob", $this->getContentLong()),
"priority" => array("integer", $this->getPriority()),
"content_is_lang_var" => array("integer", $this->getContentIsLangVar()),
"content_text_is_lang_var" => array("integer", (int) $this->getContentTextIsLangVar()),
"mob_id" => array("integer", $this->getMobId()),
"playtime" => array("text", $this->getPlaytime())
));
$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 1073 of file class.ilNewsItem.php.

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

References $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:

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

Deliver mob file.

Parameters
@return

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

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

{
$mob = $this->getMobId();
include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
$mob = new ilObjMediaObject($mob);
$mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
// check purpose
if (!$mob->hasPurposeItem($a_purpose))
{
return false;
}
$m_item = $mob->getMediaItem($a_purpose);
if ($m_item->getLocationType() != "Reference")
{
$file = $mob_dir."/".$m_item->getLocation();
if (file_exists($file) && is_file($file))
{
if ($a_increase_download_cnt)
{
}
ilUtil::deliverFile($file, $m_item->getLocation());
}
else
{
ilUtil::sendFailure("File not found!",true);
return false;
}
}
else
{
if ($a_increase_download_cnt)
{
}
ilUtil::redirect($m_item->getLocation());
}
}

+ Here is the call graph for this function:

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

Determine new content.

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

References $lng.

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

{
global $lng;
if ($a_is_lang_var)
{
$lng->loadLanguageModule($a_context_obj_type);
return $lng->txt($a_content);
}
else
{
return $a_content;
}
}

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

References $lng.

Referenced by ilNewsForContextBlockGUI\fillRow(), ilObjectFeedWriter\ilObjectFeedWriter(), ilUserFeedWriter\ilUserFeedWriter(), ilMembershipCronNotifications\sendMail(), 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 = "",
  $a_ending_date = '',
  $ignore_period = false 
)
static

Checks whether news are available for.

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

References $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 633 of file class.ilNewsItem.php.

References $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"]];
}
$data = ilNewsItem::mergeNews($data, $news);
// 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,
  $a_user_id = null 
)

Get news aggregation (e.g.

for courses, groups)

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

References $ref_id, aggregateFiles(), filterObjIdsPerNews(), mergeNews(), ilObjectActivation\preloadData(), 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);
// do not check for lft (materialized path)
if($cur_node)
{
$nodes = (array) $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)
{
include_once "Services/Object/classes/class.ilObjectActivation.php";
}
// 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)
{
if(!$a_user_id)
{
$acc = $ilAccess->checkAccess("read", "", $node["child"]);
}
else
{
$acc = $ilAccess->checkAccessOfUser($a_user_id, "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, $a_user_id);
$to_del = array();
foreach ($news as $k => $v)
{
$news[$k]["ref_id"] = $ref_id[$v["context_obj_id"]];
}
$data = ilNewsItem::mergeNews($data, $news);
$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::getContentTextIsLangVar ( )

Get content text ist lang var.

Returns
boolean

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

Referenced by create(), and update().

{
return $this->content_text_is_lang_var;
}

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

References $query.

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

{
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:

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

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

Referenced by ilWikiPage\updateNews().

{
global $ilDB;
// Determine how many rows should be deleted
$query = "SELECT id, update_date ".
"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).
" ORDER BY update_date DESC";
$ilDB->setLimit(1);
$set = $ilDB->query($query);
$rec = $ilDB->fetchAssoc($set);
$id = (int) $rec["id"];
if ($a_only_today)
{
$now = ilUtil::now();
if (substr($now, 0, 10) != substr($rec["update_date"], 0, 10))
{
$id = 0;
}
}
return $id;
}

+ Here is the call graph for this function:

+ 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::getMobDownloadCounter ( )

Get mob download counter.

Returns
int counter

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

Referenced by increaseDownloadCounter(), and update().

{
return $this->mob_cnt_download;
}

+ Here is the caller graph for this function:

ilNewsItem::getMobPlayCounter ( )

Get mob play counter.

Returns
int counter

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

Referenced by increasePlayCounter(), and update().

{
return $this->mob_cnt_play;
}

+ 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,
  $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().

{
$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, $a_user_id);
}
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]);
}
}
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 1453 of file class.ilNewsItem.php.

References $privFeedId.

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

+ Here is the caller graph for this function:

ilNewsItem::increaseDownloadCounter ( )

Increase download counter.

Parameters
@return

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

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

Referenced by deliverMobFile().

{
global $ilDB;
$cnt = $this->getMobDownloadCounter();
$cnt++;
$this->setMobDownloadCounter($cnt);
$ilDB->manipulate("UPDATE il_news_item SET ".
" mob_cnt_download = ".$ilDB->quote($cnt, "integer").
" WHERE id = ".$ilDB->quote($this->getId(), "integer")
);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilNewsItem::increasePlayCounter ( )

Increase play counter.

Parameters
@return

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

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

{
global $ilDB;
$cnt = $this->getMobPlayCounter();
$cnt++;
$this->setMobPlayCounter($cnt);
$ilDB->manipulate("UPDATE il_news_item SET ".
" mob_cnt_play = ".$ilDB->quote($cnt, "integer").
" WHERE id = ".$ilDB->quote($this->getId(), "integer")
);
}

+ Here is the call 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 1018 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,
  $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 716 of file class.ilNewsItem.php.

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

{
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_limit > 0 && count($result) >= $a_limit)
{
continue;
}
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;
}
}
// do we get data for rss and may the time limit by an issue?
// do a second query without time limit.
// this is not very performant, but I do not have a better
// idea. The keep_rss_min setting is currently (Jul 2012) only set
// by mediacasts
if ($a_time_period != "" && $a_for_rss_use)
{
include_once("./Services/Block/classes/class.ilBlockSetting.php");
$keep_rss_min = ilBlockSetting::_lookup("news", "keep_rss_min",
0, $this->getContextObjId());
if ($keep_rss_min > 0)
{
return $this->queryNewsForContext(true, 0,
$a_starting_date, $a_no_auto_generated, $a_oldest_first, $keep_rss_min);
}
}
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,
  $a_user_id = null 
)

Query News for multiple Contexts.

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

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

References $ilCtrl, $ilUser, $lng, $query, $result, ilNewsItemGen\$user_id, 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
{
if($a_user_id)
{
$user_id = $a_user_id;
}
else
{
$user_id = $ilUser->getId();
}
$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($user_id, "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::read ( )

Read item from database.

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

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

{
global $ilDB;
$query = "SELECT * FROM il_news_item WHERE id = ".
$ilDB->quote($this->getId(), "integer");
$set = $ilDB->query($query);
$rec = $ilDB->fetchAssoc($set);
$this->setTitle($rec["title"]);
$this->setContent($rec["content"]);
$this->setContextObjId((int) $rec["context_obj_id"]);
$this->setContextObjType($rec["context_obj_type"]);
$this->setContextSubObjId((int) $rec["context_sub_obj_id"]);
$this->setContextSubObjType($rec["context_sub_obj_type"]);
$this->setContentType($rec["content_type"]);
$this->setCreationDate($rec["creation_date"]);
$this->setUpdateDate($rec["update_date"]);
$this->setUserId($rec["user_id"]);
$this->setVisibility($rec["visibility"]);
$this->setContentLong($rec["content_long"]);
$this->setPriority($rec["priority"]);
$this->setContentIsLangVar($rec["content_is_lang_var"]);
$this->setContentTextIsLangVar((int) $rec["content_text_is_lang_var"]);
$this->setMobId($rec["mob_id"]);
$this->setPlaytime($rec["playtime"]);
$this->setMobPlayCounter($rec["mob_cnt_play"]);
$this->setMobDownloadCounter($rec["mob_cnt_download"]);
}

+ Here is the call graph for this function:

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

{
$this->content_text_is_lang_var = $a_val;
}

+ 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 700 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::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().

{
$this->mob_cnt_download = $a_val;
}

+ Here is the caller graph for this function:

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

{
$this->mob_cnt_play = $a_val;
}

+ Here is the caller graph for this function:

ilNewsItem::setPrivateFeedId (   $a_userId)

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

References $privFeedId.

Referenced by ilObjectFeedWriter\ilObjectFeedWriter().

{
}

+ Here is the caller graph for this function:

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

{
global $ilDB;
$fields = array(
"title" => array("text", $this->getTitle()),
"content" => array("clob", $this->getContent()),
"context_obj_id" => array("integer", $this->getContextObjId()),
"context_obj_type" => array("text", $this->getContextObjType()),
"context_sub_obj_id" => array("integer", $this->getContextSubObjId()),
"context_sub_obj_type" => array("text", $this->getContextSubObjType()),
"content_type" => array("text", $this->getContentType()),
"user_id" => array("integer", $this->getUserId()),
"visibility" => array("text", $this->getVisibility()),
"content_long" => array("clob", $this->getContentLong()),
"priority" => array("integer", $this->getPriority()),
"content_is_lang_var" => array("integer", $this->getContentIsLangVar()),
"content_text_is_lang_var" => array("integer", (int) $this->getContentTextIsLangVar()),
"mob_id" => array("integer", $this->getMobId()),
"mob_cnt_play" => array("integer", $this->getMobPlayCounter()),
"mob_cnt_download" => array("integer", $this->getMobDownloadCounter()),
"playtime" => array("text", $this->getPlaytime())
);
$now = ilUtil::now();
if ($a_as_new)
{
$fields["creation_date"] = array("timestamp", $now);
$fields["update_date"] = array("timestamp", $now);
}
else
{
$fields["update_date"] = array("timestamp", $now);
}
$ilDB->update("il_news_item", $fields, array(
"id" => array("integer", $this->getId())
));
}

+ Here is the call 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: