ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilUserFeedWriter Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilUserFeedWriter:
+ Collaboration diagram for ilUserFeedWriter:

Public Member Functions

 __construct (int $a_user_id, string $a_hash, bool $privFeed=false)
 
- Public Member Functions inherited from ilFeedWriter
 __construct ()
 
 setEncoding (string $a_enc)
 
 getEncoding ()
 
 setChannelAbout (string $a_ab)
 
 getChannelAbout ()
 
 setChannelTitle (string $a_title)
 
 getChannelTitle ()
 
 setChannelLink (string $a_link)
 
 getChannelLink ()
 
 setChannelDescription (string $a_desc)
 
 getChannelDescription ()
 
 addItem (ilFeedItem $a_item)
 
 getItems ()
 
 prepareStr (string $a_str)
 
 getFeed ()
 
 showFeed ()
 
 getContextPath (int $a_ref_id)
 

Protected Attributes

ilSetting $settings
 
ilLanguage $lng
 
- Protected Attributes inherited from ilFeedWriter
ilTree $tree
 
ilLanguage $lng
 
ilTemplate $tpl
 

Additional Inherited Members

- Data Fields inherited from ilFeedWriter
string $encoding = "UTF-8"
 
string $ch_about = ""
 
string $ch_title = ""
 
string $ch_link = ""
 
string $ch_description = ""
 
array $items = array()
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Feed writer for personal user feeds.

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

Definition at line 23 of file class.ilUserFeedWriter.php.

Constructor & Destructor Documentation

◆ __construct()

ilUserFeedWriter::__construct ( int  $a_user_id,
string  $a_hash,
bool  $privFeed = false 
)

Definition at line 28 of file class.ilUserFeedWriter.php.

References $DIC, $ilSetting, ilFeedWriter\$items, ILIAS\GlobalScreen\Provider\__construct(), ilNewsItem\_getNewsItemsOfUser(), ilObjForumAccess\_getThreadForPosting(), ilObjUser\_lookupFeedHash(), ilObject\_lookupObjId(), ilObjMediaCastAccess\_lookupOnline(), ilNewsItem\_lookupRSSPeriod(), ilObject\_lookupTitle(), ilObject\_lookupType(), ilFeedWriter\addItem(), CLIENT_ID, ilNewsItem\determineNewsContent(), ilNewsItem\determineNewsTitle(), ilFeedWriter\getContextPath(), ILIAS\Repository\lng(), ilWikiPage\lookupTitle(), ilFeedWriter\prepareStr(), ilFeedWriter\setChannelAbout(), ilFeedWriter\setChannelLink(), ilFeedWriter\setChannelTitle(), and ILIAS\Repository\settings().

32  {
33  global $DIC;
34 
35  $this->settings = $DIC->settings();
36  $this->lng = $DIC->language();
37  $ilSetting = $DIC->settings();
38 
40 
41  if ($a_user_id == "" || $a_hash == "") {
42  return;
43  }
44 
45  $news_set = new ilSetting("news");
46  if (!$news_set->get("enable_rss_for_internal")) {
47  return;
48  }
49 
50  $hash = ilObjUser::_lookupFeedHash($a_user_id);
51 
52  $rss_period = ilNewsItem::_lookupRSSPeriod();
53 
54  if ($a_hash == $hash) {
55  if ($privFeed) {
56  //ilNewsItem::setPrivateFeedId($a_user_id);
57  $items = ilNewsItem::_getNewsItemsOfUser($a_user_id, false, true, $rss_period);
58  } else {
59  $items = ilNewsItem::_getNewsItemsOfUser($a_user_id, true, true, $rss_period);
60  }
61 
62  if ($ilSetting->get('short_inst_name') != "") {
63  $this->setChannelTitle($ilSetting->get('short_inst_name'));
64  } else {
65  $this->setChannelTitle("ILIAS");
66  }
67 
68  $this->setChannelAbout(ILIAS_HTTP_PATH);
69  $this->setChannelLink(ILIAS_HTTP_PATH);
70  //$this->setChannelDescription("ILIAS Channel Description");
71  foreach ($items as $item) {
72  $obj_id = ilObject::_lookupObjId($item["ref_id"]);
73  $obj_type = ilObject::_lookupType($obj_id);
74  $obj_title = ilObject::_lookupTitle($obj_id);
75 
76  // not nice, to do: general solution
77  if ($obj_type == "mcst") {
79  continue;
80  }
81  }
82 
83  $feed_item = new ilFeedItem();
85  $item["context_obj_type"],
86  $item["title"],
87  (bool) $item["content_is_lang_var"],
88  (int) ($item["agg_ref_id"] ?? 0),
89  $item["aggregation"] ?? []
90  );
91 
92  // path
93  $loc = $this->getContextPath($item["ref_id"]);
94 
95  // title
96  if ($news_set->get("rss_title_format") == "news_obj") {
97  $feed_item->setTitle($this->prepareStr(str_replace("<br />", " ", $title)) .
98  " (" . $this->prepareStr($loc) . " " . $this->prepareStr($obj_title) .
99  ")");
100  } else {
101  $feed_item->setTitle($this->prepareStr($loc) . " " . $this->prepareStr($obj_title) .
102  ": " . $this->prepareStr(str_replace("<br />", " ", $title)));
103  }
104 
105  // description
106  $content = $this->prepareStr(nl2br(
108  $item["context_obj_type"],
109  $item["content"],
110  $item["content_text_is_lang_var"]
111  )
112  ));
113  $feed_item->setDescription($content);
114 
115  // lm page hack, not nice
116  if ($item["context_obj_type"] == "lm" && $item["context_sub_obj_type"] == "pg"
117  && $item["context_sub_obj_id"] > 0) {
118  $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID .
119  "&amp;target=pg_" . $item["context_sub_obj_id"] . "_" . $item["ref_id"]);
120  } elseif ($item["context_obj_type"] == "wiki" && $item["context_sub_obj_type"] == "wpg"
121  && $item["context_sub_obj_id"] > 0) {
122  $wptitle = ilWikiPage::lookupTitle($item["context_sub_obj_id"]);
123  $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID .
124  "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"] . "_" . urlencode($wptitle)); // #14629
125  } elseif ($item["context_obj_type"] == "frm" && $item["context_sub_obj_type"] == "pos"
126  && $item["context_sub_obj_id"] > 0) {
127  // frm hack, not nice
128  $thread_id = ilObjForumAccess::_getThreadForPosting($item["context_sub_obj_id"]);
129  if ($thread_id > 0) {
130  $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID .
131  "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"] . "_" . $thread_id . "_" . $item["context_sub_obj_id"]);
132  } else {
133  $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID .
134  "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"]);
135  }
136  } else {
137  $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID .
138  "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"]);
139  }
140  $feed_item->setAbout($feed_item->getLink() . "&amp;il_about_feed=" . $item["id"]);
141  $feed_item->setDate($item["creation_date"]);
142  $this->addItem($feed_item);
143  }
144  }
145  }
setChannelTitle(string $a_title)
static determineNewsContent(string $a_context_obj_type, string $a_content, bool $a_is_lang_var, ?ilLanguage $lng=null)
Determine new content.
static _lookupRSSPeriod()
addItem(ilFeedItem $a_item)
static _getNewsItemsOfUser(int $a_user_id, bool $a_only_public=false, bool $a_prevent_aggregation=false, int $a_per=0, array &$a_cnt=[], bool $no_auto_generated=false, array $excluded=[], int $a_limit=0)
Get all news items for a user.
static lookupTitle(int $a_page_id, string $lang="-")
static _lookupObjId(int $ref_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupTitle(int $obj_id)
static determineNewsTitle(string $a_context_obj_type, string $a_title, bool $a_content_is_lang_var, int $a_agg_ref_id=0, array $a_aggregation=[], ?ilLanguage $lng=null)
Determine title for news item entry.
const CLIENT_ID
Definition: constants.php:41
global $DIC
Definition: shib_login.php:22
setChannelLink(string $a_link)
static _getThreadForPosting(int $a_pos_id)
prepareStr(string $a_str)
static _lookupFeedHash(int $a_user_id, bool $a_create=false)
Lookup news feed hash for user.
global $ilSetting
Definition: privfeed.php:31
__construct(Container $dic, ilPlugin $plugin)
getContextPath(int $a_ref_id)
static _lookupType(int $id, bool $reference=false)
setChannelAbout(string $a_ab)
+ Here is the call graph for this function:

Field Documentation

◆ $lng

ilLanguage ilUserFeedWriter::$lng
protected

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

◆ $settings

ilSetting ilUserFeedWriter::$settings
protected

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


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