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");
104 global $ilUser, $ilAccess;
106 include_once(
"./Services/News/classes/class.ilNewsCache.php");
117 $this->acache->storeEntry($ilUser->getId().
":0",
171 $next_class = $ilCtrl->getNextClass();
172 $cmd = $ilCtrl->getCmd(
"getHTML");
177 return $this->
$cmd();
194 $ilBench->start(
"News",
"ilPDNewsBlockGUI_fillDataSection");
196 $ilBench->stop(
"News",
"ilPDNewsBlockGUI_fillDataSection");
201 if (count($this->
getData()) == 0)
217 $this->
setFooterInfo($lng->txt(
"news_block_information"),
true);
220 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
221 $allow_shorter_periods = $news_set->get(
"allow_shorter_periods");
222 $allow_longer_periods = $news_set->get(
"allow_longer_periods");
223 $enable_private_feed = $news_set->get(
"enable_private_feed");
226 include_once(
"./Services/News/classes/class.ilNewsSubscription.php");
229 if ($enable_internal_rss)
232 $ilCtrl->getLinkTarget($this,
"showFeedUrl"),
236 if ($allow_shorter_periods || $allow_longer_periods || $enable_private_feed)
239 $ilCtrl->getLinkTarget($this,
"editSettings"),
240 $lng->txt(
"settings"));
251 case 5: $per_str = sprintf($lng->txt(
"news_period_x_days"), $per);
break;
252 case 7: $per_str = $lng->txt(
"news_period_1_week");
break;
253 case 14: $per_str = sprintf($lng->txt(
"news_period_x_weeks"), 2);
break;
254 case 30: $per_str = $lng->txt(
"news_period_1_month");
break;
255 case 60: $per_str = sprintf($lng->txt(
"news_period_x_months"), 2);
break;
256 case 120: $per_str = sprintf($lng->txt(
"news_period_x_months"), 4);
break;
257 case 180: $per_str = sprintf($lng->txt(
"news_period_x_months"), 6);
break;
258 case 366: $per_str = $lng->txt(
"news_period_1_year");
break;
262 $this->
setTitle($this->
getTitle().
' <span style="font-weight:normal;">- '.$per_str.
"</span>");
272 if ($ilUser->getPref(
"il_feed_js") ==
"n")
291 include_once(
"./Services/News/classes/class.ilNewsItem.php");
293 if ($news_set->get(
"enable_private_feed") && $ilUser->_getFeedPass(
$_SESSION[
"AccountId"]))
295 $tpl =
new ilTemplate(
"tpl.show_priv_feed_url.html",
true,
true,
"Services/News");
298 $tpl->setVariable(
"TXT_PRIV_TITLE", $lng->txt(
"news_get_priv_feed_title"));
299 $tpl->setVariable(
"TXT_PRIV_INFO", $lng->txt(
"news_get_priv_feed_info"));
300 $tpl->setVariable(
"TXT_PRIV_FEED_URL", $lng->txt(
"news_feed_url"));
301 $tpl->setVariable(
"VAL_PRIV_FEED_URL",
302 str_replace(
"://",
"://" . $ilUser->getLogin() .
":-password-@", ILIAS_HTTP_PATH).
"/privfeed.php?client_id=".rawurlencode(CLIENT_ID).
"&user_id=".$ilUser->getId().
303 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
304 $tpl->setVariable(
"VAL_PRIV_FEED_URL_TXT",
305 str_replace(
"://",
"://" . $ilUser->getLogin() .
":-password-@", ILIAS_HTTP_PATH).
"/privfeed.php?client_id=".rawurlencode(CLIENT_ID).
"&<br />user_id=".$ilUser->getId().
306 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
310 $tpl =
new ilTemplate(
"tpl.show_feed_url.html",
true,
true,
"Services/News");
312 $tpl->setVariable(
"TXT_TITLE", $lng->txt(
"news_get_feed_title"));
313 $tpl->setVariable(
"TXT_INFO", $lng->txt(
"news_get_feed_info"));
314 $tpl->setVariable(
"TXT_FEED_URL", $lng->txt(
"news_feed_url"));
315 $tpl->setVariable(
"VAL_FEED_URL",
316 ILIAS_HTTP_PATH.
"/feed.php?client_id=".rawurlencode(CLIENT_ID).
"&user_id=".$ilUser->getId().
317 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
318 $tpl->setVariable(
"VAL_FEED_URL_TXT",
319 ILIAS_HTTP_PATH.
"/feed.php?client_id=".rawurlencode(CLIENT_ID).
"&<br />user_id=".$ilUser->getId().
320 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
322 include_once(
"./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php");
324 $content_block->setContent(
$tpl->get());
325 $content_block->setTitle($lng->txt(
"news_internal_news"));
327 $content_block->addHeaderCommand($ilCtrl->getParentReturn($this),
328 $lng->txt(
"selected_items_back"));
330 return $content_block->getHTML();
337 $a_content_block->addHeaderCommand($ilCtrl->getParentReturn($this),
338 $lng->txt(
"selected_items_back"));
364 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
365 $allow_shorter_periods = $news_set->get(
"allow_shorter_periods");
366 $allow_longer_periods = $news_set->get(
"allow_longer_periods");
367 $enable_private_feed = $news_set->get(
"enable_private_feed");
369 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
371 if ($allow_shorter_periods || $allow_longer_periods )
374 include_once(
"./Services/News/classes/class.ilNewsItem.php");
378 $form->setTitle($lng->txt(
"news_settings"));
381 $form->setTableWidth(
"100%");
384 2 =>
"2 ".$lng->txt(
"days"),
385 3 =>
"3 ".$lng->txt(
"days"),
386 5 =>
"5 ".$lng->txt(
"days"),
387 7 =>
"1 ".$lng->txt(
"week"),
388 14 =>
"2 ".$lng->txt(
"weeks"),
389 30 =>
"1 ".$lng->txt(
"month"),
390 60 =>
"2 ".$lng->txt(
"months"),
391 120 =>
"4 ".$lng->txt(
"months"),
392 180 =>
"6 ".$lng->txt(
"months"),
393 366 =>
"1 ".$lng->txt(
"year"));
396 foreach($per_opts as $k => $opt)
398 if (!$allow_shorter_periods && ($k < $default_per)) $unset[$k] = $k;
399 if (!$allow_longer_periods && ($k > $default_per)) $unset[$k] = $k;
401 foreach($unset as $k)
403 unset($per_opts[$k]);
410 $per_sel->setValue((
int) $per);
411 $form->addItem($per_sel);
420 $form->addCommandButton(
"saveSettings", $lng->txt(
"save"));
421 $form->addCommandButton(
"cancelSettings", $lng->txt(
"cancel"));
422 $form->setFormAction($ilCtrl->getFormaction($this));
424 $returnForm = $form->getHTML();
427 if ($enable_private_feed)
430 $feed_form->setTitle($lng->txt(
"priv_feed_settings"));
433 $feed_form->setTableWidth(
"100%");
435 $enable_private_feed =
new ilCheckboxInputGUI($lng->txt(
"news_enable_private_feed"),
"enable_private_feed");
438 $retype_pass =
new ilTextInputGUI($lng->txt(
"retype_password"),
"retype_password");
439 $desired_pass =
new ilTextInputGUI($lng->txt(
"desired_password"),
"desired_password");
444 $enable_private_feed->setChecked(
true);
449 $retype_pass->setInputType(
"password");
451 $feed_form->addItem($enable_private_feed);
452 $feed_form->addItem($desired_pass);
453 $feed_form->addItem($retype_pass);
455 $feed_form->addCommandButton(
"changeFeedSettings", $lng->txt(
"save"));
456 $feed_form->addCommandButton(
"cancelSettings", $lng->txt(
"cancel"));
457 $feed_form->setFormAction($ilCtrl->getFormaction($this));
459 $returnForm .= ($returnForm==
"")?$feed_form->getHTML():
"<br>".$feed_form->getHTML();
472 $ilCtrl->returnToParent($this);
483 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
489 include_once(
"./Services/News/classes/class.ilNewsCache.php");
491 $cache->deleteEntry($ilUser->getId().
":0");
493 $ilCtrl->returnToParent($this);
504 if (empty(
$_POST[
"enable_private_feed"]))
507 $ilUser->_setFeedPass(
$_SESSION[
"AccountId"],
"");
508 $ilCtrl->returnToParent($this);
513 if (
$_POST[
"desired_password"] !=
$_POST[
"retype_password"])
516 $ilCtrl->redirectByClass(
"ilPDNewsBlockGUI",
"editSettings");
522 $ilCtrl->redirectByClass(
"ilPDNewsBlockGUI",
"editSettings");
525 else if (md5(
$_POST[
"desired_password"]) == $ilUser->getPasswd())
528 $ilCtrl->redirectByClass(
"ilPDNewsBlockGUI",
"editSettings");
530 else if (
$_POST[
"desired_password"] !=
"")
533 $ilUser->_setFeedPass(
$_SESSION[
"AccountId"],
$_POST[
"desired_password"]);
534 $ilCtrl->returnToParent($this);