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 $cmd =
$DIC->ctrl()->getCmd();
73 case "changeFeedSettings":
83 $cmd = $this->
ctrl->getCmd();
97 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
98 $allow_shorter_periods = $news_set->get(
"allow_shorter_periods");
99 $allow_longer_periods = $news_set->get(
"allow_longer_periods");
100 $enable_private_feed = $news_set->get(
"enable_private_feed");
102 if ($enable_internal_rss) {
105 $ilCtrl->getLinkTarget($this,
"showFeedUrl"),
110 if ($allow_shorter_periods || $allow_longer_periods || $enable_private_feed) {
112 $ilCtrl->getLinkTarget($this,
"editSettings"),
118 if ($ilUser->getPref(
"il_feed_js") ===
"n") {
134 if ($news_set->get(
"enable_private_feed")) {
135 $tpl =
new ilTemplate(
"tpl.show_priv_feed_url.html",
true,
true,
"components/ILIAS/News");
145 str_replace(
"://",
"://" . $ilUser->getLogin() .
":-password-@", ILIAS_HTTP_PATH) .
"/privfeed.php?client_id=" . rawurlencode(
CLIENT_ID) .
"&user_id=" . $ilUser->getId() .
149 "VAL_PRIV_FEED_URL_TXT",
150 str_replace(
"://",
"://" . $ilUser->getLogin() .
":-password-@", ILIAS_HTTP_PATH) .
"/privfeed.php?client_id=" . rawurlencode(
CLIENT_ID) .
"&<br />user_id=" . $ilUser->getId() .
155 $tpl->
setVariable(
"EDIT_SETTINGS_URL", $ilCtrl->getLinkTarget($this,
"editSettings"));
159 $tpl =
new ilTemplate(
"tpl.show_feed_url.html",
true,
true,
"components/ILIAS/News");
166 ILIAS_HTTP_PATH .
"/feed.php?client_id=" . rawurlencode(
CLIENT_ID) .
"&user_id=" . $ilUser->getId() .
171 ILIAS_HTTP_PATH .
"/feed.php?client_id=" . rawurlencode(
CLIENT_ID) .
"&<br />user_id=" . $ilUser->getId() .
176 $panel = $this->
ui->factory()->panel()->standard(
177 $lng->
txt(
"news_internal_news"),
178 $this->ui->factory()->legacy()->content(
$tpl->
get())
181 return $this->
ui->renderer()->render($panel);
192 $allow_shorter_periods = $news_set->get(
"allow_shorter_periods");
193 $allow_longer_periods = $news_set->get(
"allow_longer_periods");
194 $enable_private_feed = $news_set->get(
"enable_private_feed");
196 if (!$a_private_form && ($allow_shorter_periods || $allow_longer_periods)) {
198 $form->setFormAction($ilCtrl->getFormAction($this));
199 $form->setTitle(
$lng->
txt(
"news_settings"));
204 $form->setTableWidth(
"100%");
211 14 =>
"2 " .
$lng->
txt(
"weeks"),
212 30 =>
"1 " .
$lng->
txt(
"month"),
213 60 =>
"2 " .
$lng->
txt(
"months"),
214 120 =>
"4 " .
$lng->
txt(
"months"),
215 180 =>
"6 " .
$lng->
txt(
"months"),
216 366 =>
"1 " .
$lng->
txt(
"year")
220 foreach ($per_opts as $k => $opt) {
221 if (!$allow_shorter_periods && ($k < $default_per)) {
224 if (!$allow_longer_periods && ($k > $default_per)) {
228 foreach ($unset as $k) {
229 unset($per_opts[$k]);
236 $per_sel->setOptions($per_opts);
237 $per_sel->setValue((
string) $per);
238 $form->addItem($per_sel);
240 $form->addCommandButton(
"saveSettings",
$lng->
txt(
"save"));
241 $form->addCommandButton(
"cancelSettings",
$lng->
txt(
"cancel"));
243 $returnForm = $form->getHTML();
246 if ($enable_private_feed) {
247 if (!$a_private_form) {
250 $returnForm .= ($returnForm ===
"")
251 ? $a_private_form->getHTML()
252 :
"<br>" . $a_private_form->getHTML();
265 $feed_form->setFormAction($ilCtrl->getFormAction($this));
266 $feed_form->setTitle(
$lng->
txt(
"priv_feed_settings"));
268 $feed_form->setTableWidth(
"100%");
272 $feed_form->addItem($enable_private_feed);
275 $passwd->setRequired(
true);
277 $enable_private_feed->addSubItem($passwd);
279 $feed_form->addCommandButton(
"changeFeedSettings",
$lng->
txt(
"save"));
280 $feed_form->addCommandButton(
"cancelSettings",
$lng->
txt(
"cancel"));
295 $this->std_request->getDashboardPeriod(),
300 $this->domain->collection()->invalidateCache($this->
user->getId());
302 $ilCtrl->returnToParent($this);
313 if ($form->checkInput()) {
315 if (!$form->getInput(
"enable_private_feed")) {
316 $ilUser->setFeedPass(
"");
317 $this->main_tpl->setOnScreenMessage(
'success',
$lng->
txt(
"priv_feed_disabled"),
true);
319 $ilCtrl->redirect($this,
"showFeedUrl");
321 $passwd = $form->getInput(
"desired_password");
322 if (LocalUserPasswordManager::getInstance()->verifyPassword($ilUser, $passwd)) {
323 $form->getItemByPostVar(
"desired_password")->setAlert(
$lng->
txt(
"passwd_equals_ilpasswd"));
324 $this->main_tpl->setOnScreenMessage(
'failure',
$lng->
txt(
"form_input_not_valid"));
326 $ilUser->setFeedPass($passwd);
327 $this->main_tpl->setOnScreenMessage(
'success',
$lng->
txt(
"saved_successfully"),
true);
328 $ilCtrl->redirect($this,
"showFeedUrl");
333 $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