4 include_once(
"Services/News/classes/class.ilNewsForContextBlockGUI.php");
29 $ilBench->start(
"News",
"ilPDNewsBlockGUI_Constructor");
36 $lng->loadLanguageModule(
"news");
37 include_once(
"./Services/News/classes/class.ilNewsItem.php");
42 $this->dynamic =
false;
51 include_once(
"./Services/News/classes/class.ilNewsCache.php");
53 $cres = $this->acache->getEntry($ilUser->getId().
":0");
54 $this->cache_hit =
false;
55 if ($this->acache->getLastAccessStatus() ==
"hit")
57 self::$st_data = unserialize($cres);
58 $this->cache_hit =
true;
63 $this->dynamic =
true;
71 if (empty(self::$st_data))
86 $this->
setTitle($lng->txt(
"news_internal_news"));
87 $this->
setRowTemplate(
"tpl.block_row_news_for_context.html",
"Services/News");
94 $ilAccess->setResults($this->acc_results);
96 $ilBench->stop(
"News",
"ilPDNewsBlockGUI_Constructor");
106 include_once(
"./Services/News/classes/class.ilNewsCache.php");
117 $this->acache->storeEntry($ilUser->getId().
":0",
161 case "changeFeedSettings":
176 $next_class = $ilCtrl->getNextClass();
177 $cmd = $ilCtrl->getCmd(
"getHTML");
182 return $this->
$cmd();
199 $ilBench->start(
"News",
"ilPDNewsBlockGUI_fillDataSection");
201 $ilBench->stop(
"News",
"ilPDNewsBlockGUI_fillDataSection");
206 if (count($this->
getData()) == 0)
222 $this->
setFooterInfo($lng->txt(
"news_block_information"),
true);
225 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
226 $allow_shorter_periods = $news_set->get(
"allow_shorter_periods");
227 $allow_longer_periods = $news_set->get(
"allow_longer_periods");
228 $enable_private_feed = $news_set->get(
"enable_private_feed");
231 include_once(
"./Services/News/classes/class.ilNewsSubscription.php");
234 if ($enable_internal_rss)
237 $ilCtrl->getLinkTarget($this,
"showFeedUrl"),
241 if ($allow_shorter_periods || $allow_longer_periods || $enable_private_feed)
244 $ilCtrl->getLinkTarget($this,
"editSettings"),
245 $lng->txt(
"settings"));
256 case 5: $per_str = sprintf($lng->txt(
"news_period_x_days"), $per);
break;
257 case 7: $per_str = $lng->txt(
"news_period_1_week");
break;
258 case 14: $per_str = sprintf($lng->txt(
"news_period_x_weeks"), 2);
break;
259 case 30: $per_str = $lng->txt(
"news_period_1_month");
break;
260 case 60: $per_str = sprintf($lng->txt(
"news_period_x_months"), 2);
break;
261 case 120: $per_str = sprintf($lng->txt(
"news_period_x_months"), 4);
break;
262 case 180: $per_str = sprintf($lng->txt(
"news_period_x_months"), 6);
break;
263 case 366: $per_str = $lng->txt(
"news_period_1_year");
break;
267 $this->
setTitle($this->
getTitle().
' <span style="font-weight:normal;">- '.$per_str.
"</span>");
277 if ($ilUser->getPref(
"il_feed_js") ==
"n")
296 include_once(
"./Services/News/classes/class.ilNewsItem.php");
298 if ($news_set->get(
"enable_private_feed"))
300 $tpl =
new ilTemplate(
"tpl.show_priv_feed_url.html",
true,
true,
"Services/News");
303 $tpl->setVariable(
"TXT_PRIV_TITLE", $lng->txt(
"news_get_priv_feed_title"));
306 if($ilUser->_getFeedPass(
$_SESSION[
"AccountId"]))
308 $tpl->setVariable(
"TXT_PRIV_INFO", $lng->txt(
"news_get_priv_feed_info"));
309 $tpl->setVariable(
"TXT_PRIV_FEED_URL", $lng->txt(
"news_feed_url"));
310 $tpl->setVariable(
"VAL_PRIV_FEED_URL",
311 str_replace(
"://",
"://" . $ilUser->getLogin() .
":-password-@", ILIAS_HTTP_PATH).
"/privfeed.php?client_id=".rawurlencode(CLIENT_ID).
"&user_id=".$ilUser->getId().
312 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
313 $tpl->setVariable(
"VAL_PRIV_FEED_URL_TXT",
314 str_replace(
"://",
"://" . $ilUser->getLogin() .
":-password-@", ILIAS_HTTP_PATH).
"/privfeed.php?client_id=".rawurlencode(CLIENT_ID).
"&<br />user_id=".$ilUser->getId().
315 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
319 $tpl->setVariable(
"TXT_PRIV_INFO", $lng->txt(
"news_inactive_private_feed_info"));
320 $tpl->setVariable(
"EDIT_SETTINGS_URL", $ilCtrl->getLinkTarget($this,
"editSettings"));
321 $tpl->setVariable(
"EDIT_SETTINGS_TXT", $lng->txt(
"news_edit_news_settings"));
326 $tpl =
new ilTemplate(
"tpl.show_feed_url.html",
true,
true,
"Services/News");
328 $tpl->setVariable(
"TXT_TITLE", $lng->txt(
"news_get_feed_title"));
329 $tpl->setVariable(
"TXT_INFO", $lng->txt(
"news_get_feed_info"));
330 $tpl->setVariable(
"TXT_FEED_URL", $lng->txt(
"news_feed_url"));
331 $tpl->setVariable(
"VAL_FEED_URL",
332 ILIAS_HTTP_PATH.
"/feed.php?client_id=".rawurlencode(CLIENT_ID).
"&user_id=".$ilUser->getId().
333 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
334 $tpl->setVariable(
"VAL_FEED_URL_TXT",
335 ILIAS_HTTP_PATH.
"/feed.php?client_id=".rawurlencode(CLIENT_ID).
"&<br />user_id=".$ilUser->getId().
336 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
338 include_once(
"./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php");
340 $content_block->setContent(
$tpl->get());
341 $content_block->setTitle($lng->txt(
"news_internal_news"));
343 $content_block->addHeaderCommand($ilCtrl->getParentReturn($this),
344 $lng->txt(
"selected_items_back"));
346 return $content_block->getHTML();
353 $a_content_block->addHeaderCommand($ilCtrl->getParentReturn($this),
354 $lng->txt(
"selected_items_back"));
380 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
381 $allow_shorter_periods = $news_set->get(
"allow_shorter_periods");
382 $allow_longer_periods = $news_set->get(
"allow_longer_periods");
383 $enable_private_feed = $news_set->get(
"enable_private_feed");
385 if (!$a_private_form && ($allow_shorter_periods || $allow_longer_periods))
387 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
389 $form->setFormAction($ilCtrl->getFormaction($this));
390 $form->setTitle($lng->txt(
"news_settings"));
393 include_once(
"./Services/News/classes/class.ilNewsItem.php");
397 $form->setTableWidth(
"100%");
400 2 =>
"2 ".$lng->txt(
"days"),
401 3 =>
"3 ".$lng->txt(
"days"),
402 5 =>
"5 ".$lng->txt(
"days"),
403 7 =>
"1 ".$lng->txt(
"week"),
404 14 =>
"2 ".$lng->txt(
"weeks"),
405 30 =>
"1 ".$lng->txt(
"month"),
406 60 =>
"2 ".$lng->txt(
"months"),
407 120 =>
"4 ".$lng->txt(
"months"),
408 180 =>
"6 ".$lng->txt(
"months"),
409 366 =>
"1 ".$lng->txt(
"year"));
412 foreach($per_opts as $k => $opt)
414 if (!$allow_shorter_periods && ($k < $default_per)) $unset[$k] = $k;
415 if (!$allow_longer_periods && ($k > $default_per)) $unset[$k] = $k;
417 foreach($unset as $k)
419 unset($per_opts[$k]);
426 $per_sel->setValue((
int) $per);
427 $form->addItem($per_sel);
436 $form->addCommandButton(
"saveSettings", $lng->txt(
"save"));
437 $form->addCommandButton(
"cancelSettings", $lng->txt(
"cancel"));
439 $returnForm = $form->getHTML();
442 if ($enable_private_feed)
448 $returnForm .= ($returnForm==
"")
449 ? $a_private_form->getHTML()
450 :
"<br>".$a_private_form->getHTML();
460 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
462 $feed_form->setFormAction($ilCtrl->getFormaction($this));
463 $feed_form->setTitle($lng->txt(
"priv_feed_settings"));
466 $feed_form->setTableWidth(
"100%");
468 $enable_private_feed =
new ilCheckboxInputGUI($lng->txt(
"news_enable_private_feed"),
"enable_private_feed");
469 $enable_private_feed->
setChecked($ilUser->_getFeedPass($ilUser->getId()));
470 $feed_form->addItem($enable_private_feed);
475 $enable_private_feed->addSubItem($passwd);
477 $feed_form->addCommandButton(
"changeFeedSettings", $lng->txt(
"save"));
478 $feed_form->addCommandButton(
"cancelSettings", $lng->txt(
"cancel"));
490 $ilCtrl->returnToParent($this);
501 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
507 include_once(
"./Services/News/classes/class.ilNewsCache.php");
509 $cache->deleteEntry($ilUser->getId().
":0");
511 $ilCtrl->returnToParent($this);
522 if($form->checkInput())
525 if (!$form->getInput(
"enable_private_feed"))
527 $ilUser->_setFeedPass($ilUser->getId(),
"");
530 $ilCtrl->redirect($this,
"showFeedUrl");
534 $passwd = $form->getInput(
"desired_password");
535 if (md5($passwd) == $ilUser->getPasswd())
537 $form->getItemByPostVar(
"desired_password")->setAlert($lng->txt(
"passwd_equals_ilpasswd"));
542 $ilUser->_setFeedPass($ilUser->getId(), $passwd);
545 $ilCtrl->redirect($this,
"showFeedUrl");
550 $form->setValuesByPost();