24 include_once(
"Services/News/classes/class.ilNewsForContextBlockGUI.php");
48 $ilBench->start(
"News",
"ilPDNewsBlockGUI_Constructor");
55 $lng->loadLanguageModule(
"news");
56 include_once(
"./Services/News/classes/class.ilNewsItem.php");
61 $this->dynamic =
false;
64 $this->acc_results = $ilAccess->getResults();
67 $this->acc_cache_hit = $ilAccess->readCache(
68 ((
int) $news_set->get(
"acc_cache_mins")) * 60);
70 if ($this->
getDynamic() && !$this->acc_cache_hit)
72 $this->dynamic =
true;
80 if (empty(self::$st_data))
95 $this->
setTitle($lng->txt(
"news_internal_news"));
96 $this->
setRowTemplate(
"tpl.block_row_news_for_context.html",
"Services/News");
103 $ilAccess->setResults($this->acc_results);
105 $ilBench->stop(
"News",
"ilPDNewsBlockGUI_Constructor");
113 global $ilUser, $ilAccess;
118 if (!$this->acc_cache_hit)
120 $ilAccess->storeCache();
173 $next_class = $ilCtrl->getNextClass();
174 $cmd = $ilCtrl->getCmd(
"getHTML");
179 return $this->
$cmd();
196 $ilBench->start(
"News",
"ilPDNewsBlockGUI_fillDataSection");
198 $ilBench->stop(
"News",
"ilPDNewsBlockGUI_fillDataSection");
203 if (count($this->
getData()) == 0)
219 $this->
setFooterInfo($lng->txt(
"news_block_information"),
true);
222 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
223 $allow_shorter_periods = $news_set->get(
"allow_shorter_periods");
224 $allow_longer_periods = $news_set->get(
"allow_longer_periods");
225 $enable_private_feed = $news_set->get(
"enable_private_feed");
228 include_once(
"./Services/News/classes/class.ilNewsSubscription.php");
231 if ($enable_internal_rss)
234 $ilCtrl->getLinkTarget($this,
"showFeedUrl"),
238 if ($allow_shorter_periods || $allow_longer_periods || $enable_private_feed)
241 $ilCtrl->getLinkTarget($this,
"editSettings"),
242 $lng->txt(
"settings"));
253 case 5: $per_str = sprintf($lng->txt(
"news_period_x_days"), $per);
break;
254 case 7: $per_str = $lng->txt(
"news_period_1_week");
break;
255 case 14: $per_str = sprintf($lng->txt(
"news_period_x_weeks"), 2);
break;
256 case 30: $per_str = $lng->txt(
"news_period_1_month");
break;
257 case 60: $per_str = sprintf($lng->txt(
"news_period_x_months"), 2);
break;
258 case 120: $per_str = sprintf($lng->txt(
"news_period_x_months"), 4);
break;
259 case 180: $per_str = sprintf($lng->txt(
"news_period_x_months"), 6);
break;
260 case 366: $per_str = $lng->txt(
"news_period_1_year");
break;
264 $this->
setTitle($this->
getTitle().
' <span style="font-weight:normal;">- '.$per_str.
"</span>");
274 if ($ilUser->getPref(
"il_feed_js") ==
"n")
293 include_once(
"./Services/News/classes/class.ilNewsItem.php");
295 if ($news_set->get(
"enable_private_feed") && $ilUser->_getFeedPass(
$_SESSION[
"AccountId"]))
297 $tpl =
new ilTemplate(
"tpl.show_priv_feed_url.html",
true,
true,
"Services/News");
300 $tpl->setVariable(
"TXT_PRIV_TITLE", $lng->txt(
"news_get_priv_feed_title"));
301 $tpl->setVariable(
"TXT_PRIV_INFO", $lng->txt(
"news_get_priv_feed_info"));
302 $tpl->setVariable(
"TXT_PRIV_FEED_URL", $lng->txt(
"news_feed_url"));
303 $tpl->setVariable(
"VAL_PRIV_FEED_URL",
304 str_replace(
"://",
"://" . $ilUser->getLogin() .
":-password-@", ILIAS_HTTP_PATH).
"/privfeed.php?client_id=".rawurlencode(CLIENT_ID).
"&user_id=".$ilUser->getId().
305 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
306 $tpl->setVariable(
"VAL_PRIV_FEED_URL_TXT",
307 str_replace(
"://",
"://" . $ilUser->getLogin() .
":-password-@", ILIAS_HTTP_PATH).
"/privfeed.php?client_id=".rawurlencode(CLIENT_ID).
"&<br />user_id=".$ilUser->getId().
308 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
312 $tpl =
new ilTemplate(
"tpl.show_feed_url.html",
true,
true,
"Services/News");
314 $tpl->setVariable(
"TXT_TITLE", $lng->txt(
"news_get_feed_title"));
315 $tpl->setVariable(
"TXT_INFO", $lng->txt(
"news_get_feed_info"));
316 $tpl->setVariable(
"TXT_FEED_URL", $lng->txt(
"news_feed_url"));
317 $tpl->setVariable(
"VAL_FEED_URL",
318 ILIAS_HTTP_PATH.
"/feed.php?client_id=".rawurlencode(CLIENT_ID).
"&user_id=".$ilUser->getId().
319 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
320 $tpl->setVariable(
"VAL_FEED_URL_TXT",
321 ILIAS_HTTP_PATH.
"/feed.php?client_id=".rawurlencode(CLIENT_ID).
"&<br />user_id=".$ilUser->getId().
322 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
324 include_once(
"./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php");
326 $content_block->setContent(
$tpl->get());
327 $content_block->setTitle($lng->txt(
"news_internal_news"));
329 $content_block->addHeaderCommand($ilCtrl->getParentReturn($this),
330 $lng->txt(
"selected_items_back"));
332 return $content_block->getHTML();
339 $a_content_block->addHeaderCommand($ilCtrl->getParentReturn($this),
340 $lng->txt(
"selected_items_back"));
366 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
367 $allow_shorter_periods = $news_set->get(
"allow_shorter_periods");
368 $allow_longer_periods = $news_set->get(
"allow_longer_periods");
369 $enable_private_feed = $news_set->get(
"enable_private_feed");
371 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
373 if ($allow_shorter_periods || $allow_longer_periods )
376 include_once(
"./Services/News/classes/class.ilNewsItem.php");
380 $form->setTitle($lng->txt(
"news_settings"));
383 $form->setTableWidth(
"100%");
386 2 =>
"2 ".$lng->txt(
"days"),
387 3 =>
"3 ".$lng->txt(
"days"),
388 5 =>
"5 ".$lng->txt(
"days"),
389 7 =>
"1 ".$lng->txt(
"week"),
390 14 =>
"2 ".$lng->txt(
"weeks"),
391 30 =>
"1 ".$lng->txt(
"month"),
392 60 =>
"2 ".$lng->txt(
"months"),
393 120 =>
"4 ".$lng->txt(
"months"),
394 180 =>
"6 ".$lng->txt(
"months"),
395 366 =>
"1 ".$lng->txt(
"year"));
398 foreach($per_opts as $k => $opt)
400 if (!$allow_shorter_periods && ($k < $default_per)) $unset[$k] = $k;
401 if (!$allow_longer_periods && ($k > $default_per)) $unset[$k] = $k;
403 foreach($unset as $k)
405 unset($per_opts[$k]);
412 $per_sel->setValue((
int) $per);
413 $form->addItem($per_sel);
422 $form->addCommandButton(
"saveSettings", $lng->txt(
"save"));
423 $form->addCommandButton(
"cancelSettings", $lng->txt(
"cancel"));
424 $form->setFormAction($ilCtrl->getFormaction($this));
426 $returnForm = $form->getHTML();
429 if ($enable_private_feed)
432 $feed_form->setTitle($lng->txt(
"priv_feed_settings"));
435 $feed_form->setTableWidth(
"100%");
437 $enable_private_feed =
new ilCheckboxInputGUI($lng->txt(
"news_enable_private_feed"),
"enable_private_feed");
440 $retype_pass =
new ilTextInputGUI($lng->txt(
"retype_password"),
"retype_password");
441 $desired_pass =
new ilTextInputGUI($lng->txt(
"desired_password"),
"desired_password");
446 $enable_private_feed->setChecked(
true);
451 $retype_pass->setInputType(
"password");
453 $feed_form->addItem($enable_private_feed);
454 $feed_form->addItem($desired_pass);
455 $feed_form->addItem($retype_pass);
457 $feed_form->addCommandButton(
"changeFeedSettings", $lng->txt(
"save"));
458 $feed_form->addCommandButton(
"cancelSettings", $lng->txt(
"cancel"));
459 $feed_form->setFormAction($ilCtrl->getFormaction($this));
461 $returnForm .= ($returnForm==
"")?$feed_form->getHTML():
"<br>".$feed_form->getHTML();
474 $ilCtrl->returnToParent($this);
485 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
488 $_POST[
"news_pd_period"],
491 $ilCtrl->returnToParent($this);
502 if (empty($_POST[
"enable_private_feed"]))
505 $ilUser->_setFeedPass(
$_SESSION[
"AccountId"],
"");
506 $ilCtrl->returnToParent($this);
511 if ($_POST[
"desired_password"] != $_POST[
"retype_password"])
514 $ilCtrl->redirectByClass(
"ilPDNewsBlockGUI",
"editSettings");
520 $ilCtrl->redirectByClass(
"ilPDNewsBlockGUI",
"editSettings");
523 else if (md5($_POST[
"desired_password"]) == $ilUser->getPasswd())
526 $ilCtrl->redirectByClass(
"ilPDNewsBlockGUI",
"editSettings");
528 else if ($_POST[
"desired_password"] !=
"")
531 $ilUser->_setFeedPass(
$_SESSION[
"AccountId"],$_POST[
"desired_password"]);
532 $ilCtrl->returnToParent($this);