/** * Display the tree of classes * * @param unknown_type $class_list list of all the classes informations of the platform * @param unknown_type $parent_class * @param unknown_type $deep * @return unknown */ function display_tree_class_in_admin($class_list, $parent_class = null, $deep = 0) { // Global variables needed $html_form = ''; 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['admin_visible_class'][$cur_class['id']]) && $_SESSION['admin_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 ELEMENT (CLASS) //Name $qty_user = get_class_user_number($cur_class['id']); $qty_cours = get_class_cours_number($cur_class['id']); $html_form .= '<tr>' . "\n" . '<td>' . "\n" . ' ' . $blankspace . $open_close_link . ' ' . $cur_class['name'] . '</td>' . "\n" . '<td align="center">' . "\n" . '<a href="' . get_path('clarolineRepositoryWeb') . 'admin/admin_class_user.php?class_id=' . $cur_class['id'] . '">' . "\n" . '<img src="' . get_icon_url('user') . '" alt="' . get_lang('User') . '" />' . "\n" . '(' . $qty_user . ' ' . get_lang('UsersMin') . ')' . "\n" . '</a>' . "\n" . '</td>' . "\n" . '<td align="center">' . "\n" . '<a href="' . get_path('clarolineRepositoryWeb') . 'admin/admin_class_cours.php?class_id=' . $cur_class['id'] . '">' . "\n" . '<img src="' . get_icon_url('course') . '" alt="' . get_lang('Course') . '" /> ' . '(' . $qty_cours . ' ' . get_lang('Course') . ') ' . "\n" . '</a>' . "\n" . '</td>' . "\n" . '<td align="center">' . "\n" . '<a href="' . $_SERVER['PHP_SELF'] . '?cmd=rqEdit&class_id=' . $cur_class['id'] . '">' . "\n" . '<img src="' . get_icon_url('edit') . '" alt="' . get_lang('Edit') . '" />' . "\n" . '</a>' . "\n" . '</td>' . "\n" . '<td align="center">' . "\n" . '<a href="' . $_SERVER['PHP_SELF'] . '?cmd=rqMove&class_id=' . $cur_class['id'] . '&class_name=' . $cur_class['name'] . '">' . "\n" . '<img src="' . get_icon_url('move') . '" alt="' . get_lang('Move') . '" />' . "\n" . '</a>' . "\n" . '</td>' . "\n" . '<td align="center">' . "\n" . '<a href="' . $_SERVER['PHP_SELF'] . '?cmd=exDelete&class_id=' . $cur_class['id'] . '"' . ' onclick="return ADMIN.confirmationDel(\'' . clean_str_for_javascript($cur_class['name']) . '\');">' . "\n" . '<img src="' . get_icon_url('delete') . '" alt="' . get_lang('Delete') . '" />' . "\n" . '</a>' . "\n" . '</td>' . "\n" . '</tr>' . "\n"; // RECURSIVE CALL TO DISPLAY CHILDREN if (isset($_SESSION['admin_visible_class'][$cur_class['id']]) && $_SESSION['admin_visible_class'][$cur_class['id']] == "open") { $html_form .= display_tree_class_in_admin($class_list, $cur_class['id'], $deep + 1); } } } return $html_form; }
$dialogBox->form('<form action="' . $_SERVER['PHP_SELF'] . '">' . '<table>' . '<tr>' . "\n" . '<td>' . "\n" . get_lang('Move') . " " . claro_htmlspecialchars($form_data['class_name']) . ' : ' . '</td>' . "\n" . '<td>' . "\n" . '<input type="hidden" name="cmd" value="exMove" />' . "\n" . '<input type="hidden" name="class_id" value="' . $form_data['class_id'] . '" />' . "\n" . displaySelectBox() . '<input type="submit" value="' . get_lang('Ok') . '" />' . "\n" . '</td>' . "\n" . '</tr>' . "\n" . '</table>' . '</form>'); break; } // Get all classes $class_list = get_class_list(); // Command list $cmdList = array(); $cmdList[] = array('img' => 'class', 'name' => get_lang('Create a new class'), 'url' => $_SERVER['PHP_SELF'] . '?cmd=rqAdd'); if (class_exist()) { $cmdList[] = array('img' => 'class', 'name' => get_lang('Empty all classes'), 'url' => $_SERVER['PHP_SELF'] . '?cmd=exEmptyAll', 'params' => array('onclick' => 'if (confirm(\'' . clean_str_for_javascript(get_lang('Empty all classes ?')) . '\')){return true;}else{return false;}"')); $cmdList[] = array('img' => 'class', 'name' => get_lang('Delete all classes'), 'url' => $_SERVER['PHP_SELF'] . '?cmd=exDeleteAll', 'params' => array('onclick' => 'if (confirm(\'' . clean_str_for_javascript(get_lang('Delete all classes ?')) . '\')){return true;}else{return false;}"')); } //------------------------------------------------------- // Display section //------------------------------------------------------- $out = ''; // Display title $out .= claro_html_tool_title($nameTools, null, $cmdList); // Display dialog Box (or any forms) $out .= $dialogBox->render(); // Display cols headers $out .= '<table class="claroTable emphaseLine" width="100%" border="0" cellspacing="2">' . "\n" . '<thead>' . "\n" . '<tr>' . '<th>' . get_lang('Classes') . '</th>' . '<th>' . get_lang('Users') . '</th>' . '<th>' . get_lang('Courses') . '</th>' . '<th>' . get_lang('Edit settings') . '</th>' . '<th>' . get_lang('Move') . '</th>' . '<th>' . get_lang('Delete') . '</th>' . '</tr>' . "\n" . '</thead>' . "\n" . '<tbody>' . "\n"; // Display class list if (display_tree_class_in_admin($class_list)) { $out .= display_tree_class_in_admin($class_list); } else { $out .= "\n" . '<tr>' . '<td colspan="6" class="centerContent">' . get_lang('Empty') . '</td>' . '</tr>' . "\n"; } $out .= '</tbody>' . "\n" . '</table>'; $claroline->display->body->appendContent($out); echo $claroline->display->render();