예제 #1
0
 function pathlist()
 {
     checkPerm('view');
     require_once _base_ . '/lib/lib.table.php';
     $out =& $GLOBALS['page'];
     $lang =& DoceboLanguage::createInstance('coursepath', 'lms');
     $acl_man =& Docebo::user()->getAclManager();
     $subscribe_perm = checkPerm('subscribe', true);
     $mod_perm = checkPerm('mod', true);
     $del_perm = checkPerm('mod', true);
     if (Get::cfg('demo_mode')) {
         $del_perm = false;
     }
     $query_pathlist = "\r\n\tSELECT id_path, path_code, path_name, path_descr\r\n\tFROM " . $GLOBALS['prefix_lms'] . "_coursepath ";
     if (Docebo::user()->getUserLevelId() != ADMIN_GROUP_GODADMIN) {
         require_once _base_ . '/lib/lib.preference.php';
         $adminManager = new AdminPreference();
         $admin_courses = $adminManager->getAdminCourse(Docebo::user()->getIdST());
         $all_courses = false;
         if (isset($admin_courses['course'][0])) {
             $all_courses = true;
         }
         if (isset($admin_courses['course'][-1])) {
             $query = "SELECT id_path" . " FROM %lms_coursepath_user" . " WHERE idUser = '******'";
             $result = sql_query($query);
             $admin_courses['coursepath'] = array();
             while (list($id_path) = sql_fetch_row($result)) {
                 $admin_courses['coursepath'][$id_path] = $id_path;
             }
             if (!empty($admin_courses['coursepath']) && Get::sett('on_catalogue_empty', 'off') == 'on') {
                 $all_courses = true;
             }
         } else {
             if (!empty($admin_courses['catalogue'])) {
                 require_once _lms_ . '/lib/lib.catalogue.php';
                 $cat_man = new Catalogue_Manager();
                 foreach ($admin_courses['catalogue'] as $id_cat) {
                     $catalogue_coursepath = $cat_man->getCatalogueCoursepath($id_cat, true);
                     $admin_courses['coursepath'] = array_merge($admin_courses['coursepath'], $catalogue_coursepath);
                 }
             }
         }
         if ($all_courses) {
             $query_pathlist .= "WHERE 1 ";
         } elseif (empty($admin_courses['coursepath'])) {
             $query_pathlist = "WHERE 0";
         } else {
             $query_pathlist .= "WHERE id_path IN (" . implode(',', $admin_courses['coursepath']) . ") ";
         }
     }
     $query_pathlist .= " ORDER BY path_name ";
     $re_pathlist = sql_query($query_pathlist);
     // find subscriptions
     $subscriptions = array();
     $query_subcription = "\r\n\tSELECT id_path, COUNT(idUser), SUM(waiting)\r\n\tFROM " . $GLOBALS['prefix_lms'] . "_coursepath_user\r\n\tGROUP BY id_path";
     if (Docebo::user()->getUserLevelId() != ADMIN_GROUP_GODADMIN) {
         require_once _base_ . '/lib/lib.preference.php';
         $adminManager = new AdminPreference();
         $admin_tree = $adminManager->getAdminTree(Docebo::user()->getIdST());
         $admin_users = $acl_man->getAllUsersFromIdst($admin_tree);
         if (!empty($admin_users)) {
             $query_subcription .= " AND idUser IN (" . implode(',', $admin_users) . ")";
         } else {
             $query_subcription .= " AND idUser = 0";
         }
     }
     $re_subscription = sql_query($query_subcription);
     while (list($id_path, $users, $waitings) = sql_fetch_row($re_subscription)) {
         $subscriptions[$id_path]['users'] = $users - $waitings;
         $subscriptions[$id_path]['waiting'] = $waitings;
     }
     $out->setWorkingZone('content');
     $out->add(getTitleArea($lang->def('_COURSEPATH'), 'coursepath') . '<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;
         }
     }
     $tb_path = new Table(0, $lang->def('_COURSE_PATH_CAPTION'), $lang->def('_COURSE_PATH_CAPTION'));
     $cont_h = array($lang->def('_CODE'), $lang->def('_NAME'), $lang->def('_DESCRIPTION'));
     $type_h = array('course_code', '', '');
     // $subscribe_perm = false;
     $cont_h[] = '<img src="' . getPathImage() . 'standard/moduser.png" alt="' . $lang->def('_SUBSCRIBE') . '" />';
     $type_h[] = 'image';
     $cont_h[] = '<img src="' . getPathImage() . 'standard/modelem.png" alt="' . $lang->def('_COURSES') . '" />';
     $type_h[] = 'image';
     if ($mod_perm) {
         $cont_h[] = '<img src="' . getPathImage() . 'standard/edit.png" alt="' . $lang->def('_MOD') . '" />';
         $type_h[] = 'image';
     }
     if ($del_perm) {
         $cont_h[] = '<img src="' . getPathImage() . 'standard/delete.png" alt="' . $lang->def('_DEL') . '" />';
         $type_h[] = 'image';
     }
     $tb_path->setColsStyle($type_h);
     $tb_path->addHead($cont_h);
     while (list($id_path, $path_code, $path_name, $path_descr) = sql_fetch_row($re_pathlist)) {
         $cont = array($path_code, $path_name, $path_descr);
         if ($subscribe_perm) {
             $url_subscribe = 'index.php?r=alms/subscription/show_coursepath&id_path=' . (int) $id_path;
             $cont[] = '<a href="' . $url_subscribe . '" ' . 'title="' . $lang->def('_SUBSCRIBE') . ' : ' . $path_name . '">' . (isset($subscriptions[$id_path]['users']) ? $subscriptions[$id_path]['users'] . ' ' : '') . '<img src="' . getPathImage() . 'standard/moduser.png" alt="' . $lang->def('_SUBSCRIBE') . ' : ' . $path_name . '" /></a>';
             $cont[] = '<a href="index.php?modname=coursepath&amp;op=pathelem&amp;id_path=' . $id_path . '" ' . 'title="' . $lang->def('_MOD') . ' : ' . $path_name . '">' . '<img src="' . getPathImage() . 'standard/modelem.png" alt="' . $lang->def('_COURSES') . ' : ' . $path_name . '" /></a>';
         } else {
             $cont[] = isset($subscriptions[$id_path]['users']) ? $subscriptions[$id_path]['users'] . ' ' : '';
             $cont[] = '<a href="index.php?modname=coursepath&amp;op=pathelem&amp;id_path=' . $id_path . '" ' . 'title="' . $lang->def('_MOD') . ' : ' . $path_name . '">' . '<img src="' . getPathImage() . 'standard/modelem.png" alt="' . $lang->def('_MOD') . ' : ' . $path_name . '" /></a>';
         }
         if ($mod_perm) {
             $cont[] = '<a href="index.php?modname=coursepath&amp;op=modcoursepath&amp;id_path=' . $id_path . '" ' . 'title="' . $lang->def('_MOD') . ' : ' . $path_name . '">' . '<img src="' . getPathImage() . 'standard/edit.png" alt="' . $lang->def('_MOD') . ' : ' . $path_name . '" /></a>';
         }
         if ($del_perm) {
             $cont[] = '<a href="index.php?modname=coursepath&amp;op=deletepath&amp;id_path=' . $id_path . '" ' . 'title="' . $lang->def('_DEL') . ' : ' . $path_name . '">' . '<img src="' . getPathImage() . 'standard/delete.png" alt="' . $lang->def('_DEL') . ' : ' . $path_name . '" /></a>';
         }
         $tb_path->addBody($cont);
     }
     require_once _base_ . '/lib/lib.dialog.php';
     setupHrefDialogBox('a[href*=deletepath]');
     if ($mod_perm) {
         $tb_path->addActionAdd('<a href="index.php?modname=coursepath&amp;op=newcoursepath" title="' . $lang->def('_ADD') . '">' . '<img src="' . getPathimage() . 'standard/add.png" alt="' . $lang->def('_ADD') . '" />' . $lang->def('_ADD') . '</a>');
     }
     $out->add($tb_path->getTable());
     $out->add('</div>');
 }