예제 #1
0
function mycourses(&$url)
{
    checkPerm('view');
    require_once _base_ . '/lib/lib.user_profile.php';
    $lang =& DoceboLanguage::createInstance('catalogue');
    require_once $GLOBALS['where_lms'] . '/lib/lib.middlearea.php';
    $ma = new Man_MiddleArea();
    $course_stats = userCourseList($url, $ma->currentCanAccessObj('lo_tab'));
    $access_career = $ma->currentCanAccessObj('career');
    $access_news = $ma->currentCanAccessObj('news');
    $access_search_form = $ma->currentCanAccessObj('search_form');
    $access_user_details_full = $ma->currentCanAccessObj('user_details_full');
    $access_user_details_short = $ma->currentCanAccessObj('user_details_short');
    $onecol = !$access_career && !$access_news && !$access_user_details_full && !$access_user_details_short;
    require_once $GLOBALS['where_framework'] . '/lib/lib.myfriends.php';
    $friends = new MyFriends(getLogUserId());
    $pendent = count($friends->getPendentRequest());
    $GLOBALS['page']->addStart('' . '<div id="mycourse_top">' . ($onecol ? '' : '<div class="mycourse_left">'), 'content');
    // user_details_short ------------------------------------------------------------------------
    if ($access_user_details_short) {
        $profile = new UserProfile(getLogUserId());
        $profile->init('profile', 'framework', 'index.php?r=' . _after_login_, 'ap');
        $GLOBALS['page']->addStart($profile->userIdMailProfile('normal', false, false), 'content');
    }
    // user_details_full ------------------------------------------------------------------------
    if ($access_user_details_full) {
        $profile = new UserProfile(getLogUserId());
        $profile->init('profile', 'framework', 'index.php?r=' . _after_login_, 'ap');
        $GLOBALS['page']->addStart($profile->homeUserProfile('normal', false, false), 'content');
    }
    // career ------------------------------------------------------------------------
    if ($access_career) {
        $base_url = 'index.php?r=' . _after_login_ . '&amp;filter=';
        $end = 0;
        if (isset($course_stats['with_ustatus'][_CUS_END]) && $course_stats['with_ustatus'][_CUS_END] != 0) {
            $end = $course_stats['with_ustatus'][_CUS_END];
        }
        $GLOBALS['page']->addStart('' . '<div class="course_stat">' . '<table summary="">' . '<caption>' . $lang->def('_CAREER') . '</caption>' . '<tr><th scope="row">' . $lang->def('_TOTAL_COURSE') . ' :</th><td><a href="' . $base_url . 'nothing">' . ($course_stats['total'] - $end) . '</a></td></tr>' . (isset($course_stats['with_ustatus'][_CUS_END]) && $course_stats['with_ustatus'][_CUS_END] != 0 ? '<tr><th scope="row">' . $lang->def('_COURSE_END') . ' :</th><td><a href="' . $base_url . 'end">' . $course_stats['with_ustatus'][_CUS_END] . '</a></td></tr>' : '') . (isset($course_stats['expiring']) && $course_stats['expiring'] != 0 ? '<tr><th scope="row">' . $lang->def('_COURSE_EXPIRING') . ' :</th><td><a href="' . $base_url . 'expiring">' . $course_stats['expiring'] . '</a></td></tr>' : ''), 'content');
        if (count($course_stats['with_ulevel']) > 1) {
            require_once $GLOBALS['where_lms'] . '/lib/lib.levels.php';
            $lvl = CourseLevel::getLevels();
            foreach ($course_stats['with_ulevel'] as $lvl_num => $quantity) {
                $GLOBALS['page']->addStart('' . '<tr><th scope="row">' . str_replace('[level]', $lvl[$lvl_num], $lang->def('_COURSE_AS')) . ' :</th><td><a href="' . $base_url . 'level&amp;filter_on=' . $lvl_num . '">' . $quantity . '</a></td></tr>', 'content');
            }
            //end foreach
        }
        $query = "SELECT c.idMetaCertificate, m.idCertificate" . " FROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_course as c" . " JOIN " . $GLOBALS['prefix_lms'] . "_certificate_meta as m ON c.idMetaCertificate = m.idMetaCertificate" . " WHERE c.idUser = '******'" . " GROUP BY c.idMetaCertificate" . " ORDER BY m.title, m.description";
        $result = sql_query($query);
        $num_meta_cert = mysql_num_rows($result);
        while (list($id_meta, $id_certificate) = sql_fetch_row($result)) {
            $query_released = "SELECT on_date" . " FROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_assign" . " WHERE idUser = '******'" . " AND idMetaCertificate = '" . $id_meta . "'";
            $result_released = sql_query($query_released);
            $query = "SELECT user_release" . " FROM " . $GLOBALS['prefix_lms'] . "_certificate" . " WHERE id_certificate = '" . $id_certificate . "'";
            list($user_release) = sql_fetch_row(sql_query($query));
            if (mysql_num_rows($result_released)) {
            } elseif ($user_release == 0) {
                $num_meta_cert--;
            } else {
                $query = "SELECT idCourse" . " FROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_course" . " WHERE idUser = '******'" . " AND idMetaCertificate = '" . $id_meta . "'";
                $result_int = sql_query($query);
                $control = true;
                while (list($id_course) = sql_fetch_row($result_int)) {
                    $query = "SELECT COUNT(*)" . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser" . " WHERE idCourse = '" . $id_course . "'" . " AND idUser = '******'" . " AND status = '" . _CUS_END . "'";
                    list($number) = sql_fetch_row(sql_query($query));
                    if (!$number) {
                        $control = false;
                    }
                }
                if (!$control) {
                    $num_meta_cert--;
                }
            }
        }
        $tot_cert = $num_meta_cert + $course_stats['cert_relesable'];
        $GLOBALS['page']->addStart('' . (isset($course_stats['cert_relesable']) && $tot_cert != 0 ? '<tr><th scope="row">' . $lang->def('_CERT_RELESABLE') . ' :</th><td><a href="index.php?modname=mycertificate&amp;op=mycertificate">' . $tot_cert . '</a></td></tr>' : '') . ($pendent != 0 ? '<tr><th scope="row">' . $lang->def('_FRIEND_PENDENT') . ' :</th><td><a href="index.php?modname=myfriends&amp;op=myfriends">' . $pendent . '</a></td></tr>' : '') . '</table>' . '</div>', 'content');
    }
    // career ------------------------------------------------------------------------
    if ($access_search_form) {
        $year_array = array(0 => $lang->def('_ALL_YEAR'));
        $query_year = "SELECT DISTINCT create_date" . " FROM " . $GLOBALS['prefix_lms'] . "_course";
        $result = sql_query($query_year);
        while (list($year) = sql_fetch_row($result)) {
            $year_array[$year[0] . $year[1] . $year[2] . $year[3]] = $year[0] . $year[1] . $year[2] . $year[3];
        }
        if (isset($year_array['0000'])) {
            unset($year_array['0000']);
        }
        $GLOBALS['page']->addStart('' . '<div class="course_search">' . '<h2>' . $lang->def('_SEARCH') . '</h2>' . Form::openForm('course_filter', 'index.php?modname=course&amp;op=mycourses') . '<p>' . Form::getLabel('search', $lang->def('_WORD')) . '</p>' . Form::getInputTextfield('textfield_nowh', 'search', 'search', importVar('search'), $lang->def('_WORD'), '255', '') . '<br/>' . '<p>' . Form::getLabel('year', $lang->def('_YEAR')) . '</p>' . Form::getInputDropdown('dropdown_nowh', 'year', 'year', $year_array, importVar('year'), '') . Form::getButton('apply_filter', 'apply_filter', $lang->def('_SEARCH')) . Form::closeForm() . '</div>', 'content');
    }
    // news ------------------------------------------------------------------------
    if ($access_news) {
        $GLOBALS['page']->addStart('' . '<div class="course_news">' . '<h2>' . $lang->def('_NEWS') . '</h2>', 'content');
        $user_level = Docebo::user()->getUserLevelId();
        $user_assigned = Docebo::user()->getArrSt();
        $query_news = "\r\n\t\tSELECT idNews, publish_date, title, short_desc, important, viewer\r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_news_internal\r\n\t\tWHERE language = '" . getLanguage() . "'\r\n\t\tORDER BY important DESC, publish_date DESC ";
        $re_news = sql_query($query_news);
        $displayed = 0;
        while (list($id_news, $publish_date, $title, $short_desc, $impo, $viewer) = sql_fetch_row($re_news)) {
            $viewer = is_string($viewer) && $viewer != false ? unserialize($viewer) : array();
            $intersect = array_intersect($user_assigned, $viewer);
            if (!empty($intersect) || empty($viewer)) {
                $GLOBALS['page']->addStart('<h3>' . $title . '</h3>' . '<div class="news_textof">' . '<span class="news_data">' . Format::date($publish_date, 'date') . ' - </span>' . $short_desc . '</div>', 'content');
                $displayed++;
            }
        }
        // end news display
        if (!$displayed) {
            $GLOBALS['page']->addStart($lang->def('_NO_CONTENT'), 'content');
        }
        $GLOBALS['page']->addStart('' . '</div>', 'content');
    }
    if (!$onecol) {
        $GLOBALS['page']->addStart('' . '</div>', 'content');
        $GLOBALS['page']->addStart('' . '<div id="mycourse_right">', 'content');
    }
    // ------------------------------------------------------------------------
    if (!$onecol) {
        $GLOBALS['page']->addEnd('' . '</div>' . '<div class="nofloat"></div>', 'content');
    }
    $GLOBALS['page']->addEnd('' . '</div>', 'content');
    if ($ma->currentCanAccessObj('lo_tab')) {
        $current_tab = importVar('current_tab', false, 'lo_plan');
        $GLOBALS['page']->addStart('<div class="lo_tab">' . '<h1>' . $lang->def('_WELCOME') . ': ' . '<span>' . Docebo::user()->getUserName() . '</span>' . '</h1>' . '<ul class="flat_tab">' . ($course_stats['with_ustatus'][_CUS_END] != $course_stats['total'] ? '<li ' . ($current_tab == 'lo_plan' ? 'class="now_selected"' : '') . '>' . '<a href="index.php?modname=course&amp;op=mycourses&amp;current_tab=lo_plan"><span>' . $lang->def('_COURSE') . '</span></a></li>' : '') . ($course_stats['with_ustatus'][_CUS_END] != 0 ? '<li ' . ($current_tab == 'lo_history' ? 'class="now_selected"' : '') . '>' . '<a href="index.php?modname=course&amp;op=mycourses&amp;current_tab=lo_history"><span>' . $lang->def('_COMPLETED') . '</span></a></li>' : '') . ($course_stats['with_wstatus'][_CUS_RESERVED] != 0 || $course_stats['with_wstatus'][_CUS_WAITING_LIST] != 0 ? '<li ' . ($current_tab == 'lo_waiting' ? 'class="now_selected"' : '') . '>' . '<a href="index.php?modname=course&amp;op=mycourses&amp;current_tab=lo_waiting"><span>' . $lang->def('_LO_WAITING') . '</span></a></li>' : '') . '</ul>' . '</div>', 'content');
    } else {
        $GLOBALS['page']->addStart('<div class="lo_tab">' . '<h1 class="no_tab">' . $lang->def('_WELCOME') . ': ' . '<span>' . Docebo::user()->getUserName() . '</span>' . '</h1>' . '</div>', 'content');
    }
}
예제 #2
0
 public function user_details_short($link)
 {
     require_once _lib_ . '/lib.user_profile.php';
     $profile = new UserProfile(getLogUserId());
     $profile->init('profile', 'framework', 'index.php?r=' . $link, 'ap');
     echo $profile->userIdMailProfile('normal', false, false);
 }