4 include_once(
"Services/News/classes/class.ilNewsForContextBlockGUI.php");
28 $ilBench->start(
"News",
"ilPDNewsBlockGUI_Constructor");
35 $lng->loadLanguageModule(
"news");
36 include_once(
"./Services/News/classes/class.ilNewsItem.php");
41 $this->dynamic =
false;
50 include_once(
"./Services/News/classes/class.ilNewsCache.php");
52 $cres = $this->acache->getEntry($ilUser->getId().
":0");
53 $this->cache_hit =
false;
54 if ($this->acache->getLastAccessStatus() ==
"hit")
56 self::$st_data = unserialize($cres);
57 $this->cache_hit =
true;
62 $this->dynamic =
true;
70 if (empty(self::$st_data))
85 $this->
setTitle($lng->txt(
"news_internal_news"));
86 $this->
setRowTemplate(
"tpl.block_row_news_for_context.html",
"Services/News");
93 $ilAccess->setResults($this->acc_results);
95 $ilBench->stop(
"News",
"ilPDNewsBlockGUI_Constructor");
103 global $ilUser, $ilAccess;
105 include_once(
"./Services/News/classes/class.ilNewsCache.php");
116 $this->acache->storeEntry($ilUser->getId().
":0",
170 $next_class = $ilCtrl->getNextClass();
171 $cmd = $ilCtrl->getCmd(
"getHTML");
176 return $this->
$cmd();
193 $ilBench->start(
"News",
"ilPDNewsBlockGUI_fillDataSection");
195 $ilBench->stop(
"News",
"ilPDNewsBlockGUI_fillDataSection");
200 if (count($this->
getData()) == 0)
216 $this->
setFooterInfo($lng->txt(
"news_block_information"),
true);
219 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
220 $allow_shorter_periods = $news_set->get(
"allow_shorter_periods");
221 $allow_longer_periods = $news_set->get(
"allow_longer_periods");
222 $enable_private_feed = $news_set->get(
"enable_private_feed");
225 include_once(
"./Services/News/classes/class.ilNewsSubscription.php");
228 if ($enable_internal_rss)
231 $ilCtrl->getLinkTarget($this,
"showFeedUrl"),
235 if ($allow_shorter_periods || $allow_longer_periods || $enable_private_feed)
238 $ilCtrl->getLinkTarget($this,
"editSettings"),
239 $lng->txt(
"settings"));
250 case 5: $per_str = sprintf($lng->txt(
"news_period_x_days"), $per);
break;
251 case 7: $per_str = $lng->txt(
"news_period_1_week");
break;
252 case 14: $per_str = sprintf($lng->txt(
"news_period_x_weeks"), 2);
break;
253 case 30: $per_str = $lng->txt(
"news_period_1_month");
break;
254 case 60: $per_str = sprintf($lng->txt(
"news_period_x_months"), 2);
break;
255 case 120: $per_str = sprintf($lng->txt(
"news_period_x_months"), 4);
break;
256 case 180: $per_str = sprintf($lng->txt(
"news_period_x_months"), 6);
break;
257 case 366: $per_str = $lng->txt(
"news_period_1_year");
break;
261 $this->
setTitle($this->
getTitle().
' <span style="font-weight:normal;">- '.$per_str.
"</span>");
271 if ($ilUser->getPref(
"il_feed_js") ==
"n")
290 include_once(
"./Services/News/classes/class.ilNewsItem.php");
292 if ($news_set->get(
"enable_private_feed") && $ilUser->_getFeedPass(
$_SESSION[
"AccountId"]))
294 $tpl =
new ilTemplate(
"tpl.show_priv_feed_url.html",
true,
true,
"Services/News");
297 $tpl->setVariable(
"TXT_PRIV_TITLE", $lng->txt(
"news_get_priv_feed_title"));
298 $tpl->setVariable(
"TXT_PRIV_INFO", $lng->txt(
"news_get_priv_feed_info"));
299 $tpl->setVariable(
"TXT_PRIV_FEED_URL", $lng->txt(
"news_feed_url"));
300 $tpl->setVariable(
"VAL_PRIV_FEED_URL",
301 str_replace(
"://",
"://" . $ilUser->getLogin() .
":-password-@", ILIAS_HTTP_PATH).
"/privfeed.php?client_id=".rawurlencode(CLIENT_ID).
"&user_id=".$ilUser->getId().
302 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
303 $tpl->setVariable(
"VAL_PRIV_FEED_URL_TXT",
304 str_replace(
"://",
"://" . $ilUser->getLogin() .
":-password-@", ILIAS_HTTP_PATH).
"/privfeed.php?client_id=".rawurlencode(CLIENT_ID).
"&<br />user_id=".$ilUser->getId().
305 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
309 $tpl =
new ilTemplate(
"tpl.show_feed_url.html",
true,
true,
"Services/News");
311 $tpl->setVariable(
"TXT_TITLE", $lng->txt(
"news_get_feed_title"));
312 $tpl->setVariable(
"TXT_INFO", $lng->txt(
"news_get_feed_info"));
313 $tpl->setVariable(
"TXT_FEED_URL", $lng->txt(
"news_feed_url"));
314 $tpl->setVariable(
"VAL_FEED_URL",
315 ILIAS_HTTP_PATH.
"/feed.php?client_id=".rawurlencode(CLIENT_ID).
"&user_id=".$ilUser->getId().
316 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
317 $tpl->setVariable(
"VAL_FEED_URL_TXT",
318 ILIAS_HTTP_PATH.
"/feed.php?client_id=".rawurlencode(CLIENT_ID).
"&<br />user_id=".$ilUser->getId().
319 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
321 include_once(
"./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php");
323 $content_block->setContent(
$tpl->get());
324 $content_block->setTitle($lng->txt(
"news_internal_news"));
326 $content_block->addHeaderCommand($ilCtrl->getParentReturn($this),
327 $lng->txt(
"selected_items_back"));
329 return $content_block->getHTML();
336 $a_content_block->addHeaderCommand($ilCtrl->getParentReturn($this),
337 $lng->txt(
"selected_items_back"));
363 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
364 $allow_shorter_periods = $news_set->get(
"allow_shorter_periods");
365 $allow_longer_periods = $news_set->get(
"allow_longer_periods");
366 $enable_private_feed = $news_set->get(
"enable_private_feed");
368 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
370 if ($allow_shorter_periods || $allow_longer_periods )
373 include_once(
"./Services/News/classes/class.ilNewsItem.php");
377 $form->setTitle($lng->txt(
"news_settings"));
380 $form->setTableWidth(
"100%");
383 2 =>
"2 ".$lng->txt(
"days"),
384 3 =>
"3 ".$lng->txt(
"days"),
385 5 =>
"5 ".$lng->txt(
"days"),
386 7 =>
"1 ".$lng->txt(
"week"),
387 14 =>
"2 ".$lng->txt(
"weeks"),
388 30 =>
"1 ".$lng->txt(
"month"),
389 60 =>
"2 ".$lng->txt(
"months"),
390 120 =>
"4 ".$lng->txt(
"months"),
391 180 =>
"6 ".$lng->txt(
"months"),
392 366 =>
"1 ".$lng->txt(
"year"));
395 foreach($per_opts as $k => $opt)
397 if (!$allow_shorter_periods && ($k < $default_per)) $unset[$k] = $k;
398 if (!$allow_longer_periods && ($k > $default_per)) $unset[$k] = $k;
400 foreach($unset as $k)
402 unset($per_opts[$k]);
409 $per_sel->setValue((
int) $per);
410 $form->addItem($per_sel);
419 $form->addCommandButton(
"saveSettings", $lng->txt(
"save"));
420 $form->addCommandButton(
"cancelSettings", $lng->txt(
"cancel"));
421 $form->setFormAction($ilCtrl->getFormaction($this));
423 $returnForm = $form->getHTML();
426 if ($enable_private_feed)
429 $feed_form->setTitle($lng->txt(
"priv_feed_settings"));
432 $feed_form->setTableWidth(
"100%");
434 $enable_private_feed =
new ilCheckboxInputGUI($lng->txt(
"news_enable_private_feed"),
"enable_private_feed");
437 $retype_pass =
new ilTextInputGUI($lng->txt(
"retype_password"),
"retype_password");
438 $desired_pass =
new ilTextInputGUI($lng->txt(
"desired_password"),
"desired_password");
443 $enable_private_feed->setChecked(
true);
448 $retype_pass->setInputType(
"password");
450 $feed_form->addItem($enable_private_feed);
451 $feed_form->addItem($desired_pass);
452 $feed_form->addItem($retype_pass);
454 $feed_form->addCommandButton(
"changeFeedSettings", $lng->txt(
"save"));
455 $feed_form->addCommandButton(
"cancelSettings", $lng->txt(
"cancel"));
456 $feed_form->setFormAction($ilCtrl->getFormaction($this));
458 $returnForm .= ($returnForm==
"")?$feed_form->getHTML():
"<br>".$feed_form->getHTML();
471 $ilCtrl->returnToParent($this);
482 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
488 include_once(
"./Services/News/classes/class.ilNewsCache.php");
490 $cache->deleteEntry($ilUser->getId().
":0");
492 $ilCtrl->returnToParent($this);
503 if (empty(
$_POST[
"enable_private_feed"]))
506 $ilUser->_setFeedPass(
$_SESSION[
"AccountId"],
"");
507 $ilCtrl->returnToParent($this);
512 if (
$_POST[
"desired_password"] !=
$_POST[
"retype_password"])
515 $ilCtrl->redirectByClass(
"ilPDNewsBlockGUI",
"editSettings");
521 $ilCtrl->redirectByClass(
"ilPDNewsBlockGUI",
"editSettings");
524 else if (md5(
$_POST[
"desired_password"]) == $ilUser->getPasswd())
527 $ilCtrl->redirectByClass(
"ilPDNewsBlockGUI",
"editSettings");
529 else if (
$_POST[
"desired_password"] !=
"")
532 $ilUser->_setFeedPass(
$_SESSION[
"AccountId"],
$_POST[
"desired_password"]);
533 $ilCtrl->returnToParent($this);