protected function getModuleLinkList() { //$toolNameList = claro_get_tool_name_list(); $claro_notifier = Claroline::getInstance()->notification; // Get tool id where new events have been recorded since last login if ($this->userId) { $date = $claro_notifier->get_notification_date($this->userId); $modified_tools = $claro_notifier->get_notified_tools($this->courseCode, $date, $this->userId); } else { $modified_tools = array(); } $toolLinkList = array(); $toolName = get_lang('Course homepage'); // Trick to find how to build URL, must be IMPROVED $url = claro_htmlspecialchars(Url::Contextualize(get_path('url') . '/claroline/course/index.php?cid=' . $this->courseCode)); $icon = get_icon_url('coursehome'); $htmlId = 'id="courseHomePage"'; $removableTool = false; $classCurrent = empty($GLOBALS['tlabelReq']) ? ' currentTool' : ''; $toolLinkList[] = '<a ' . $htmlId . 'class="item' . $classCurrent . '" href="' . $url . '">' . '<img class="clItemTool" src="' . $icon . '" alt="" /> ' . $toolName . '</a>' . "\n"; // Generate tool lists $toolListSource = claro_get_course_tool_list($this->courseCode, $this->profileId, true); foreach ($toolListSource as $thisTool) { // Special case when display mode is student and tool invisible doesn't display it if ($this->viewMode == 'STUDENT' && !$thisTool['visibility']) { continue; } if (isset($thisTool['label'])) { $thisToolName = $thisTool['name']; $toolName = get_lang($thisToolName); // Trick to find how to build URL, must be IMPROVED $url = claro_htmlspecialchars(Url::Contextualize(get_module_url($thisTool['label']) . '/' . $thisTool['url'], $this->currentCourseContext)); $icon = get_module_url($thisTool['label']) . '/' . $thisTool['icon']; $htmlId = 'id="' . $thisTool['label'] . '"'; $removableTool = false; } else { if (!empty($thisTool['external_name'])) { $toolName = $thisTool['external_name']; } else { $toolName = '<i>no name</i>'; } $url = claro_htmlspecialchars(trim($thisTool['url'])); $icon = get_icon_url('link'); $htmlId = ''; $removableTool = true; } $style = !$thisTool['visibility'] ? 'invisible ' : ''; $classItem = in_array($thisTool['id'], $modified_tools) ? ' hot' : ''; $classCurrent = isset($thisTool['label']) && $thisTool['label'] == $GLOBALS['tlabelReq'] ? ' currentTool' : ''; if (!empty($url)) { $toolLinkList[] = '<a ' . $htmlId . 'class="' . $style . 'item' . $classItem . $classCurrent . '" href="' . $url . '">' . '<img class="clItemTool" src="' . $icon . '" alt="" /> ' . $toolName . '</a>' . "\n"; } else { $toolLinkList[] = '<span ' . $style . '>' . '<img class="clItemTool" src="' . $icon . '" alt="" /> ' . $toolName . '</span>' . "\n"; } } return $toolLinkList; }
$is_toolAllowed = false; } else { $is_toolAllowed = true; } } else { $is_toolAllowed = false; } } else { $is_toolAllowed = !empty($_SESSION['is_toolAllowed']) ? $_SESSION['is_toolAllowed'] : null; } /*--------------------------------------------------------------------------- Course tool list initialisation for current user ---------------------------------------------------------------------------*/ if ($uidReset || $cidReset) { if ($_cid) { $_courseToolList = claro_get_course_tool_list($_cid, $_profileId, true, true); } else { $_courseToolList = null; } } else { $_courseToolList = !empty($_SESSION['_courseToolList']) ? $_SESSION['_courseToolList'] : null; } /*=========================================================================== Save all variables in session ===========================================================================*/ /*--------------------------------------------------------------------------- User info in the platform ---------------------------------------------------------------------------*/ $_SESSION['_uid'] = $_uid; $_SESSION['_user'] = $_user; $_SESSION['is_allowedCreateCourse'] = $is_allowedCreateCourse;
/** * Search in all activated modules * * @param string $cidReq */ private function loadModuleRenderer() { if (!is_null($this->courseId)) { $profileId = claro_get_current_user_profile_id_in_course($this->courseId); $toolList = claro_get_course_tool_list($this->courseId, $profileId); } else { $toolList = claro_get_main_course_tool_list(); } foreach ($toolList as $tool) { if (!is_null($tool['label'])) { $file = get_module_path($tool['label']) . '/connector/tracking.cnr.php'; if (file_exists($file)) { require_once $file; if (claro_debug_mode()) { pushClaroMessage('Tracking : ' . $tool['label'] . ' tracking renderers loaded', 'debug'); } } } } }
/** * Returns the tool list for each cours of the user. * @throws InvalidArgumentException if the cid in not provided. * @webservice{/module/MOBILE/User/getCoursToolList/cidReq} * @ws_arg{method,getCoursToolList} * @ws_arg{cidReq,SYSCODE of requested cours} * @return array of course object with only the syscode and tool-related fields filled. */ function getToolList() { $cid = claro_get_current_course_id(); if ($cid == null) { throw new InvalidArgumentException('Missing cid argument!'); } FromKernel::uses('courselist.lib'); $tools = array(); foreach (claro_get_course_tool_list($cid, claro_get_current_user_profile_id_in_course($cid)) as $tool) { if (isset($tool['label']) && $tool['installed'] && $tool['activated'] && ($tool['visibility'] || claro_is_allowed_to_edit())) { unset($tool['id']); unset($tool['tool_id']); unset($tool['external_name']); unset($tool['external']); unset($tool['icon']); unset($tool['activation']); unset($tool['url']); unset($tool['activated']); unset($tool['installed']); $tool['name'] = get_lang($tool['name']); $tool['visibility'] = $tool['visibility'] == true; // Force the boolean representation in JSON $tools[] = $tool; } } return $tools; }
public function getResourceList(ResourceLocator $rootNodeLocator) { $courseToolList = claro_get_course_tool_list($rootNodeLocator->getCourseId(), claro_get_current_user_profile_id_in_course($rootNodeLocator->getCourseId())); $courseResource = new LinkerResourceIterator(); foreach ($courseToolList as $courseTool) { if (!is_null($courseTool['label'])) { $locator = new ClarolineResourceLocator($rootNodeLocator->getCourseId(), $courseTool['label']); $name = get_lang($courseTool['name']); } else { $locator = new ExternalResourceLocator($courseTool['url']); $name = $courseTool['name']; } if (!is_null($courseTool['label']) && ResourceLinkerNavigator::loadModuleNavigator($courseTool['label'])) { $isNavigable = true; } else { $isNavigable = false; } $resource = new LinkerResource($name, $locator, true, $courseTool['visibility'] ? true : false, $isNavigable); $courseResource->addResource($resource); } return $courseResource; }
include get_path('incRepositorySys') . '/claro_init_local.inc.php'; } else { $dialogBox->error(get_lang('Cannot add tool to course')); } } else { $dialogBox->error(get_lang('Not a valid tool')); } } else { $dialogBox->error(get_lang('This tool is activable by the platform administrator only')); } } } // Build course tool list // $_profileId is set in claro_init_local // get all tools for the course $toolList = claro_get_course_tool_list(claro_get_current_course_id(), $_profileId, true, true, false); $displayToolList = array(); // Split course tool foreach ($toolList as $thisTool) { $tid = $thisTool['id']; if (!empty($thisTool['label'])) { $main_tid = $thisTool['tool_id']; // course_tool $displayToolList[$main_tid]['tid'] = $tid; $displayToolList[$main_tid]['icon'] = get_module_url($thisTool['label']) . '/' . $thisTool['icon']; $displayToolList[$main_tid]['visibility'] = (bool) $thisTool['visibility']; $displayToolList[$main_tid]['activation'] = (bool) $thisTool['activation']; } } // Get external link list $courseExtLinkList = claro_get_course_external_link_list();
/** * Get the course tid for a given course tool from its main tool id * @param int $tool_id id of the tool instance in the platform * @param string $courseId id (sysCode) of the course (optional, current course used if missing) * @param int $profileId profile of the user to get the tool list from (optional, current user used if missing) * @return int tid, course tool id */ function claro_get_course_tid_from_tool_id($tool_id, $courseId = null, $profileId = null) { $courseId = empty($courseId) ? claro_get_current_course_id() : $courseId; $profileId = empty($profileId) ? claro_get_current_user_profile_id_in_course($courseId) : $profileId; $courseToolList = claro_get_course_tool_list($courseId, $profileId); foreach ($courseToolList as $courseTool) { if ($courseTool['tool_id'] == $tool_id) { return $courseTool['id']; } } return false; }