/** * Display the tree of classes * * @author Guillaume Lederer * @param list of all the classes informations of the platform * @param list of the classes that must be visible * @return * * @see * */ function display_tree_class_in_user($class_list, $course_code, $parent_class = null, $deep = 0) { $tbl_mdb_names = claro_sql_get_main_tbl(); $tbl_course = $tbl_mdb_names['course']; $html_form = ''; // Get the course id with cours code $sql = "SELECT `C`.`cours_id`\n FROM `" . $tbl_course . "` as C\n WHERE `code` = '" . $course_code . "'"; claro_sql_query_get_single_value($sql); foreach ($class_list as $cur_class) { if ($parent_class == $cur_class['class_parent_id']) { // Set space characters to add in name display $blankspace = ' '; for ($i = 0; $i < $deep; $i++) { $blankspace .= ' '; } // See if current class to display has children $has_children = FALSE; foreach ($class_list as $search_parent) { if ($cur_class['id'] == $search_parent['class_parent_id']) { $has_children = TRUE; break; } } // Set link to open or close current class if ($has_children) { if (isset($_SESSION['class_add_visible_class'][$cur_class['id']]) && $_SESSION['class_add_visible_class'][$cur_class['id']] == "open") { $open_close_link = '<a href="' . $_SERVER['PHP_SELF'] . '?cmd=exClose&class_id=' . $cur_class['id'] . '">' . "\n" . '<img src="' . get_icon_url('collapse') . '" alt="" />' . "\n" . '</a>' . "\n"; } else { $open_close_link = '<a href="' . $_SERVER['PHP_SELF'] . '?cmd=exOpen&class_id=' . $cur_class['id'] . '">' . "\n" . '<img src="' . get_icon_url('expand') . '" alt="" />' . "\n" . '</a>' . "\n"; } } else { $open_close_link = ' ° '; } // Display current class $qty_user = get_class_user_number($cur_class['id']); // Need some optimisation here ... $html_form .= '<tr>' . "\n" . '<td>' . "\n" . $blankspace . $open_close_link . " " . $cur_class['name'] . '</td>' . "\n" . '<td align="center">' . "\n" . $qty_user . ' ' . get_lang('UsersMin') . '</td>' . "\n" . '<td align="center">' . "\n"; if (empty($cur_class['course_id'])) { $html_form .= '<a href="' . $_SERVER['PHP_SELF'] . '?cmd=exEnrol&class_id=' . $cur_class['id'] . '"' . ' onclick="return confirmation_enrol(\'' . clean_str_for_javascript($cur_class['name']) . '\');">' . '<img src="' . get_icon_url('enroll') . '" alt="' . get_lang('Enrol to course') . '" />' . "\n" . '</a>' . "\n"; } else { $html_form .= '<a href="' . $_SERVER['PHP_SELF'] . '?cmd=exUnenrol&class_id=' . $cur_class['id'] . '"' . ' onclick="return confirmation_unenrol(\'' . clean_str_for_javascript($cur_class['name']) . '\');">' . '<img src="' . get_icon_url('unenroll') . '" alt="' . get_lang('Unenrol from course') . '" />' . "\n" . '</a>' . "\n"; } $html_form .= '</td>' . "\n" . '</tr>' . "\n"; // RECURSIVE CALL TO DISPLAY CHILDREN if (isset($_SESSION['class_add_visible_class'][$cur_class['id']]) && $_SESSION['class_add_visible_class'][$cur_class['id']] == 'open') { $html_form .= display_tree_class_in_user($class_list, $course_code, $cur_class['id'], $deep + 1); } } } return $html_form; }
return true; } // End --> </script>'); $content .= get_lang('To send a message, select groups of users (marked with a * in the front) or single users from the list on the left.') . "<br/><br/>\n"; $content .= '<div class="messagesform">' . "\n"; $content .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '" name="datos" ' . 'onsubmit="return valida();">' . "\n" . claro_form_relay_context() . "\n" . '<div class="userList">' . "\n" . '<input type="hidden" name="claroFormId" value="' . uniqid('') . '" />' . "\n" . '<input type="hidden" name="cmd" value="exSendMessage" />' . "\n" . '<table class="multiselect">' . "\n" . '<tr>' . "\n" . '<td>' . "\n" . get_lang('User list') . '<br/>' . "\n" . '<select name="nocorreo[]" size="15" multiple="multiple" id="mslist1">' . "\n"; if ($groupList) { foreach ($groupList as $thisGroup) { $content .= '<option value="GROUP:' . $thisGroup['id'] . '">' . '* ' . $thisGroup['name'] . ' (' . $thisGroup['userNb'] . ' ' . get_lang('Users') . ')' . '</option>' . "\n"; } } if ($classList) { foreach ($classList as $thisClass) { $content .= '<option value="CLASS:' . $thisClass['id'] . '">' . '* ' . $thisClass['name'] . ' (' . get_class_user_number($thisClass['id']) . ' ' . get_lang('Users') . ')' . '</option>' . "\n"; } } $content .= '<option value="">' . '---------------------------------------------------------' . '</option>' . "\n"; // display user list foreach ($userList as $thisUser) { $content .= '<option value="USER:'******'user_id'] . '">' . ucwords(strtolower($thisUser['nom'] . ' ' . $thisUser['prenom'])) . '</option>' . "\n"; } // WATCH OUT ! form elements are called by numbers "form.element[3]"... // because select name contains "[]" causing a javascript // element name problem List of selected users $content .= '</select></td>' . "\n" . '<td class="arrows">' . '<a href="#" class="msadd"><img src="' . get_icon_url('go_right') . '" /></a>' . '<br /><br />' . '<a href="#" class="msremove"><img src="' . get_icon_url('go_left') . '" /></a>' . '</td>' . '<td>' . get_lang('Selected Users') . "<br/>" . "\n" . '<select name="incorreo[]" size="15" multiple="multiple" id="mslist2">' . '</select>' . "\n" . '</td>' . '</tr>' . '</table>' . "\n" . '<div class="composeMessage">' . "\n" . '<br/>' . get_lang('Subject') . '<br />' . "\n" . '<input type="text" name="subject" maxlength="255" size="40" />' . '<br/>' . get_lang('Message') . '<br/>' . "\n" . claro_html_textarea_editor('content', "") . '<br/><input type="submit" name="submitMessage" value="' . get_lang('Submit') . '" />' . claro_html_button(claro_htmlspecialchars(Url::Contextualize($from)), get_lang('Cancel')) . '</div>' . "\n" . '</div>' . "\n\n" . '</form>' . "\n\n" . '</div>'; } $claroline->display->body->appendContent(claro_html_tool_title(get_lang('Messages to selected users'))); $claroline->display->body->appendContent($content); // ------------- Display page -----------------------------