function get_sort_url_list($url, $defaultArrayKeyList = array(), $context = null) { $urlList = array(); $sortArgList = array(); if (count($this->get_result_list())) { list($firstResultRow) = $this->get_result_list(); $sortArgList = array_keys($firstResultRow); } else { $sortArgList = $defaultArrayKeyList; } foreach ($sortArgList as $thisArg) { if (array_key_exists($thisArg, $this->sortKeyList) && $this->sortKeyList[$thisArg] != SORT_DESC) { $direction = SORT_DESC; } else { $direction = SORT_ASC; } $urlList[$thisArg] = $url . (strstr($url, '?') !== false ? '&' : '?') . $this->sortKeyParamName . '=' . urlencode($thisArg) . '&' . $this->sortDirParamName . '=' . $direction . claro_url_relay_context('&', $context); } return $urlList; }
/** * This dirty function is a blackbox to provide normalised output of tool list for a group * like get_course_tool_list($course_id=NULL) in course_home. * * It's dirty because data structure is dirty. * Tool_list (with clarolabel and tid come from tool tables and group properties and localinit) * @param $course_id * @param boolean $active, if set to true, only activated tools of the platform must be returned * @author Christophe Gesche <*****@*****.**> * @return array */ function get_group_tool_list($course_id = NULL, $active = true) { global $forumId; $_groupProperties = claro_get_current_group_properties_data(); $isAllowedToEdit = claro_is_course_manager() || claro_is_platform_admin(); $tbl = claro_sql_get_main_tbl(array('module', 'course_tool')); $tbl_cdb_names = claro_sql_get_course_tbl(claro_get_course_db_name_glued($course_id)); $tbl['course_tool'] = $tbl_cdb_names['tool']; // This stupid array is an hack to simulate the context // managing by module structure // It's represent tools aivailable to work in a group context. // $aivailable_tool_in_group = array('CLFRM','CLCHT','CLDOC','CLWIKI'); $sql = "\nSELECT tl.id id,\n tl.script_name name,\n tl.visibility visibility,\n tl.rank rank,\n IFNULL(ct.script_url,tl.script_url) url,\n ct.claro_label label,\n ct.icon icon,\n m.activation activation\nFROM `" . $tbl['course_tool'] . "` tl\nLEFT JOIN `" . $tbl['tool'] . "` `ct`\nON ct.id = tl.tool_id\nLEFT JOIN `" . $tbl['module'] . "` `m`\nON m.label = ct.claro_label\nLEFT JOIN `" . $tbl['module_contexts'] . "` `mc`\nON m.id = mc.module_id\nWHERE `mc`.`context` = 'group'\nORDER BY tl.rank\n\n"; $tool_list = claro_sql_query_fetch_all($sql); $group_tool_list = array(); foreach ($tool_list as $tool) { $tool['label'] = trim($tool['label'], '_'); if ($active !== true || 'activated' == $tool['activation']) { switch ($tool['label']) { case 'CLFRM': if (!empty($_groupProperties['tools']['CLFRM']) || $isAllowedToEdit) { $tool['url'] = 'viewforum.php?forum=' . $forumId . claro_url_relay_context('&'); $group_tool_list[] = $tool; } break; default: if (isset($_groupProperties['tools'][$tool['label']]) && $_groupProperties['tools'][$tool['label']] || $isAllowedToEdit) { $tool['url'] .= claro_url_relay_context('?'); $group_tool_list[] = $tool; } break; } } } return $group_tool_list; }
* @package CLCHT * * @author Claro Team <*****@*****.**> * @author Christophe Gesché <*****@*****.**> * @copyright (c) 2001-2011, Universite catholique de Louvain (UCL) * */ require '../inc/claro_init_global.inc.php'; $is_allowedToManage = claro_is_course_manager() || claro_is_in_a_group() && claro_is_group_tutor(); // header $htmlHeadXtra[] = ' <script type="text/javascript"> function prepare_message() { document.chatForm.chatLine.value=document.chatForm.msg.value; document.chatForm.msg.value = ""; document.chatForm.msg.focus(); return true; } </script>'; $cmdMenu = array(); if ($is_allowedToManage) { $cmdMenu[] = claro_html_cmd_link('messageList.php?cmd=reset' . claro_url_relay_context('&'), get_lang('Reset'), array('target' => "messageList")); $cmdMenu[] = claro_html_cmd_link('messageList.php?cmd=store' . claro_url_relay_context('&'), get_lang('Store Chat'), array('target' => "messageList")); } $hide_banner = TRUE; // Turn off session lost $warnSessionLost = false; include get_path('incRepositorySys') . '/claro_init_header.inc.php'; echo '<form name="chatForm" action="messageList.php#final" method="post" target="messageList" onsubmit="return prepare_message();">' . "\n" . claro_form_relay_context() . '<input type="text" name="msg" size="80" />' . "\n" . '<input type="hidden" name="chatLine" />' . "\n" . '<input type="submit" value=" >> " />' . "\n" . '<br />' . "\n" . '' . "\n" . claro_html_menu_horizontal($cmdMenu) . '</form>'; include get_path('incRepositorySys') . '/claro_init_footer.inc.php';
} else { Console::error("Class {$form_data['class_id']} cannot be removed from course " . claro_get_current_course_id() . " by " . claro_get_current_user_id() . " : " . var_export($registration->getErrorLog(), true)); $dialogBox->error(get_lang('Cannot enrol class')); } break; } /*---------------------------------------------------------------------*/ /*----------------------FIND information SECTION-----------------------*/ /*---------------------------------------------------------------------*/ $classList = get_class_list_by_course(claro_get_current_course_id()); /*---------------------------------------------------------------------*/ /*----------------------DISPLAY SECTION--------------------------------*/ /*---------------------------------------------------------------------*/ // set bredcrump $nameTools = get_lang('Enrol class'); ClaroBreadCrumbs::getInstance()->prepend(get_lang('Users'), 'user.php' . claro_url_relay_context('?')); // javascript confirm pop up declaration for header $htmlHeadXtra[] = '<script type="text/javascript"> function confirmation_enrol (name) { if (confirm("' . clean_str_for_javascript(get_lang('Are you sure you want to enrol the whole class on the course ?')) . '")) {return true;} else {return false;} } function confirmation_unenrol (name) { if (confirm("' . clean_str_for_javascript(get_lang('Are you sure you want to unenrol the whole class on the course ?')) . '")) {return true;} else {return false;}
/** * This function is used to display comments of module or learning path with admin links if needed. * Admin links are 'edit' and 'delete' links. * * @param string $type MODULE_ , LEARNINGPATH_ , LEARNINGPATHMODULE_ * @param string $mode DISPLAY_ , UPDATE_ , DELETE_ * * @author Piraux S�bastien <*****@*****.**> * @author Lederer Guillaume <*****@*****.**> */ function commentBox($type, $mode) { $tbl_cdb_names = claro_sql_get_course_tbl(); $tbl_lp_learnPath = $tbl_cdb_names['lp_learnPath']; $tbl_lp_rel_learnPath_module = $tbl_cdb_names['lp_rel_learnPath_module']; $tbl_lp_module = $tbl_cdb_names['lp_module']; $out = ''; // globals global $is_allowedToEdit; // will be set 'true' if the comment has to be displayed $dsp = false; // those vars will be used to build sql queries according to the comment type switch ($type) { case MODULE_: $defaultTxt = get_lang('blockDefaultModuleComment'); $col_name = 'comment'; $tbl_name = $tbl_lp_module; if (isset($_REQUEST['module_id'])) { $module_id = $_REQUEST['module_id']; } else { $module_id = $_SESSION['module_id']; } $where_cond = "`module_id` = " . (int) $module_id; // use backticks ( ` ) for col names and simple quote ( ' ) for string break; case LEARNINGPATH_: $defaultTxt = get_lang('blockDefaultLearningPathComment'); $col_name = 'comment'; $tbl_name = $tbl_lp_learnPath; $where_cond = '`learnPath_id` = ' . (int) $_SESSION['path_id']; // use backticks ( ` ) for col names and simple quote ( ' ) for string break; case LEARNINGPATHMODULE_: $defaultTxt = get_lang('blockDefaultModuleAddedComment'); $col_name = 'specificComment'; $tbl_name = $tbl_lp_rel_learnPath_module; $where_cond = "`learnPath_id` = " . (int) $_SESSION['path_id'] . "\n AND `module_id` = " . (int) $_SESSION['module_id']; // use backticks ( ` ) for col names and simple quote ( ' ) for string break; } // update mode // allow to chose between // - update and show the comment and the pencil and the delete cross (UPDATE_) // - update and nothing displayed after form sent (UPDATENOTSHOWN_) if (($mode == UPDATE_ || $mode == UPDATENOTSHOWN_) && $is_allowedToEdit) { if (isset($_POST['insertCommentBox'])) { $sql = "UPDATE `" . $tbl_name . "`\n SET `" . $col_name . "` = \"" . claro_sql_escape($_POST['insertCommentBox']) . "\"\n WHERE " . $where_cond; claro_sql_query($sql); if ($mode == UPDATE_) { $dsp = true; } elseif ($mode == UPDATENOTSHOWN_) { $dsp = false; } } else { // get info to fill the form in $sql = "SELECT `" . $col_name . "`\n FROM `" . $tbl_name . "`\n WHERE " . $where_cond; $oldComment = claro_sql_query_get_single_value($sql); $out .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">' . "\n" . claro_html_textarea_editor('insertCommentBox', $oldComment, 15, 55) . '<br />' . "\n" . '<input type="hidden" name="cmd" value="update' . $col_name . '" />' . '<input type="submit" value="' . get_lang('Ok') . '" />' . "\n" . '<br />' . "\n" . '</form>' . "\n"; } } // delete mode if ($mode == DELETE_ && $is_allowedToEdit) { $sql = "UPDATE `" . $tbl_name . "`\n SET `" . $col_name . "` = ''\n WHERE " . $where_cond; claro_sql_query($sql); $dsp = TRUE; } // display mode only or display was asked by delete mode or update mode if ($mode == DISPLAY_ || $dsp == TRUE) { $sql = "SELECT `" . $col_name . "`\n FROM `" . $tbl_name . "`\n WHERE " . $where_cond; $currentComment = claro_sql_query_get_single_value($sql); // display nothing if this is default comment and not an admin if ($currentComment == $defaultTxt && !$is_allowedToEdit) { return ''; } if (empty($currentComment)) { // if no comment and user is admin : display link to add a comment if ($is_allowedToEdit) { $textLink = ''; if ($type == MODULE_) { $textLink = get_lang('Add a comment to this module'); } elseif ($type == LEARNINGPATHMODULE_) { $textLink = get_lang('Add a specific comment to this module'); } else { $textLink = get_lang('Add a comment'); } $out .= '<p>' . "\n" . claro_html_cmd_link($_SERVER['PHP_SELF'] . '?cmd=update' . $col_name . claro_url_relay_context('&'), $textLink) . '</p>' . "\n"; } } else { // display comment $out .= "<p>" . claro_parse_user_text($currentComment) . "</p>"; // display edit and delete links if user as the right to see it if ($is_allowedToEdit) { $out .= '<p>' . "\n" . '<small>' . "\n" . '<a href="' . $_SERVER['PHP_SELF'] . '?cmd=update' . $col_name . '">' . "\n" . '<img src="' . get_icon_url('edit') . '" alt="' . get_lang('Modify') . '" />' . "\n" . '</a>' . "\n" . '<a href="' . $_SERVER['PHP_SELF'] . '?cmd=del' . $col_name . '" ' . ' onclick="javascript:if(!confirm(\'' . clean_str_for_javascript(get_lang('Please confirm your choice')) . '\')) return false;">' . "\n" . '<img src="' . get_icon_url('delete') . '" alt="' . get_lang('Delete') . '" />' . "\n" . '</a>' . "\n" . '</small>' . "\n" . '</p>' . "\n"; } } } return $out; }
if ($cmd == 'registration') { /* * Two possible ways to enroll a user to a course : * Registration of a completly new user from $userData * Registration of an existing user form its $userId */ if ($userData && !$userId) { $errorMsgList = user_validate_form_registration($userData); if (count($errorMsgList) == 0) { $validUserData = true; } else { $validUserData = false; } if (in_array(get_lang('This official code is already used by another user.'), $errorMsgList)) { $userList = user_search(array('officialCode' => $userData['officialCode']), claro_get_current_course_id(), false, true, false); $dialogBox->error(get_lang('This official code is already used by another user.') . '<br />' . get_lang('Take one of these options') . ' : ' . '<ul>' . '<li>' . '<a href="#resultTable">' . get_lang('Click on the enrollment command beside the concerned user') . '</a>' . '</li>' . '<li>' . '<a href="' . $_SERVER['PHP_SELF'] . '?cmd=cancel' . claro_url_relay_context('&') . '">' . get_lang('Cancel the operation') . '</a>' . '</li>' . '</ul>'); $displayResultTable = true; } elseif (!$userData['confirmUserCreate'] && !(empty($userData['lastname']) && empty($userData['email']))) { $userList = user_search(array('lastname' => $userData['lastname'], 'email' => $userData['email']), claro_get_current_course_id(), false, true, false); if (count($userList) > 0) { // PREPARE THE URL command TO CONFIRM THE USER CREATION $confirmUserCreateUrl = array(); foreach ($userData as $thisDataKey => $thisDataValue) { $confirmUserCreateUrl[] = $thisDataKey . '=' . urlencode($thisDataValue); } $confirmUserCreateUrl = Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=registration&' . implode('&', $confirmUserCreateUrl) . '&confirmUserCreate=1'); $dialogBox->warning(get_lang('Notice') . '. ' . get_lang('Users with similar settings exist on the system yet') . '<br />' . get_lang('Take one of these options') . ' : ' . '<ul>' . '<li>' . '<a href="#resultTable" onclick="highlight(\'resultTable\');">' . get_lang('Click on the enrollment command beside the concerned user') . '</a>' . '</li>' . '<li>' . '<a href="' . claro_htmlspecialchars($confirmUserCreateUrl) . '">' . get_lang('Confirm the creation of a new user') . '</a>' . '<br /><small>' . $userData['lastname'] . ' ' . $userData['firstname'] . $userData['officialCode'] . ' ' . $userData['email'] . '</small>' . '</li>' . '<li>' . '<a href="' . claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=cancel')) . '">' . get_lang('Cancel the operation') . '</a>' . '</li>' . '</ul>'); $displayForm = false; $displayResultTable = true; } } else {
if ($cmd == 'rqFlush' && $is_allowedToEdit) { $msgList = new ChatMsgList($courseId, $groupId); if ($msgList->flush()) { $dialogBox = new DialogBox(); $dialogBox->success(get_lang('Chat reset')); echo claro_utf8_encode($dialogBox->render()); } return; } if ($cmd == 'rqLogs' && $is_allowedToEdit) { $msgList = new ChatMsgList($courseId, $groupId); $msgList->load(1, $_SESSION['chat_connectionTime']); echo claro_utf8_encode($msgList->render()); return; } if ($cmd == 'rqArchive' && $is_allowedToEdit) { $msgList = new ChatMsgList($courseId, $groupId); $msgList->load(); if ($chatFilename = $msgList->archive()) { $downloadLink = '<a href="' . get_module_url('CLDOC') . '/document.php' . claro_url_relay_context('?') . '">' . basename($chatFilename) . '</a>'; $dialogBox = new DialogBox(); $dialogBox->success(get_lang('%chat_filename is now in the document tool. (<em>This file is visible</em>)', array('%chat_filename' => $downloadLink))); echo claro_utf8_encode($dialogBox->render()); return; } else { $dialogBox = new DialogBox(); $dialogBox->error(get_lang('Store failed')); echo claro_utf8_encode($dialogBox->render()); return; } }
$claroline->display->banner->breadcrumbs->append(get_lang('Administration'), get_path('rootAdminWeb')); } elseif ($_REQUEST['typeRecipient'] == 'group') { $recipient = new GroupRecipient($_POST['groupRecipient'], $_POST['courseRecipient']); $message->setCourse($_POST['courseRecipient']); $message->setGroup($_POST['groupRecipient']); } else { claro_die(get_lang('unknow recipient type')); } $recipient->sendMessage($message); $informationString = get_lang('Message sent') . '<br /><br />' . '<a href="messagebox.php?box=inbox">' . get_lang('Back to inbox') . '</a>'; $dialogbox = new DialogBox(); $dialogbox->info($informationString); if ($failure = claro_failure::get_last_failure()) { $dialogbox->warning($failure); } $content .= $dialogbox->render(); } } } } // ------------ Prepare display -------------------- if ($addForm) { $message = claro_html_sanitize_all($message); $content .= "<br/>"; $content .= '<form method="post" action="sendmessage.php?cmd=exSendMessage' . claro_url_relay_context('&') . '">' . "\n" . '<input type="hidden" name="claroFormId" value="' . uniqid('') . '" />' . "\n" . claro_form_relay_context() . "\n" . '<input type="hidden" name="cmd" value="exSendMessage" />' . "\n" . '<input type="hidden" name="typeRecipient" value="' . $typeRecipient . '" />' . "\n" . '<input type="hidden" name="userRecipient" value="' . $userRecipient . '" />' . "\n" . '<input type="hidden" name="courseRecipient" value="' . $courseRecipient . '" />' . "\n" . '<input type="hidden" name="groupRecipient" value="' . $groupRecipient . '" />' . "\n" . '<input type="hidden" name="responseTo" value="' . $responseTo . '" />' . "\n" . '<label for="message_subject">' . get_lang('Subject') . ' : </label><br/><input type="text" id="message_subject" name="subject" value="' . claro_htmlspecialchars($subject) . '" maxlength="255" size="40" /><br/>' . "\n" . '<label for="message">' . get_lang('Message') . ' : </label><br/>' . claro_html_textarea_editor('message', $message) . '<br/><br/>' . "\n" . '<input type="submit" value="' . get_lang('Send') . '" name="send" />' . "\n" . '</form>' . "\n\n"; } $claroline->display->body->appendContent(claro_html_tool_title(get_lang('Compose a message'))); $claroline->display->body->appendContent($content); // ------------- Display page ----------------------------- echo $claroline->display->render(); // ------------- End of script ----------------------------