34 $this->prevent_initial_loading =
true;
37 $this->dynamic =
false;
39 $this->
setTitle($this->
lng->txt(
"news_internal_news"));
40 $this->
setRowTemplate(
"tpl.block_row_news_for_context.html",
"components/ILIAS/News");
50 $collection = $this->domain->collection()->getNewsForUser(
52 new NewsCriteria(period: $news_period, only_public:
false),
67 return match(
$DIC->ctrl()->getCmd()) {
68 'showNews',
'showFeedUrl',
'editSettings',
'saveSettings',
'changeFeedSettings' =>
IL_SCREEN_CENTER,
75 $cmd = $this->
ctrl->getCmd();
89 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
90 $allow_shorter_periods = $news_set->get(
"allow_shorter_periods");
91 $allow_longer_periods = $news_set->get(
"allow_longer_periods");
92 $enable_private_feed = $news_set->get(
"enable_private_feed");
94 if ($enable_internal_rss) {
97 $ilCtrl->getLinkTarget($this,
"showFeedUrl"),
102 if ($allow_shorter_periods || $allow_longer_periods || $enable_private_feed) {
104 $ilCtrl->getLinkTarget($this,
"editSettings"),
110 if ($ilUser->getPref(
"il_feed_js") ===
"n") {
126 if ($news_set->get(
"enable_private_feed")) {
127 $tpl =
new ilTemplate(
"tpl.show_priv_feed_url.html",
true,
true,
"components/ILIAS/News");
137 str_replace(
"://",
"://" . $ilUser->getLogin() .
":-password-@", ILIAS_HTTP_PATH) .
"/privfeed.php?client_id=" . rawurlencode(
CLIENT_ID) .
"&user_id=" . $ilUser->getId() .
141 "VAL_PRIV_FEED_URL_TXT",
142 str_replace(
"://",
"://" . $ilUser->getLogin() .
":-password-@", ILIAS_HTTP_PATH) .
"/privfeed.php?client_id=" . rawurlencode(
CLIENT_ID) .
"&<br />user_id=" . $ilUser->getId() .
147 $tpl->
setVariable(
"EDIT_SETTINGS_URL", $ilCtrl->getLinkTarget($this,
"editSettings"));
151 $tpl =
new ilTemplate(
"tpl.show_feed_url.html",
true,
true,
"components/ILIAS/News");
158 ILIAS_HTTP_PATH .
"/feed.php?client_id=" . rawurlencode(
CLIENT_ID) .
"&user_id=" . $ilUser->getId() .
163 ILIAS_HTTP_PATH .
"/feed.php?client_id=" . rawurlencode(
CLIENT_ID) .
"&<br />user_id=" . $ilUser->getId() .
168 $panel = $this->
ui->factory()->panel()->standard(
169 $lng->
txt(
"news_internal_news"),
170 $this->ui->factory()->legacy()->content(
$tpl->
get())
173 return $this->
ui->renderer()->render($panel);
184 $allow_shorter_periods = $news_set->get(
"allow_shorter_periods");
185 $allow_longer_periods = $news_set->get(
"allow_longer_periods");
186 $enable_private_feed = $news_set->get(
"enable_private_feed");
188 if (!$a_private_form && ($allow_shorter_periods || $allow_longer_periods)) {
190 $form->setFormAction($ilCtrl->getFormAction($this));
191 $form->setTitle(
$lng->
txt(
"news_settings"));
196 $form->setTableWidth(
"100%");
203 14 =>
"2 " .
$lng->
txt(
"weeks"),
204 30 =>
"1 " .
$lng->
txt(
"month"),
205 60 =>
"2 " .
$lng->
txt(
"months"),
206 120 =>
"4 " .
$lng->
txt(
"months"),
207 180 =>
"6 " .
$lng->
txt(
"months"),
208 366 =>
"1 " .
$lng->
txt(
"year")
212 foreach ($per_opts as $k => $opt) {
213 if (!$allow_shorter_periods && ($k < $default_per)) {
216 if (!$allow_longer_periods && ($k > $default_per)) {
220 foreach ($unset as $k) {
221 unset($per_opts[$k]);
228 $per_sel->setOptions($per_opts);
229 $per_sel->setValue((
string) $per);
230 $form->addItem($per_sel);
232 $form->addCommandButton(
"saveSettings",
$lng->
txt(
"save"));
233 $form->addCommandButton(
"cancelSettings",
$lng->
txt(
"cancel"));
235 $returnForm = $form->getHTML();
238 if ($enable_private_feed) {
239 if (!$a_private_form) {
242 $returnForm .= ($returnForm ===
"")
243 ? $a_private_form->getHTML()
244 :
"<br>" . $a_private_form->getHTML();
257 $feed_form->setFormAction($ilCtrl->getFormAction($this));
258 $feed_form->setTitle(
$lng->
txt(
"priv_feed_settings"));
260 $feed_form->setTableWidth(
"100%");
264 $feed_form->addItem($enable_private_feed);
267 $passwd->setRequired(
true);
269 $enable_private_feed->addSubItem($passwd);
271 $feed_form->addCommandButton(
"changeFeedSettings",
$lng->
txt(
"save"));
272 $feed_form->addCommandButton(
"cancelSettings",
$lng->
txt(
"cancel"));
287 $this->std_request->getDashboardPeriod(),
292 $this->domain->collection()->invalidateCache($this->
user->getId());
294 $ilCtrl->returnToParent($this);
305 if ($form->checkInput()) {
307 if (!$form->getInput(
"enable_private_feed")) {
308 $ilUser->setFeedPass(
"");
309 $this->main_tpl->setOnScreenMessage(
'success',
$lng->
txt(
"priv_feed_disabled"),
true);
311 $ilCtrl->redirect($this,
"showFeedUrl");
313 $passwd = $form->getInput(
"desired_password");
314 if (LocalUserPasswordManager::getInstance()->verifyPassword($ilUser, $passwd)) {
315 $form->getItemByPostVar(
"desired_password")->setAlert(
$lng->
txt(
"passwd_equals_ilpasswd"));
316 $this->main_tpl->setOnScreenMessage(
'failure',
$lng->
txt(
"form_input_not_valid"));
318 $ilUser->setFeedPass($passwd);
319 $this->main_tpl->setOnScreenMessage(
'success',
$lng->
txt(
"saved_successfully"),
true);
320 $ilCtrl->redirect($this,
"showFeedUrl");
325 $form->setValuesByPost();
setVariable($variable, $value='')
Sets a variable value.
News Criteria DTO for querying news items supports caching, JSON serialization, and validation.
setTitle(string $a_title)
setPresentation(int $type)
addBlockCommand(string $a_href, string $a_text, string $a_onclick="", ?RoundTrip $modal=null)
setRowTemplate(string $a_rowtemplatename, string $a_rowtemplatedir="")
Set Row Template Name.
static _write(string $a_type, string $a_setting, string $a_value, int $a_user=0, int $a_block_id=0)
Write setting to database.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
BlockGUI class for block NewsForContext.
editSettings()
Show settings screen.
NewsCollection $collection
handleView()
Handles show/hide notification view and removes notifications if hidden.
initData(NewsCollection $collection)
static _lookupUserPDPeriod(int $a_user_id)
static _lookupDefaultPDPeriod()
static _lookupFeedHash(int $a_user_id, bool $a_create=false)
static _getFeedPass(int $a_user_id)
BlockGUI class for block NewsForContext.
editSettings(?ilPropertyFormGUI $a_private_form=null)
static string $block_type
initPrivateSettingsForm()
static getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo()
special template class to simplify handling of ITX/PEAR
get(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
Returns a block with all replacements done.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc