コード例 #1
0
ファイル: notes.php プロジェクト: abhinay100/forma_app
    function notes()
    {
        checkPerm('view');
        require_once _base_ . '/lib/lib.table.php';
        $lang =& DoceboLanguage::createInstance('notes', 'lms');
        $nav_bar = new NavBar('ini', Get::sett('visuItem'), 0);
        $ini = $nav_bar->getSelectedElement();
        $ord = importVar('ord');
        $inv = importVar('inv');
        switch ($ord) {
            case "tit":
                $ord = $order = 'title';
                if ($inv != 'y') {
                    $a_down = '&inv=y';
                } else {
                    $order .= ' DESC';
                    $a_down = '';
                }
                break;
            default:
                $ord = $order = 'data';
                if ($inv == 'y') {
                    $a_down = '';
                } else {
                    $order .= ' DESC';
                    $a_down = '&inv=y';
                }
        }
        $reNotes = sql_query("\r\n\tSELECT idNotes, data, title \r\n\tFROM " . $GLOBALS['prefix_lms'] . "_notes \r\n\tWHERE owner ='" . getLogUserId() . "' AND idCourse='" . $_SESSION['idCourse'] . "' \r\n\tORDER BY {$order} \r\n\tLIMIT {$ini}," . Get::sett('visuItem'));
        list($num_notes) = sql_fetch_row(sql_query("SELECT COUNT(*) \r\n\tFROM " . $GLOBALS['prefix_lms'] . "_notes \r\n\tWHERE owner ='" . getLogUserId() . "' AND idCourse='" . $_SESSION['idCourse'] . "' "));
        $nav_bar->setElementTotal($num_notes);
        $img_up = '<img class="valing-middle" src="' . getPathImage() . 'standard/up_arrow.png" alt="' . $lang->def('_UP') . '"/>';
        $img_down = '<img class="valing-middle" src="' . getPathImage() . 'standard/down_arrow.png" alt="' . $lang->def('_DOWN') . '"/>';
        $tb = new Table(Get::sett('visuItem'), $lang->def('_NOTES'), $lang->def('_NOTES'));
        $contentH = array(($ord == 'data' ? $inv == 'y' ? $img_up : $img_down : '') . '<a href="index.php?modname=notes&amp;op=notes' . $a_down . '"> ' . $lang->def('_DATE') . '</a>', ($ord == 'title' ? $inv == 'y' ? $img_up : $img_down : '') . '<a href="index.php?modname=notes&amp;op=notes&amp;ord=tit' . $a_down . '">' . $lang->def('_TITLE') . '</a>', '<img src="' . getPathImage() . 'standard/edit.png" title="' . $lang->def('_MOD') . '" alt="' . $lang->def('_MOD') . '" />', '<img src="' . getPathImage() . 'standard/delete.png" title="' . $lang->def('_DEL') . '" alt="' . $lang->def('_DEL') . '" />');
        $typeH = array('min-cell', '', 'image', 'image');
        $tb->setColsStyle($typeH);
        $tb->addHead($contentH);
        while (list($idNotes, $data, $title) = sql_fetch_row($reNotes)) {
            $content = array(Format::date($data), '<a href="index.php?modname=notes&amp;op=displaynotes&amp;idNotes=' . $idNotes . '" title="' . $lang->def('_MORET') . '">' . $title . '</a>', '<a href="index.php?modname=notes&amp;op=modnotes&amp;idNotes=' . $idNotes . '">
				<img src="' . getPathImage() . 'standard/edit.png" title="' . $lang->def('_MOD') . '" alt="' . $lang->def('_MOD') . '" /></a>', '<a id="delnotes_' . $idNotes . '"' . ' href="index.php?modname=notes&amp;op=delnotes&amp;idNotes=' . $idNotes . '"' . ' title="' . $lang->def('_TITLE') . ' : ' . strip_tags(str_replace(array('"', "'"), '', $title)) . '">
				<img src="' . getPathImage() . 'standard/delete.png" alt="' . $lang->def('_DEL') . '" /></a>');
            $tb->addBody($content);
        }
        $tb->addActionAdd('<a href="index.php?modname=notes&amp;op=addnotes">' . '<img src="' . getPathImage() . 'standard/add.png" title="' . $lang->def('_ADD') . '" alt="' . $lang->def('_ADD') . '" /> ' . $lang->def('_ADD_NOTES') . '</a>');
        $GLOBALS['page']->add(getTitleArea(array($lang->def('_NOTES')), 'notes') . '<div class="std_block">', 'content');
        if (isset($_POST['result'])) {
            switch ($_POST['result']) {
                case "ok":
                    $GLOBALS['page']->add(getResultUi($lang->def('_OPERATION_SUCCESSFUL')), 'content');
                case "err":
                    $GLOBALS['page']->add(getErrorUi($lang->def('_OPERATION_FAILURE')), 'content');
            }
        }
        $GLOBALS['page']->add($tb->getTable() . $nav_bar->getNavBar($ini), 'content');
        require_once _base_ . '/lib/lib.dialog.php';
        setupHrefDialogBox('a[href*=delnotes]');
        $GLOBALS['page']->add('</div>', 'content');
    }
コード例 #2
0
ファイル: statistic.php プロジェクト: abhinay100/forma_app
function sessiondetails()
{
    checkPerm('view');
    require_once _base_ . '/lib/lib.table.php';
    $idst_user = importVar('id', true, 0);
    $id_enter = importVar('id_enter', true, 0);
    $p_ini = importVar('p_ini');
    $link = 'index.php?modname=statistic&amp;op=sessiondetails&amp;id=' . $idst_user . '&amp;id_enter=' . $id_enter;
    $nav_bar = new NavBar('ini', Get::sett('visuItem'), 0, 'link');
    $nav_bar->setLink($link . '&amp;p_ini=' . $p_ini);
    $ini = $nav_bar->getSelectedElement();
    $lang =& DoceboLanguage::createInstance('statistic', 'lms');
    $acl_man = Docebo::user()->getAclManager();
    $user_info =& $acl_man->getUser($idst_user, false);
    $query_track = "\r\n\tSELECT g.function, g.type, g.timeof, UNIX_TIMESTAMP(g.timeof) AS unix_time \r\n\tFROM " . $GLOBALS['prefix_lms'] . "_trackingeneral AS g\r\n\tWHERE g.idCourse = '" . (int) $_SESSION['idCourse'] . "' AND g.idUser = '******' AND " . " ( g.idEnter = '" . $id_enter . "' OR (  g.idEnter = 0 AND g.session_id = '" . importVar('sid') . "' ) ) " . " ORDER BY g.timeof \r\n\tLIMIT " . $ini . ", " . Get::sett('visuItem');
    $re_tracks = sql_query($query_track);
    $query_tot_track = "\r\n\tSELECT COUNT(*) \r\n\tFROM " . $GLOBALS['prefix_lms'] . "_trackingeneral \r\n\tWHERE idCourse = '" . (int) $_SESSION['idCourse'] . "' AND idUser = '******' AND idEnter = '" . $id_enter . "'";
    list($tot_elem) = sql_fetch_row(sql_query($query_tot_track));
    $nav_bar->setElementTotal($tot_elem);
    // Find modulename -> name int his course
    require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
    $course_man = new Man_Course();
    $mods_names =& $course_man->getModulesName($_SESSION['idCourse']);
    $page_title = array('index.php?modname=statistic&amp;op=statistic' => $lang->def('_STATISTICS'), 'index.php?modname=statistic&amp;op=userdetails&amp;id=' . $idst_user . '&amp;p_ini=' . $p_ini => $user_info[ACL_INFO_LASTNAME] . $user_info[ACL_INFO_FIRSTNAME] ? $user_info[ACL_INFO_LASTNAME] . ' ' . $user_info[ACL_INFO_FIRSTNAME] : $acl_man->relativeId($user_info[ACL_INFO_USERID]), $lang->def('_VIEW_SESSION_DETAILS'));
    $GLOBALS['page']->add(getTitleArea($page_title, 'statistic') . '<div class="std_block">' . getBackUi('index.php?modname=statistic&amp;op=userdetails&amp;id=' . $idst_user . '&amp;p_ini=' . $p_ini, $lang->def('_BACK')), 'content');
    $tb = new Table(0, $lang->def('_VIEW_SESSION_DETAILS'), $lang->def('_VIEW_SESSION_DETAILS'));
    $type_h = array('', '', '');
    $cont_h = array($lang->def('_DATE'), $lang->def('_TYPE_OF_OPERATION'), $lang->def('_TIME_IN'));
    $tb->setColsStyle($type_h);
    $tb->addHead($cont_h);
    $type_h[2] = 'align_right';
    $tb->setColsStyle($type_h);
    $total_sec = 0;
    $read_previous = false;
    while ($read = mysql_fetch_assoc($re_tracks)) {
        if ($read_previous !== false) {
            $time_in = $read['unix_time'] - $read_previous['unix_time'];
            $hours = (int) ($time_in / 3600);
            $minutes = (int) ($time_in % 3600 / 60);
            $seconds = (int) ($time_in % 60);
            if ($minutes < 10) {
                $minutes = '0' . $minutes;
            }
            if ($seconds < 10) {
                $seconds = '0' . $seconds;
            }
            $readable = $hours . 'h ' . $minutes . 'm ' . $seconds . 's ';
            $cont = array(Format::date($read_previous['timeof'], false, true), '<span class="text_bold">' . (isset($mods_names[$read_previous['function']]) ? $mods_names[$read_previous['function']] : $read_previous['function']) . '</span> [' . $read_previous['type'] . ']', $readable);
            $tb->addBody($cont);
        }
        $read_previous = $read;
    }
    $query_last_track = "\r\n\tSELECT g.function, g.type, g.timeof, UNIX_TIMESTAMP(g.timeof) AS unix_time \r\n\tFROM " . $GLOBALS['prefix_lms'] . "_trackingeneral AS g\r\n\tWHERE g.idCourse = '" . (int) $_SESSION['idCourse'] . "' AND g.idUser = '******' AND g.idEnter = '" . $id_enter . "' \r\n\tLIMIT " . ($ini + Get::sett('visuItem')) . ", 1";
    $re_track = sql_query($query_last_track);
    if (mysql_num_rows($re_track) > 0) {
        $read = mysql_fetch_assoc($re_track);
        $time_in = $read['unix_time'] - $read_previous['unix_time'];
        $hours = (int) ($time_in / 3600);
        $minutes = (int) ($time_in % 3600 / 60);
        $seconds = (int) ($time_in % 60);
        if ($minutes < 10) {
            $minutes = '0' . $minutes;
        }
        if ($seconds < 10) {
            $seconds = '0' . $seconds;
        }
        $readable = $hours . 'h ' . $minutes . 'm ' . $seconds . 's ';
    } else {
        $readable = '';
    }
    $cont = array(Format::date($read_previous['timeof']), '<span class="text_bold">' . (isset($mods_names[$read_previous['function']]) ? $mods_names[$read_previous['function']] : $read_previous['function']) . '</span> [' . $read_previous['type'] . ']', $readable);
    $tb->addBody($cont);
    $GLOBALS['page']->add($tb->getTable() . $nav_bar->getNavBar() . getBackUi('index.php?modname=statistic&amp;op=userdetails&amp;id=' . $idst_user . '&amp;p_ini=' . $p_ini, $lang->def('_BACK')) . '</div>', 'content');
}
コード例 #3
0
function news()
{
    checkPerm('view');
    require_once _base_ . '/lib/lib.form.php';
    require_once _base_ . '/lib/lib.table.php';
    require_once _base_ . '/lib/lib.navbar.php';
    $mod_perm = checkPerm('mod', true);
    $lang =& DoceboLanguage::createInstance('admin_news', 'lms');
    $out =& $GLOBALS['page'];
    $out->setWorkingZone('content');
    $tb = new Table(Get::sett('visuItem'), $lang->def('_NEWS'), $lang->def('_NEWS_SUMMARY'));
    $nav_bar = new NavBar('ini', Get::sett('visuItem'), 0, 'link');
    $ini = $nav_bar->getSelectedElement();
    //search query
    $query_news = "\r\n\tSELECT idNews, publish_date, title, short_desc, important\r\n\tFROM " . $GLOBALS['prefix_lms'] . "_news_internal\r\n\tORDER BY important DESC, publish_date DESC\r\n\tLIMIT {$ini}," . Get::sett('visuItem');
    $query_news_tot = "\r\n\tSELECT COUNT(*)\r\n\tFROM " . $GLOBALS['prefix_lms'] . "_news_internal ";
    $re_news = sql_query($query_news);
    list($tot_news) = sql_fetch_row(sql_query($query_news_tot));
    $nav_bar->setElementTotal($tot_news);
    $impo_gif = '<img src="' . getPathImage('lms') . 'standard/important.png" ' . 'title="' . $lang->def('_TITLE_IMPORTANT') . '" ' . 'alt="' . $lang->def('_IMPORTANT') . '" />';
    $type_h = array('image', '', '', 'news_short_td');
    $cont_h = array($impo_gif, $lang->def('_DATE'), $lang->def('_TITLE'), $lang->def('_SHORTDESC'));
    if ($mod_perm) {
        $cont_h[] = '<img src="' . getPathImage() . 'standard/moduser.png" title="' . $lang->def('_RECIPIENTS') . '" ' . 'alt="' . $lang->def('_RECIPIENTS') . '" />';
        $type_h[] = 'image';
        $cont_h[] = '<img src="' . getPathImage() . 'standard/edit.png" title="' . $lang->def('_MOD') . '" ' . 'alt="' . $lang->def('_MOD') . '" />';
        $type_h[] = 'image';
        $cont_h[] = '<img src="' . getPathImage() . 'standard/delete.png" title="' . $lang->def('_DEL') . '" ' . 'alt="' . $lang->def('_DEL') . '"" />';
        $type_h[] = 'image';
    }
    $tb->setColsStyle($type_h);
    $tb->addHead($cont_h);
    while (list($id_news, $publish_date, $title, $short_desc, $impo) = sql_fetch_row($re_news)) {
        $cont = array($impo ? $impo_gif : '', Format::date($publish_date), $title, Util::cut($short_desc));
        if ($mod_perm) {
            $cont[] = '<a href="index.php?modname=internal_news&amp;op=editviewer&amp;load=1&amp;id_news=' . $id_news . '" ' . 'title="' . $lang->def('_RECIPIENTS') . ' : ' . $title . '">' . '<img src="' . getPathImage() . 'standard/moduser.png" alt="' . $lang->def('_RECIPIENTS') . ' : ' . $title . '" /></a>';
            $cont[] = '<a href="index.php?modname=internal_news&amp;op=modnews&amp;id_news=' . $id_news . '" ' . 'title="' . $lang->def('_MOD') . ' : ' . $title . '">' . '<img src="' . getPathImage() . 'standard/edit.png" alt="' . $lang->def('_MOD') . ' : ' . $title . '" /></a>';
            $cont[] = '<a href="index.php?modname=internal_news&amp;op=delnews&amp;id_news=' . $id_news . '" ' . 'title="' . $lang->def('_DEL') . ' : ' . $title . '">' . '<img src="' . getPathImage() . 'standard/delete.png" alt="' . $lang->def('_DEL') . ' : ' . $title . '" /></a>';
        }
        $tb->addBody($cont);
    }
    require_once _base_ . '/lib/lib.dialog.php';
    setupHrefDialogBox('a[href*=delnews]');
    if ($mod_perm) {
        $tb->addActionAdd('<a href="index.php?modname=internal_news&amp;op=addnews" title="' . $lang->def('_NEW') . '">' . '<img src="' . getPathImage() . 'standard/add.png" alt="' . $lang->def('_ADD') . '" />' . $lang->def('_NEW') . '</a>');
    }
    $out->add(getTitleArea($lang->def('_NEWS'), 'news') . '<div class="std_block">');
    if (isset($_GET['result'])) {
        switch ($_GET['result']) {
            case "ok":
                $out->add(getResultUi($lang->def('_OPERATION_SUCCESSFUL')));
                break;
            case "err":
                $out->add(getErrorUi($lang->def('_OPERATION_FAILURE')));
                break;
            case "err_del":
                $out->add(getErrorUi($lang->def('_OPERATION_FAILURE')));
                break;
        }
    }
    if ($mod_perm) {
        $form = new Form();
        $how_much = Get::sett('visuNewsHomePage');
        if (isset($_POST['save_homepage'])) {
            $query_how_news = "\r\n\t\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_setting\r\n\t\t\tSET param_value = '" . abs((int) $_POST['howmuch']) . "'\r\n\t\t\tWHERE param_name = 'visuNewsHomePage'";
            if (sql_query($query_how_news)) {
                $how_much = abs((int) $_POST['howmuch']);
            }
        }
    }
    $out->add($tb->getTable() . $nav_bar->getNavBar($ini) . '</div>');
}
コード例 #4
0
ファイル: webpages.php プロジェクト: abhinay100/forma_app
function webpages()
{
    checkPerm('view');
    require_once _base_ . '/lib/lib.table.php';
    require_once _base_ . '/lib/lib.form.php';
    $mod_perm = checkPerm('mod', true);
    $lang =& DoceboLanguage::createInstance('admin_webpages', 'lms');
    $out =& $GLOBALS['page'];
    $out->setWorkingZone('content');
    $tb = new Table(0, $lang->def('_WEBPAGES_CAPTION'));
    $nav_bar = new NavBar('ini', Get::sett('visuItem'), 0, 'button');
    $ini = $nav_bar->getSelectedElement();
    //search query
    $query_pages = "\r\n\tSELECT idPages, title, publish, in_home, sequence \r\n\tFROM " . $GLOBALS['prefix_lms'] . "_webpages \r\n\tORDER BY sequence \r\n\tLIMIT {$ini}," . Get::sett('visuItem');
    $num_query_pages = "\r\n\tSELECT COUNT(*) \r\n\tFROM " . $GLOBALS['prefix_lms'] . "_webpages ";
    //do query
    $re_pages = sql_query($query_pages);
    list($tot_pages) = sql_fetch_row(sql_query($num_query_pages));
    $nav_bar->setElementTotal($tot_pages);
    //-Table---------------------------------------------------------
    $cont_h = array($lang->def('_TITLE'), '<img src="' . getPathImage() . 'webpages/home.png" alt="' . $lang->def('_ALT_HOME') . '" title="' . $lang->def('_TITLE_HOME') . '" />', '<img src="' . getPathImage() . 'standard/publish.png" alt="' . $lang->def('_PUBLISH') . '" title="' . $lang->def('_STATUS') . '" />');
    $type_h = array('', 'image', 'image', 'image');
    if ($mod_perm) {
        $cont_h[] = '<img src="' . getPathImage() . 'standard/down.png" alt="' . $lang->def('_DOWN') . '" title="' . $lang->def('_MOVE_DOWN') . '" />';
        $type_h[] = 'image';
        $cont_h[] = '<img src="' . getPathImage() . 'standard/up.png" alt="' . $lang->def('_UP') . '" title="' . $lang->def('_MOVE_UP') . '" />';
        $type_h[] = 'image';
        $cont_h[] = '<img src="' . getPathImage() . 'standard/edit.png" alt="' . $lang->def('_MOD') . '" title="' . $lang->def('_MOD') . '" />';
        $type_h[] = 'image';
        $cont_h[] = '<img src="' . getPathImage() . 'standard/delete.png" alt="' . $lang->def('_DEL') . '" title="' . $lang->def('_DEL') . '" />';
        $type_h[] = 'image';
    }
    $tb->setColsStyle($type_h);
    $tb->addHead($cont_h);
    $i = 1;
    while (list($id, $title, $publish, $in_home) = sql_fetch_row($re_pages)) {
        $cont = array($title, $in_home ? '<img src="' . getPathImage() . 'webpages/home.png" alt="' . $lang->def('_ALT_HOME') . '" title="' . $lang->def('_TITLE_HOME') . '" />' : '');
        if ($publish) {
            $cont[] = '<a href="index.php?modname=webpages&amp;op=unpublish&amp;id_page=' . $id . '" title="' . $lang->def('_PUBLISH') . ' : ' . $title . '">' . '<img src="' . getPathImage() . 'standard/publish.png" alt="' . $lang->def('_PUBLISH') . ' : ' . $title . '" /></a>';
        } else {
            $cont[] = '<a href="index.php?modname=webpages&amp;op=publish&amp;id_page=' . $id . '" title="' . $lang->def('_UNPUBLISH') . ' : ' . $title . '">' . '<img src="' . getPathImage() . 'standard/unpublish.png" alt="' . $lang->def('_UNPUBLISH') . ' : ' . $title . '" /></a>';
        }
        if ($mod_perm) {
            if ($i != $tot_pages - $ini * Get::sett('visuItem')) {
                $cont[] = '<a href="index.php?modname=webpages&amp;op=movedown&amp;id_page=' . $id . '" title="' . $lang->def('_MOVE_DOWN') . ' : ' . $title . '">' . '<img src="' . getPathImage() . 'standard/down.png" alt="' . $lang->def('_DOWN') . ' : ' . $title . '" /></a>';
            } else {
                $cont[] = '&nbsp;';
            }
            if ($i != 1 || $ini != 0) {
                $cont[] = '<a href="index.php?modname=webpages&amp;op=moveup&amp;id_page=' . $id . '" title="' . $lang->def('_MOVE_UP') . ' : ' . $title . '">' . '<img src="' . getPathImage() . 'standard/up.png" alt="' . $lang->def('_UP') . ' : ' . $title . '" /></a>';
            } else {
                $cont[] = '&nbsp;';
            }
            $cont[] = '<a href="index.php?modname=webpages&amp;op=modpages&amp;id_page=' . $id . '" title="' . $lang->def('_MOD') . ' : ' . $title . '">' . '<img src="' . getPathImage() . 'standard/edit.png" alt="' . $lang->def('_MOD') . ' : ' . $title . '" /></a>';
            $cont[] = '<a href="index.php?modname=webpages&amp;op=delpages&amp;id_page=' . $id . '" title="' . $lang->def('_DEL') . ' : ' . $title . '">' . '<img src="' . getPathImage() . 'standard/delete.png" alt="' . $lang->def('_DEL') . ' : ' . $title . '" /></a>';
        }
        $tb->addBody($cont);
        ++$i;
    }
    if ($mod_perm) {
        $tb->addActionAdd('<a class="ico-wt-sprite subs_add" href="index.php?modname=webpages&amp;op=addpages" title="' . Lang::t('_ADD', 'webpages') . '"><span>' . Lang::t('_ADD', 'webpages') . '</span></a>');
    }
    //visualize result
    $out->add(getTitleArea($lang->def('_TITLE_WEBPAGES'), 'webpages') . '<div class="std_block">');
    if (isset($_GET['result'])) {
        switch ($_GET['result']) {
            case "ok":
                $out->add(getResultUi($lang->def('_OPERATION_SUCCESSFUL')));
                break;
            case "err":
                $out->add(getErrorUi($lang->def('_OPERATION_FAILURE')));
                break;
            case "err_del":
                $out->add(getErrorUi($lang->def('_OPERATION_FAILURE')));
                break;
        }
    }
    $out->add($tb->getTable() . Form::openForm('nav_webpages', 'index.php?modname=webpages&amp;op=webpages') . $nav_bar->getNavBar($ini) . Form::closeForm() . '</div>');
    if ($mod_perm) {
        require_once _base_ . '/lib/lib.dialog.php';
        setupHrefDialogBox('a[href*=delpages]');
    }
}
コード例 #5
0
ファイル: advice.php プロジェクト: abhinay100/forma_app
function archiveList()
{
    require_once _base_ . '/lib/lib.table.php';
    $lang =& DoceboLanguage::createInstance('advice');
    $mod_perm = checkPerm('mod', true);
    $out = $GLOBALS['page'];
    $out->setWorkingZone('content');
    $nav_bar = new NavBar('ini', Get::sett('visuItem'), 0, 'button');
    $ini = $nav_bar->getSelectedElement();
    $query_my_arch_advice = "\r\n\t\tSELECT DISTINCT idAdvice\r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_adviceuser\r\n\t\tWHERE idUser = '******' AND archivied = '1'";
    $re_my_arch_advice = sql_query($query_my_arch_advice);
    while (list($id) = sql_fetch_row($re_my_arch_advice)) {
        $advice_arch[] = $id;
    }
    if (!empty($advice_arch)) {
        $query_advice = "\r\n\t\t\tSELECT idAdvice, posted, title, description, important, author\r\n\t\t\tFROM " . $GLOBALS['prefix_lms'] . "_advice\r\n\t\t\tWHERE idCourse='" . $_SESSION['idCourse'] . "' AND idAdvice IN ( " . implode($advice_arch, ',') . " )\r\n\t\t\tORDER BY posted DESC\r\n\t\t\tLIMIT {$ini}," . Get::sett('visuItem');
        $re_advice = sql_query($query_advice);
        list($numofadvice) = sql_fetch_row(sql_query("\r\n\t\t\tSELECT COUNT(DISTINCT idAdvice)\r\n\t\t\tFROM " . $GLOBALS['prefix_lms'] . "_advice\r\n\t\t\tWHERE idCourse='" . $_SESSION['idCourse'] . "' AND idAdvice IN ( " . implode($advice_arch, ',') . " )"));
        $nav_bar->setElementTotal($numofadvice);
        if (isset($_GET['result'])) {
            switch ($_GET['result']) {
                case "ok":
                    $out->add(getResultUi($lang->def('_OPERATION_SUCCESSFUL')));
                    break;
                case "err":
                    $out->add(getErrorUi($lang->def('_ERR_INSERT')));
                    break;
                case "err_user":
                    $out->add(getErrorUi($lang->def('_OPERATION_FAILURE')));
                    break;
            }
        }
        while (list($idA, $posted, $title, $description, $impo, $author) = sql_fetch_row($re_advice)) {
            $out->add('<div class="list_block">' . '<h2 class="heading">');
            if ($impo) {
                $out->add('<img src="' . getPathImage() . 'standard/important.png" alt="' . $lang->def('_IMPORTANT') . '" /> ');
            } else {
                $out->add('');
            }
            $out->add($title . '</h2>' . '<div class="content"><p class="publish-date">' . Format::date($posted) . '</p>' . $description . '</div>' . '<div class="actions">');
            if ($mod_perm) {
                $out->add('<ul class="link_list_inline">' . '<li><a class="ico-wt-sprite subs_users" href="index.php?modname=advice&amp;op=modreader&amp;id_advice=' . $idA . '&amp;load=1" title="' . $lang->def('_VIEW_PERMISSION') . ' : ' . $title . '">' . '<span>' . $lang->def('_MOD') . '</span></a></li>' . '<li><a class="ico-wt-sprite subs_mod" href="index.php?modname=advice&amp;op=modadvice&amp;idAdvice=' . $idA . '" title="' . $lang->def('_MOD') . ' : ' . $title . '">' . '<span>' . $lang->def('_MOD') . '</span></a></li>' . '<li><a class="ico-wt-sprite subs_del" href="index.php?modname=advice&amp;op=deladvice&amp;idAdvice=' . $idA . '" title="' . $lang->def('_DEL') . ' : ' . $title . '">' . '<span>' . $lang->def('_DEL') . '</span></a></li>' . '</ul>');
                require_once _base_ . '/lib/lib.dialog.php';
                setupHrefDialogBox('a[href*=deladvice]');
            }
            $out->add('</div>' . '</div><br />');
        }
    }
    $form = new Form();
    $out->add($form->getHidden('archive_status', 'archive_status', '1') . $nav_bar->getNavBar($ini));
}
コード例 #6
0
/**
 * @version  $Id:$
 * @author	 Fabio Pirovano <fabio [at] docebo-com>
 * @package course
 */
function displayCourseList(&$url, $order_type)
{
    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.course.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.coursereport.php';
    require_once $GLOBALS["where_framework"] . "/lib/lib.ajax_comment.php";
    require_once $GLOBALS['where_lms'] . '/lib/lib.classroom.php';
    // cahce classroom
    $classroom_man = new ClassroomManager();
    $classrooms = $classroom_man->getClassroomNameList();
    $lang =& DoceboLanguage::createInstance('catalogue');
    $lang_c =& DoceboLanguage::createInstance('course');
    $nav_bar = new NavBar('ini', Get::sett('visuItem'), 0);
    $man_course = new Man_Course();
    $id_parent = importVar('id_parent', false, 0);
    $nav_url = $id_parent != 0 ? $url->getUrl('id_parent=' . $id_parent) : $url->getUrl();
    $nav_bar->setLink($nav_url);
    $ini = $nav_bar->getSelectedElement();
    $profile = new UserProfile(getLogUserId());
    $profile->init('profile', 'framework', '', 'ap');
    $profile->addStyleSheet('lms');
    // searching courses
    $use_category = $order_type == 'category';
    $select_course = "" . " SELECT c.idCourse, c.course_type, c.idCategory, c.code, c.name, c.description, c.lang_code, c.difficult, " . "\tc.subscribe_method, c.date_begin, c.date_end, c.max_num_subscribe, " . "\tc.selling, c.prize, c.create_date, c.status AS course_status, c.course_edition, " . "\tc.classrooms, c.img_material, c.course_demo, c.course_vote, COUNT(*) as enrolled, " . "\tc.can_subscribe, c.sub_start_date, c.sub_end_date, c.allow_overbooking, c.max_num_subscribe, c.min_num_subscribe, c.direct_play, " . "\tc.valid_time, c.userStatusOp, u.level, u.date_inscr, u.date_first_access, u.date_complete, u.status AS user_status, u.waiting, c.advance ";
    $from_course = " FROM " . $GLOBALS['prefix_lms'] . "_course AS c " . "\tLEFT JOIN " . $GLOBALS['prefix_lms'] . "_courseuser AS u " . "\t\tON ( c.idCourse = u.idCourse ) ";
    $where_course = " c.status <> '" . CST_PREPARATION . "' ";
    if (Get::sett('catalogue_hide_ended') == 'on') {
        $where_course .= " AND ( c.date_end = '0000-00-00'" . " OR c.date_end > '" . date('Y-m-d') . "' ) ";
    }
    $group_by_course = " GROUP BY c.idCourse ";
    switch ($order_type) {
        case "mostscore":
            $order_course = " ORDER BY c.course_vote DESC ";
            break;
        case "popular":
            $order_course = " ORDER BY enrolled DESC ";
            break;
        case "recent":
            $order_course = " ORDER BY c.create_date DESC ";
            break;
        default:
            $order_course = " ORDER BY c.name ";
    }
    $limit_course = " LIMIT " . $ini . ", " . Get::sett('visuItem');
    $where_course .= " AND c.course_type <> 'assessment'";
    if (Docebo::user()->isAnonymous()) {
        $where_course .= " AND c.show_rules = 0";
    } else {
        $where_course .= " AND c.show_rules  <> 2";
    }
    // maybe a must apply some filter to remove from the list some courses --------------
    $cat_man = new Catalogue_Manager();
    $catalogues =& $cat_man->getUserAllCatalogueId(getLogUserId());
    // at least one catalogue is assigned to this user
    if (!empty($catalogues)) {
        $cat_courses = $cat_man->getAllCourseOfUser(getLogUserId());
        if (empty($cat_courses)) {
            $where_course .= " AND 0 ";
        } else {
            $where_course .= " AND c.idCourse IN ( " . implode(',', $cat_courses) . " ) ";
        }
    } elseif (Get::sett('on_catalogue_empty') == 'off') {
        $where_course .= " AND 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']['course'])) {
            $where_course = " ( ( " . $where_course . " ) OR c.idCourse IN (" . implode(',', $ass_elem['parsed']['course']) . ") ) ";
        }
    }
    // apply search filter --------------------------------------------------------------
    $s_searched = get_searched('simple_search', '');
    $filter_lang = get_searched('filter_lang', 'all');
    $filter_date_begin = get_searched('filter_date_begin', '');
    if ($filter_date_begin != '') {
        $filter_date_begin = Format::dateDb($filter_date_begin, 'date') . ' 00:00:00';
    }
    $filter_date_end = get_searched('filter_date_end', '');
    if ($filter_date_end != '') {
        $filter_date_end = Format::dateDb($filter_date_end, 'date') . ' 00:00:00';
    }
    $all_lang = Docebo::langManager()->getAllLangCode();
    if (must_search_filter()) {
        if (trim($s_searched) != '') {
            $where_course .= " AND ( c.code LIKE '%" . $s_searched . "%' " . " OR c.name LIKE '%" . $s_searched . "%' " . " OR c.description LIKE '%" . $s_searched . "%' ) ";
        }
        if ($filter_lang != 'all') {
            $where_course .= " AND c.lang_code = '" . $all_lang[$filter_lang] . "' ";
        }
        if ($filter_date_begin != '') {
            $where_course .= " AND ( c.date_begin >= '" . $filter_date_begin . "' OR c.course_edition = 1 ) ";
        }
        if ($filter_date_end != '') {
            $where_course .= " AND ( c.date_end <= '" . $filter_date_end . "' OR c.course_edition = 1 ) ";
        }
    }
    if ($use_category) {
        $where_course .= " AND c.idCategory = '" . (int) $id_parent . "'";
    }
    $re_course = sql_query($select_course . $from_course . " WHERE " . $where_course . $group_by_course . $order_course . $limit_course);
    list($course_number) = sql_fetch_row(sql_query("SELECT COUNT(*) " . " FROM " . $GLOBALS['prefix_lms'] . "_course AS c " . " WHERE " . $where_course));
    $nav_bar->setElementTotal($course_number);
    // retrive editions ----------------------------------------------------------------
    $select_edition = " SELECT e.* ";
    $from_edition = " FROM " . $GLOBALS["prefix_lms"] . "_course_edition AS e";
    $where_edition = " WHERE e.status <> '" . CST_PREPARATION . "' ";
    $where_edition .= " AND (e.date_begin > '" . date("Y-m-d H:i:s") . "' OR e.date_begin = '0000-00-00 00:00:00')";
    $order_edition = " ORDER BY date_begin ";
    if (must_search_filter()) {
        if ($filter_date_begin != '') {
            $where_edition .= " AND date_begin >= '" . $filter_date_begin . "' ";
        }
        if ($filter_date_end != '') {
            $where_edition .= " AND date_end <= '" . $filter_date_end . "' ";
        }
    }
    $re_edition = sql_query($select_edition . $from_edition . $where_edition . $order_edition);
    $editions = array();
    if ($re_edition) {
        while ($edition_elem = mysql_fetch_assoc($re_edition)) {
            $edition_elem['classrooms'] = isset($classrooms[$edition_elem['classrooms']]) ? $classrooms[$edition_elem['classrooms']] : '';
            $edition_elem['waiting'] = 0;
            $edition_elem['user_count'] = 0;
            $edition_elem['theacher_list'] = getSubscribed($edition_elem["idCourse"], false, 6, true, $edition_elem["idCourseEdition"]);
            $editions[$edition_elem["idCourse"]][$edition_elem["idCourseEdition"]] = $edition_elem;
        }
    }
    // retrive editions subscribed -----------------------------------------------------
    $select_ed_count = "SELECT u.idCourse, u.edition_id, sum(u.waiting) as waiting, COUNT(*) as user_count ";
    $from_ed_count = " FROM " . $GLOBALS["prefix_lms"] . "_courseuser AS u";
    $where_ed_count = " WHERE u.edition_id <> 0 " . " AND u.level = '3'" . " AND u.status IN ('" . _CUS_CONFIRMED . "', '" . _CUS_SUBSCRIBED . "', '" . _CUS_BEGIN . "', '" . _CUS_END . "', '" . _CUS_SUSPEND . "', '" . _CUS_WAITING_LIST . "')" . " AND u.absent = '0'";
    $group_ed_count = "GROUP BY u.edition_id ";
    $re_ed_count = sql_query($select_ed_count . $from_ed_count . $where_ed_count . $group_ed_count);
    if ($re_ed_count) {
        while ($ed_count_elem = mysql_fetch_assoc($re_ed_count)) {
            if (isset($editions[$ed_count_elem["idCourse"]][$ed_count_elem["edition_id"]])) {
                $editions[$ed_count_elem["idCourse"]][$ed_count_elem["edition_id"]]['waiting'] = $ed_count_elem['waiting'];
                $editions[$ed_count_elem["idCourse"]][$ed_count_elem["edition_id"]]['user_count'] = $ed_count_elem['user_count'];
            }
        }
    }
    // retrive course subscription -----------------------------------------------------
    $man_courseuser = new Man_CourseUser();
    $usercourses = $man_courseuser->getUserSubscriptionsInfo(getLogUserId(), false);
    $user_score = $man_courseuser->getUserCourseScored(getLogUserId());
    require_once $GLOBALS['where_lms'] . '/lib/lib.orgchart.php';
    $first_is_scorm = OrganizationManagement::objectFilter(array_keys($usercourses), 'scormorg');
    // load search form ----------------------------------------------------------------
    $GLOBALS['page']->add(searchForm($url, $lang), 'content');
    if ($use_category && !must_search_filter()) {
        // show category selection -----------------------------------------------------
        $descendant = $man_course->getCategoryCourseAndSonCount();
        $GLOBALS['page']->add('<p class="category_path">' . '<b>' . $lang->def('_CATEGORY_PATH', 'course') . ' :</b> ' . $man_course->getCategoryPath($id_parent, $lang->def('_MAIN_CATEGORY', 'course'), $lang->def('_TITLE_CATEGORY_JUMP', 'course'), $url->getUrl(), 'id_parent') . '</p>', 'content');
        $categories =& $man_course->getCategoriesInfo($id_parent);
        if (!empty($categories)) {
            $GLOBALS['page']->add('<ul class="category_list">', 'content');
            while (list($id_cat, $cat) = each($categories)) {
                $GLOBALS['page']->add('<li' . (!isset($descendant[$id_cat]) ? ' class="empty_folder"' : '') . '>' . '<a href="' . $url->getUrl('id_parent=' . $id_cat) . '">' . $cat['name'] . '<br />' . '<b>' . str_replace(array('[course]', '[category]'), array(isset($descendant[$id_cat]['course']) ? $descendant[$id_cat]['course'] : 0, isset($descendant[$id_cat]['category']) ? $descendant[$id_cat]['category'] : 0), $lang->def('_COURSE_CONTENT', 'course')) . '</b>' . '</a></li>', 'content');
            }
            $GLOBALS['page']->add('</ul>' . '<div class="nofloat"></div>', 'content');
        }
    }
    if (!$re_course || !mysql_num_rows($re_course)) {
        // no course found for the criteria --------------------------------------------
        $GLOBALS['page']->add('<p class="no_course_found">' . $lang->def('_NO_COURSE_FOUND') . '</p>' . '</div>', 'content');
        return;
    }
    $ax_comm = new AjaxComment('course', 'lms');
    $comment_count = $ax_comm->getResourceCommentCount();
    $GLOBALS['page']->add($nav_bar->getNavBar($ini), 'content');
    $i = 0;
    $direct_play = false;
    while ($cinfo = mysql_fetch_assoc($re_course)) {
        if (must_search_filter()) {
            $s_searched = get_searched('simple_search', '');
            if ($s_searched != '') {
                $cinfo['code'] = preg_replace("/" . $s_searched . "/i", '<b class="filter_evidence">' . $s_searched . '</b>', $cinfo['code']);
                $cinfo['name'] = preg_replace("/" . $s_searched . "/i", '<b class="filter_evidence">' . $s_searched . '</b>', $cinfo['name']);
                $cinfo['description'] = preg_replace("/" . $s_searched . "/i", '<b class="filter_evidence">' . $s_searched . '</b>', $cinfo['description']);
            }
        }
        $cinfo['theacher_list'] = getSubscribed($cinfo['idCourse'], false, 6, true);
        $cinfo['edition_list'] = isset($editions[$cinfo['idCourse']]) ? $editions[$cinfo['idCourse']] : array();
        $cinfo['edition_available'] = count($cinfo['edition_list']);
        $cinfo['user_score'] = isset($user_score[$cinfo['idCourse']]) ? $user_score[$cinfo['idCourse']] : NULL;
        $cinfo['classrooms'] = isset($classrooms[$cinfo['classrooms']]) ? $classrooms[$cinfo['classrooms']] : '';
        if (isset($first_is_scorm[$cinfo['idCourse']])) {
            $cinfo['first_is_scorm'] = $first_is_scorm[$cinfo['idCourse']];
        } else {
            $cinfo['first_is_scorm'] = false;
        }
        if (isset($comment_count[$cinfo['idCourse']])) {
            $cinfo['comment_count'] = $comment_count[$cinfo['idCourse']];
        }
        $view = true;
        if (must_search_filter()) {
            if ($cinfo['course_edition'] == 1 && empty($cinfo['edition_list'])) {
                $view = false;
            }
        }
        if ($view) {
            $GLOBALS['page']->add(dashcourse($url, $lang_c, $cinfo, isset($usercourses[$cinfo['idCourse']]) ? $usercourses[$cinfo['idCourse']] : false, $i++), 'content');
        }
        if ($cinfo['direct_play'] == 1) {
            $direct_play = true;
        }
    }
    if ($direct_play) {
        $GLOBALS['page']->add('' . '	<link href="' . getPathTemplate() . '/style/shadowbox.css" rel="stylesheet" type="text/css" />' . '<script type="text/javascript" src="' . $GLOBALS['where_framework_relative'] . '/addons/shadowbox/shadowbox-yui.js"></script>' . "\n" . '<script type="text/javascript" src="' . $GLOBALS['where_framework_relative'] . '/addons/shadowbox/shadowbox.js"></script>' . "\n", 'page_head');
        $GLOBALS['page']->add('<script type="text/javascript">
	
		YAHOO.util.Event.onDOMReady(function() {
			var options = { listenOverlay:false, overlayOpacity:"0.8", 
				loadingImage:"' . getPathImage('lms') . 'standard/loading.gif", overlayBgImage:"' . getPathImage('lms') . 'standard/overlay-85.png", 
				text: {close: "' . Lang::t('_CLOSE') . '", cancel: "' . Lang::t('_UNDO') . '", loading:"' . Lang::t('_LOADING') . '" },
				onOpen: function (gallery) { window.onbeforeunload = function() { return "' . Lang::t('_CONFIRM_EXIT', 'organization', 'lms') . '"; } }
		    }; 
			Shadowbox.init(options); 
			Shadowbox.close = function() {
				window.onbeforeunload = null;
				window.frames[\'shadowbox_content\'].uiPlayer.closePlayer(true, window);
			}
		});
		</script>');
    }
    $GLOBALS['page']->add($nav_bar->getNavBar($ini), 'content');
}