function printOut()
 {
     //		addScriptaculousJs();
     addJs($GLOBALS['where_lms_relative'] . '/modules/public_user_admin/', 'ajax.public_user_admin.js');
     require_once _base_ . '/lib/lib.user_profile.php';
     $profile = new UserProfile(getLogUserId());
     $profile->init('profile', 'framework', 'modname=public_user_admin&op=org_chart', 'ap');
     $profile->addStyleSheet('lms');
     $GLOBALS['page']->add('<script type="text/javascript">' . ' setup_directory(\'' . $GLOBALS['where_lms_relative'] . '/modules/directory/ajax.public_user_admin.php\'); ' . '</script>', 'page_head');
     $out = '';
     if ($this->select_all) {
         // This is not a beautiful position for this operation but at this point
         // I'm sure that all filter was applied
         $rs_all = $this->data->getAllRowsIdst();
         if ($rs_all !== FALSE) {
             $this->itemSelectedMulti = array();
             while (list($all_idst) = sql_fetch_row($rs_all)) {
                 $this->itemSelectedMulti[] = $all_idst;
             }
         }
         $this->itemSelected = $this->itemSelectedMulti;
     }
     require_once _base_ . '/lib/lib.form.php';
     $ord = importVar('ord', false, 'trans');
     $flip = importVar('flip', true, 0);
     $filter = new Form();
     $out .= $filter->getOpenFieldset($this->lang->def('_SEARCH'));
     $out .= $filter->getHidden('ord', 'ord', $ord);
     $out .= $filter->getHidden('flip', 'flip', $flip);
     if ($this->lms_editions_filter === true) {
         if (isset($GLOBALS['course_descriptor']) && $GLOBALS['course_descriptor']->hasEdition()) {
             // add editions filter ============================================================
             $ed_list = array();
             if ($this->editions == false) {
                 $this->editions = $GLOBALS['course_descriptor']->getEditionsSimpleList(getLogUserId(), true);
             }
             $sel = isset($_POST[$this->id]['edition_filter']) ? (int) $_POST[$this->id]['edition_filter'] : $GLOBALS['course_descriptor']->getActualEditionsForUser(getLogUserId());
             if (!empty($this->editions)) {
                 $out .= $filter->getDropdown($this->lang->def('_FILTER_BY_EDITION'), $this->id . '_edition_filter', $this->id . '[edition_filter]', $this->editions, $sel);
             }
         }
     }
     // end lms editions filter
     if ($this->show_simple_filter === TRUE) {
         // show simple filter ============================================================
         $out .= $filter->getTextfield($this->lang->def('_SIMPLE_FILTER'), $this->id . '_simple_fulltext_search', $this->id . '[simple_fulltext_search]', 255, isset($_POST[$this->id]['simple_fulltext_search']) ? strip_tags(html_entity_decode($_POST[$this->id]['simple_fulltext_search'])) : '', strip_tags($this->lang->def('_SIMPLE_FILTER')));
         $out .= '<div class="align_right">' . $filter->getButton($this->id . '_search', $this->id . '[search]', $this->lang->def('_SEARCH'), 'button_nowh') . '</div>';
     } else {
         // show complex filter ===========================================================
         $out .= '<h2 id="customize_filter">' . $this->lang->def('_CUSTOMIZE_FILTERS') . '</h2>';
         // --- print check box for flat mode
         if ($this->show_flat_mode_flag) {
             $out .= $filter->getCheckbox($this->lang->def('_DIRECTORY_FILTER_FLATMODE'), $this->id . '_flat_mode', $this->id . '[flat_mode]', 'flat_mode', $this->flat_mode, "onclick=\"window.document.forms['directory_org_chart'].submit();\"");
         } else {
             $out .= $filter->getHidden($this->id . '_flat_mode', $this->id . '[flat_mode]', $this->flat_mode ? 'flat_mode' : '');
         }
         // line for add a field filter
         $out .= $filter->openFormLine();
         foreach ($this->add_nat_fields as $nat_id => $nat_info) {
             $local_arr_fields_translation[$nat_id] = $this->lang->def('_DIRECTORY_FILTER_' . $nat_id);
         }
         $filter_to_show = $this->arr_fields_translation;
         if (is_array($this->arr_fields_filter)) {
             foreach ($this->arr_fields_filter as $filter_info) {
                 if (isset($filter_info['fieldname'])) {
                     unset($filter_to_show[$filter_info['fieldname']]);
                 } else {
                     unset($filter_to_show[$filter_info[0]]);
                 }
             }
         }
         if (is_array($filter_to_show) && !empty($filter_to_show)) {
             $out .= $filter->getInputDropdown('new_filter', $this->id . '_add_field_filter', $this->id . '[add_field_filter]', $filter_to_show, '', '');
             $out .= $filter->getButton($this->id . '_add_filter', $this->id . '[add_filter]', $this->lang->def('_NEW_FILTER'), 'button_nowh');
         }
         $out .= $filter->getButton($this->id . '_del_filter', $this->id . '[del_filter]', $this->lang->def('_RESET'), 'button_nowh');
         $out .= $filter->closeFormLine();
         if (is_array($this->arr_fields_filter)) {
             foreach ($this->arr_fields_filter as $field_id => $field_prop) {
                 if (!isset($field_prop['fieldname'])) {
                     // custom field
                     $arr_field_info = $this->field_list->getBaseFieldInfo($field_prop[FIELD_INFO_TYPE]);
                     require_once $GLOBALS['where_framework'] . '/modules/field/' . $arr_field_info[FIELD_BASEINFO_FILE];
                     $field_obj = new $arr_field_info[FIELD_BASEINFO_CLASS]($field_id);
                     $del_spot = '<input type="image" class="cancel_filter" ' . ' src="' . getPathImage('framework') . 'standard/cancel.png"' . ' id="' . $this->id . '_del_filter_' . $field_id . '"' . ' name="' . $this->id . '[del_filter][' . $field_id . ']"' . ' title="' . $this->lang->def('_DEL') . '"' . ' alt="' . $this->lang->def('_DEL') . '" />';
                     $out .= $field_obj->play_filter($field_id, isset($field_prop['value']) ? $field_prop['value'] : false, $field_prop[FIELD_INFO_TRANSLATION], $this->id, $del_spot, '', $field_prop[FIELD_INFO_ID]);
                     //play_filter( $id_field, $value = FALSE, $label = FALSE, $field_prefix = FALSE, $other_after = '', $other_before = '', $field_special = FALSE )
                 } else {
                     // base field
                     $arr_field_info = $this->field_list->getBaseFieldInfo($field_prop['field_type']);
                     require_once $GLOBALS['where_framework'] . '/modules/field/' . $arr_field_info[FIELD_BASEINFO_FILE];
                     $field_obj = new $arr_field_info[FIELD_BASEINFO_CLASS](0);
                     $del_spot = '<input type="image" class="cancel_filter" ' . ' src="' . getPathImage('framework') . 'standard/cancel.png"' . ' id="' . $this->id . '_del_filter_' . $field_id . '"' . ' name="' . $this->id . '[del_filter][' . $field_id . ']"' . ' title="' . $this->lang->def('_DEL') . '"' . ' alt="' . $this->lang->def('_DEL') . '" />';
                     $out .= $field_obj->play_filter($field_id, isset($field_prop['value']) ? $field_prop['value'] : false, $this->lang->def('_DIRECTORY_FILTER_' . $field_prop['fieldname']), $this->id, $del_spot, '', '');
                 }
             }
         }
         $out .= $filter->openButtonSpace();
         $out .= $filter->getButton('search', 'search', $this->lang->def('_SEARCH'));
         $out .= $filter->closeButtonSpace();
     }
     // end else for filter
     $out .= $filter->getCloseFieldset();
     // ---------------------------------------------------------------------------------------
     // set order rows
     if (is_array($this->arr_fields_order)) {
         foreach ($this->arr_fields_order as $ordFieldName => $isDesc) {
             $this->data->setOrderCol($ordFieldName, $isDesc);
         }
     }
     $this->getRows($this->_getStartRow(), $this->_getRowsPage());
     $totRow = $this->getTotalRows();
     if ($totRow == -1) {
         $totRow = $this->getLoadedRows();
     }
     $colInfo = $this->_getCols();
     $colData = $colInfo;
     $this->rend->setCaption($this->_getTitle());
     $type_h = array();
     $cont_h = array();
     while (list($key, $contentCell) = each($colInfo)) {
         if ($contentCell['toDisplay']) {
             $type_h[] = $contentCell['hClass'];
             $cont_h[] = $contentCell['hLabel'];
         }
     }
     reset($colInfo);
     $this->rend->addHead($cont_h, $type_h);
     while ($values = $this->fetchRecord()) {
         $colData = array();
         foreach ($colInfo as $key => $fieldInfo) {
             $colData[] = $values[$colInfo[$key]['data']];
         }
         $this->rend->addBody($colData, false, false, 'user_row_' . $values['idst']);
         if ($this->_expand_user == $values['idst']) {
             // extra user info if requested
             $this->rend->addBodyExpanded($this->userExtraData($this->_expand_user), 'user_more_info');
         }
     }
     if ($this->insNew) {
         $this->rend->addActionAdd('<input type="submit" class="transparent_add_button"' . ' id="' . $this->id . '_' . $this->_getOpCreateItemId() . '" ' . ' name="' . $this->id . '[' . $this->_getOpCreateItemId() . '][0]" ' . ' value="' . $this->lang->def('_ADD') . '"' . ' title="' . $this->_getCreateLabel() . '" ' . ' alt="' . $this->_getCreateAlt() . '" />');
     }
     $this->rend->initNavBar($this->_getIdInitRowId(), 'button');
     $out .= $this->rend->getTable() . $this->rend->getNavBar($this->_getStartRow(), $totRow) . $this->printState();
     // ---------------------------------------------------------------------------------------
     if ($this->select_all) {
         $arr_notPrint = array_diff($this->itemSelectedMulti, $this->printedItems);
         foreach ($arr_notPrint as $id_notPrint) {
             $out .= '<input type="checkbox" ' . ' id="' . DIRECTORY_ID . DIRECTORY_OP_SELECTITEM . '_' . $id_notPrint . '" ' . 'name="' . DIRECTORY_ID . '[' . DIRECTORY_OP_SELECTITEM . '][' . $id_notPrint . ']" ' . 'value="" checked="checked" style="display:none;" />';
         }
     }
     return $out;
 }
예제 #2
0
function displayCoursePathList(&$url, $selected_tab)
{
    require_once _base_ . '/lib/lib.form.php';
    require_once _base_ . '/lib/lib.user_profile.php';
    require_once _base_ . '/lib/lib.navbar.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.preassessment.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.catalogue.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.coursepath.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.preassessment.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.coursereport.php';
    $lang =& DoceboLanguage::createInstance('catalogue');
    $lang_c =& DoceboLanguage::createInstance('course');
    $nav_bar = new NavBar('ini', Get::sett('visuItem'), 0);
    $nav_bar->setLink($url->getUrl());
    $ini = $nav_bar->getSelectedElement();
    $course_man = new Man_Course();
    $path_man = new CoursePath_Manager();
    $cat_man = new Catalogue_Manager();
    $man_courseuser = new Man_CourseUser();
    $profile = new UserProfile(getLogUserId());
    $profile->init('profile', 'framework', '', 'ap');
    $profile->addStyleSheet('lms');
    $catalogues =& $cat_man->getUserAllCatalogueId(getLogUserId());
    if (!empty($catalogues)) {
        // at least one catalogue is assigned to this user
        $cat_path =& $cat_man->getAllCoursepathOfUser(getLogUserId());
        if (!empty($cat_path)) {
            $path_man->filterInPath($cat_path);
        }
    } elseif (Get::sett('on_catalogue_empty') == 'off') {
        $path_man->filterInPath(array(0));
    }
    if (!Docebo::user()->isAnonymous()) {
        if (!isset($_SESSION['cp_assessment_effect'])) {
            $pa_man = new AssessmentList();
            $arr_assessment = $pa_man->getUserAssessmentSubsription(Docebo::user()->getArrSt());
            $report = new CourseReportManager();
            $user_result = $report->getAllUserFinalScore(getLogUserId(), $arr_assessment['course_list']);
            $rule_man = new AssessmentRule();
            $ass_elem = $rule_man->getCompleteEffectListForAssessmentWithUserResult($arr_assessment['course_list'], $user_result);
            $_SESSION['cp_assessment_effect'] = urlencode(serialize($ass_elem));
        } else {
            $ass_elem = unserialize(urldecode($_SESSION['cp_assessment_effect']));
        }
        if (!empty($ass_elem['parsed']['coursepath'])) {
            $path_man->filterOrInPath($ass_elem['parsed']['coursepath']);
        }
    }
    // retrive all the classroorm
    // search for the coursepath ------------------------------------------------------
    $coursepath = $path_man->getCoursepathList($ini, Get::sett('visuItem'));
    if (empty($coursepath)) {
        // no path found for the criteria ---------------------------------------------
        $GLOBALS['page']->add('<p class="no_course_found">' . $lang->def('_NO_COURSE_FOUND') . '</p></div>', 'content');
        return;
    }
    // find structures of the course path ---------------------------------------------
    $courses = $path_man->getPathStructure(array_keys($coursepath));
    $path_slot = $path_man->getPathSlot(array_keys($coursepath));
    // fin user subscription needed ---------------------------------------------------
    $user_paths =& $path_man->getUserSubscriptionsInfo(getLogUserId(), false);
    $usercourses =& $man_courseuser->getUserSubscriptionsInfo(getLogUserId(), false);
    // find course basilar information ------------------------------------------------
    $course_info = $course_man->getAllCourses(false, false, $courses['all_items'], true);
    $GLOBALS['page']->add($nav_bar->getNavBar($ini), 'content');
    while (list($id_path, $path) = each($coursepath)) {
        $html = '<div class="coursepath_container">';
        $in_h = ' <span class="coursepath_subscribe">';
        $can_subs = true;
        if (isset($ass_elem['parsed']['coursepath'])) {
            if (isset($ass_elem['not_done']['coursepath']) && in_array($id_path, $ass_elem['not_done']['coursepath'])) {
                // the assosiacted preassessment is not done
                $in_h .= '';
                //$lang->def('_MUST_DO_PREASSESSMENT');
                $can_subs = false;
            } elseif (isset($ass_elem['to_apply']['coursepath']) && in_array($id_path, $ass_elem['to_apply']['coursepath'])) {
                // the assosiacted preassessment suggest this coursepath
                $in_h .= $lang->def('_PREASSESSMENT_SUGGESTION');
            }
        } else {
            switch ($path[COURSEPATH_METHOD]) {
                case METHOD_WAIT:
                    $in_h .= $lang->def('_METHOD_WAIT');
                    break;
                case METHOD_AUTO:
                    $in_h .= $lang->def('_METHOD_AUTO');
                    break;
                case METHOD_MANUAL:
                default:
                    $in_h .= $lang->def('_METHOD_MANUAL');
                    $can_subs = false;
                    break;
            }
        }
        $in_h .= '</span>';
        $in_h .= ' <span class="coursepath_status">';
        if (isset($usercourses[$id_path])) {
            // user is alredy subscribed to this coursepath
            if ($usercourses[$id_path]['waiting']) {
                $in_h .= $lang->def('_COURSEPATH_WAITING');
            } else {
                $in_h .= $lang->def('_USER_STATUS_SUBS');
            }
        }
        $in_h .= '</span>';
        // -------------------------------------------------------------
        $html .= '<div class="coursepath_info_container">';
        $html .= '<h2 class="pathtitle">' . $in_h . ($path[COURSEPATH_CODE] != '' ? '[' . $path[COURSEPATH_CODE] . '] ' : '') . $path[COURSEPATH_NAME] . '</h2>' . '<p class="course_support_info">' . str_replace('[enrolled]', $path[CP_ENROLLED], $lang->def('_COURSEPATH_INTRO')) . '</p>';
        if (!isset($courses[$id_path]) || empty($courses[$id_path])) {
            $html .= $lang->def('_NO_COURSE_ASSIGNED_TO_COURSEPATH') . '<br />';
        } else {
            // display the slots
            foreach ($path_slot[$id_path] as $id_slot => $slot_info) {
                if ($id_slot == 0) {
                    $html .= '<h4>' . $lang->def('_MANDATORY') . '</h4>';
                    if (!empty($courses[$id_path][$id_slot])) {
                        $html .= '<ul class="coursepath_mainslot">';
                    }
                } else {
                    if ($slot_info['min_selection'] > 0 && $slot_info['max_selection'] > 0) {
                        $title = str_replace(array('[min_selection]', '[max_selection]'), array($slot_info['min_selection'], $slot_info['max_selection']), $lang->def('_COURSE_PATH_SLOT_MIN_MAX'));
                    } elseif ($slot_info['max_selection'] > 0) {
                        $title = str_replace('[max_selection]', $slot_info['max_selection'], $lang->def('_COURSE_PATH_SLOT_MAX'));
                    } else {
                        $title = $lang->def('_COURSE_PATH_SLOT');
                    }
                    $html .= '<h4>' . $title . '</h4>';
                    if (!empty($courses[$id_path][$id_slot])) {
                        $html .= '<ul class="coursepath_otherslot">';
                    }
                }
                $i = 0;
                while (list($id) = each($courses[$id_path][$id_slot])) {
                    $html .= '<li class="path_course ' . ($i % 2 ? 'path_odd' : '') . '">' . '<a class="show_details_more" href="javascript:;" onclick="course_dash(this, \'' . $id . '\',\'info_' . $id_path . '_' . $id . '\', \'' . $can_subs . '\');">' . $lang->def('_DETAILS') . '</a>' . ($course_info[$id]['code'] != '' ? ' [' . $course_info[$id]['code'] . '] ' : '') . $course_info[$id]['name'] . '<div id="info_' . $id_path . '_' . $id . '"></div>' . '</li>';
                    $i++;
                }
                if (!empty($courses[$id_path][$id_slot])) {
                    $html .= '</ul>';
                }
            }
        }
        $html .= '</div>';
        $html .= '</div>';
        $GLOBALS['page']->add($html, 'content');
    }
    $GLOBALS['page']->add($nav_bar->getNavBar($ini), 'content');
}