/** * Edit news settings. */ public function editSettings() { global $ilCtrl, $lng, $ilSetting; $news_set = new ilSetting("news"); $feed_set = new ilSetting("feed"); $enable_internal_news = $ilSetting->get("block_activated_news"); $enable_internal_rss = $news_set->get("enable_rss_for_internal"); $rss_title_format = $news_set->get("rss_title_format"); $enable_private_feed = $news_set->get("enable_private_feed"); $news_default_visibility = $news_set->get("default_visibility") != "" ? $news_set->get("default_visibility") : "users"; $disable_repository_feeds = $feed_set->get("disable_rep_feeds"); $nr_personal_desktop_feeds = $ilSetting->get("block_limit_pdfeed"); $allow_shorter_periods = $news_set->get("allow_shorter_periods"); $allow_longer_periods = $news_set->get("allow_longer_periods"); include_once "./Services/News/classes/class.ilNewsItem.php"; $rss_period = ilNewsItem::_lookupRSSPeriod(); include_once "./Services/Form/classes/class.ilPropertyFormGUI.php"; $form = new ilPropertyFormGUI(); $form->setFormAction($ilCtrl->getFormAction($this)); $form->setTitle($lng->txt("news_settings")); // Enable internal news $cb_prop = new ilCheckboxInputGUI($lng->txt("news_enable_internal_news"), "enable_internal_news"); $cb_prop->setValue("1"); $cb_prop->setInfo($lng->txt("news_enable_internal_news_info")); $cb_prop->setChecked($enable_internal_news); $form->addItem($cb_prop); // Default Visibility $radio_group = new ilRadioGroupInputGUI($lng->txt("news_default_visibility"), "news_default_visibility"); $radio_option = new ilRadioOption($lng->txt("news_visibility_users"), "users"); $radio_group->addOption($radio_option); $radio_option = new ilRadioOption($lng->txt("news_visibility_public"), "public"); $radio_group->addOption($radio_option); $radio_group->setInfo($lng->txt("news_news_item_visibility_info")); $radio_group->setRequired(false); $radio_group->setValue($news_default_visibility); $form->addItem($radio_group); // Number of news items per object $nr_opts = array(50 => 50, 100 => 100, 200 => 200); $nr_sel = new ilSelectInputGUI($lng->txt("news_nr_of_items"), "news_max_items"); $nr_sel->setInfo($lng->txt("news_nr_of_items_info")); $nr_sel->setOptions($nr_opts); $nr_sel->setValue($news_set->get("max_items")); $form->addItem($nr_sel); // Access Cache $min_opts = array(0 => 0, 1 => 1, 2 => 2, 5 => 5, 10 => 10, 20 => 20, 30 => 30, 60 => 60); $min_sel = new ilSelectInputGUI($lng->txt("news_cache"), "news_acc_cache_mins"); $min_sel->setInfo($lng->txt("news_cache_info")); $min_sel->setOptions($min_opts); $min_sel->setValue($news_set->get("acc_cache_mins")); $form->addItem($min_sel); // PD News Period $per_opts = array(2 => "2 " . $lng->txt("days"), 3 => "3 " . $lng->txt("days"), 5 => "5 " . $lng->txt("days"), 7 => "1 " . $lng->txt("week"), 14 => "2 " . $lng->txt("weeks"), 30 => "1 " . $lng->txt("month"), 60 => "2 " . $lng->txt("months"), 120 => "4 " . $lng->txt("months"), 180 => "6 " . $lng->txt("months"), 366 => "1 " . $lng->txt("year")); $per_sel = new ilSelectInputGUI($lng->txt("news_pd_period"), "news_pd_period"); $per_sel->setInfo($lng->txt("news_pd_period_info")); $per_sel->setOptions($per_opts); $per_sel->setValue((int) ilNewsItem::_lookupDefaultPDPeriod()); $form->addItem($per_sel); // Allow user to choose lower values $sp_prop = new ilCheckboxInputGUI($lng->txt("news_allow_shorter_periods"), "allow_shorter_periods"); $sp_prop->setValue("1"); $sp_prop->setInfo($lng->txt("news_allow_shorter_periods_info")); $sp_prop->setChecked($allow_shorter_periods); $form->addItem($sp_prop); // Allow user to choose higher values $lp_prop = new ilCheckboxInputGUI($lng->txt("news_allow_longer_periods"), "allow_longer_periods"); $lp_prop->setValue("1"); $lp_prop->setInfo($lng->txt("news_allow_longer_periods_info")); $lp_prop->setChecked($allow_longer_periods); $form->addItem($lp_prop); // Enable rss for internal news $cb_prop = new ilCheckboxInputGUI($lng->txt("news_enable_internal_rss"), "enable_internal_rss"); $cb_prop->setValue("1"); $cb_prop->setInfo($lng->txt("news_enable_internal_rss_info")); $cb_prop->setChecked($enable_internal_rss); // RSS News Period $rssp_opts = array(2 => "2 " . $lng->txt("days"), 3 => "3 " . $lng->txt("days"), 5 => "5 " . $lng->txt("days"), 7 => "1 " . $lng->txt("week"), 14 => "2 " . $lng->txt("weeks"), 30 => "1 " . $lng->txt("month"), 60 => "2 " . $lng->txt("months"), 120 => "4 " . $lng->txt("months"), 180 => "6 " . $lng->txt("months"), 365 => "1 " . $lng->txt("year")); $rssp_sel = new ilSelectInputGUI($lng->txt("news_rss_period"), "news_rss_period"); $rssp_sel->setOptions($rssp_opts); $rssp_sel->setValue((int) $rss_period); $cb_prop->addSubItem($rssp_sel); // Section Header: RSS $sh = new ilFormSectionHeaderGUI(); $sh->setTitle($lng->txt("news_rss")); $form->addItem($sh); // title format for rss entries $options = array("" => $lng->txt("news_rss_title_format_obj_news"), "news_obj" => $lng->txt("news_rss_title_format_news_obj")); $si = new ilSelectInputGUI($lng->txt("news_rss_title_format"), "rss_title_format"); $si->setOptions($options); $si->setValue($rss_title_format); $cb_prop->addSubItem($si); $form->addItem($cb_prop); // Enable private news feed $cb_prop = new ilCheckboxInputGUI($lng->txt("news_enable_private_feed"), "enable_private_feed"); $cb_prop->setValue("1"); $cb_prop->setInfo($lng->txt("news_enable_private_feed_info")); $cb_prop->setChecked($enable_private_feed); $form->addItem($cb_prop); // Section Header: External Web Feeds Settings $sh = new ilFormSectionHeaderGUI(); $sh->setTitle($lng->txt("feed_settings")); $form->addItem($sh); // Number of External Feeds on personal desktop $sel = new ilSelectInputGUI($lng->txt("feed_nr_pd_feeds"), "nr_pd_feeds"); $sel->setInfo($lng->txt("feed_nr_pd_feeds_info")); $sel->setOptions(array(0 => "0", 1 => "1", 2 => "2", 3 => "3", 4 => "4", 5 => "5")); $sel->setValue($nr_personal_desktop_feeds); $form->addItem($sel); // Disable External Web Feeds in catetegories $cb_prop = new ilCheckboxInputGUI($lng->txt("feed_disable_rep_feeds"), "disable_repository_feeds"); $cb_prop->setValue("1"); $cb_prop->setInfo($lng->txt("feed_disable_rep_feeds_info")); $cb_prop->setChecked($disable_repository_feeds); $form->addItem($cb_prop); // command buttons $form->addCommandButton("saveSettings", $lng->txt("save")); $form->addCommandButton("view", $lng->txt("cancel")); $this->tpl->setContent($form->getHTML()); }
function ilObjectFeedWriter($a_ref_id, $a_userid = false, $a_purpose = false) { global $ilSetting, $lng; parent::ilFeedWriter(); if ($a_ref_id <= 0) { return; } include_once "./Services/Block/classes/class.ilBlockSetting.php"; $news_set = new ilSetting("news"); if (!$news_set->get("enable_rss_for_internal")) { return; } $obj_id = ilObject::_lookupObjId($a_ref_id); $obj_type = ilObject::_lookupType($obj_id); $obj_title = ilObject::_lookupTitle($obj_id); if (!ilBlockSetting::_lookup("news", "public_feed", 0, $obj_id)) { return; } if ($ilSetting->get('short_inst_name') != "") { $this->setChannelTitle($ilSetting->get('short_inst_name') . " - " . $this->prepareStr($loc . $obj_title)); } else { $this->setChannelTitle("ILIAS" . " - " . $this->prepareStr($loc . $obj_title . ($a_purpose ? " - " . $a_purpose : ""))); } $this->setChannelAbout(ILIAS_HTTP_PATH); $this->setChannelLink(ILIAS_HTTP_PATH); // not nice, to do: general solution if ($obj_type == "mcst") { include_once "./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php"; if (!ilObjMediaCastAccess::_lookupOnline($obj_id)) { $lng->loadLanguageModule("mcst"); $feed_item = new ilFeedItem(); $feed_item->setTitle($lng->txt("mcst_media_cast_not_online")); $feed_item->setDescription($lng->txt("mcst_media_cast_not_online_text")); $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&target=" . $item["context_obj_type"]); $this->addItem($feed_item); return; } } include_once "./Services/Locator/classes/class.ilLocatorGUI.php"; $cont_loc = new ilLocatorGUI(); $cont_loc->addContextItems($a_ref_id, true); $cont_loc->setTextOnly(true); $loc = $cont_loc->getTextVersion(); if (trim($loc) != "") { $loc = " [" . $loc . "] "; } $rss_period = ilNewsItem::_lookupRSSPeriod(); ilNewsItem::setPrivateFeedId($a_userid); $news_item = new ilNewsItem(); $news_item->setContextObjId($obj_id); $news_item->setContextObjType($obj_type); $items = $news_item->getNewsForRefId($a_ref_id, true, false, $rss_period, true); if ($a_purpose) { include_once "./Services/MediaObjects/classes/class.ilMediaItem.php"; } $i = 0; foreach ($items as $item) { $i++; if ($a_purpose != false && $obj_type == "mcst") { $mob = ilMediaItem::_getMediaItemsOfMObId($item[mob_id], $a_purpose); if ($mob == false) { continue; } } $obj_title = ilObject::_lookupTitle($item["context_obj_id"]); $feed_item = new ilFeedItem(); $title = ilNewsItem::determineNewsTitle($item["context_obj_type"], $item["title"], $item["content_is_lang_var"], $item["agg_ref_id"], $item["aggregation"]); // path $cont_loc = new ilLocatorGUI(); $cont_loc->addContextItems($item["ref_id"], true, $a_ref_id); $cont_loc->setTextOnly(true); $loc = $cont_loc->getHTML(); if (trim($loc) != "") { $loc = "[" . $loc . "]"; } if ($news_set->get("rss_title_format") == "news_obj") { $sep = trim($this->prepareStr($loc)) == "" ? "" : " "; $feed_item->setTitle($this->prepareStr($title) . " (" . $this->prepareStr($loc) . $sep . $this->prepareStr($obj_title) . ")"); } else { $feed_item->setTitle($this->prepareStr($loc) . " " . $this->prepareStr($obj_title) . ": " . $this->prepareStr($title)); } $feed_item->setDescription($this->prepareStr(nl2br(ilNewsItem::determineNewsContent($item["context_obj_type"], $item["content"], $item["content_text_is_lang_var"])))); // lm hack, not nice if (in_array($item["context_obj_type"], array("dbk", "lm")) && $item["context_sub_obj_type"] == "pg" && $item["context_sub_obj_id"] > 0) { $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&target=pg_" . $item["context_sub_obj_id"] . "_" . $item["ref_id"]); } else { if ($item["context_obj_type"] == "wiki" && $item["context_sub_obj_type"] == "wpg" && $item["context_sub_obj_id"] > 0) { include_once "./Modules/Wiki/classes/class.ilWikiPage.php"; $wptitle = ilWikiPage::lookupTitle($item["context_sub_obj_id"]); $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&target=" . $item["context_obj_type"] . "_" . $item["ref_id"] . "_" . $wptitle); } else { if (in_array($item["context_obj_type"], array("frm")) && $item["context_sub_obj_type"] == "pos" && $item["context_sub_obj_id"] > 0) { // frm hack, not nice include_once "./Modules/Forum/classes/class.ilObjForumAccess.php"; $thread_id = ilObjForumAccess::_getThreadForPosting($item["context_sub_obj_id"]); if ($thread_id > 0) { $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&target=" . $item["context_obj_type"] . "_" . $item["ref_id"] . "_" . $thread_id . "_" . $item["context_sub_obj_id"]); } else { $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&target=" . $item["context_obj_type"] . "_" . $item["ref_id"]); } } else { $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&target=" . $item["context_obj_type"] . "_" . $item["ref_id"]); //echo "<br>".ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID. // "&target=".$item["context_obj_type"]."_".$item["ref_id"]; } } } $feed_item->setAbout($feed_item->getLink() . "&il_about_feed=" . $item["id"]); $feed_item->setDate($item["creation_date"]); // Enclosure if ($item["content_type"] == NEWS_AUDIO && $item["mob_id"] > 0 && ilObject::_exists($item["mob_id"])) { $go_on = true; if ($obj_type == "mcst") { include_once "./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php"; if (!ilObjMediaCastAccess::_lookupPublicFiles($obj_id)) { $go_on = false; } } if ($go_on) { include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; $url = ilObjMediaObject::_lookupItemPath($item["mob_id"], true, true, $mob["purpose"]); $file = ilObjMediaObject::_lookupItemPath($item["mob_id"], false, false, $mob["purpose"]); if (is_file($file)) { $size = filesize($file); } $feed_item->setEnclosureUrl($url); $feed_item->setEnclosureType(isset($mob["format"]) ? $mob["format"] : "audio/mpeg"); $feed_item->setEnclosureLength($size); } } $this->addItem($feed_item); } }
/** * Init Settings Form */ function initSettingsForm() { global $tpl, $lng, $ilCtrl; $lng->loadLanguageModule("mcst"); include "Services/Form/classes/class.ilPropertyFormGUI.php"; $this->form_gui = new ilPropertyFormGUI(); $this->form_gui->setTitle($lng->txt("mcst_settings")); // Title $tit = new ilTextInputGUI($lng->txt("title"), "title"); $tit->setValue($this->object->getTitle()); $tit->setRequired(true); $this->form_gui->addItem($tit); // description $des = new ilTextAreaInputGUI($lng->txt("description"), "description"); $des->setValue($this->object->getLongDescription()); $this->form_gui->addItem($des); // Online $online = new ilCheckboxInputGUI($lng->txt("online"), "online"); $online->setChecked($this->object->getOnline()); $this->form_gui->addItem($online); // Sorting $sort = new ilRadioGroupInputGUI($lng->txt("mcst_ordering"), "order"); $sort->addOption(new ilRadioOption($lng->txt("mcst_ordering_title"), ilObjMediaCast::ORDER_TITLE)); $sort->addOption(new ilRadioOption($lng->txt("mcst_ordering_creation_date_asc"), ilObjMediaCast::ORDER_CREATION_DATE_ASC)); $sort->addOption(new ilRadioOption($lng->txt("mcst_ordering_creation_date_desc"), ilObjMediaCast::ORDER_CREATION_DATE_DESC)); $sort->addOption(new ilRadioOption($lng->txt("mcst_ordering_manual"), ilObjMediaCast::ORDER_MANUAL)); $sort->setValue($this->object->getOrder()); $this->form_gui->addItem($sort); // view mode $options = array(ilObjMediaCast::VIEW_LIST => $lng->txt("mcst_list"), ilObjMediaCast::VIEW_GALLERY => $lng->txt("mcst_gallery")); $si = new ilSelectInputGUI($this->lng->txt("mcst_viewmode"), "viewmode"); $si->setOptions($options); $si->setValue($this->object->getViewMode()); $this->form_gui->addItem($si); // Downloadable $downloadable = new ilCheckboxInputGUI($lng->txt("mcst_downloadable"), "downloadable"); $downloadable->setChecked($this->object->getDownloadable()); $downloadable->setInfo($lng->txt("mcst_downloadable_info")); $this->form_gui->addItem($downloadable); $news_set = new ilSetting("news"); $enable_internal_rss = $news_set->get("enable_rss_for_internal"); //Default Visibility if ($enable_internal_rss) { $radio_group = new ilRadioGroupInputGUI($lng->txt("news_default_visibility"), "defaultaccess"); $radio_option = new ilRadioOption($lng->txt("news_visibility_users"), "0"); $radio_group->addOption($radio_option); $radio_option = new ilRadioOption($lng->txt("news_visibility_public"), "1"); $radio_group->addOption($radio_option); $radio_group->setInfo($lng->txt("news_news_item_visibility_info")); $radio_group->setRequired(false); $radio_group->setValue($this->object->getDefaultAccess()); #$ch->addSubItem($radio_group); $this->form_gui->addItem($radio_group); //Extra Feed include_once "./Services/Block/classes/class.ilBlockSetting.php"; $public_feed = ilBlockSetting::_lookup("news", "public_feed", 0, $this->object->getId()); $ch = new ilCheckboxInputGUI($lng->txt("news_public_feed"), "extra_feed"); $ch->setInfo($lng->txt("news_public_feed_info")); $ch->setChecked($public_feed); $this->form_gui->addItem($ch); // keep minimal x number of items $ni = new ilNumberInputGUI($this->lng->txt("news_keep_minimal_x_items"), "keep_rss_min"); $ni->setMaxValue(100); $ni->setMinValue(0); $ni->setMaxLength(3); $ni->setSize(3); $ni->setInfo($this->lng->txt("news_keep_minimal_x_items_info") . " (" . ilNewsItem::_lookupRSSPeriod() . " " . (ilNewsItem::_lookupRSSPeriod() == 1 ? $lng->txt("day") : $lng->txt("days")) . ")"); $ni->setValue((int) ilBlockSetting::_lookup("news", "keep_rss_min", 0, $this->object->getId())); $ch->addSubItem($ni); // Include Files in Pubic Items $incl_files = new ilCheckboxInputGUI($lng->txt("mcst_incl_files_in_rss"), "public_files"); $incl_files->setChecked($this->object->getPublicFiles()); $incl_files->setInfo($lng->txt("mcst_incl_files_in_rss_info")); #$ch->addSubItem($incl_files); $this->form_gui->addItem($incl_files); } // Form action and save button $this->form_gui->addCommandButton("saveSettings", $lng->txt("save")); $this->form_gui->setFormAction($ilCtrl->getFormAction($this, "saveSettings")); }
function ilUserFeedWriter($a_user_id, $a_hash, $privFeed = false) { global $ilSetting, $lng; parent::ilFeedWriter(); //$lng->loadLanguageModule("news"); if ($a_user_id == "" || $a_hash == "") { return; } $news_set = new ilSetting("news"); if (!$news_set->get("enable_rss_for_internal")) { return; } include_once "Services/User/classes/class.ilObjUser.php"; $hash = ilObjUser::_lookupFeedHash($a_user_id); include_once "./Services/News/classes/class.ilNewsItem.php"; $rss_period = ilNewsItem::_lookupRSSPeriod(); if ($a_hash == $hash) { if ($privFeed) { //ilNewsItem::setPrivateFeedId($a_user_id); $items = ilNewsItem::_getNewsItemsOfUser($a_user_id, false, true, $rss_period); } else { $items = ilNewsItem::_getNewsItemsOfUser($a_user_id, true, true, $rss_period); } if ($ilSetting->get('short_inst_name') != "") { $this->setChannelTitle($ilSetting->get('short_inst_name')); } else { $this->setChannelTitle("ILIAS"); } $this->setChannelAbout(ILIAS_HTTP_PATH); $this->setChannelLink(ILIAS_HTTP_PATH); //$this->setChannelDescription("ILIAS Channel Description"); $i = 0; foreach ($items as $item) { $obj_id = ilObject::_lookupObjId($item["ref_id"]); $obj_type = ilObject::_lookupType($obj_id); $obj_title = ilObject::_lookupTitle($obj_id); // not nice, to do: general solution if ($obj_type == "mcst") { include_once "./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php"; if (!ilObjMediaCastAccess::_lookupOnline($obj_id)) { continue; } } $i++; $feed_item = new ilFeedItem(); $title = ilNewsItem::determineNewsTitle($item["context_obj_type"], $item["title"], $item["content_is_lang_var"], $item["agg_ref_id"], $item["aggregation"]); // path $loc = $this->getContextPath($item["ref_id"]); // title if ($news_set->get("rss_title_format") == "news_obj") { $feed_item->setTitle($this->prepareStr(str_replace("<br />", " ", $title)) . " (" . $this->prepareStr($loc) . " " . $this->prepareStr($obj_title) . ")"); } else { $feed_item->setTitle($this->prepareStr($loc) . " " . $this->prepareStr($obj_title) . ": " . $this->prepareStr(str_replace("<br />", " ", $title))); } // description $content = $this->prepareStr(nl2br(ilNewsItem::determineNewsContent($item["context_obj_type"], $item["content"], $item["content_text_is_lang_var"]))); $feed_item->setDescription($content); // lm page hack, not nice if (in_array($item["context_obj_type"], array("dbk", "lm")) && $item["context_sub_obj_type"] == "pg" && $item["context_sub_obj_id"] > 0) { $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&target=pg_" . $item["context_sub_obj_id"] . "_" . $item["ref_id"]); } else { if ($item["context_obj_type"] == "wiki" && $item["context_sub_obj_type"] == "wpg" && $item["context_sub_obj_id"] > 0) { include_once "./Modules/Wiki/classes/class.ilWikiPage.php"; $wptitle = ilWikiPage::lookupTitle($item["context_sub_obj_id"]); $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&target=" . $item["context_obj_type"] . "_" . $item["ref_id"] . "_" . urlencode($wptitle)); // #14629 } else { if (in_array($item["context_obj_type"], array("frm")) && $item["context_sub_obj_type"] == "pos" && $item["context_sub_obj_id"] > 0) { // frm hack, not nice include_once "./Modules/Forum/classes/class.ilObjForumAccess.php"; $thread_id = ilObjForumAccess::_getThreadForPosting($item["context_sub_obj_id"]); if ($thread_id > 0) { $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&target=" . $item["context_obj_type"] . "_" . $item["ref_id"] . "_" . $thread_id . "_" . $item["context_sub_obj_id"]); } else { $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&target=" . $item["context_obj_type"] . "_" . $item["ref_id"]); } } else { $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&target=" . $item["context_obj_type"] . "_" . $item["ref_id"]); } } } $feed_item->setAbout($feed_item->getLink() . "&il_about_feed=" . $item["id"]); $feed_item->setDate($item["creation_date"]); $this->addItem($feed_item); } } }