public function renderContent() { $output = ''; $course = claro_get_current_course_data(); $course['db'] = $course['dbName']; $toolId = get_tool_id_from_module_label('CLANN'); if (is_module_installed_in_course('CLANN', claro_get_current_course_id()) && is_tool_activated_in_course($toolId, claro_get_current_course_id()) && claro_is_tool_visible($toolId, claro_get_current_course_id())) { $announcementList = announcement_get_course_item_list_portlet($course); // Manage announcement's datas if ($announcementList) { $output .= '<dl id="portletAnnouncements">' . "\n"; $i = 0; foreach ($announcementList as $announcementItem) { // Generate announcement URL $announcementItem['url'] = get_path('url') . '/claroline/announcements/announcements.php?cidReq=' . $course['sysCode']; // Generate announcement title and content $announcementItem['title'] = trim(strip_tags($announcementItem['title'])); if ($announcementItem['title'] == '') { $announcementItem['title'] = substr($announcementItem['title'], 0, 60) . (strlen($announcementItem['title']) > 60 ? ' (...)' : ''); } $announcementItem['content'] = trim(strip_tags($announcementItem['content'])); if ($announcementItem['content'] == '') { $announcementItem['content'] = substr($announcementItem['content'], 0, 60) . (strlen($announcementItem['content']) > 60 ? ' (...)' : ''); } // Don't display hidden and expired elements $isVisible = (bool) ($announcementItem['visibility'] == 'SHOW') ? 1 : 0; $isOffDeadline = (bool) (isset($announcementItem['visibleFrom']) && strtotime($announcementItem['visibleFrom']) > time() || isset($announcementItem['visibleUntil']) && time() >= strtotime($announcementItem['visibleUntil'])) ? 1 : 0; // Prepare the render $displayChar = 250; if (strlen($announcementItem['content']) > $displayChar) { $content = substr($announcementItem['content'], 0, $displayChar) . '... <a href="' . claro_htmlspecialchars(Url::Contextualize($announcementItem['url'])) . '">' . '<b>' . get_lang('Read more »') . '</b></a>'; } else { $content = $announcementItem['content']; } if ($isVisible && !$isOffDeadline) { $output .= '<dt>' . "\n" . '<h2> ' . '<a href="' . $announcementItem['url'] . '#item' . $announcementItem['id'] . '">' . (!empty($announcementItem['title']) ? $announcementItem['title'] : get_lang('No title')) . '</a></h2>' . "\n" . '</dt>' . "\n" . '<dd' . ($i == count($announcementList) - 1 ? ' class="last"' : '') . '>' . "\n" . $content . "\n" . (claro_is_allowed_to_edit() ? '<div class="manageTools"><a href="' . claro_htmlspecialchars(Url::Contextualize(get_module_url('CLANN') . '/announcements.php?cmd=rqEdit&id=' . $announcementItem['id'])) . '" title="' . get_lang('Edit this item') . '"> <img src="' . get_icon_url('edit') . '" alt="' . get_lang('Edit') . '" /> </a> <a href="' . claro_htmlspecialchars(Url::Contextualize(get_module_url('CLANN') . '/announcements.php?cmd=exDelete&id=' . $announcementItem['id'])) . '" title="' . get_lang('Delete this item') . '"> <img src="' . get_icon_url('delete') . '" alt="' . get_lang('Delete') . '" /> </a></div>' : '') . '</dd>' . "\n"; } $i++; } $output .= '</dl>'; } else { $output .= "\n" . '<dl>' . "\n" . '<dt></dt>' . "\n" . '<dd class="last">' . ' ' . get_lang('No announcement') . "\n" . '</dd>' . "\n" . '</dl>' . "\n\n"; } } return $output; }
$tmp = array(); foreach ($courseToolList as $thisCourseTool) { $tmp[$thisCourseTool['label']] = $thisCourseTool['toolId']; } // 3. compare the two lists and register and install/activate missing tool if necessary $listOfToolsToAdd = array(); foreach ($mainCourseToolList as $thisToolId => $thisMainCourseTool) { if (!array_key_exists($thisMainCourseTool['label'], $tmp)) { $listOfToolsToAdd[$thisMainCourseTool['label']] = $thisToolId; } } foreach ($listOfToolsToAdd as $toolLabel => $toolId) { if (!is_module_registered_in_course($toolId, $_cid)) { register_module_in_single_course($toolId, $_cid); } if (!is_module_installed_in_course($toolLabel, $_cid) && 'AUTOMATIC' == get_module_data($toolLabel, 'add_in_course')) { install_module_in_course($toolLabel, $_cid); } if ('AUTOMATIC' == get_module_data($toolLabel, 'add_in_course')) { if ('activated' == get_module_data($toolLabel, 'activation')) { update_course_tool_activation_in_course($toolId, $_cid, true); set_module_visibility_in_course($toolId, $_cid, true); } } } } /*--------------------------------------------------------------------------- Course / tool relation initialisation ---------------------------------------------------------------------------*/ // if the requested tool is different from the current tool in session // (special request can come from the tool id, or the tool label)
/** * build the rss file and place it in directory * * @param array $context context of claroline * @param string $calType : ics,xcs,rdf * @return string ical file path */ function buildICal($context, $calType = 'ics') { if (is_array($context) && count($context) > 0) { $iCalRepositorySys = get_path('rootSys') . get_conf('iCalRepositoryCache', 'tmp/cache/iCal/'); if (!file_exists($iCalRepositorySys)) { require_once dirname(__FILE__) . '/fileManage.lib.php'; claro_mkdir($iCalRepositorySys, CLARO_FILE_PERMISSIONS, true); if (!file_exists($iCalRepositorySys)) { claro_failure::set_failure('CANT_CREATE_ICAL_DIR'); } } $iCal = (object) new iCal('', 0, $iCalRepositorySys); // (ProgrammID, Method (1 = Publish | 0 = Request), Download Directory) $toolLabelList = ical_get_tool_compatible_list(); foreach ($toolLabelList as $toolLabel) { if (is_tool_activated_in_course(get_tool_id_from_module_label($toolLabel), $context[CLARO_CONTEXT_COURSE])) { if (!is_module_installed_in_course($toolLabel, $context[CLARO_CONTEXT_COURSE])) { install_module_in_course($toolLabel, $context[CLARO_CONTEXT_COURSE]); } $icalToolLibPath = get_module_path($toolLabel) . '/connector/ical.write.cnr.php'; $icalToolFuncName = $toolLabel . '_write_ical'; if (file_exists($icalToolLibPath)) { require_once $icalToolLibPath; if (function_exists($icalToolFuncName)) { $iCal = call_user_func($icalToolFuncName, $iCal, $context); } } } } $iCalFilePath = $iCalRepositorySys; if (array_key_exists(CLARO_CONTEXT_COURSE, $context)) { $iCalFilePath .= $context[CLARO_CONTEXT_COURSE] . '.'; } if (array_key_exists(CLARO_CONTEXT_GROUP, $context)) { $iCalFilePath .= 'g' . $context[CLARO_CONTEXT_GROUP] . '.'; } if ('ics' == $calType || get_conf('iCalGenStandard', true)) { $stdICalFilePath = $iCalFilePath . 'ics'; if (false !== ($fpICal = @fopen($stdICalFilePath, 'w'))) { fwrite($fpICal, $iCal->getOutput('ics')); fclose($fpICal); } } if ('xcs' == $calType || get_conf('iCalGenXml', true)) { $xmlICalFilePath = $iCalFilePath . 'xml'; if (false !== ($fpICal = @fopen($xmlICalFilePath, 'w'))) { fwrite($fpICal, $iCal->getOutput('xcs')); fclose($fpICal); } } if ('rdf' == $calType || get_conf('iCalGenRdf', false)) { $rdfICalFilePath = $iCalFilePath . 'rdf'; if (false !== ($fpICal = @fopen($rdfICalFilePath, 'w'))) { fwrite($fpICal, $iCal->getOutput('rdf')); fclose($fpICal); } } switch ($calType) { case 'xcs': return $xmlICalFilePath; break; case 'rdf': return $rdfICalFilePath; break; default: return $stdICalFilePath; break; } } return false; }
save_course_current_version($currentCourseCode, $currentCourseVersion); } /*--------------------------------------------------------------------- Upgrade 1.9 to 1.10 ---------------------------------------------------------------------*/ if (preg_match('/^1.9/', $currentCourseVersion)) { // Function to upgrade tool to 1.10 $function_list = array(); if (is_module_installed_in_course('CLANN', $currentCourseCode)) { $function_list[] = 'announcements_upgrade_to_110'; } if (is_module_installed_in_course('CLCAL', $currentCourseCode)) { $function_list[] = 'calendar_upgrade_to_110'; } $function_list[] = 'tool_intro_upgrade_to_110'; if (is_module_installed_in_course('CLQWZ', $currentCourseCode)) { $function_list[] = 'exercise_upgrade_to_110'; } foreach ($function_list as $function) { $step = $function($currentCourseCode); if ($step > 0) { echo 'Error : ' . $function . ' at step ' . $step . '<br />'; $error = true; } } if (!$error) { // Upgrade succeeded clean_upgrade_status($currentCourseCode); $currentCourseVersion = '1.10'; } else { // Upgrade failed
function build_rss($context) { if (is_array($context) && count($context) > 0) { $rss = new UniversalFeedCreator(); if (array_key_exists(CLARO_CONTEXT_COURSE, $context)) { // $rssFilePath .= $context[CLARO_CONTEXT_COURSE] . '.'; $_course = claro_get_course_data($context[CLARO_CONTEXT_COURSE]); $rss->title = '[' . get_conf('siteName') . '] ' . $_course['officialCode']; $rss->description = $_course['name']; $rss->editor = $_course['titular'] == '' ? get_conf('administrator_name') : $_course['titular']; $rss->editorEmail = $_course['email'] == '' ? get_conf('administrator_email') : $_course['email']; $rss->link = get_path('rootWeb') . get_path('coursesRepositoryAppend') . claro_get_course_path(); $rss->generator = 'Feedcreator'; if (array_key_exists(CLARO_CONTEXT_GROUP, $context)) { // $rssFilePath .= 'g'.$context[CLARO_CONTEXT_GROUP] . '.'; $rss->title .= '[' . get_lang('Group') . $context[CLARO_CONTEXT_GROUP] . ']'; $rss->description .= get_lang('Group') . $context[CLARO_CONTEXT_GROUP]; } } else { $rss->title = '[' . get_conf('siteName') . '] ' . $_course['officialCode']; $rss->description = $_course['name']; $rss->editor = get_conf('administrator_name'); $rss->editorEmail = get_conf('administrator_email'); $rss->link = get_path('rootWeb'); } $rss->language = get_locale('iso639_1_code'); $rss->docs = 'http://blogs.law.harvard.edu/tech/rss'; $rss->pubDate = date("r", time()); $toolLabelList = rss_get_tool_compatible_list(); //var_dump($toolLabelList); $rssItems = array(); foreach ($toolLabelList as $toolLabel) { /*var_dump(is_tool_activated_in_course( get_tool_id_from_module_label( $toolLabel ), $context[CLARO_CONTEXT_COURSE] ));*/ if (is_tool_activated_in_course(get_tool_id_from_module_label($toolLabel), $context[CLARO_CONTEXT_COURSE])) { if (!is_module_installed_in_course($toolLabel, $context[CLARO_CONTEXT_COURSE])) { install_module_in_course($toolLabel, $context[CLARO_CONTEXT_COURSE]); } $rssToolLibPath = get_module_path($toolLabel) . '/connector/rss.write.cnr.php'; $rssToolFuncName = $toolLabel . '_write_rss'; if (file_exists($rssToolLibPath)) { include_once $rssToolLibPath; if (function_exists($rssToolFuncName)) { $rssItems = array_merge($rssItems, call_user_func($rssToolFuncName, $context)); } } } } $sortDate = array(); foreach ($rssItems as $key => $rssItem) { $sortDate[$key] = $rssItem['pubDate']; } // die(var_export($sortDate, true)); array_multisort($sortDate, SORT_DESC, $rssItems); foreach ($rssItems as $rssItem) { $item = new FeedItem(); $item->title = claro_utf8_encode($rssItem['title'], get_conf('charset')); $item->description = claro_utf8_encode($rssItem['description']); $item->category = $rssItem['category']; $item->guid = $rssItem['guid']; $item->link = $rssItem['link']; $item->date = $rssItem['pubDate']; $rss->addItem($item); } return $rss->outputFeed("RSS2.0"); } return false; }
} } if ($tlabelReq !== 'CLWRK' && $tlabelReq !== 'CLGRP' && !claro_is_module_allowed() && !(isset($_SESSION['inPathMode']) && $_SESSION['inPathMode'] && ($tlabelReq == 'CLQWZ' || $tlabelReq == 'CLDOC'))) { if (!claro_is_user_authenticated()) { claro_disp_auth_form(true); } else { claro_die(get_lang('Not allowed')); } } if ($tlabelReq !== 'CLGRP' && $tlabelReq !== 'CLWRK' && claro_is_in_a_group() && (!claro_is_group_allowed() || !claro_is_allowed_to_edit() && !is_tool_activated_in_groups($_cid, $tlabelReq))) { claro_die(get_lang('Not allowed')); } /*---------------------------------------------------------------------- Install module ----------------------------------------------------------------------*/ if (claro_is_in_a_course() && !is_module_installed_in_course($tlabelReq, claro_get_current_course_id())) { install_module_database_in_course($tlabelReq, claro_get_current_course_id()); } } /*---------------------------------------------------------------------- Context from URL ----------------------------------------------------------------------*/ // if page is called from another tool ... (from LP for an example) if (isset($_REQUEST['calledFrom'])) { $calledFrom = $_REQUEST['calledFrom']; } else { $calledFrom = false; } // if page is embedded hide banner and footer if (isset($_REQUEST['embedded']) && $_REQUEST['embedded'] == 'true') { // old school method