4 include_once(
"Services/News/classes/class.ilNewsForContextBlockGUI.php");
29 $ilBench->start(
"News",
"ilPDNewsBlockGUI_Constructor");
34 $lng->loadLanguageModule(
"news");
35 include_once(
"./Services/News/classes/class.ilNewsItem.php");
40 $this->dynamic =
false;
49 include_once(
"./Services/News/classes/class.ilNewsCache.php");
51 $cres = $this->acache->getEntry($ilUser->getId().
":0");
52 $this->cache_hit =
false;
53 if ($this->acache->getLastAccessStatus() ==
"hit")
55 self::$st_data = unserialize($cres);
56 $this->cache_hit =
true;
61 $this->dynamic =
true;
69 if (empty(self::$st_data))
84 $this->
setTitle($lng->txt(
"news_internal_news"));
85 $this->
setRowTemplate(
"tpl.block_row_news_for_context.html",
"Services/News");
92 $ilAccess->setResults($this->acc_results);
94 $ilBench->stop(
"News",
"ilPDNewsBlockGUI_Constructor");
104 include_once(
"./Services/News/classes/class.ilNewsCache.php");
115 $this->acache->storeEntry($ilUser->getId().
":0",
159 case "changeFeedSettings":
174 $next_class = $ilCtrl->getNextClass();
175 $cmd = $ilCtrl->getCmd(
"getHTML");
180 return $this->
$cmd();
197 $ilBench->start(
"News",
"ilPDNewsBlockGUI_fillDataSection");
199 $ilBench->stop(
"News",
"ilPDNewsBlockGUI_fillDataSection");
204 if (count($this->
getData()) == 0)
220 $this->
setFooterInfo($lng->txt(
"news_block_information"),
true);
223 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
224 $allow_shorter_periods = $news_set->get(
"allow_shorter_periods");
225 $allow_longer_periods = $news_set->get(
"allow_longer_periods");
226 $enable_private_feed = $news_set->get(
"enable_private_feed");
229 include_once(
"./Services/News/classes/class.ilNewsSubscription.php");
232 if ($enable_internal_rss)
234 include_once(
"./Services/News/classes/class.ilRSSButtonGUI.php");
236 $ilCtrl->getLinkTarget($this,
"showFeedUrl"),
240 if ($allow_shorter_periods || $allow_longer_periods || $enable_private_feed)
243 $ilCtrl->getLinkTarget($this,
"editSettings"),
244 $lng->txt(
"settings"));
255 case 5: $per_str = sprintf($lng->txt(
"news_period_x_days"), $per);
break;
256 case 7: $per_str = $lng->txt(
"news_period_1_week");
break;
257 case 14: $per_str = sprintf($lng->txt(
"news_period_x_weeks"), 2);
break;
258 case 30: $per_str = $lng->txt(
"news_period_1_month");
break;
259 case 60: $per_str = sprintf($lng->txt(
"news_period_x_months"), 2);
break;
260 case 120: $per_str = sprintf($lng->txt(
"news_period_x_months"), 4);
break;
261 case 180: $per_str = sprintf($lng->txt(
"news_period_x_months"), 6);
break;
262 case 366: $per_str = $lng->txt(
"news_period_1_year");
break;
266 $this->
setTitle($this->
getTitle().
' <span style="font-weight:normal;">- '.$per_str.
"</span>");
276 if ($ilUser->getPref(
"il_feed_js") ==
"n")
295 include_once(
"./Services/News/classes/class.ilNewsItem.php");
297 if ($news_set->get(
"enable_private_feed"))
299 $tpl =
new ilTemplate(
"tpl.show_priv_feed_url.html",
true,
true,
"Services/News");
301 $tpl->setVariable(
"TXT_PRIV_TITLE", $lng->txt(
"news_get_priv_feed_title"));
304 if($ilUser->_getFeedPass(
$_SESSION[
"AccountId"]))
306 $tpl->setVariable(
"TXT_PRIV_INFO", $lng->txt(
"news_get_priv_feed_info"));
307 $tpl->setVariable(
"TXT_PRIV_FEED_URL", $lng->txt(
"news_feed_url"));
308 $tpl->setVariable(
"VAL_PRIV_FEED_URL",
309 str_replace(
"://",
"://" . $ilUser->getLogin() .
":-password-@", ILIAS_HTTP_PATH).
"/privfeed.php?client_id=".rawurlencode(CLIENT_ID).
"&user_id=".$ilUser->getId().
310 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
311 $tpl->setVariable(
"VAL_PRIV_FEED_URL_TXT",
312 str_replace(
"://",
"://" . $ilUser->getLogin() .
":-password-@", ILIAS_HTTP_PATH).
"/privfeed.php?client_id=".rawurlencode(CLIENT_ID).
"&<br />user_id=".$ilUser->getId().
313 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
317 $tpl->setVariable(
"TXT_PRIV_INFO", $lng->txt(
"news_inactive_private_feed_info"));
318 $tpl->setVariable(
"EDIT_SETTINGS_URL", $ilCtrl->getLinkTarget($this,
"editSettings"));
319 $tpl->setVariable(
"EDIT_SETTINGS_TXT", $lng->txt(
"news_edit_news_settings"));
324 $tpl =
new ilTemplate(
"tpl.show_feed_url.html",
true,
true,
"Services/News");
326 $tpl->setVariable(
"TXT_TITLE", $lng->txt(
"news_get_feed_title"));
327 $tpl->setVariable(
"TXT_INFO", $lng->txt(
"news_get_feed_info"));
328 $tpl->setVariable(
"TXT_FEED_URL", $lng->txt(
"news_feed_url"));
329 $tpl->setVariable(
"VAL_FEED_URL",
330 ILIAS_HTTP_PATH.
"/feed.php?client_id=".rawurlencode(CLIENT_ID).
"&user_id=".$ilUser->getId().
331 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
332 $tpl->setVariable(
"VAL_FEED_URL_TXT",
333 ILIAS_HTTP_PATH.
"/feed.php?client_id=".rawurlencode(CLIENT_ID).
"&<br />user_id=".$ilUser->getId().
334 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
336 include_once(
"./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php");
338 $content_block->setContent(
$tpl->get());
339 $content_block->setTitle($lng->txt(
"news_internal_news"));
340 $content_block->addHeaderCommand($ilCtrl->getParentReturn($this),
341 $lng->txt(
"selected_items_back"));
343 return $content_block->getHTML();
350 $a_content_block->addHeaderCommand($ilCtrl->getParentReturn($this),
351 $lng->txt(
"selected_items_back"));
377 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
378 $allow_shorter_periods = $news_set->get(
"allow_shorter_periods");
379 $allow_longer_periods = $news_set->get(
"allow_longer_periods");
380 $enable_private_feed = $news_set->get(
"enable_private_feed");
382 if (!$a_private_form && ($allow_shorter_periods || $allow_longer_periods))
384 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
386 $form->setFormAction($ilCtrl->getFormaction($this));
387 $form->setTitle($lng->txt(
"news_settings"));
389 include_once(
"./Services/News/classes/class.ilNewsItem.php");
393 $form->setTableWidth(
"100%");
396 2 =>
"2 ".$lng->txt(
"days"),
397 3 =>
"3 ".$lng->txt(
"days"),
398 5 =>
"5 ".$lng->txt(
"days"),
399 7 =>
"1 ".$lng->txt(
"week"),
400 14 =>
"2 ".$lng->txt(
"weeks"),
401 30 =>
"1 ".$lng->txt(
"month"),
402 60 =>
"2 ".$lng->txt(
"months"),
403 120 =>
"4 ".$lng->txt(
"months"),
404 180 =>
"6 ".$lng->txt(
"months"),
405 366 =>
"1 ".$lng->txt(
"year"));
408 foreach($per_opts as $k => $opt)
410 if (!$allow_shorter_periods && ($k < $default_per)) $unset[$k] = $k;
411 if (!$allow_longer_periods && ($k > $default_per)) $unset[$k] = $k;
413 foreach($unset as $k)
415 unset($per_opts[$k]);
422 $per_sel->setValue((
int) $per);
423 $form->addItem($per_sel);
432 $form->addCommandButton(
"saveSettings", $lng->txt(
"save"));
433 $form->addCommandButton(
"cancelSettings", $lng->txt(
"cancel"));
435 $returnForm = $form->getHTML();
438 if ($enable_private_feed)
444 $returnForm .= ($returnForm==
"")
445 ? $a_private_form->getHTML()
446 :
"<br>".$a_private_form->getHTML();
456 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
458 $feed_form->setFormAction($ilCtrl->getFormaction($this));
459 $feed_form->setTitle($lng->txt(
"priv_feed_settings"));
461 $feed_form->setTableWidth(
"100%");
463 $enable_private_feed =
new ilCheckboxInputGUI($lng->txt(
"news_enable_private_feed"),
"enable_private_feed");
464 $enable_private_feed->
setChecked($ilUser->_getFeedPass($ilUser->getId()));
465 $feed_form->addItem($enable_private_feed);
470 $enable_private_feed->addSubItem($passwd);
472 $feed_form->addCommandButton(
"changeFeedSettings", $lng->txt(
"save"));
473 $feed_form->addCommandButton(
"cancelSettings", $lng->txt(
"cancel"));
485 $ilCtrl->returnToParent($this);
496 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
502 include_once(
"./Services/News/classes/class.ilNewsCache.php");
504 $cache->deleteEntry($ilUser->getId().
":0");
506 $ilCtrl->returnToParent($this);
517 if($form->checkInput())
520 if (!$form->getInput(
"enable_private_feed"))
522 $ilUser->_setFeedPass($ilUser->getId(),
"");
525 $ilCtrl->redirect($this,
"showFeedUrl");
529 $passwd = $form->getInput(
"desired_password");
530 require_once
'Services/User/classes/class.ilUserPasswordManager.php';
531 if(ilUserPasswordManager::getInstance()->verifyPassword($ilUser, $passwd))
533 $form->getItemByPostVar(
"desired_password")->setAlert($lng->txt(
"passwd_equals_ilpasswd"));
538 $ilUser->_setFeedPass($ilUser->getId(), $passwd);
541 $ilCtrl->redirect($this,
"showFeedUrl");
546 $form->setValuesByPost();