4include_once(
"Services/News/classes/class.ilNewsForContextBlockGUI.php");
29 $this->lng =
$DIC->language();
30 $this->
user = $DIC->user();
31 $this->access =
$DIC->access();
32 $this->ctrl =
$DIC->ctrl();
36 $ilAccess =
$DIC->access();
37 $this->obj_definition =
$DIC[
"objDefinition"];
38 $this->ui =
$DIC->ui();
43 $lng->loadLanguageModule(
"news");
44 include_once(
"./Services/News/classes/class.ilNewsItem.php");
49 $this->dynamic =
false;
51 include_once(
"./Services/News/classes/class.ilNewsCache.php");
53 $cres = unserialize($this->acache->getEntry(
$ilUser->getId() .
":0"));
54 $this->cache_hit =
false;
55 if ($this->acache->getLastAccessStatus() ==
"hit" && is_array($cres)) {
58 $this->cache_hit =
true;
61 if ($this->
getDynamic() && !$this->cache_hit) {
62 $this->dynamic =
true;
68 if (empty(self::$st_data)) {
79 $this->
setRowTemplate(
"tpl.block_row_news_for_context.html",
"Services/News");
86 $ilAccess->setResults($this->acc_results);
96 include_once(
"./Services/News/classes/class.ilNewsCache.php");
107 $this->acache->storeEntry(
141 if ($cmd ==
"post" && is_array(
$_POST[
"cmd"])) {
142 $cmd = array_pop(array_keys(
$_POST[
"cmd"]));
149 case "changeFeedSettings":
164 $next_class =
$ilCtrl->getNextClass();
165 $cmd =
$ilCtrl->getCmd(
"getHTML");
167 switch ($next_class) {
169 return $this->$cmd();
178 if ($this->dynamic) {
181 parent::fillDataSection();
184 if (count($this->
getData()) == 0) {
204 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
205 $allow_shorter_periods = $news_set->get(
"allow_shorter_periods");
206 $allow_longer_periods = $news_set->get(
"allow_longer_periods");
207 $enable_private_feed = $news_set->get(
"enable_private_feed");
210 include_once(
"./Services/News/classes/class.ilNewsSubscription.php");
213 if ($enable_internal_rss) {
214 include_once(
"./Services/News/classes/class.ilRSSButtonGUI.php");
216 $ilCtrl->getLinkTarget($this,
"showFeedUrl"),
217 $lng->txt(
"news_get_feed_url"),
226 if ($allow_shorter_periods || $allow_longer_periods || $enable_private_feed) {
228 $ilCtrl->getLinkTarget($this,
"editSettings"),
229 $lng->txt(
"settings")
239 case 5: $per_str = sprintf(
$lng->txt(
"news_period_x_days"), $per);
break;
240 case 7: $per_str =
$lng->txt(
"news_period_1_week");
break;
241 case 14: $per_str = sprintf(
$lng->txt(
"news_period_x_weeks"), 2);
break;
242 case 30: $per_str =
$lng->txt(
"news_period_1_month");
break;
243 case 60: $per_str = sprintf(
$lng->txt(
"news_period_x_months"), 2);
break;
244 case 120: $per_str = sprintf(
$lng->txt(
"news_period_x_months"), 4);
break;
245 case 180: $per_str = sprintf(
$lng->txt(
"news_period_x_months"), 6);
break;
246 case 366: $per_str =
$lng->txt(
"news_period_1_year");
break;
248 if ($per_str !=
"") {
249 $this->
setTitle($this->
getTitle() .
' <span style="font-weight:normal;">- ' . $per_str .
"</span>");
258 if (
$ilUser->getPref(
"il_feed_js") ==
"n") {
279 include_once(
"./Services/News/classes/class.ilNewsItem.php");
281 if ($news_set->get(
"enable_private_feed")) {
282 $tpl =
new ilTemplate(
"tpl.show_priv_feed_url.html",
true,
true,
"Services/News");
284 $tpl->setVariable(
"TXT_PRIV_TITLE",
$lng->txt(
"news_get_priv_feed_title"));
288 $tpl->setVariable(
"TXT_PRIV_INFO",
$lng->txt(
"news_get_priv_feed_info"));
289 $tpl->setVariable(
"TXT_PRIV_FEED_URL",
$lng->txt(
"news_feed_url"));
292 str_replace(
"://",
"://" .
$ilUser->getLogin() .
":-password-@", ILIAS_HTTP_PATH) .
"/privfeed.php?client_id=" . rawurlencode(CLIENT_ID) .
"&user_id=" .
$ilUser->getId() .
296 "VAL_PRIV_FEED_URL_TXT",
297 str_replace(
"://",
"://" .
$ilUser->getLogin() .
":-password-@", ILIAS_HTTP_PATH) .
"/privfeed.php?client_id=" . rawurlencode(CLIENT_ID) .
"&<br />user_id=" .
$ilUser->getId() .
301 $tpl->setVariable(
"TXT_PRIV_INFO",
$lng->txt(
"news_inactive_private_feed_info"));
302 $tpl->setVariable(
"EDIT_SETTINGS_URL",
$ilCtrl->getLinkTarget($this,
"editSettings"));
303 $tpl->setVariable(
"EDIT_SETTINGS_TXT",
$lng->txt(
"news_edit_news_settings"));
306 $tpl =
new ilTemplate(
"tpl.show_feed_url.html",
true,
true,
"Services/News");
308 $tpl->setVariable(
"TXT_TITLE",
$lng->txt(
"news_get_feed_title"));
309 $tpl->setVariable(
"TXT_INFO",
$lng->txt(
"news_get_feed_info"));
310 $tpl->setVariable(
"TXT_FEED_URL",
$lng->txt(
"news_feed_url"));
313 ILIAS_HTTP_PATH .
"/feed.php?client_id=" . rawurlencode(CLIENT_ID) .
"&user_id=" .
$ilUser->getId() .
318 ILIAS_HTTP_PATH .
"/feed.php?client_id=" . rawurlencode(CLIENT_ID) .
"&<br />user_id=" .
$ilUser->getId() .
322 include_once(
"./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php");
324 $content_block->setContent(
$tpl->get());
325 $content_block->setTitle(
$lng->txt(
"news_internal_news"));
326 $content_block->addHeaderCommand(
327 $ilCtrl->getParentReturn($this),
328 $lng->txt(
"selected_items_back")
331 return $content_block->getHTML();
339 $a_content_block->addHeaderCommand(
340 $ilCtrl->getParentReturn($this),
341 $lng->txt(
"selected_items_back")
357 return parent::showNews();
371 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
372 $allow_shorter_periods = $news_set->get(
"allow_shorter_periods");
373 $allow_longer_periods = $news_set->get(
"allow_longer_periods");
374 $enable_private_feed = $news_set->get(
"enable_private_feed");
376 if (!$a_private_form && ($allow_shorter_periods || $allow_longer_periods)) {
377 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
380 $form->setTitle(
$lng->txt(
"news_settings"));
382 include_once(
"./Services/News/classes/class.ilNewsItem.php");
386 $form->setTableWidth(
"100%");
389 2 =>
"2 " .
$lng->txt(
"days"),
390 3 =>
"3 " .
$lng->txt(
"days"),
391 5 =>
"5 " .
$lng->txt(
"days"),
392 7 =>
"1 " .
$lng->txt(
"week"),
393 14 =>
"2 " .
$lng->txt(
"weeks"),
394 30 =>
"1 " .
$lng->txt(
"month"),
395 60 =>
"2 " .
$lng->txt(
"months"),
396 120 =>
"4 " .
$lng->txt(
"months"),
397 180 =>
"6 " .
$lng->txt(
"months"),
398 366 =>
"1 " .
$lng->txt(
"year"));
401 foreach ($per_opts as $k => $opt) {
402 if (!$allow_shorter_periods && ($k < $default_per)) {
405 if (!$allow_longer_periods && ($k > $default_per)) {
409 foreach ($unset as $k) {
410 unset($per_opts[$k]);
414 $lng->txt(
"news_pd_period"),
418 $per_sel->setOptions($per_opts);
419 $per_sel->setValue((
int) $per);
420 $form->addItem($per_sel);
429 $form->addCommandButton(
"saveSettings",
$lng->txt(
"save"));
430 $form->addCommandButton(
"cancelSettings",
$lng->txt(
"cancel"));
432 $returnForm =
$form->getHTML();
435 if ($enable_private_feed) {
436 if (!$a_private_form) {
439 $returnForm .= ($returnForm ==
"")
440 ? $a_private_form->getHTML()
441 :
"<br>" . $a_private_form->getHTML();
453 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
455 $feed_form->setFormAction(
$ilCtrl->getFormaction($this));
456 $feed_form->setTitle(
$lng->txt(
"priv_feed_settings"));
458 $feed_form->setTableWidth(
"100%");
460 $enable_private_feed =
new ilCheckboxInputGUI(
$lng->txt(
"news_enable_private_feed"),
"enable_private_feed");
461 $enable_private_feed->setChecked(
$ilUser->_getFeedPass(
$ilUser->getId()));
462 $feed_form->addItem($enable_private_feed);
465 $passwd->setRequired(
true);
467 $enable_private_feed->addSubItem($passwd);
469 $feed_form->addCommandButton(
"changeFeedSettings",
$lng->txt(
"save"));
470 $feed_form->addCommandButton(
"cancelSettings",
$lng->txt(
"cancel"));
482 $ilCtrl->returnToParent($this);
494 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
504 include_once(
"./Services/News/classes/class.ilNewsCache.php");
506 $cache->deleteEntry(
$ilUser->getId() .
":0");
508 $ilCtrl->returnToParent($this);
521 if (
$form->checkInput()) {
523 if (!
$form->getInput(
"enable_private_feed")) {
525 ilUtil::sendSuccess(
$lng->txt(
"priv_feed_disabled"),
true);
527 $ilCtrl->redirect($this,
"showFeedUrl");
529 $passwd =
$form->getInput(
"desired_password");
530 require_once
'Services/User/classes/class.ilUserPasswordManager.php';
532 $form->getItemByPostVar(
"desired_password")->setAlert(
$lng->txt(
"passwd_equals_ilpasswd"));
536 ilUtil::sendSuccess(
$lng->txt(
"saved_successfully"),
true);
538 $ilCtrl->redirect($this,
"showFeedUrl");
543 $form->setValuesByPost();
An exception for terminatinating execution or to throw for unit testing.
setRowTemplate($a_rowtemplatename, $a_rowtemplatedir="")
Set Row Template Name.
setLimit($a_limit)
Set Limit.
setFooterInfo($a_footerinfo, $a_hide_and_icon=false)
Set Footer Info.
getCurrentDetailLevel()
Get Current Detail Level.
setAvailableDetailLevels($a_max, $a_min=0)
Set Available Detail Levels.
setEnableDetailRow($a_enabledetailrow)
Set EnableDetailRow.
setData($a_data)
Set Data.
__construct()
Constructor.
setDataSection($a_content)
Call this from overwritten fillDataSection(), if standard row based data is not used.
setTitle($a_title)
Set Title.
setEnableNumInfo($a_enablenuminfo)
Set Enable Item Number Info.
addBlockCommand( $a_href, $a_text, $a_target="", $a_img="", $a_right_aligned=false, $a_checked=false, $a_html="")
Add Block Command.
getHTML()
Handle config status.
static _write($a_type, $a_setting, $a_value, $a_user=0, $a_block_id=0)
Write setting to database.
BlockGUI class for block NewsForContext.
editSettings()
Show settings screen.
handleView()
Handles show/hide notification view and removes notifications if hidden.
getOverview()
Get overview.
static prepareNewsDataFromCache($a_cres)
Prepare news data from cache.
static _getNewsItemsOfUser( $a_user_id, $a_only_public=false, $a_prevent_aggregation=false, $a_per=0, &$a_cnt=null)
Get all news items for a user.
static _lookupUserPDPeriod($a_user_id)
static _lookupDefaultPDPeriod()
static _lookupFeedHash($a_user_id, $a_create=false)
Lookup news feed hash for user.
BlockGUI class for (centered) Content on Personal Desktop.
BlockGUI class for block NewsForContext.
executeCommand()
execute command
getNewsData()
Get news for context.
cancelSettings()
Cancel settings.
changeFeedSettings()
change user password
getHTML()
Get bloch HTML code.
saveSettings()
Save settings.
addCloseCommand($a_content_block)
fillDataSection()
Fill data section.
showFeedUrl()
Show feed URL.
isRepositoryObject()
Returns whether block has a corresponding repository object.bool
__construct()
Constructor.
static getScreenMode()
Get Screen Mode for current command.
editSettings(ilPropertyFormGUI $a_private_form=null)
Show settings screen.
initPrivateSettingsForm()
special template class to simplify handling of ITX/PEAR
static getInstance()
Single method to reduce footprint (included files, created instances)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo()
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
if(isset($_POST['submit'])) $form