/** * Init Filter */ function initFilter() { global $lng, $ilUser; // period $per = $_SESSION["news_pd_news_per"] != "" ? $_SESSION["news_pd_news_per"] : ilNewsItem::_lookupUserPDPeriod($ilUser->getId()); $news_set = new ilSetting("news"); $allow_shorter_periods = $news_set->get("allow_shorter_periods"); $allow_longer_periods = $news_set->get("allow_longer_periods"); $default_per = ilNewsItem::_lookupDefaultPDPeriod(); $options = array(2 => sprintf($lng->txt("news_period_x_days"), 2), 3 => sprintf($lng->txt("news_period_x_days"), 3), 5 => sprintf($lng->txt("news_period_x_days"), 5), 7 => $lng->txt("news_period_1_week"), 14 => sprintf($lng->txt("news_period_x_weeks"), 2), 30 => $lng->txt("news_period_1_month"), 60 => sprintf($lng->txt("news_period_x_months"), 2), 120 => sprintf($lng->txt("news_period_x_months"), 4), 180 => sprintf($lng->txt("news_period_x_months"), 6), 366 => $lng->txt("news_period_1_year")); $unset = array(); foreach ($options as $k => $opt) { if (!$allow_shorter_periods && $k < $default_per) { $unset[$k] = $k; } if (!$allow_longer_periods && $k > $default_per) { $unset[$k] = $k; } } foreach ($unset as $k) { unset($options[$k]); } include_once "./Services/Form/classes/class.ilSelectInputGUI.php"; $si = new ilSelectInputGUI($this->lng->txt("news_time_period"), "news_per"); $si->setOptions($options); $si->setValue($per); $this->addFilterItem($si); // related to... $si = new ilSelectInputGUI($this->lng->txt("context"), "news_ref_id"); $si->setOptions($this->contexts); $si->setValue($this->selected_context); $this->addFilterItem($si); }
/** * Get tail dependencies * * @param string entity * @param string target release * @param array ids * @return array array of array with keys "component", entity", "ids" */ function getXmlExportHeadDependencies($a_entity, $a_target_release, $a_ids) { include_once "./Services/News/classes/class.ilNewsItem.php"; $mob_ids = array(); foreach ($a_ids as $id) { $mob_id = ilNewsItem::_lookupMobId($id); if ($mob_id > 0) { $mob_ids[$mob_id] = $mob_id; } } return array(array("component" => "Services/MediaObjects", "entity" => "mob", "ids" => $mob_ids)); }
function view() { global $ilUser, $lng, $tpl, $ilCtrl; $ref_ids = array(); $obj_ids = array(); $pd_items = $ilUser->getDesktopItems(); foreach ($pd_items as $item) { $ref_ids[] = $item["ref_id"]; $obj_ids[] = $item["obj_id"]; } $sel_ref_id = $_GET["news_ref_id"] > 0 ? $_GET["news_ref_id"] : $ilUser->getPref("news_sel_ref_id"); include_once "./Services/News/classes/class.ilNewsItem.php"; $per = $_SESSION["news_pd_news_per"] != "" ? $_SESSION["news_pd_news_per"] : ilNewsItem::_lookupUserPDPeriod($ilUser->getId()); $news_obj_ids = ilNewsItem::filterObjIdsPerNews($obj_ids, $per); // related objects (contexts) of news $contexts[0] = $lng->txt("news_all_items"); $conts = array(); $sel_has_news = false; foreach ($ref_ids as $ref_id) { $obj_id = ilObject::_lookupObjId($ref_id); $title = ilObject::_lookupTitle($obj_id); $conts[$ref_id] = $title; if ($sel_ref_id == $ref_id) { $sel_has_news = true; } } $cnt = array(); $nitem = new ilNewsItem(); $news_items = $nitem->_getNewsItemsOfUser($ilUser->getId(), false, true, $per, $cnt); // reset selected news ref id, if no news are given for id if (!$sel_has_news) { $sel_ref_id = ""; } asort($conts); foreach ($conts as $ref_id => $title) { $contexts[$ref_id] = $title . " (" . (int) $cnt[$ref_id] . ")"; } if ($sel_ref_id > 0) { $obj_id = ilObject::_lookupObjId($sel_ref_id); $obj_type = ilObject::_lookupType($obj_id); $nitem->setContextObjId($obj_id); $nitem->setContextObjType($obj_type); $news_items = $nitem->getNewsForRefId($sel_ref_id, false, false, $per, true); } include_once "./Services/News/classes/class.ilPDNewsTableGUI.php"; $pd_news_table = new ilPDNewsTableGUI($this, "view", $contexts, $sel_ref_id); $pd_news_table->setData($news_items); $pd_news_table->setNoEntriesText($lng->txt("news_no_news_items")); $tpl->setContent($pd_news_table->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); } }
/** * Get's the repository object ID of a parent object, if possible */ function getParentObjectIdForUsage($a_usage, $a_include_all_access_obj_ids = false) { if (is_int(strpos($a_usage["type"], ":"))) { $us_arr = explode(":", $a_usage["type"]); $type = $us_arr[1]; $cont_type = $us_arr[0]; } else { $type = $a_usage["type"]; } $id = $a_usage["id"]; $obj_id = false; switch ($type) { case "html": // "old" category pages if ($cont_type == "cat") { $obj_id = $id; } // Test InfoScreen Text if ($cont_type == "tst" || $cont_type == "svy") { $obj_id = $id; //var_dump($qinfo); } // Question Pool *Question* Text (Test) if ($cont_type == "qpl") { include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $qinfo = assQuestion::_getQuestionInfo($id); if ($qinfo["original_id"] > 0) { include_once "./Modules/Test/classes/class.ilObjTest.php"; $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id); // usage in test } else { $obj_id = $qinfo["obj_fi"]; // usage in pool } } // Question Pool *Question* Text (Survey) if ($cont_type == "spl") { include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php"; $quest = SurveyQuestion::_instanciateQuestion($id); if ($quest) { if ($quest->getOriginalId() > 0) { $obj_id = $quest->getSurveyId(); } else { $obj_id = $quest->getObjId(); // usage in pool } unset($quest); } } // Forum if ($cont_type == "frm") { $post_pk = $a_usage['id']; include_once 'Modules/Forum/classes/class.ilForumPost.php'; include_once 'Modules/Forum/classes/class.ilForum.php'; $oPost = new ilForumPost($post_pk); $frm_pk = $oPost->getForumId(); $obj_id = ilForum::_lookupObjIdForForumId($frm_pk); } if ($cont_type == 'frm~') { $obj_id = $a_usage['id']; } if ($cont_type == "dcl") { $obj_id = $id; } break; case "pg": // Question Pool Question Pages if ($cont_type == "qpl") { include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $qinfo = assQuestion::_getQuestionInfo($id); if ($qinfo["original_id"] > 0) { include_once "./Modules/Test/classes/class.ilObjTest.php"; $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id); // usage in test } else { $obj_id = $qinfo["obj_fi"]; // usage in pool } } // learning modules if ($cont_type == "lm" || $cont_type == "dbk") { include_once "./Modules/LearningModule/classes/class.ilLMObject.php"; $obj_id = ilLMObject::_lookupContObjID($id); } // glossary definition if ($cont_type == "gdf") { include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php"; include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php"; $term_id = ilGlossaryDefinition::_lookupTermId($id); $obj_id = ilGlossaryTerm::_lookGlossaryID($term_id); } // wiki page if ($cont_type == 'wpg') { include_once 'Modules/Wiki/classes/class.ilWikiPage.php'; $obj_id = ilWikiPage::lookupObjIdByPage($id); } // sahs page if ($cont_type == 'sahs') { // can this implementation be used for other content types, too? include_once './Services/COPage/classes/class.ilPageObject.php'; $obj_id = ilPageObject::lookupParentId($id, 'sahs'); } // repository pages if (in_array($cont_type, array("crs", "grp", "cat", "fold", "root"))) { $obj_id = $id; } if ($cont_type == 'prtf') { include_once "Services/Portfolio/classes/class.ilPortfolioPage.php"; $obj_id = ilPortfolioPage::findPortfolioForPage($id); } if ($cont_type == 'blp') { include_once './Services/COPage/classes/class.ilPageObject.php'; $obj_id = ilPageObject::lookupParentId($id, 'blp'); } break; // Media Pool // Media Pool case "mep": $obj_id = $id; break; // News Context Object (e.g. MediaCast) // News Context Object (e.g. MediaCast) case "news": include_once "./Services/News/classes/class.ilNewsItem.php"; $obj_id = ilNewsItem::_lookupContextObjId($id); break; } return $obj_id; }
/** * Send news mail for 1 object and 1 user * * @param int $a_user_id * @param int $a_ref_id * @param array $news */ public function sendMail($a_user_id, $a_ref_id, array $news) { global $lng, $ilUser; $obj_id = ilObject::_lookupObjId($a_ref_id); $obj_type = ilObject::_lookupType($obj_id); $this->initLanguage($a_user_id); $this->getLanguage()->loadLanguageModule("crs"); $this->getLanguage()->loadLanguageModule("news"); // needed for ilNewsItem $lng = $this->getLanguage(); $this->initMail(); $obj_title = $this->getLanguageText($obj_type) . " \"" . ilObject::_lookupTitle($obj_id) . "\""; $this->setRecipients($a_user_id); $this->setSubject(sprintf($this->getLanguageText("crs_subject_course_group_notification"), $obj_title)); $this->setBody(ilMail::getSalutation($a_user_id, $this->getLanguage())); $this->appendBody("\n\n"); $this->appendBody(sprintf($this->getLanguageText("crs_intro_course_group_notification_for"), $obj_title)); $this->appendBody("\n\n"); // ilDatePresentation::setUseRelativeDates(false); // news summary $counter = 1; foreach ($news as $item) { $title = ilNewsItem::determineNewsTitle($item["context_obj_type"], $item["title"], $item["content_is_lang_var"], $item["agg_ref_id"], $item["aggregation"]); $content = ilNewsItem::determineNewsContent($item["context_obj_type"], $item["content"], $item["content_text_is_lang_var"]); /* process sub-item info if($item["aggregation"]) { $sub = array(); foreach($item["aggregation"] as $subitem) { $sub_id = ilObject::_lookupObjId($subitem["ref_id"]); $sub_title = ilObject::_lookupTitle($sub_id); // to include posting title if($subitem["context_obj_type"] == "frm") { $sub_title = ilNewsItem::determineNewsTitle($subitem["context_obj_type"], $subitem["title"], $subitem["content_is_lang_var"]); } $sub[] = $sub_title; $sub_content = ilNewsItem::determineNewsContent($subitem["context_obj_type"], $subitem["content"], $subitem["content_text_is_lang_var"]); if($sub_content) { $sub[] = strip_tags($sub_content); } } $content .= "\n".implode("\n\n", $sub); } */ $obj_id = ilObject::_lookupObjId($item["ref_id"]); $obj_title = ilObject::_lookupTitle($obj_id); // path include_once './Services/Locator/classes/class.ilLocatorGUI.php'; $cont_loc = new ilLocatorGUI(); $cont_loc->addContextItems($item["ref_id"], true); $cont_loc->setTextOnly(true); // #9954/#10044 // see ilInitialisation::requireCommonIncludes() @(include_once "HTML/Template/ITX.php"); // new implementation if (class_exists("HTML_Template_ITX")) { include_once "./Services/UICore/classes/class.ilTemplateHTMLITX.php"; } else { include_once "HTML/ITX.php"; // old implementation include_once "./Services/UICore/classes/class.ilTemplateITX.php"; } require_once "./Services/UICore/classes/class.ilTemplate.php"; $loc = "[" . $cont_loc->getHTML() . "]"; $this->appendBody("----------------------------------------------------------------------------------------------"); $this->appendBody("\n\n"); $this->appendBody('#' . $counter . " - " . $loc . " " . $obj_title . "\n\n"); $this->appendBody($title); if ($content) { $this->appendBody("\n"); $this->appendBody($content); } $this->appendBody("\n\n"); ++$counter; } $this->appendBody("----------------------------------------------------------------------------------------------"); $this->appendBody("\n\n"); // link to object $this->appendBody($this->getLanguageText("crs_course_group_notification_link")); $this->appendBody("\n"); $object_link = ilUtil::_getHttpPath(); $object_link .= "/goto.php?target=" . $obj_type . "_" . $a_ref_id . "&client_id=" . CLIENT_ID; $this->appendBody($object_link); $this->appendBody("\n\n"); $this->appendBody(ilMail::_getAutoGeneratedMessageString($this->getLanguage())); $this->appendBody(ilMail::_getInstallationSignature()); // #10044 $mail = new ilMail($ilUser->getId()); $mail->enableSOAP(false); // #10410 $mail->sendMail(ilObjUser::_lookupLogin($a_user_id), null, null, $this->getSubject(), $this->getBody(), null, array("system")); }
/** * Copy items * * @param * @return */ function copyItems($a_new_obj) { global $ilUser; include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; foreach ($this->readItems(true) as $item) { // copy media object $mob_id = $item["mob_id"]; $mob = new ilObjMediaObject($mob_id); $new_mob = $mob->duplicate(); // copy news item // create new media cast item include_once "./Services/News/classes/class.ilNewsItem.php"; $mc_item = new ilNewsItem(); $mc_item->setMobId($new_mob->getId()); $mc_item->setContentType(NEWS_AUDIO); $mc_item->setContextObjId($a_new_obj->getId()); $mc_item->setContextObjType($a_new_obj->getType()); $mc_item->setUserId($ilUser->getId()); $mc_item->setPlaytime($item["playtime"]); $mc_item->setTitle($item["title"]); $mc_item->setContent($item["content"]); $mc_item->setVisibility($item["visibility"]); $mc_item->create(); } }
/** * Get's the repository object ID of a parent object, if possible * * see ilWebAccessChecker */ function getParentObjectIdForUsage($a_usage, $a_include_all_access_obj_ids = false) { if (is_int(strpos($a_usage["type"], ":"))) { $us_arr = explode(":", $a_usage["type"]); $type = $us_arr[1]; $cont_type = $us_arr[0]; } else { $type = $a_usage["type"]; } $id = $a_usage["id"]; $obj_id = false; switch ($type) { // RTE / tiny mce case "html": switch ($cont_type) { case "qpl": // Question Pool *Question* Text (Test) include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $qinfo = assQuestion::_getQuestionInfo($id); if ($qinfo["original_id"] > 0) { include_once "./Modules/Test/classes/class.ilObjTest.php"; $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id); // usage in test } else { $obj_id = $qinfo["obj_fi"]; // usage in pool } break; case "spl": // Question Pool *Question* Text (Survey) include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php"; $quest = SurveyQuestion::_instanciateQuestion($id); if ($quest) { if ($quest->getOriginalId() > 0) { $obj_id = $quest->getSurveyId(); } else { $obj_id = $quest->getObjId(); // usage in pool } unset($quest); } break; case "exca": // Exercise assignment $returned_pk = $a_usage['id']; // we are just checking against exercise object include_once 'Modules/Exercise/classes/class.ilObjExercise.php'; $obj_id = ilObjExercise::lookupExerciseIdForReturnedId($returned_pk); break; case "frm": // Forum $post_pk = $a_usage['id']; include_once 'Modules/Forum/classes/class.ilForumPost.php'; include_once 'Modules/Forum/classes/class.ilForum.php'; $oPost = new ilForumPost($post_pk); $frm_pk = $oPost->getForumId(); $obj_id = ilForum::_lookupObjIdForForumId($frm_pk); break; // temporary items (per user) // temporary items (per user) case "frm~": case "exca~": $obj_id = $a_usage['id']; break; // "old" category pages // "old" category pages case "cat": // InfoScreen Text // InfoScreen Text case "tst": case "svy": // data collection // data collection case "dcl": $obj_id = $id; break; } break; // page editor // page editor case "pg": switch ($cont_type) { case "qpl": // Question Pool Question Pages include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $qinfo = assQuestion::_getQuestionInfo($id); if ($qinfo["original_id"] > 0) { include_once "./Modules/Test/classes/class.ilObjTest.php"; $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id); // usage in test } else { $obj_id = $qinfo["obj_fi"]; // usage in pool } break; case "lm": case "dbk": // learning modules include_once "./Modules/LearningModule/classes/class.ilLMObject.php"; $obj_id = ilLMObject::_lookupContObjID($id); break; case "gdf": // glossary definition include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php"; include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php"; $term_id = ilGlossaryDefinition::_lookupTermId($id); $obj_id = ilGlossaryTerm::_lookGlossaryID($term_id); break; case "wpg": // wiki page include_once 'Modules/Wiki/classes/class.ilWikiPage.php'; $obj_id = ilWikiPage::lookupObjIdByPage($id); break; case "sahs": // sahs page // can this implementation be used for other content types, too? include_once './Services/COPage/classes/class.ilPageObject.php'; $obj_id = ilPageObject::lookupParentId($id, 'sahs'); break; case "prtf": // portfolio include_once "Modules/Portfolio/classes/class.ilPortfolioPage.php"; $obj_id = ilPortfolioPage::findPortfolioForPage($id); break; case "prtt": // portfolio template include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php"; $obj_id = ilPortfolioTemplatePage::findPortfolioForPage($id); break; case "blp": // blog include_once './Services/COPage/classes/class.ilPageObject.php'; $obj_id = ilPageObject::lookupParentId($id, 'blp'); break; case "crs": case "grp": case "cat": case "fold": case "root": // repository pages $obj_id = $id; break; } break; // Media Pool // Media Pool case "mep": $obj_id = $id; break; // News Context Object (e.g. MediaCast) // News Context Object (e.g. MediaCast) case "news": include_once "./Services/News/classes/class.ilNewsItem.php"; $obj_id = ilNewsItem::_lookupContextObjId($id); break; } return $obj_id; }
/** * Moves all posts within the current thread to a new forum * * @param integer $old_obj_id object id of the current forum * @param integer $old_pk primary key of old forum * @param integer $new_obj_id object id of the new forum * @param integer $new_pk primary key of new forum * @return integer number of afffected rows by updating posts * @access public */ public function movePosts($old_obj_id, $old_pk, $new_obj_id, $new_pk) { global $ilDB; if ($this->id) { $nodes = $this->getAllPosts(); if (is_array($nodes)) { // Move attachments foreach ($nodes as $node) { $file_obj = new ilFileDataForum((int) $old_obj_id, (int) $node->pos_pk); $file_obj->moveFilesOfPost((int) $new_obj_id); unset($file_obj); } } $this->db->lockTables(array(0 => array('name' => 'frm_user_read', 'type' => ilDB::LOCK_WRITE), 1 => array('name' => 'frm_thread_access', 'type' => ilDB::LOCK_WRITE))); $this->db->manipulateF(' DELETE FROM frm_user_read WHERE obj_id = %s AND thread_id =%s', array('integer', 'integer'), array($new_obj_id, $this->id)); $this->db->manipulateF(' UPDATE frm_user_read SET obj_id = %s WHERE thread_id = %s', array('integer', 'integer'), array($new_obj_id, $this->id)); $this->db->manipulateF(' DELETE FROM frm_thread_access WHERE obj_id = %s AND thread_id =%s', array('integer', 'integer'), array($new_obj_id, $this->id)); $this->db->manipulateF(' UPDATE frm_thread_access SET obj_id = %s WHERE thread_id =%s', array('integer', 'integer'), array($new_obj_id, $this->id)); $this->db->unlockTables(); $this->db->manipulateF(' UPDATE frm_posts SET pos_top_fk = %s WHERE pos_thr_fk = %s', array('integer', 'integer'), array($new_pk, $this->id)); // update all related news $posts = $ilDB->queryf(' SELECT * FROM frm_posts WHERE pos_thr_fk = %s', array('integer'), array($this->id)); $old_obj_id = ilForum::_lookupObjIdForForumId($old_pk); $new_obj_id = ilForum::_lookupObjIdForForumId($new_pk); while ($post = $posts->fetchRow(DB_FETCHMODE_ASSOC)) { include_once "./Services/News/classes/class.ilNewsItem.php"; $news_id = ilNewsItem::getFirstNewsIdForContext($old_obj_id, "frm", $post["pos_pk"], "pos"); $news_item = new ilNewsItem($news_id); $news_item->setContextObjId($new_obj_id); $news_item->update(); //echo "<br>-".$post["pos_pk"]."-".$old_obj_id."-".$new_obj_id."-"; } return count($nodes); } return 0; }
/** * Handle player event * * @param * @return */ function handlePlayerEventObject() { if ($_GET["event"] == "play") { $player = explode("_", $_GET["player"]); $news_id = (int) $player[1]; include_once "./Services/News/classes/class.ilNewsItem.php"; $item = new ilNewsItem($news_id); $item->increasePlayCounter(); } exit; }
/** * Import record * * @param * @return */ function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version) { //echo $a_entity; //var_dump($a_rec); switch ($a_entity) { case "news": $mob_id = null; if ($a_rec["MobId"] > 0) { $mob_id = $a_mapping->getMapping("Services/MediaObjects", "mob", $a_rec["MobId"]); } $c = (int) $a_rec["ContextObjId"] . ":" . $a_rec["ContextObjType"] . ":" . (int) $a_rec["ContextSubObjId"] . ":" . $a_rec["ContextSubObjType"]; $context = $a_mapping->getMapping("Services/News", "news_context", $c); $context = explode(":", $context); //var_dump($c); //var_dump($a_mapping->mappings["Services/News"]["news_context"]); include_once "./Services/News/classes/class.ilNewsItem.php"; $newObj = new ilNewsItem(); $newObj->setTitle($a_rec["Title"]); $newObj->setContent($a_rec["Content"]); $newObj->setPriority($a_rec["Priority"]); $newObj->setContextObjId($context[0]); $newObj->setContextObjType($context[1]); $newObj->setContextSubObjId($context[2]); $newObj->setContextSubObjType($context[3]); $newObj->setContentType($a_rec["ContentType"]); $newObj->setVisibility($a_rec["Visibility"]); $newObj->setContentLong($a_rec["ContentLong"]); $newObj->setContentIsLangVar($a_rec["ContentIsLangVar"]); $newObj->setMobId($mob_id); $newObj->setPlaytime($a_rec["Playtime"]); $newObj->create(); $a_mapping->addMapping("Services/News", "news", $a_rec["Id"], $newObj->getId()); break; } }
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); } } }
function addNewsNotification($a_lang_var) { // BEGIN WebDAV Suppress news notification for hidden files if ($this->isHidden()) { return; } // END WebDAV Suppress news notification for hidden files global $ilUser; // Add Notification to news include_once "./Services/News/classes/class.ilNewsItem.php"; include_once "./Modules/File/classes/class.ilObjFileAccess.php"; $news_item = new ilNewsItem(); $news_item->setContext($this->getId(), $this->getType()); $news_item->setPriority(NEWS_NOTICE); $news_item->setTitle($a_lang_var); $news_item->setContentIsLangVar(true); if ($this->getDescription() != "") { $news_item->setContent("<p>" . $this->getDescription() . "</p>"); } $news_item->setUserId($ilUser->getId()); $news_item->setVisibility(NEWS_USERS); $news_item->create(); }
/** * Show settings screen. */ function editSettings(ilPropertyFormGUI $a_private_form = null) { global $ilUser, $lng, $ilCtrl, $ilSetting; $news_set = new ilSetting("news"); $enable_internal_rss = $news_set->get("enable_rss_for_internal"); $allow_shorter_periods = $news_set->get("allow_shorter_periods"); $allow_longer_periods = $news_set->get("allow_longer_periods"); $enable_private_feed = $news_set->get("enable_private_feed"); if (!$a_private_form && ($allow_shorter_periods || $allow_longer_periods)) { include_once "./Services/Form/classes/class.ilPropertyFormGUI.php"; $form = new ilPropertyFormGUI(); $form->setFormAction($ilCtrl->getFormaction($this)); $form->setTitle($lng->txt("news_settings")); include_once "./Services/News/classes/class.ilNewsItem.php"; $default_per = ilNewsItem::_lookupDefaultPDPeriod(); $per = ilNewsItem::_lookupUserPDPeriod($ilUser->getId()); $form->setTableWidth("100%"); $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")); $unset = array(); foreach ($per_opts as $k => $opt) { if (!$allow_shorter_periods && $k < $default_per) { $unset[$k] = $k; } if (!$allow_longer_periods && $k > $default_per) { $unset[$k] = $k; } } foreach ($unset as $k) { unset($per_opts[$k]); } $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) $per); $form->addItem($per_sel); //$form->addCheckboxProperty($lng->txt("news_public_feed"), "notifications_public_feed", // "1", $public_feed, $lng->txt("news_public_feed_info")); //if ($this->getProperty("public_notifications_option")) //{ // $form->addCheckboxProperty($lng->txt("news_notifications_public"), "notifications_public", // "1", $public, $lng->txt("news_notifications_public_info")); //} $form->addCommandButton("saveSettings", $lng->txt("save")); $form->addCommandButton("cancelSettings", $lng->txt("cancel")); $returnForm = $form->getHTML(); } if ($enable_private_feed) { if (!$a_private_form) { $a_private_form = $this->initPrivateSettingsForm(); } $returnForm .= $returnForm == "" ? $a_private_form->getHTML() : "<br>" . $a_private_form->getHTML(); } return $returnForm; }
/** * * * @param * @return */ function checkAccessMobUsage($usage, $oid) { /** * @var $ilObjDataCache ilObjectDataCache */ global $ilObjDataCache; switch ($usage['type']) { case 'lm:pg': if ($oid > 0) { if ($this->checkAccessLM($oid, 'lm', $usage['id'])) { return true; } } break; case 'news': // media objects in news (media casts) include_once "./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php"; include_once "./Services/News/classes/class.ilNewsItem.php"; if ($this->checkAccessObject($oid, 'mcst')) { return true; } elseif (ilObjMediaCastAccess::_lookupPublicFiles($oid) && ilNewsItem::_lookupVisibility($usage["id"]) == NEWS_PUBLIC) { return true; } break; case 'dcl:html': include_once "./Modules/DataCollection/classes/class.ilObjDataCollectionAccess.php"; include_once "./Services/Object/classes/class.ilObject2.php"; $ref_ids = ilObject2::_getAllReferences($oid); foreach ($ref_ids as $ref_id) { if (ilObjDataCollectionAccess::_checkAccess("view", "read", $ref_id, $oid)) { return true; } } break; case 'frm~:html': // $oid = userid foreach ($this->check_users as $user_id) { if ($ilObjDataCache->lookupType($oid) == 'usr' && $oid == $user_id) { return true; } } break; case 'qpl:pg': case 'qpl:html': // test questions if ($this->checkAccessTestQuestion($oid, $usage['id'])) { return true; } break; case 'gdf:pg': // special check for glossary terms if ($this->checkAccessGlossaryTerm($oid, $usage['id'])) { return true; } break; case 'sahs:pg': // check for scorm pages if ($this->checkAccessObject($oid, 'sahs')) { return true; } break; case 'prtf:pg': // special check for portfolio pages if ($this->checkAccessPortfolioPage($oid, $usage['id'])) { return true; } break; case 'blp:pg': // special check for blog pages if ($this->checkAccessBlogPage($oid, $usage['id'])) { return true; } break; default: // standard object check if ($this->checkAccessObject($oid)) { return true; } break; } return false; }
public function __appendChildLinks($html, $item, &$item_list_gui) { if (!count($item['child'])) { return $html; } $tpl = new ilTemplate('tpl.detail_links.html', true, true, 'Services/Search'); switch ($item['type']) { case 'lm': $tpl->setVariable("HITS", $this->lng->txt('search_hits')); include_once 'Modules/LearningModule/classes/class.ilLMObject.php'; foreach ($item['child'] as $child) { $tpl->setCurrentBlock("link_row"); switch (ilLMObject::_lookupType($child)) { case 'pg': $tpl->setVariable("CHAPTER_PAGE", $this->lng->txt('obj_pg')); break; case 'st': $tpl->setVariable("CHAPTER_PAGE", $this->lng->txt('obj_st')); break; } $item_list_gui->setChildId($child); $tpl->setVariable("SEPERATOR", ' -> '); $tpl->setVariable("LINK", $item_list_gui->getCommandLink('page')); $tpl->setVariable("TARGET", $item_list_gui->getCommandFrame('page')); $tpl->setVariable("TITLE", ilLMObject::_lookupTitle($child)); $tpl->parseCurrentBlock(); } break; case 'frm': $tpl->setVariable("HITS", $this->lng->txt('search_hits')); include_once './Modules/Forum/classes/class.ilObjForum.php'; foreach ($item['child'] as $child) { $thread_post = explode('_', $child); $tpl->setCurrentBlock("link_row"); $tpl->setVariable("CHAPTER_PAGE", $this->lng->txt('thread')); $item_list_gui->setChildId($thread_post); $tpl->setVariable("SEPERATOR", ': '); $tpl->setVariable("LINK", $item_list_gui->getCommandLink('posting')); $tpl->setVariable("TARGET", $item_list_gui->getCommandFrame('')); $tpl->setVariable("TITLE", ilObjForum::_lookupThreadSubject($thread_post[0])); $tpl->parseCurrentBlock(); } break; case 'glo': $tpl->setVariable("HITS", $this->lng->txt('search_hits')); include_once './Modules/Glossary/classes/class.ilGlossaryTerm.php'; $this->lng->loadLanguageModule('content'); foreach ($item['child'] as $child) { $tpl->setCurrentBlock("link_row"); $tpl->setVariable("CHAPTER_PAGE", $this->lng->txt('cont_term')); $tpl->setVariable("SEPERATOR", ': '); $tpl->setVariable("LINK", ilLink::_getLink($item['ref_id'], 'git', array('target' => 'git_' . $child . '_' . $item['ref_id']))); $tpl->setVariable("TITLE", ilGlossaryTerm::_lookGlossaryTerm($child)); $tpl->parseCurrentBlock(); } break; case 'wiki': $tpl->setVariable("HITS", $this->lng->txt('search_hits')); include_once './Modules/Wiki/classes/class.ilWikiPage.php'; include_once './Modules/Wiki/classes/class.ilWikiUtil.php'; $this->lng->loadLanguageModule('wiki'); foreach ($item['child'] as $child) { $page_title = ilWikiPage::lookupTitle($child); $tpl->setCurrentBlock("link_row"); $tpl->setVariable("CHAPTER_PAGE", $this->lng->txt('wiki_page')); $tpl->setVariable("SEPERATOR", ': '); $tpl->setVariable("LINK", ilLink::_getLink($item['ref_id'], 'wiki', array(), "_" . ilWikiUtil::makeUrlTitle($page_title))); $tpl->setVariable("TITLE", $page_title); $tpl->parseCurrentBlock(); } break; case 'mcst': $tpl->setVariable("HITS", $this->lng->txt('search_hits')); include_once "./Services/News/classes/class.ilNewsItem.php"; foreach ($item['child'] as $child) { $tpl->setCurrentBlock("link_row"); //$tpl->setVariable("CHAPTER_PAGE",$this->lng->txt('item')); $item_list_gui->setChildId($child); //$tpl->setVariable("SEPERATOR",': '); $tpl->setVariable("LINK", $item_list_gui->getCommandLink('listItems')); $tpl->setVariable("TARGET", $item_list_gui->getCommandFrame('')); $tpl->setVariable("TITLE", ilNewsItem::_lookupTitle($child)); $tpl->parseCurrentBlock(); } break; default: } return $html . $tpl->get(); }
/** * delete object or referenced object * (in the case of a referenced object, object data is only deleted * if last reference is deleted) * This function removes an object entirely from system!! * * @access public * @return boolean true if object was removed completely; false if only a references was removed */ function delete() { global $rbacadmin, $log, $ilDB; $remove = false; // delete object_data entry if (!$this->referenced || $this->countReferences() == 1) { // check type match $db_type = ilObject::_lookupType($this->getId()); if ($this->type != $db_type) { $message = "ilObject::delete(): Type mismatch. Object with obj_id: " . $this->id . " " . "was instantiated by type '" . $this->type . "'. DB type is: " . $db_type; // write log entry $log->write($message); // raise error $this->ilias->raiseError("ilObject::delete(): Type mismatch. (" . $this->type . "/" . $this->id . ")", $this->ilias->error_obj->WARNING); } // delete entry in object_data $q = "DELETE FROM object_data " . "WHERE obj_id = " . $ilDB->quote($this->getId(), "integer"); $ilDB->manipulate($q); // delete long description $query = "DELETE FROM object_description WHERE obj_id = " . $ilDB->quote($this->getId(), "integer"); $ilDB->manipulate($query); // write log entry $log->write("ilObject::delete(), deleted object, obj_id: " . $this->getId() . ", type: " . $this->getType() . ", title: " . $this->getTitle()); // remove news include_once "./Services/News/classes/class.ilNewsItem.php"; $news_item = new ilNewsItem(); $news_item->deleteNewsOfContext($this->getId(), $this->getType()); include_once "./Services/Block/classes/class.ilBlockSetting.php"; ilBlockSetting::_deleteSettingsOfBlock($this->getId(), "news"); include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php'; ilDidacticTemplateObjSettings::deleteByObjId($this->getId()); /* remove notes (see infoscreen gui) as they can be seen as personal data we are keeping them for now include_once("Services/Notes/classes/class.ilNote.php"); foreach(array(IL_NOTE_PRIVATE, IL_NOTE_PUBLIC) as $note_type) { foreach(ilNote::_getNotesOfObject($this->id, 0, $this->type, $note_type) as $note) { $note->delete(); } } */ // BEGIN WebDAV: Delete WebDAV properties $query = "DELETE FROM dav_property " . "WHERE obj_id = " . $ilDB->quote($this->getId(), 'integer'); $res = $ilDB->manipulate($query); // END WebDAV: Delete WebDAV properties include_once './Services/Tracking/classes/class.ilChangeEvent.php'; ilChangeEvent::_delete($this->getId()); include_once './Services/Tracking/classes/class.ilLPCollections.php'; ilLPCollections::_deleteAll($this->getId()); include_once './Services/WebServices/ECS/classes/class.ilECSImport.php'; ilECSImport::_deleteByObjId($this->getId()); $remove = true; } else { // write log entry $log->write("ilObject::delete(), object not deleted, number of references: " . $this->countReferences() . ", obj_id: " . $this->getId() . ", type: " . $this->getType() . ", title: " . $this->getTitle()); } // delete object_reference entry if ($this->referenced) { include_once "Services/Object/classes/class.ilObjectActivation.php"; ilObjectActivation::deleteAllEntries($this->getRefId()); // delete entry in object_reference $query = "DELETE FROM object_reference " . "WHERE ref_id = " . $ilDB->quote($this->getRefId(), 'integer'); $res = $ilDB->manipulate($query); // write log entry $log->write("ilObject::delete(), reference deleted, ref_id: " . $this->getRefId() . ", obj_id: " . $this->getId() . ", type: " . $this->getType() . ", title: " . $this->getTitle()); // DELETE PERMISSION ENTRIES IN RBAC_PA // DONE: method overwritten in ilObjRole & ilObjUser. // this call only applies for objects in rbac (not usr,role,rolt) // TODO: Do this for role templates too $rbacadmin->revokePermission($this->getRefId(), 0, false); include_once "Services/AccessControl/classes/class.ilRbacLog.php"; ilRbacLog::delete($this->getRefId()); // Remove applied didactic template setting include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php'; ilDidacticTemplateObjSettings::deleteByRefId($this->getRefId()); // Remove desktop items ilUtil::removeItemFromDesktops($this->getRefId()); } // remove conditions if ($this->referenced) { $ch =& new ilConditionHandler(); $ch->delete($this->getRefId()); unset($ch); } return $remove; }
/** * 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()); }
/** * Create */ function updateNews($a_update = false) { global $ilUser; $news_set = new ilSetting("news"); $default_visibility = $news_set->get("default_visibility") != "" ? $news_set->get("default_visibility") : "users"; include_once "./Services/News/classes/class.ilNewsItem.php"; if (!$a_update) { $news_item = new ilNewsItem(); $news_item->setContext($this->getWikiId(), "wiki", $this->getId(), "wpg"); $news_item->setPriority(NEWS_NOTICE); $news_item->setTitle($this->getTitle()); $news_item->setContentTextIsLangVar(true); $news_item->setContent("wiki_news_page_created"); $news_item->setUserId($ilUser->getId()); $news_item->setVisibility($default_visibility); $news_item->create(); } else { // get last news item of the day (if existing) $news_id = ilNewsItem::getLastNewsIdForContext($this->getWikiId(), "wiki", $this->getId(), "wpg", true); if ($news_id > 0) { $news_item = new ilNewsItem($news_id); $news_item->setContent("wiki_news_page_changed"); $news_item->setUserId($ilUser->getId()); $news_item->setTitle($this->getTitle()); $news_item->setContentTextIsLangVar(true); $news_item->update(true); } else { $news_item = new ilNewsItem(); $news_item->setContext($this->getWikiId(), "wiki", $this->getId(), "wpg"); $news_item->setPriority(NEWS_NOTICE); $news_item->setTitle($this->getTitle()); $news_item->setContentTextIsLangVar(true); $news_item->setContent("wiki_news_page_changed"); $news_item->setUserId($ilUser->getId()); $news_item->setVisibility($default_visibility); $news_item->create(); } } }
/** * * * @param * @return */ function checkAccessMobUsage($usage, $oid) { /** * @var $ilObjDataCache ilObjectDataCache */ global $ilObjDataCache; switch ($usage['type']) { case 'lm:pg': if ($this->checkAccessObject($oid, 'lm')) { return true; } /* as $usage['id'] (== page) is not processed anymore, we can use standard if ($oid > 0) { if ($this->checkAccessLM($oid, 'lm', $usage['id'])) { return true; } } */ break; case 'news': // media objects in news (media casts) include_once "./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php"; include_once "./Services/News/classes/class.ilNewsItem.php"; if ($this->checkAccessObject($oid, 'mcst')) { return true; } elseif (ilObjMediaCastAccess::_lookupPublicFiles($oid) && ilNewsItem::_lookupVisibility($usage["id"]) == NEWS_PUBLIC) { return true; } break; /* see default case 'dcl:html': include_once("./Modules/DataCollection/classes/class.ilObjDataCollectionAccess.php"); include_once("./Services/Object/classes/class.ilObject2.php"); $ref_ids = ilObject2::_getAllReferences($oid); foreach($ref_ids as $ref_id) if(ilObjDataCollectionAccess::_checkAccess("view", "read", $ref_id, $oid)) return true; break; */ /* see default case 'dcl:html': include_once("./Modules/DataCollection/classes/class.ilObjDataCollectionAccess.php"); include_once("./Services/Object/classes/class.ilObject2.php"); $ref_ids = ilObject2::_getAllReferences($oid); foreach($ref_ids as $ref_id) if(ilObjDataCollectionAccess::_checkAccess("view", "read", $ref_id, $oid)) return true; break; */ case 'frm~:html': case 'exca~:html': // $oid = userid foreach ($this->check_users as $user_id) { if ($ilObjDataCache->lookupType($oid) == 'usr' && $oid == $user_id) { return true; } } break; case 'qpl:pg': case 'qpl:html': // test questions if ($this->checkAccessTestQuestion($oid, $usage['id'])) { return true; } break; case 'gdf:pg': // special check for glossary terms if ($this->checkAccessGlossaryTerm($oid, $usage['id'])) { return true; } break; case 'sahs:pg': // check for scorm pages if ($this->checkAccessObject($oid, 'sahs')) { return true; } break; case 'prtf:pg': // special check for portfolio pages if ($this->checkAccessPortfolioPage($oid, $usage['id'])) { return true; } break; case 'blp:pg': // special check for blog pages if ($this->checkAccessBlogPage($oid, $usage['id'])) { return true; } break; case 'lobj:pg': // special check for learning objective pages if ($this->checkAccessLearningObjectivePage($oid, $usage['id'])) { return true; } break; case 'impr:pg': include_once 'Services/Imprint/classes/class.ilImprint.php'; return ilImprint::isActive() || $this->checkAccessObject(SYSTEM_FOLDER_ID, 'adm'); case 'cstr:pg': default: // standard object check if ($this->checkAccessObject($oid)) { return true; } break; } return false; }
/** * 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")); }
/** * Send news mail for 1 object and 1 user * * @param int $a_user_id * @param int $a_ref_id * @param array $news */ protected function sendMail($a_user_id, $a_ref_id, array $news) { global $lng, $ilUser; $obj_id = ilObject::_lookupObjId($a_ref_id); $obj_type = ilObject::_lookupType($obj_id); include_once "./Services/Notification/classes/class.ilSystemNotification.php"; $ntf = new ilSystemNotification(); $ntf->setLangModules(array("crs", "news")); $ntf->setRefId($a_ref_id); $ntf->setGotoLangId('url'); $ntf->setSubjectLangId('crs_subject_course_group_notification'); // user specific language $lng = $ntf->getUserLanguage($a_user_id); $obj_title = $lng->txt($obj_type) . " \"" . ilObject::_lookupTitle($obj_id) . "\""; $ntf->setIntroductionDirect(sprintf($lng->txt("crs_intro_course_group_notification_for"), $obj_title)); $subject = sprintf($lng->txt("crs_subject_course_group_notification"), $obj_title); // news summary $counter = 1; $txt = ""; foreach ($news as $item) { $title = ilNewsItem::determineNewsTitle($item["context_obj_type"], $item["title"], $item["content_is_lang_var"], $item["agg_ref_id"], $item["aggregation"]); $content = ilNewsItem::determineNewsContent($item["context_obj_type"], $item["content"], $item["content_text_is_lang_var"]); $obj_id = ilObject::_lookupObjId($item["ref_id"]); $obj_title = ilObject::_lookupTitle($obj_id); // path include_once './Services/Locator/classes/class.ilLocatorGUI.php'; $cont_loc = new ilLocatorGUI(); $cont_loc->addContextItems($item["ref_id"], true); $cont_loc->setTextOnly(true); // #9954/#10044 // see ilInitialisation::requireCommonIncludes() @(include_once "HTML/Template/ITX.php"); // new implementation if (class_exists("HTML_Template_ITX")) { include_once "./Services/UICore/classes/class.ilTemplateHTMLITX.php"; } else { include_once "HTML/ITX.php"; // old implementation include_once "./Services/UICore/classes/class.ilTemplateITX.php"; } require_once "./Services/UICore/classes/class.ilTemplate.php"; $loc = "[" . $cont_loc->getHTML() . "]"; if ($counter > 1) { $txt .= $ntf->getBlockBorder(); } $txt .= '#' . $counter . " - " . $loc . " " . $obj_title . "\n\n"; $txt .= $title; if ($content) { $txt .= "\n" . $content; } $txt .= "\n\n"; ++$counter; } $ntf->addAdditionalInfo("news", $txt, true); // #10044 $mail = new ilMail($ilUser->getId()); $mail->enableSOAP(false); // #10410 $mail->sendMail(ilObjUser::_lookupLogin($a_user_id), null, null, $subject, $ntf->composeAndGetMessage($a_user_id, null, "read", true), null, array("system")); }
function setPrivateFeedId($a_userId) { ilNewsItem::$privFeedId = $a_userId; }
public function createSettings() { // news settings (public notifications yes/no) include_once "./Services/News/classes/class.ilNewsItem.php"; $default_visibility = ilNewsItem::_getDefaultVisibilityForRefId($_GET["ref_id"]); if ($default_visibility == "public") { ilBlockSetting::_write("news", "public_notifications", 1, 0, $this->getId()); } return true; }
/** * Init setting form */ function initSettingsForm() { global $ilUser, $lng, $ilCtrl, $ilSetting, $ilTabs; $ilTabs->clearTargets(); $news_set = new ilSetting("news"); $enable_internal_rss = $news_set->get("enable_rss_for_internal"); $public = ilBlockSetting::_lookup($this->getBlockType(), "public_notifications", 0, $this->block_id); $public_feed = ilBlockSetting::_lookup($this->getBlockType(), "public_feed", 0, $this->block_id); $hide_block = ilBlockSetting::_lookup($this->getBlockType(), "hide_news_block", 0, $this->block_id); $hide_news_per_date = ilBlockSetting::_lookup($this->getBlockType(), "hide_news_per_date", 0, $this->block_id); $hide_news_date = ilBlockSetting::_lookup($this->getBlockType(), "hide_news_date", 0, $this->block_id); if ($hide_news_date != "") { $hide_news_date = explode(" ", $hide_news_date); } include_once "./Services/Form/classes/class.ilPropertyFormGUI.php"; $this->settings_form = new ilPropertyFormGUI(); $this->settings_form->setTitle($lng->txt("news_settings")); $this->settings_form->setTitleIcon(ilUtil::getImagePath("icon_news.png")); // hide news block for learners if ($this->getProperty("hide_news_block_option")) { $ch = new ilCheckboxInputGUI($lng->txt("news_hide_news_block"), "hide_news_block"); $ch->setInfo($lng->txt("news_hide_news_block_info")); $ch->setChecked($hide_block); $this->settings_form->addItem($ch); $hnpd = new ilCheckboxInputGUI($lng->txt("news_hide_news_per_date"), "hide_news_per_date"); $hnpd->setInfo($lng->txt("news_hide_news_per_date_info")); $hnpd->setChecked($hide_news_per_date); $dt_prop = new ilDateTimeInputGUI($lng->txt("news_hide_news_date"), "hide_news_date"); if ($hide_news_date != "") { $dt_prop->setDate(new ilDateTime($hide_news_date[0] . ' ' . $hide_news_date[1], IL_CAL_DATETIME)); } #$dt_prop->setDate($hide_news_date[0]); #$dt_prop->setTime($hide_news_date[1]); $dt_prop->setShowTime(true); //$dt_prop->setInfo($lng->txt("news_hide_news_date_info")); $hnpd->addSubItem($dt_prop); $this->settings_form->addItem($hnpd); } // default visibility if ($this->getProperty("default_visibility_option") && $enable_internal_rss) { $default_visibility = ilBlockSetting::_lookup($this->getBlockType(), "default_visibility", 0, $this->block_id); if ($default_visibility == "") { $default_visibility = ilNewsItem::_getDefaultVisibilityForRefId($_GET["ref_id"]); } // Default Visibility $radio_group = new ilRadioGroupInputGUI($lng->txt("news_default_visibility"), "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($default_visibility); $this->settings_form->addItem($radio_group); } // public notifications if ($this->getProperty("public_notifications_option") && $enable_internal_rss) { $ch = new ilCheckboxInputGUI($lng->txt("news_notifications_public"), "notifications_public"); $ch->setInfo($lng->txt("news_notifications_public_info")); $ch->setChecked($public); $this->settings_form->addItem($ch); } // extra rss feed if ($enable_internal_rss) { $ch = new ilCheckboxInputGUI($lng->txt("news_public_feed"), "notifications_public_feed"); $ch->setInfo($lng->txt("news_public_feed_info")); $ch->setChecked($public_feed); $this->settings_form->addItem($ch); } //$this->settings_form->addCheckboxProperty($lng->txt("news_public_feed"), "notifications_public_feed", // "1", $public_feed, $lng->txt("news_public_feed_info")); //if ($this->getProperty("public_notifications_option")) //{ // $this->settings_form->addCheckboxProperty($lng->txt("news_notifications_public"), "notifications_public", // "1", $public, $lng->txt("news_notifications_public_info")); //} $this->settings_form->addCommandButton("saveSettings", $lng->txt("save")); $this->settings_form->addCommandButton("cancelSettings", $lng->txt("cancel")); $this->settings_form->setFormAction($ilCtrl->getFormaction($this)); }
public function savePostObject() { /** * @var $ilUser ilObjUser * @var $ilAccess ilAccessHandler * @var $lng ilLanguage */ global $ilUser, $ilAccess, $lng; if (!isset($_POST['del_file']) || !is_array($_POST['del_file'])) { $_POST['del_file'] = array(); } if ($this->objCurrentTopic->isClosed()) { $_GET['action'] = ''; return $this->viewThreadObject(); } $oReplyEditForm = $this->getReplyEditForm(); if ($oReplyEditForm->checkInput()) { require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php'; if ($ilUser->isAnonymous() && !$ilUser->isCaptchaVerified() && ilCaptchaUtil::isActiveForForum()) { $ilUser->setCaptchaVerified(true); } // init objects $oForumObjects = $this->getForumObjects(); /** * @var $forumObj ilObjForum */ $forumObj = $oForumObjects['forumObj']; /** * @var $frm ilForum */ $frm = $oForumObjects['frm']; $frm->setMDB2WhereCondition(' top_frm_fk = %s ', array('integer'), array($frm->getForumId())); $topicData = $frm->getOneTopic(); // Generating new posting if ($_GET['action'] == 'ready_showreply') { if (!$ilAccess->checkAccess('add_reply', '', (int) $_GET['ref_id'])) { $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE); } // reply: new post $status = 1; $send_activation_mail = 0; if ($this->objProperties->isPostActivationEnabled()) { if (!$this->is_moderator) { $status = 0; $send_activation_mail = 1; } else { if ($this->objCurrentPost->isAnyParentDeactivated()) { $status = 0; } } } if ($this->objProperties->isAnonymized()) { if (!strlen($oReplyEditForm->getInput('alias'))) { $user_alias = $this->lng->txt('forums_anonymous'); } else { $user_alias = $oReplyEditForm->getInput('alias'); } } else { $user_alias = $ilUser->getLogin(); } $newPost = $frm->generatePost($topicData['top_pk'], $this->objCurrentTopic->getId(), $ilUser->getId(), $this->objProperties->isAnonymized() ? 0 : $ilUser->getId(), ilRTE::_replaceMediaObjectImageSrc($oReplyEditForm->getInput('message'), 0), $this->objCurrentPost->getId(), (int) $oReplyEditForm->getInput('notify'), $this->handleFormInput($oReplyEditForm->getInput('subject'), false), $user_alias, '', $status, $send_activation_mail); // mantis #8115: Mark parent as read $this->object->markPostRead($ilUser->getId(), (int) $this->objCurrentTopic->getId(), (int) $this->objCurrentPost->getId()); // copy temporary media objects (frm~) include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php'; $mediaObjects = ilRTE::_getMediaObjects($oReplyEditForm->getInput('message'), 0); $myMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $ilUser->getId()); foreach ($mediaObjects as $mob) { foreach ($myMediaObjects as $myMob) { if ($mob == $myMob) { // change usage ilObjMediaObject::_removeUsage($mob, 'frm~:html', $ilUser->getId()); break; } } ilObjMediaObject::_saveUsage($mob, 'frm:html', $newPost); } $oFDForum = new ilFileDataForum($forumObj->getId(), $newPost); $file = $_FILES['userfile']; if (is_array($file) && !empty($file)) { $oFDForum->storeUploadedFile($file); } // FINALLY SEND MESSAGE if ($this->ilias->getSetting("forum_notification") == 1 && (int) $status) { $objPost = new ilForumPost((int) $newPost, $this->is_moderator); $post_data = array(); $post_data = $objPost->getDataAsArray(); $titles = $this->getTitlesByRefId(array($this->object->getRefId())); $post_data["top_name"] = $titles[0]; $post_data["ref_id"] = $this->object->getRefId(); $frm->__sendMessage($objPost->getParentId(), $post_data); $frm->sendForumNotifications($post_data); $frm->sendThreadNotifications($post_data); } $message = ''; if (!$this->is_moderator && !$status) { $message .= $lng->txt('forums_post_needs_to_be_activated'); } else { $message .= $lng->txt('forums_post_new_entry'); } $_SESSION['frm'][(int) $_GET['thr_pk']]['openTreeNodes'][] = (int) $this->objCurrentPost->getId(); ilUtil::sendSuccess($message, true); $this->ctrl->setParameter($this, 'pos_pk', $newPost); $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId()); $this->ctrl->redirect($this, 'viewThread'); } else { if (!$this->is_moderator && !$this->objCurrentPost->isOwner($ilUser->getId()) || $this->objCurrentPost->isCensored() || $ilUser->getId() == ANONYMOUS_USER_ID) { $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE); } // remove usage of deleted media objects include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php'; $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm:html', $this->objCurrentPost->getId()); $curMediaObjects = ilRTE::_getMediaObjects($oReplyEditForm->getInput('message'), 0); foreach ($oldMediaObjects as $oldMob) { $found = false; foreach ($curMediaObjects as $curMob) { if ($oldMob == $curMob) { $found = true; break; } } if (!$found) { if (ilObjMediaObject::_exists($oldMob)) { ilObjMediaObject::_removeUsage($oldMob, 'frm:html', $this->objCurrentPost->getId()); $mob_obj = new ilObjMediaObject($oldMob); $mob_obj->delete(); } } } // if post has been edited posting mus be activated again by moderator $status = 1; $send_activation_mail = 0; if ($this->objProperties->isPostActivationEnabled()) { if (!$this->is_moderator) { $status = 0; $send_activation_mail = 1; } else { if ($this->objCurrentPost->isAnyParentDeactivated()) { $status = 0; } } } $this->objCurrentPost->setStatus($status); $this->objCurrentPost->setSubject($this->handleFormInput($oReplyEditForm->getInput('subject'), false)); $this->objCurrentPost->setMessage(ilRTE::_replaceMediaObjectImageSrc($oReplyEditForm->getInput('message'), 0)); $this->objCurrentPost->setNotification((int) $oReplyEditForm->getInput('notify')); $this->objCurrentPost->setChangeDate(date('Y-m-d H:i:s')); $this->objCurrentPost->setUpdateUserId($ilUser->getId()); // edit: update post if ($this->objCurrentPost->update()) { $this->objCurrentPost->reload(); // Change news item accordingly include_once 'Services/News/classes/class.ilNewsItem.php'; // note: $this->objCurrentPost->getForumId() does not give us the forum ID here (why?) $news_id = ilNewsItem::getFirstNewsIdForContext($forumObj->getId(), 'frm', $this->objCurrentPost->getId(), 'pos'); if ($news_id > 0) { $news_item = new ilNewsItem($news_id); $news_item->setTitle($this->objCurrentPost->getSubject()); $news_item->setContent(ilRTE::_replaceMediaObjectImageSrc($frm->prepareText($this->objCurrentPost->getMessage(), 0), 1)); $news_item->update(); } // attachments $oFDForum = $oForumObjects['file_obj']; $file = $_FILES['userfile']; if (is_array($file) && !empty($file)) { $oFDForum->storeUploadedFile($file); } $file2delete = $oReplyEditForm->getInput('del_file'); if (is_array($file2delete) && count($file2delete)) { $oFDForum->unlinkFilesByMD5Filenames($file2delete); } } if (!$status && $send_activation_mail) { $pos_data = $this->objCurrentPost->getDataAsArray(); $pos_data["top_name"] = $this->object->getTitle(); $frm->sendPostActivationNotification($pos_data); } ilUtil::sendSuccess($lng->txt('forums_post_modified'), true); $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId()); $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId()); $this->ctrl->setParameter($this, 'viewmode', $_SESSION['viewmode']); $this->ctrl->redirect($this, 'viewThread'); } } else { $_GET['action'] = substr($_GET['action'], 6); } return $this->viewThreadObject(); }
/** * TABLE NewsForContext: Get table HTML. * */ public function getNewsForContextTable() { global $lng; $news_item = new ilNewsItem(); $news_item->setContextObjId($this->getContextObjId()); $news_item->setContextObjType($this->getContextObjType()); $news_item->setContextSubObjId($this->getContextSubObjId()); $news_item->setContextSubObjType($this->getContextSubObjType()); $perm_ref_id = 0; if (in_array($this->getContextObjType(), array("cat", "grp", "crs", "root"))) { $data = $news_item->getNewsForRefId($_GET["ref_id"], false, false, 0, true, false, true, true); } else { $perm_ref_id = $_GET["ref_id"]; if ($this->getContextSubObjId() > 0) { $data = $news_item->queryNewsForContext(false, 0, "", true, true); } else { $data = $news_item->queryNewsForContext(); } } include_once "Services/News/classes/class.ilNewsForContextTableGUI.php"; $table_gui = new ilNewsForContextTableGUI($this, "getNewsForContextTable", $perm_ref_id); $table_gui->setTitle($lng->txt("news_table_news_for_context")); $table_gui->setRowTemplate("tpl.table_row_news_for_context.html", "Services/News"); $table_gui->setData($data); $table_gui->setDefaultOrderField("creation_date"); $table_gui->setDefaultOrderDirection("desc"); $table_gui->addMultiCommand("confirmDeletionNewsItems", $lng->txt("delete")); $table_gui->setTitle($lng->txt("news"), "icon_news.png", $lng->txt("news")); $table_gui->setSelectAllCheckbox("news_id"); return $table_gui->getHTML(); }
/** * @param string $change */ public function addNews($obj_id, $change = 'created') { global $lng, $ilUser; $ilNewsItem = new ilNewsItem(); $ilNewsItem->setTitle($lng->txt('news_title_' . $change)); $ilNewsItem->setPriority(NEWS_NOTICE); $ilNewsItem->setContext($obj_id, $this->getType()); $ilNewsItem->setUserId($ilUser->getId()); $ilNewsItem->setVisibility(NEWS_USERS); $ilNewsItem->setContentTextIsLangVar(false); $ilNewsItem->create(); }
/** * delete page object */ function delete() { global $ilDB; $mobs = array(); $files = array(); if (!$this->page_not_found) { $this->buildDom(); $mobs = $this->collectMediaObjects(false); } $this->__beforeDelete(); // delete style usages $this->deleteStyleUsages(false); // delete internal links $this->deleteInternalLinks(); // delete all mob usages include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; ilObjMediaObject::_deleteAllUsages($this->getParentType() . ":pg", $this->getId()); // delete news include_once "./Services/News/classes/class.ilNewsItem.php"; ilNewsItem::deleteNewsOfContext($this->getParentId(), $this->getParentType(), $this->getId(), "pg"); // delete page_object entry $ilDB->manipulate("DELETE FROM page_object " . "WHERE page_id = " . $ilDB->quote($this->getId(), "integer") . " AND parent_type= " . $ilDB->quote($this->getParentType(), "text")); //$this->ilias->db->query($query); // delete media objects foreach ($mobs as $mob_id) { if (ilObject::_lookupType($mob_id) != 'mob') { $GLOBALS['ilLog']->write(__METHOD__ . ': Type mismatch. Ignoring mob with id: ' . $mob_id); continue; } if (ilObject::_exists($mob_id)) { $mob_obj =& new ilObjMediaObject($mob_id); $mob_obj->delete(); } } /* delete public and private notes (see PageObjectGUI->getNotesHTML()) as they can be seen as personal data we are keeping them for now include_once("Services/Notes/classes/class.ilNote.php"); foreach(array(IL_NOTE_PRIVATE, IL_NOTE_PUBLIC) as $note_type) { foreach(ilNote::_getNotesOfObject($this->getParentId(), $this->getId(), $this->getParentType(), $note_type) as $note) { $note->delete(); } } */ }
/** * delete post and sub-posts * @param integer $post: ID * @access public * @return integer 0 or thread-ID */ public function deletePost($post) { global $ilDB; include_once "./Modules/Forum/classes/class.ilObjForum.php"; // delete tree and get id's of all posts to delete $p_node = $this->getPostNode($post); $del_id = $this->deletePostTree($p_node); // Delete User read entries foreach ($del_id as $post_id) { ilObjForum::_deleteReadEntries($post_id); } // DELETE ATTACHMENTS ASSIGNED TO POST $this->__deletePostFiles($del_id); $dead_pos = count($del_id); $dead_thr = 0; // if deletePost is thread opener ... if ($p_node["parent"] == 0) { // delete thread access data include_once './Modules/Forum/classes/class.ilObjForum.php'; ilObjForum::_deleteAccessEntries($p_node['tree']); // delete thread $dead_thr = $p_node["tree"]; $statement = $ilDB->manipulateF(' DELETE FROM frm_threads WHERE thr_pk = %s', array('integer'), array($p_node['tree'])); // update num_threads $statement = $ilDB->manipulateF(' UPDATE frm_data SET top_num_threads = top_num_threads - 1 WHERE top_frm_fk = %s', array('integer'), array($this->id)); // delete all related news $posset = $ilDB->queryf(' SELECT * FROM frm_posts WHERE pos_thr_fk = %s', array('integer'), array($p_node['tree'])); while ($posrec = $ilDB->fetchAssoc($posset)) { include_once "./Services/News/classes/class.ilNewsItem.php"; $news_id = ilNewsItem::getFirstNewsIdForContext($this->id, "frm", $posrec["pos_pk"], "pos"); if ($news_id > 0) { $news_item = new ilNewsItem($news_id); $news_item->delete(); } try { include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php'; $mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $posrec['pos_pk']); foreach ($mobs as $mob) { if (ilObjMediaObject::_exists($mob)) { ilObjMediaObject::_removeUsage($mob, 'frm:html', $posrec['pos_pk']); $mob_obj = new ilObjMediaObject($mob); $mob_obj->delete(); } } } catch (Exception $e) { } } // delete all posts of this thread $statement = $ilDB->manipulateF(' DELETE FROM frm_posts WHERE pos_thr_fk = %s', array('integer'), array($p_node['tree'])); } else { // delete this post and its sub-posts for ($i = 0; $i < $dead_pos; $i++) { $statement = $ilDB->manipulateF(' DELETE FROM frm_posts WHERE pos_pk = %s', array('integer'), array($del_id[$i])); // delete related news item include_once "./Services/News/classes/class.ilNewsItem.php"; $news_id = ilNewsItem::getFirstNewsIdForContext($this->id, "frm", $del_id[$i], "pos"); if ($news_id > 0) { $news_item = new ilNewsItem($news_id); $news_item->delete(); } try { include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php'; $mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $del_id[$i]); foreach ($mobs as $mob) { if (ilObjMediaObject::_exists($mob)) { ilObjMediaObject::_removeUsage($mob, 'frm:html', $del_id[$i]); $mob_obj = new ilObjMediaObject($mob); $mob_obj->delete(); } } } catch (Exception $e) { } } // update num_posts in frm_threads $statement = $ilDB->manipulateF(' UPDATE frm_threads SET thr_num_posts = thr_num_posts - %s WHERE thr_pk = %s', array('integer', 'integer'), array($dead_pos, $p_node['tree'])); // get latest post of thread and update last_post $res1 = $ilDB->queryf(' SELECT * FROM frm_posts WHERE pos_thr_fk = %s ORDER BY pos_date DESC', array('integer'), array($p_node['tree'])); if ($res1->numRows() == 0) { $lastPost_thr = ""; } else { $z = 0; while ($selData = $ilDB->fetchAssoc($res1)) { if ($z > 0) { break; } $lastPost_thr = $selData["pos_top_fk"] . "#" . $selData["pos_thr_fk"] . "#" . $selData["pos_pk"]; $z++; } } $statement = $ilDB->manipulateF(' UPDATE frm_threads SET thr_last_post = %s WHERE thr_pk = %s', array('text', 'integer'), array($lastPost_thr, $p_node['tree'])); } // update num_posts in frm_data $statement = $ilDB->manipulateF(' UPDATE frm_data SET top_num_posts = top_num_posts - %s WHERE top_frm_fk = %s', array('integer', 'integer'), array($dead_pos, $this->id)); // get latest post of forum and update last_post $res2 = $ilDB->queryf(' SELECT * FROM frm_posts, frm_data WHERE pos_top_fk = top_pk AND top_frm_fk = %s ORDER BY pos_date DESC', array('integer'), array($this->id)); if ($res2->numRows() == 0) { $lastPost_top = ""; } else { $z = 0; while ($selData = $ilDB->fetchAssoc($res2)) { if ($z > 0) { break; } $lastPost_top = $selData["pos_top_fk"] . "#" . $selData["pos_thr_fk"] . "#" . $selData["pos_pk"]; $z++; } } $statement = $ilDB->manipulateF(' UPDATE frm_data SET top_last_post = %s WHERE top_frm_fk = %s', array('text', 'integer'), array($lastPost_top, $this->id)); return $dead_thr; }