public function isAllowedToDownload($requestedUrl) { if (!$this->isModuleAllowed()) { return false; } if (claro_is_in_a_course()) { if (!claro_is_course_allowed()) { pushClaroMessage('course not allowed', 'debug'); return false; } else { if (claro_is_in_a_group()) { if (!claro_is_group_allowed()) { pushClaroMessage('group not allowed', 'debug'); return false; } else { return true; } } else { return $this->isDocumentDownloadableInCourse($requestedUrl); } } } else { return false; } }
public function render() { if ($this->hidden) { return '<!-- footer hidden -->' . "\n"; } $currentCourse = claro_get_current_course_data(); if (claro_is_in_a_course()) { $courseManagerOutput = '<div id="courseManager">' . get_lang('Manager(s) for %course_code', array('%course_code' => $currentCourse['officialCode'])) . ' : '; $currentCourseTitular = empty($currentCourse['titular']) ? get_lang('Course manager') : $currentCourse['titular']; if (empty($currentCourse['email'])) { $courseManagerOutput .= '<a href="' . get_module_url('CLUSR') . '/user.php">' . $currentCourseTitular . '</a>'; } else { $courseManagerOutput .= '<a href="mailto:' . $currentCourse['email'] . '?body=' . $currentCourse['officialCode'] . '&subject=[' . rawurlencode(get_conf('siteName')) . ']' . '">' . $currentCourseTitular . '</a>'; } $courseManagerOutput .= '</div>'; $this->assign('courseManager', $courseManagerOutput); } else { $this->assign('courseManager', ''); } $platformManagerOutput = '<div id="platformManager">' . get_lang('Administrator for %site_name', array('%site_name' => get_conf('siteName'))) . ' : ' . '<a href="mailto:' . get_conf('administrator_email') . '?subject=[' . rawurlencode(get_conf('siteName')) . ']' . '">' . get_conf('administrator_name') . '</a>'; if (get_conf('administrator_phone') != '') { $platformManagerOutput .= '<br />' . "\n" . get_lang('Phone : %phone_number', array('%phone_number' => get_conf('administrator_phone'))); } $platformManagerOutput .= '</div>'; $this->assign('platformManager', $platformManagerOutput); $poweredByOutput = '<span class="poweredBy">' . get_lang('Powered by') . ' <a href="http://www.claroline.net" target="_blank">Claroline</a> ' . '© 2001 - 2013' . '</span>'; $this->assign('poweredBy', $poweredByOutput); return parent::render(); }
/** * * @param AuthProfile $userAuthProfile profile of the user we want to enrol to the cours * @param Claro_Course $course kernel object representing the course * @param type $givenCourseKey optionnal given registration key (default null) * @param type $categoryId optionnal given categoryId (default null) */ public function __construct(AuthProfile $userAuthProfile, Claro_Course $course, $givenCourseKey = null, $categoryId = null) { $this->userAuthProfile = $userAuthProfile; $this->course = $course; $this->givenCourseKey = $givenCourseKey; $this->categoryId = $categoryId; // is the user doing the registration a super user ? if (claro_is_in_a_course() && claro_get_current_course_id() == $this->course->courseId) { $this->isSuperUser = claro_is_platform_admin() || claro_is_course_manager() || claro_is_allowed_tool_edit(get_module_data('CLUSER', 'id')); } else { $this->isSuperUser = claro_is_platform_admin(); } }
public function render() { $out = ''; if (!claro_is_user_authenticated()) { if (get_conf('claro_displayLocalAuthForm', true) == true) { $out .= $this->renderLoginLink(); } } elseif (!claro_is_platform_admin() && (claro_is_in_a_course() && !claro_is_course_member()) && claro_get_current_course_data('registrationAllowed')) { if (claro_is_current_user_enrolment_pending()) { $out .= '<img src="' . get_icon_url('warning') . '" alt="off" /> ' . '<b>' . get_lang('Enrolment pending') . '</b>'; } else { $out .= $this->renderRegistrationLink(); } } elseif (claro_is_display_mode_available()) { $out .= $this->renderViewModeSwitch(); } return $out; }
public function isAllowedToDownload($requestedUrl) { $fromCLLNP = isset($_SESSION['fromCLLNP']) && $_SESSION['fromCLLNP'] === true ? true : false; // unset CLLNP mode unset($_SESSION['fromCLLNP']); if (!$fromCLLNP || !$this->isModuleAllowed()) { return false; } if (claro_is_in_a_course()) { if (!claro_is_course_allowed()) { pushClaroMessage('course not allowed', 'debug'); return false; } else { return $this->isDocumentDownloadableInCourse($requestedUrl); } } else { return false; } }
/** * Get the given context array formated for use in urls * @param array $givenContext * @return array */ public static function getUrlContext($givenContext) { $context = array(); if (claro_is_in_a_group() && !isset($givenContext[CLARO_CONTEXT_GROUP]) || isset($givenContext[CLARO_CONTEXT_GROUP])) { $context['gidReset'] = 'true'; } if (claro_is_in_a_course() && !isset($givenContext[CLARO_CONTEXT_COURSE]) || isset($givenContext[CLARO_CONTEXT_COURSE])) { $context['cidReset'] = 'true'; } if (isset($givenContext[CLARO_CONTEXT_COURSE])) { $context['cidReq'] = $givenContext[CLARO_CONTEXT_COURSE]; } if (isset($givenContext[CLARO_CONTEXT_GROUP])) { $context['gidReq'] = $givenContext[CLARO_CONTEXT_GROUP]; } if (isset($_REQUEST['inPopup'])) { $context['inPopup'] = $_REQUEST['inPopup']; } if (isset($_REQUEST['inFrame'])) { $context['inFrame'] = $_REQUEST['inFrame']; } if (isset($_REQUEST['embedded'])) { $context['embedded'] = $_REQUEST['embedded']; } if (isset($_REQUEST['hide_banner'])) { $context['hide_banner'] = $_REQUEST['hide_banner']; } if (isset($_REQUEST['hide_footer'])) { $context['hide_footer'] = $_REQUEST['hide_footer']; } if (isset($_REQUEST['hide_body'])) { $context['hide_body'] = $_REQUEST['hide_body']; } if ($moduleLabel = claro_called_from()) { $context['calledFrom'] = $moduleLabel; } return $context; }
/** * return the autorisation of the current user to send a message to the user in parameter * * @param int $userId user id of the recipient * @return bool true if the current user is autorised do send a message to the user in parameter * flase if the current user is not autorised do send a message to the user in parameter */ function current_user_is_allowed_to_send_message_to_user($userId) { if (claro_is_platform_admin()) { return true; } if (claro_is_in_a_group()) { if (claro_is_group_tutor() || claro_is_course_manager()) { $userList = get_group_user_list(claro_get_current_group_id(), claro_get_current_course_id()); for ($count = 0; $count < count($userList); $count++) { if ($userList[$count]['id'] == $userId) { return true; } } } return false; } elseif (claro_is_in_a_course()) { if (claro_is_course_manager()) { $userList = claro_get_course_user_list(); for ($count = 0; $count < count($userList); $count++) { if ($userList[$count]['user_id'] == $userId) { return true; } } } return false; } else { // can answerd to a user $tableName = get_module_main_tbl(array('im_message', 'im_recipient')); $select = "SELECT count(*)\n" . " FROM `" . $tableName['im_message'] . "` as M\n" . " INNER JOIN `" . $tableName['im_recipient'] . "` as R ON R.message_id = M.message_id\n" . " WHERE (R.user_id = " . (int) claro_get_current_user_id() . " OR R.user_id = 0)\n" . " AND M.sender = " . (int) $userId; $nbMessage = claro_sql_query_fetch_single_value($select); if ($nbMessage > 0) { return true; } elseif (get_conf('userCanSendMessage')) { } return true; return false; } }
/** * Render the HTML page header * @return string */ public function render() { $this->_globalVarsCompat(); $this->addInlineJavascript(JavascriptLanguage::getInstance()->buildJavascript()); $titlePage = ''; if (empty($this->_toolName) && !empty($this->_nameTools)) { $titlePage .= $this->_nameTools . ' - '; } elseif (!empty($this->_toolName)) { $titlePage .= $this->_toolName . ' - '; } if (claro_is_in_a_course() && claro_get_current_course_data('officialCode') != '') { $titlePage .= claro_get_current_course_data('officialCode') . ' - '; } $titlePage .= get_conf('siteName'); $this->assign('pageTitle', $titlePage); if (true === get_conf('warnSessionLost', true) && claro_get_current_user_id()) { $this->assign('warnSessionLost', "function claro_session_loss_countdown(sessionLifeTime){\n var chrono = setTimeout('claro_warn_of_session_loss()', sessionLifeTime * 1000);\n}\n\nfunction claro_warn_of_session_loss() {\n alert('" . clean_str_for_javascript(get_lang('WARNING ! You have just lost your session on the server.') . "\n" . get_lang('Copy any text you are currently writing and paste it outside the browser')) . "');\n}\n"); } else { $this->assign('warnSessionLost', ''); } $htmlXtraHeaders = ''; if (!empty($this->_htmlXtraHeaders)) { $htmlXtraHeaders .= implode("\n", $this->_htmlXtraHeaders); } $this->assign('htmlScriptDefinedHeaders', $htmlXtraHeaders); return parent::render() . "\n"; }
// XSS $subject = strip_tags($subject); if (isset($_REQUEST['message'])) { $message = $_REQUEST['message']; } else { $message = ''; } // XSS $message = preg_replace('/<script[^\\>]*>|<\\/script>|(onabort|onblur|onchange|onclick|ondbclick|onerror|onfocus|onkeydown|onkeypress|onkeyup|onload|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onreset|onresize|onselect|onsubmit|onunload)\\s*=\\s*"[^"]+"/i', '', $message); $forumSettingList = get_forum_settings($forum_id); $is_allowedToEdit = claro_is_allowed_to_edit() || claro_is_group_tutor() && !claro_is_course_manager(); // ( claro_is_group_tutor() // is added to give admin status to tutor // && !claro_is_course_manager()) // is added to let course admin, tutor of current group, use student mode if (!claro_is_user_authenticated() || !claro_is_in_a_course()) { claro_disp_auth_form(true); } elseif ($forumSettingList) { $forum_name = stripslashes($forumSettingList['forum_name']); $forum_post_allowed = $forumSettingList['forum_access'] != 0 ? true : false; $forum_type = $forumSettingList['forum_type']; $forum_groupId = $forumSettingList['idGroup']; $forum_cat_id = $forumSettingList['cat_id']; /* * Check if the topic isn't attached to a group, or -- if it is attached --, * check the user is allowed to see the current group forum. */ if (!$forum_post_allowed || !is_null($forumSettingList['idGroup']) && (!claro_is_in_a_group() || !claro_is_group_allowed() || $forumSettingList['idGroup'] != claro_get_current_group_id())) { // NOTE : $forumSettingList['idGroup'] != claro_get_current_group_id() is necessary to prevent any hacking // attempt like rewriting the request without $cidReq. If we are in group // forum and the group of the concerned forum isn't the same as the session
public static function current_language() { // FIXME : use init.lib instead of global variables !!! global $_course, $_user, $platformLanguage; if (claro_is_in_a_course() && isset($_course['language'])) { // course language return $_course['language']; } else { if (claro_is_user_authenticated() && !empty($_user['language'])) { // user language return $_user['language']; } else { if (isset($_REQUEST['language']) && in_array($_REQUEST['language'], array_keys(get_language_list()))) { // selected language $_SESSION['language'] = $_REQUEST['language']; return $_REQUEST['language']; } else { if (empty($_SESSION['language'])) { // default platform language return $platformLanguage; } else { return $_SESSION['language']; } } } } }
*/ $acceptedCmdList = array('getFileList'); if (isset($_REQUEST['cmd']) && in_array($_REQUEST['cmd'], $acceptedCmdList)) { $cmd = $_REQUEST['cmd']; } else { $cmd = null; } if (!empty($_REQUEST['relPath']) && $_REQUEST['relPath'] != '/' && $_REQUEST['relPath'] != '.') { $relPath = str_replace('..', '', $_REQUEST['relPath']) . '/'; } else { $relPath = ''; } /* * Init other vars */ if (claro_is_in_a_course() && !claro_is_in_a_group()) { $course_data = claro_get_course_data(); // course context $is_allowedToEdit = claro_is_allowed_to_edit(); $pathSys = get_path('coursesRepositorySys') . claro_get_course_path() . '/document/'; $pathWeb = get_path('coursesRepositoryWeb') . claro_get_course_path() . '/document/'; } elseif (claro_is_in_a_group()) { // course context $is_allowedToEdit = claro_is_allowed_to_edit(); $pathSys = get_path('coursesRepositorySys') . claro_get_course_path() . '/group/' . claro_get_current_group_data('directory'); $pathWeb = get_path('coursesRepositoryWeb') . claro_get_course_path() . '/group/' . claro_get_current_group_data('directory'); require claro_get_conf_repository() . 'CLDOC.conf.php'; $maxFilledSpace = get_conf('maxFilledSpace_for_course'); } else { // platform context $is_allowedToEdit = claro_is_platform_admin();
public function getCurrentLocator($params = array()) { $locator = new ClarolineResourceLocator(); if (claro_is_in_a_course()) { $locator->setCourseId(claro_get_current_course_id()); } if (claro_is_in_a_group()) { $locator->setGroupId(claro_get_current_group_id()); } if (get_current_module_label()) { $locator->setModuleLabel(get_current_module_label()); $navigator = $this->loadModuleNavigator(get_current_module_label()); if ($resourceId = $navigator->getResourceId($params)) { $locator->setResourceId($resourceId); } } return $locator; }
/** * Display table with tool/right of the profile */ public function displayProfileToolRightList() { $html = ''; $html_table_header_list = array(); $html_table_row_list = array(); foreach ($this->rightProfileToolRightList as $profile_id => $rightProfileToolRight) { $isLocked = $rightProfileToolRight->profile->isLocked(); $className = get_class($rightProfileToolRight); // use strtolower for PHP4 : get_class returns class name in lowercase $className = strtolower($className); $html_table_header_list[$profile_id] = claro_get_profile_name($profile_id); if ($isLocked && $className == strtolower('RightCourseProfileToolRight')) { $displayMode = claro_is_platform_admin() ? $this->displayMode : 'read'; $html_table_header_list[$profile_id] .= ' <img src="' . get_icon_url('locked') . '" alt="' . get_lang('Profile locked') . '" />'; } else { $displayMode = $this->displayMode; } foreach ($rightProfileToolRight->toolActionList as $tool_id => $action_list) { $action_right = $rightProfileToolRight->getToolRight($tool_id); $html_right = ''; if ($displayMode == 'edit') { $param_append = '?profile_id=' . urlencode($profile_id) . '&tool_id=' . urlencode($tool_id) . '&cmd=set_right'; foreach ($this->urlParamAppendList as $name => $value) { $param_append .= '&' . $name . '=' . $value; } } if (claro_get_profile_label($profile_id) != ANONYMOUS_PROFILE && claro_get_profile_label($profile_id) != GUEST_PROFILE) { if ($action_right == 'none') { $action_param_value = 'user'; $html_right = '<img src="' . get_icon_url('forbidden') . '" alt="' . get_lang('No access') . '" /> <span style="font-size: smaller;">' . get_lang('No access') . "</span>\n"; } elseif ($action_right == 'user') { $action_param_value = 'manager'; $html_right = '<img src="' . get_icon_url('user') . '" alt="' . get_lang('Access allowed') . '" /> <span style="font-size: smaller;">' . get_lang('Access allowed') . "</span>\n"; } else { $action_param_value = 'none'; $html_right = '<img src="' . get_icon_url('manager') . '" alt="' . get_lang('Edition allowed') . '" /> <span style="font-size: smaller;">' . get_lang('Edition allowed') . "</span>\n"; } } else { if ($action_right == 'none') { $action_param_value = 'user'; $html_right = '<img src="' . get_icon_url('forbidden') . '" alt="' . get_lang('No access') . '" /> <span style="font-size: smaller;">' . get_lang('No access') . "</span>\n"; } else { $action_param_value = 'none'; $html_right = '<img src="' . get_icon_url('user') . '" alt="' . get_lang('Access allowed') . '" /> <span style="font-size: smaller;">' . get_lang('Access allowed') . "</span>\n"; } } if ($displayMode == 'edit') { $html_right = '<a href="' . $_SERVER['PHP_SELF'] . $param_append . '&right_value=' . $action_param_value . '">' . $html_right . '</a>'; } $html_table_row_list[$tool_id][$profile_id] = $html_right; } } // build table $html .= '<table class="claroTable emphaseLine" >' . "\n" . '<thead>' . "\n" . '<tr class="headerX">' . "\n" . '<th>' . get_lang('Tools') . '</th>' . "\n"; // visibility column if ($this->isSetCourseToolInfo()) { $html .= '<th style="text-align:center; width:100px;" >' . get_lang('Visibility') . '</th>' . "\n"; } foreach ($html_table_header_list as $html_table_header) { $html .= '<th style="text-align:center; width:100px;" >' . $html_table_header . '</th>' . "\n"; } $html .= '</tr>' . "\n" . '</thead>' . "\n" . '<tbody>'; foreach ($html_table_row_list as $tool_id => $html_table_row) { if (claro_is_in_a_course() && (!$this->isSetCourseToolInfo() || !isset($this->courseToolInfo[$tool_id]))) { // Not activated in course ! continue; } $html .= '<tr>' . "\n"; if ($this->isSetCourseToolInfo()) { // Add visibility and icon from courseToolInfo $html .= '<td ' . ($this->courseToolInfo[$tool_id]['visibility'] == true ? '' : 'class="invisible"') . '>' . '<img src="' . $this->courseToolInfo[$tool_id]['icon'] . '" alt="" />' . get_lang(claro_get_tool_name($tool_id)) . '</td>'; } else { $html .= '<td>' . get_lang(claro_get_tool_name($tool_id)) . '</td>' . "\n"; } // visibility column if ($this->isSetCourseToolInfo()) { if ($this->courseToolInfo[$tool_id]['visibility'] == true) { $html .= '<td align="center">' . '<a href="' . $_SERVER['PHP_SELF'] . '?cmd=exInvisible&tool_id=' . $this->courseToolInfo[$tool_id]['tid'] . '" >' . '<img src="' . get_icon_url('visible') . '" alt="' . get_lang('Visible') . '" />' . '</a>' . '</td>' . "\n"; } else { $html .= '<td align="center">' . '<a href="' . $_SERVER['PHP_SELF'] . '?cmd=exVisible&tool_id=' . $this->courseToolInfo[$tool_id]['tid'] . '" >' . '<img src="' . get_icon_url('invisible') . '" alt="' . get_lang('Invisible') . '" />' . '</a></td>' . "\n"; } } // profile colums foreach ($html_table_row as $html_table_row_cell) { $html .= '<td align="center">' . $html_table_row_cell . '</td>'; } $html .= '</tr>' . "\n"; } $html .= '</tbody></table>'; return $html; }
/** * @param string $template name of the template */ public function __construct($template) { $template = secure_file_path($template); $customTemplatePath = get_path('rootSys') . '/platform/templates/' . $template; $defaultTemplatePath = get_path('includePath') . '/templates/' . $template; if (file_exists($customTemplatePath)) { parent::__construct($customTemplatePath); } elseif (file_exists($defaultTemplatePath)) { parent::__construct($defaultTemplatePath); } else { throw new Exception("Template not found {$template} " . "at custom location {$customTemplatePath} " . "or default location {$defaultTemplatePath} !"); } if (claro_is_in_a_course()) { $this->course = claro_get_current_course_data(); require_once dirname(__FILE__) . '/../claroCourse.class.php'; $this->courseObject = new ClaroCourse(); $this->courseObject->load(claro_get_current_course_id()); // Fetch related courses $this->relatedCourses = $this->courseObject->getRelatedCourses(); // $this->relatedUserCourses = $this->courseObject->getRelatedUserCourses(claro_get_current_user_id()); if (claro_is_in_a_group()) { $this->group = claro_get_current_group_data(); } } if (claro_is_user_authenticated()) { $this->user = claro_get_current_user_data(); } }
/* * Init request vars */ if (!empty($_REQUEST['relativePath']) && $_REQUEST['relativePath'] != '/' && $_REQUEST['relativePath'] != '.') { $relativePath = str_replace('..', '', $_REQUEST['relativePath']) . '/'; } else { $relativePath = '/'; } /* * Handle upload */ if ($is_allowedToEdit && isset($_FILES['sentFile']['tmp_name']) && is_uploaded_file($_FILES['sentFile']['tmp_name'])) { $imgFile = $_FILES['sentFile']; $imgFile['name'] = replace_dangerous_char($imgFile['name'], 'strict'); $imgFile['name'] = get_secure_file_name($imgFile['name']); if (claro_is_in_a_course()) { $enoughSize = enough_size($_FILES['sentFile']['size'], $pathSys, $maxFilledSpace); } else { $enoughSize = true; } if (is_image($imgFile['name']) && $enoughSize) { // rename if file already exists if (file_exists($pathSys . $relativePath . $imgFile['name'])) { $pieceList = explode('.', $imgFile['name']); $base = $pieceList[0]; $ext = $pieceList[1]; $i = 1; while (file_exists($pathSys . $relativePath . $base . '_' . $i . '.' . $ext)) { $i++; } $imgFile['name'] = $base . '_' . $i . '.' . $ext;
/** * Add an event generated in a course to the tracking system * @param Event $event * @return boolean */ public function trackInCourse($event) { $event_args = $event->getArgs(); $tid = array_key_exists('tid', $event_args) ? $event_args['tid'] : null; $gid = array_key_exists('gid', $event_args) ? $event_args['gid'] : null; $uid = array_key_exists('uid', $event_args) ? $event_args['uid'] : null; $date = array_key_exists('date', $event_args) ? $event_args['date'] : claro_date("Y-m-d H:i:s"); if (array_key_exists('data', $event_args)) { $data = serialize($event_args['data']); } else { $data = ''; } $eventType = $event->getEventType(); if (claro_debug_mode()) { Console::message('Data added in course tracking ' . $eventType . ' : ' . var_export($event, true)); } if (claro_is_in_a_course()) { $tbl_cdb_names = claro_sql_get_course_tbl(claro_get_course_db_name_glued(claro_get_current_course_id())); $tbl_tracking_event = $tbl_cdb_names['tracking_event']; $sql = "INSERT INTO `" . $tbl_tracking_event . "`\n SET `tool_id` = " . (is_null($tid) ? "NULL" : "'" . claro_sql_escape($tid) . "'") . ",\n `group_id` = " . (is_null($gid) ? "NULL" : "'" . claro_sql_escape($gid) . "'") . ",\n `user_id` = " . (is_null($uid) ? "NULL" : "'" . claro_sql_escape($uid) . "'") . ",\n `date` = '" . $date . "',\n `type` = '" . claro_sql_escape($eventType) . "',\n `data` = '" . claro_sql_escape($data) . "'"; return claro_sql_query($sql); } else { return false; } }
require_once dirname(__FILE__) . '/../../claroline/inc/claro_init_global.inc.php'; include claro_get_conf_repository() . 'CLMSG.conf.php'; require_once dirname(__FILE__) . '/lib/message/messagetosend.lib.php'; require_once dirname(__FILE__) . '/lib/recipient/userlistrecipient.lib.php'; require_once get_path('incRepositorySys') . '/lib/group.lib.inc.php'; require_once get_path('incRepositorySys') . '/lib/class.lib.php'; require_once get_path('incRepositorySys') . '/lib/course_user.lib.php'; claro_set_display_mode_available(true); // move to kernel $claroline = Claroline::getInstance(); // ------------- Business Logic --------------------------- require_once 'lib/messagebox/inbox.lib.php'; if (!claro_is_user_authenticated()) { claro_disp_auth_form(true); } if (!claro_is_in_a_course() || !claro_is_course_manager() && !claro_is_platform_admin()) { claro_die(get_lang("Not allowed")); } $displayForm = FALSE; $content = ""; $from = isset($_REQUEST['from']) ? get_module_entry_url(strtoupper($_REQUEST['from'])) : $_SERVER['PHP_SELF']; //commande $acceptedCmdList = array('exSendMessage'); if (isset($_REQUEST['cmd']) && in_array($_REQUEST['cmd'], $acceptedCmdList)) { if ($_REQUEST['cmd'] == 'exSendMessage') { /* * Explode the values of incorreo in groups and users */ $userIdList = array(); $groupIdList = array(); $classIdList = array();
/** * Render the page body * @return string */ public function render() { if (claro_is_in_a_course()) { $this->assign('courseToolList', new CurrentCourseToolListBlock()); } if (!$this->claroBodyHidden) { $this->assign('claroBodyStart', true); $this->assign('claroBodyEnd', true); } else { $this->assign('claroBodyStart', false); $this->assign('claroBodyEnd', false); } // automatic since $this->content already exists // $this->assign('content', $this->getContent() ); if ($this->inPopup) { $this->hideCourseTitleAndTools(); $output = PopupWindowHelper::popupEmbed(parent::render()); } else { $output = parent::render(); } return $output; }
public function getFilePath($requestedUrl) { if (claro_is_in_a_course()) { $basePath = get_path('coursesRepositorySys') . claro_get_course_path(claro_get_current_course_id()) . '/' . $this->moduleLabel; if (claro_is_in_a_group()) { $basePath .= '/.group/' . claro_get_current_group_id(); } } else { $basePath = get_path('rootSys') . 'platform/module_data/' . $this->moduleLabel; } return $basePath . '/' . $requestedUrl; }
public function render() { $claro_buffer = new ClaroBuffer(); $claro_buffer->append("\n" . '<!-- ' . $this->name . ' -->' . "\n"); foreach ($this->appletList as $applet) { set_current_module_label($applet['label']); pushClaroMessage('Current module label set to : ' . get_current_module_label(), 'debug'); // install course applet if (claro_is_in_a_course()) { install_module_in_course($applet['label'], claro_get_current_course_id()); } if ($applet['activation'] == 'activated' && file_exists($applet['path'])) { load_module_config(); Language::load_module_translation(); if ($this->useList() && count($this->appletList) > 0) { $claro_buffer->append("<li\n id=\"dock-" . $this->name . "-applet-" . $applet['label'] . "\"\n class=\"applet dock-" . $this->name . " applet-" . $applet['label'] . "\"><span>\n"); } else { $claro_buffer->append("<span\n id=\"dock-" . $this->name . "-applet-" . $applet['label'] . "\"\n class=\"applet dock-" . $this->name . " applet-" . $applet['label'] . "\">\n"); } include_once $applet['path']; if ($this->useList() && count($this->appletList) > 0) { $claro_buffer->append("\n</span></li>\n"); } else { $claro_buffer->append("\n</span>\n"); } } else { Console::debug("Applet not found or not activated : " . $applet['label']); } clear_current_module_label(); pushClaroMessage('Current module label set to : ' . get_current_module_label(), 'debug'); } $claro_buffer->append("\n" . '<!-- End of ' . $this->name . ' -->' . "\n"); return $claro_buffer->getContent(); }
function claro_is_module_allowed() { if (!array_key_exists('tlabelReq', $GLOBALS)) { return claro_failure::set_failure('MISSING TOOL LABEL'); } $moduleLabel = $GLOBALS['tlabelReq']; $moduleData = get_module_data($moduleLabel); if ($moduleData['type'] == 'tool') { $contextList = get_module_context_list($moduleLabel); // pushClaroMessage(var_export(iterator_to_array($contextList), true),'kernel'); if (!claro_is_in_a_course() && in_array('platform', iterator_to_array($contextList))) { return get_module_data($moduleLabel, 'activation') == 'activated'; } // if a course tool, use claro_is_tool_allowed return claro_is_tool_allowed(); } else { // if an applet "tool", return true if activated // and let module manage it's access by itself return $moduleData['activation'] == 'activated'; } }
/** * Load configuration file for a module * @param $module module label (default null for current module) */ function load_module_config($moduleLabel = null) { if (!$moduleLabel) { $moduleLabel = get_current_module_label(); } // load main config file $mainConfigFile = claro_get_conf_repository() . $moduleLabel . '.conf.php'; if (file_exists($mainConfigFile)) { include $mainConfigFile; } // check if config overwritten in course and load config file if (claro_is_in_a_course()) { $courseConfigFile = get_conf('coursesRepositorySys') . claro_get_current_course_data('path') . '/conf/' . $moduleLabel . '.conf.php'; if (file_exists($courseConfigFile)) { include $courseConfigFile; } } }
/** * Return the breadcrumb to display in the header * * @global string $nameTools * @global array $interbredcrump * @global boolean $noPHP_SELF * @global boolean $noQUERY_STRING * * @return string html content */ function claro_html_breadcrumb() { // dirty global to keep value (waiting a refactoring) global $nameTools, $interbredcrump, $noPHP_SELF, $noQUERY_STRING; /****************************************************************************** BREADCRUMB LINE ******************************************************************************/ $htmlBC = ''; if (claro_is_in_a_course() || isset($nameTools) || isset($interbredcrump) && is_array($interbredcrump)) { $htmlBC .= '<div id="breadcrumbLine">' . "\n\n" . '<hr />' . "\n"; $breadcrumbUrlList = array(); $breadcrumbNameList = array(); $breadcrumbUrlList[] = get_path('url') . '/index.php'; $breadcrumbNameList[] = get_conf('siteName'); if (claro_is_in_a_course()) { $breadcrumbUrlList[] = get_path('clarolineRepositoryWeb') . 'course/index.php?cid=' . claro_htmlspecialchars(claro_get_current_course_id()); $breadcrumbNameList[] = claro_get_current_course_data('officialCode'); } if (claro_is_in_a_group()) { $breadcrumbUrlList[] = get_module_url('CLGRP') . '/index.php?cidReq=' . claro_htmlspecialchars(claro_get_current_course_id()); $breadcrumbNameList[] = get_lang('Groups'); $breadcrumbUrlList[] = get_module_url('CLGRP') . '/group_space.php?cidReq=' . claro_htmlspecialchars(claro_get_current_course_id()) . '&gidReq=' . (int) claro_get_current_group_id(); $breadcrumbNameList[] = claro_get_current_group_data('name'); } if (isset($interbredcrump) && is_array($interbredcrump)) { while (list(, $bredcrumpStep) = each($interbredcrump)) { $breadcrumbUrlList[] = $bredcrumpStep['url']; $breadcrumbNameList[] = $bredcrumpStep['name']; } } if (isset($nameTools)) { $breadcrumbNameList[] = $nameTools; if (isset($noPHP_SELF) && $noPHP_SELF) { $breadcrumbUrlList[] = null; } elseif (isset($noQUERY_STRING) && $noQUERY_STRING) { $breadcrumbUrlList[] = $_SERVER['PHP_SELF']; } else { // set Query string to empty if not exists if (!isset($_SERVER['QUERY_STRING'])) { $_SERVER['QUERY_STRING'] = ''; } $breadcrumbUrlList[] = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']; } } $htmlBC .= claro_html_breadcrumbtrail($breadcrumbNameList, $breadcrumbUrlList, ' > ', get_icon_url('home')); if (!claro_is_user_authenticated()) { $htmlBC .= "\n" . '<div id="toolViewOption" style="padding-right:10px">' . '<a href="' . get_path('clarolineRepositoryWeb') . 'auth/login.php' . '?sourceUrl=' . urlencode(base64_encode((isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])) . '" target="_top">' . get_lang('Login') . '</a>' . '</div>' . "\n"; } elseif (claro_is_in_a_course() && !claro_is_course_member() && claro_get_current_course_data('registrationAllowed') && !claro_is_platform_admin()) { $htmlBC .= '<div id="toolViewOption">' . '<a href="' . get_path('clarolineRepositoryWeb') . 'auth/courses.php?cmd=exReg&course=' . claro_get_current_course_id() . '">' . '<img src="' . get_icon_url('enroll') . '" alt="" /> ' . '<b>' . get_lang('Enrolment') . '</b>' . '</a>' . '</div>' . "\n"; } elseif (claro_is_display_mode_available()) { $htmlBC .= "\n" . '<div id="toolViewOption">' . "\n"; if (isset($_REQUEST['View mode'])) { $htmlBC .= claro_html_tool_view_option($_REQUEST['View mode']); } else { $htmlBC .= claro_html_tool_view_option(); } if (claro_is_platform_admin() && !claro_is_course_member()) { $htmlBC .= ' | <a href="' . get_path('clarolineRepositoryWeb') . 'auth/courses.php?cmd=exReg&course=' . claro_get_current_course_id() . '">'; $htmlBC .= '<img src="' . get_icon_url('enroll') . '" alt="" /> '; $htmlBC .= '<b>' . get_lang('Enrolment') . '</b>'; $htmlBC .= '</a>'; } $htmlBC .= "\n" . '</div>' . "\n"; } $htmlBC .= '<div class="spacer"></div>' . "\n" . '<hr />' . "\n" . '</div>' . "\n"; } else { // $htmlBC .= '<div style="height:1em"></div>'; } return $htmlBC; }
/** * Is tool visible * * @param integer $tid tool identifier * @param string courseId * @todo to move in a lib * * @return boolean 'true' if it's visible */ function claro_is_tool_visible($tid, $courseId) { global $_mainToolId; static $toolVisibilityCache = false; // load tool id if (is_null($tid)) { if (!empty($_mainToolId)) { $tid = $_mainToolId; } else { return false; } } // load course id if (is_null($courseId)) { if (claro_is_in_a_course()) { $courseId = claro_get_current_course_id(); } else { return false; } } if (!$toolVisibilityCache) { $toolVisibilityCache = array(); $tbl_cdb_names = claro_sql_get_course_tbl(claro_get_course_db_name_glued($courseId)); $sql = " SELECT tool_id, visibility\n FROM `" . $tbl_cdb_names['tool'] . "`"; $tool_visibilityTmp = claro_sql_query_fetch_all_rows($sql); foreach ($tool_visibilityTmp as $tool) { $toolVisibilityCache[$tool['tool_id']] = $tool['visibility']; } } return (bool) $toolVisibilityCache[$tid]; }
* @copyright (c) 2001-2011, Universite catholique de Louvain (UCL) * * @license http://www.gnu.org/copyleft/gpl.html (GPL) GENERAL PUBLIC LICENSE * * @see http://www.claroline.net/wiki/index.php/CLCHT * * @package CLCHT * * @author Claro Team <*****@*****.**> * @author Christophe Gesche <*****@*****.**> * @copyright (c) 2001-2011, Universite catholique de Louvain (UCL) * */ $tlabelReq = 'CLCHT'; require '../inc/claro_init_global.inc.php'; if (!claro_is_in_a_course() || !claro_is_course_allowed() && !claro_is_user_authenticated()) { claro_disp_auth_form(true); } $_course = claro_get_current_course_data(); $nameTools = get_lang('Chat'); $titlePage = ''; if (!empty($nameTools)) { $titlePage .= $nameTools . ' - '; } if (!empty($_course['officialCode'])) { $titlePage .= $_course['officialCode'] . ' - '; } $titlePage .= get_conf('siteName'); // Redirect previously sent paramaters in the correct subframe (messageList.php) $paramList = array(); if (isset($_REQUEST['gidReset']) && $_REQUEST['gidReset'] == TRUE) {
function printInit($selection = "*") { global $uidReset, $cidReset, $gidReset, $tidReset, $uidReq, $cidReq, $gidReq, $tidReq, $tlabelReq, $_user, $_course, $_groupUser, $_courseTool, $_SESSION, $_claro_local_run; if ($_claro_local_run) { echo "local init runned"; } else { echo '<font color="red"> local init never runned during this script </font>'; } echo ' <table width="100%" border="1" cellspacing="4" cellpadding="1" bordercolor="#808080" bgcolor="#C0C0C0" lang="en"> <TR>'; if ($selection == "*" or strstr($selection, "u")) { echo ' <TD valign="top" > <strong>User</strong> : (_uid) : ' . var_export(claro_get_current_user_id(), 1) . ' | (session[_uid]) : ' . var_export($_SESSION["_uid"], 1) . ' <br /> reset = ' . var_export($uidReset, 1) . ' | req = ' . var_export($uidReq, 1) . '<br /> _user : <pre>' . var_export($_user, 1) . '</pre> <br />is_platformAdmin :' . var_export(claro_is_platform_admin(), 1) . ' <br />is_allowedCreateCourse :' . var_export(claro_is_allowed_to_create_course(), 1) . ' </TD>'; } if ($selection == "*" or strstr($selection, "c")) { echo "\n <TD valign=\"top\" >\n <strong>Course</strong> : (_cid)" . var_export(claro_get_current_course_id(), 1) . "\n <br />\n reset = " . var_export($cidReset, 1) . " | req = " . var_export($cidReq, 1) . "\n <br />\n _course : <pre>" . var_export($_course, 1) . "</pre>\n <br />\n _groupProperties :\n <PRE>\n " . var_export(claro_get_current_group_properties_data(), 1) . "\n </PRE>\n </TD>"; } echo ' </TR> <TR>'; if ($selection == "*" or strstr($selection, "g")) { echo '<TD valign="top" ><strong>Group</strong> : (_gid) ' . var_export(claro_get_current_group_id(), 1) . '<br /> reset = ' . var_export($GLOBALS['gidReset'], 1) . ' | req = ' . var_export($gidReq, 1) . "<br />\n _group :<pre>" . var_export(claro_get_current_group_data(), 1) . "</pre></TD>"; } if ($selection == "*" or strstr($selection, "t")) { echo '<TD valign="top" ><strong>Tool</strong> : (_tid)' . var_export(claro_get_current_tool_id(), 1) . '<br /> reset = ' . var_export($tidReset, 1) . ' | req = ' . var_export($tidReq, 1) . '| req = ' . var_export($tlabelReq, 1) . ' <br /> _tool :' . var_export(get_init('_tool'), 1) . "</TD>"; } echo "</TR>"; if ($selection == "*" or strstr($selection, "u") && strstr($selection, "c")) { echo '<TR><TD valign="top" colspan="2"><strong>Course-User</strong>'; if (claro_is_user_authenticated()) { echo '<br /><strong>User</strong> :' . var_export(claro_is_in_a_course(), 1); } if (claro_is_in_a_course()) { echo ' in ' . var_export(claro_get_current_course_id(), 1) . '<br />'; } if (claro_is_user_authenticated() && claro_get_current_course_id()) { echo '_courseUser : <pre>' . var_export(getInit('_courseUser'), 1) . '</pre>'; } echo '<br />is_courseMember : ' . var_export(claro_is_course_member(), 1); echo '<br />is_courseAdmin : ' . var_export(claro_is_course_manager(), 1); echo '<br />is_courseAllowed : ' . var_export(claro_is_course_allowed(), 1); echo '<br />is_courseTutor : ' . var_export(claro_is_course_tutor(), 1); echo '</TD></TR>'; } echo ""; if ($selection == "*" or strstr($selection, "u") && strstr($selection, "g")) { echo '<TR><TD valign="top" colspan="2">' . '<strong>Course-Group-User</strong>'; if (claro_is_user_authenticated()) { echo '<br /><strong>User</strong> :' . var_export(claro_is_in_a_course(), 1); } if (claro_is_in_a_group()) { echo ' in ' . var_export(claro_get_current_group_id(), 1); } if (claro_is_in_a_group()) { echo '<br />_groupUser:'******'_groupUser'), 1); } echo '<br />is_groupMember:' . var_export(claro_is_group_member(), 1) . '<br />is_groupTutor: ' . var_export(claro_is_group_tutor(), 1) . '<br />is_groupAllowed:' . var_export(claro_is_group_allowed(), 1) . '</TD>' . '</tr>'; } if ($selection == "*" or strstr($selection, "c") && strstr($selection, "t")) { echo '<tr> <TD valign="top" colspan="2" ><strong>Course-Tool</strong><br />'; if (claro_get_current_tool_id()) { echo 'Tool :' . claro_get_current_tool_id(); } if (claro_is_in_a_course()) { echo ' in ' . claro_get_current_course_id() . '<br />'; } if (claro_get_current_tool_id()) { echo "_courseTool : <pre>" . var_export($_courseTool, 1) . '</pre><br />'; } echo 'is_toolAllowed : ' . var_export(claro_is_tool_allowed(), 1); echo "</TD>"; } echo "</TR></TABLE>"; }
private function autoPrepend() { if (empty($this->currentNode) && array_key_exists('nameTools', $GLOBALS)) { $name = $GLOBALS['nameTools']; if (array_key_exists('noPHP_SELF', $GLOBALS) && $GLOBALS['noPHP_SELF']) { $url = null; } elseif (array_key_exists('noQUERY_STRING', $GLOBALS) && $GLOBALS['noQUERY_STRING']) { $url = $_SERVER['PHP_SELF']; } else { if (!array_key_exists('noQUERY_STRING', $_SERVER)) { $url = $_SERVER['PHP_SELF']; } else { $url = $_SERVER['PHP_SELF'] . '?' . claro_htmlspecialchars(strip_tags($_SERVER['QUERY_STRING'])); } } $url = claro_htmlspecialchars(Url::Contextualize($url)); $this->setCurrentNode(new BreadCrumbsNode($name, $url)); } if (claro_is_in_a_group()) { $this->prependNode(new BreadCrumbsNode(claro_get_current_group_data('name'), claro_htmlspecialchars(get_module_url('CLGRP') . '/group_space.php?cidReq=' . claro_htmlspecialchars(claro_get_current_course_id()) . '&gidReq=' . (int) claro_get_current_group_id()))); $this->prependNode(new BreadCrumbsNode(get_lang('Groups'), claro_htmlspecialchars(get_module_url('CLGRP') . '/index.php?cidReq=' . claro_htmlspecialchars(claro_get_current_course_id())))); } if (claro_is_in_a_course()) { $this->prependNode(new BreadCrumbsNode(claro_get_current_course_data('officialCode'), claro_htmlspecialchars(get_path('clarolineRepositoryWeb') . 'course/index.php?cid=' . claro_get_current_course_id()))); } $this->prependNode(new BreadCrumbsNode(get_conf('siteName'), claro_htmlspecialchars(get_path('url') . '/index.php'), get_icon_url('home'))); }
if ($cmd == 'exEnable') { if (!claro_is_course_manager() && !claro_is_platform_admin()) { claro_die(get_lang("Not allowed")); exit; } if (($course->status == 'disable' || $course->status == 'trash') && !claro_is_platform_admin()) { claro_die(get_lang("Not allowed")); exit; } elseif (($course->status == 'disable' || $course->status == 'trash') && claro_is_platform_admin()) { $course->status = 'enable'; if ($course->save()) { $dialogBox->success(get_lang('This course has been activated and is now available on this platform')); } else { $dialogBox->error(get_lang('Unable to reactivate this course')); } } elseif ($course->status == 'pending' && claro_is_in_a_course() && claro_is_course_manager()) { $course->status = 'enable'; if ($course->save()) { $dialogBox->success(get_lang('This course has been activated and is now available on this platform')); } else { $dialogBox->error(get_lang('Unable to reactivate this course')); } } else { $dialogBox->error(get_lang('This course is already activated')); } } if ($cmd == 'exEdit') { $course->handleForm(); if ($course->validate()) { if ($course->save()) { $dialogBox->success(get_lang('The information have been modified'));
<?php // $Id: question_pool.php 14420 2013-04-12 12:22:30Z zefredz $ /** * CLAROLINE * * @version $Revision: 14420 $ * @copyright (c) 2001-2011, Universite catholique de Louvain (UCL) * @license http://www.gnu.org/copyleft/gpl.html (GPL) GENERAL PUBLIC LICENSE * @author Claro Team <*****@*****.**> */ $tlabelReq = 'CLQWZ'; require '../../inc/claro_init_global.inc.php'; if (!claro_is_in_a_course() || !claro_is_course_allowed()) { claro_disp_auth_form(true); } $is_allowedToEdit = claro_is_allowed_to_edit(); // courseadmin reserved page if (!$is_allowedToEdit) { header("Location: " . Url::Contextualize("../exercise.php")); exit; } require_once '../lib/add_missing_table.lib.php'; init_qwz_questions_categories(); // tool libraries include_once '../lib/exercise.class.php'; include_once '../lib/question.class.php'; include_once '../lib/exercise.lib.php'; // claroline libraries include_once get_path('incRepositorySys') . '/lib/form.lib.php'; include_once get_path('incRepositorySys') . '/lib/pager.lib.php';
/** * Get the authentication profile for the given user id * @param int $userId * @return AuthProfile */ public static function getUserAuthProfile($userId) { if ($userId != claro_get_current_user_id()) { $user = new Claro_User($userId); $user->loadFromDatabase(); } else { $user = Claro_CurrentUser::getInstance(); } $authSource = $user->authSource; if (!$authSource) { throw new Exception("Cannot find user authentication source for user {$userId}"); } try { $profileOptions = AuthDriverManager::getDriver($authSource)->getAuthProfileOptions(); } catch (Exception $e) { if (claro_is_platform_admin() || claro_is_in_a_course() && claro_is_course_manager() && $userId != claro_get_current_user_id()) { Console::warning("Cannot find user authentication source for user {$userId}, use claroline default options instead"); $profileOptions = AuthDriverManager::getDriver('claroline')->getAuthProfileOptions(); } else { throw $e; } } $authProfile = new AuthProfile($userId, $authSource); $authProfile->setAuthDriverOptions($profileOptions); if (claro_debug_mode()) { pushClaroMessage(var_export($profileOptions, true), 'debug'); } return $authProfile; }