Ejemplo n.º 1
0
function lmsLoginOperation()
{
    require_once $GLOBALS['where_lms'] . '/lib/lib.subscribe.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.preassessment.php';
    $pa_man = new AssessmentList();
    $user_course_as_assessment = $pa_man->getUserAssessmentSubsription(Docebo::user()->getArrSt());
    if (is_array($user_course_as_assessment)) {
        $subs_man = new CourseSubscribe_Management();
        $subs_man->multipleUserSubscribe(getLogUserId(), $user_course_as_assessment['course_list'], $user_course_as_assessment['level_number']);
    }
}
Ejemplo n.º 2
0
 function actionEvent(&$event)
 {
     require_once $GLOBALS['where_lms'] . '/lib/lib.subscribe.php';
     parent::actionEvent($event);
     $acl_man =& Docebo::user()->getACLManager();
     // recover event information
     $id_user = $event->getProperty('userdeleted');
     $man_subs = new CourseSubscribe_Management();
     $man_subs->unsubscribeUserFromAllCourses($id_user);
     return true;
 }
Ejemplo n.º 3
0
 public function setRulesFromScore($score_arr)
 {
     require_once _base_ . '/lib/lib.json.php';
     require_once _lms_ . '/lib/lib.subscribe.php';
     $res = true;
     $where_score_arr = array();
     foreach ($score_arr as $val) {
         $where_score_arr[] = "(category_id = '" . (int) $val['category_id'] . "' " . "AND from_score <= '" . (int) $val['score'] . "' AND to_score >= '" . (int) $val['score'] . "')";
     }
     if (empty($where_score_arr)) {
         return '';
     }
     $fields = "*";
     $qtxt = "SELECT " . $fields . " FROM %lms_assessment_rule\r\n\t\t\tWHERE test_id='" . $this->test_id . "'\r\n\t\t\tAND (" . implode(' OR ', $where_score_arr) . ")\r\n\t\t\tORDER BY from_score ASC";
     $q = $this->db->query($qtxt);
     $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
     $csm = new CourseSubscribe_Management();
     $cmpman = new CompetencesAdm();
     $feedback_txt = array();
     while ($row = $this->db->fetch_assoc($q)) {
         $course_arr = $json->decode($row['courses_list']);
         $competence_arr = $json->decode($row['competences_list']);
         $feedback_txt[] = $row['feedback_txt'];
         //courses subscriptions - only students are affected
         if (!empty($course_arr) && $_SESSION['levelCourse'] <= 3) {
             $arr_courses = array_keys($course_arr);
             $csm->multipleUserSubscribe(getLogUserId(), $arr_courses, 3);
         }
         //competences assignment - only students are affected
         if (!empty($competence_arr) && $_SESSION['levelCourse'] <= 3) {
             foreach ($competence_arr as $c_id => $data) {
                 if ($data['type'] == 'score') {
                     $score = isset($data['score']) ? $data['score'] : 0;
                     if ($score > 0) {
                         if (!$cmpman->userHasCompetence($c_id, Docebo::user()->getIdst())) {
                             $cmpman->assignCompetenceUsers($c_id, array(Docebo::user()->getIdst() => $score));
                         } else {
                             $cmpman->addScoreToUsers($c_id, array(Docebo::user()->getIdst()), $score);
                         }
                     }
                 } else {
                     if (!$cmpman->userHasCompetence($c_id, Docebo::user()->getIdst())) {
                         $cmpman->assignCompetenceUsers($c_id, array(Docebo::user()->getIdst() => 1));
                     }
                 }
             }
         }
     }
     $output = "";
     if (!empty($feedback_txt)) {
         $output = implode('<br/><br />', $feedback_txt);
     }
     return $output;
 }
Ejemplo n.º 4
0
 public function rollbackLog($id_log)
 {
     require_once _lms_ . '/lib/lib.subscribe.php';
     $cs = new CourseSubscribe_Management();
     // remove all the subscription
     $cs->removeRuleLogSubscription($id_log);
     // remove the log
     $query = "DELETE FROM %adm_rules_log WHERE id_log = '" . $id_log . "'";
     if (!$this->db->query($query)) {
         return false;
     }
     return true;
 }
Ejemplo n.º 5
0
function coursecatalogue($id_block, $title, $option = array())
{
    YuiLib::load(array('animation' => 'my_animation', 'container' => 'container-min', 'container' => 'container_core-min'));
    cout(Util::get_js(Get::rel_path('cms') . '/modules/catalog/catalog.js', true), 'page_head');
    if (!isset($_SESSION['chart'])) {
        $_SESSION['chart'] = array();
    }
    $id_course = Get::req('id_course', DOTY_INT, 0);
    $action = Get::req('action', DOTY_STRING, '');
    if ($id_course !== 0 && $action === '') {
        $_SESSION['chart'][$id_course]['idCourse'] = $id_course;
    } else {
        require_once _lms_ . '/lib/lib.subscribe.php';
        $man_subscribe = new CourseSubscribe_Management();
        $man_subscribe->subscribeToCourse(getLogUserId(), $id_course);
    }
    require_once _cms_ . '/lib/lib.catalog.php';
    require_once _base_ . '/lib/lib.navbar.php';
    cout('<link href="./modules/catalog/catalog.css" type="text/css" rel="stylesheet"/>', 'page_head');
    $css_path = Get::tmpl_path('base') . 'yui-skin';
    cout(Util::get_css($css_path . '/tabview.css', true), 'page_head');
    $lang =& DoceboLanguage::CreateInstance('catalogue', 'cms');
    $man_cat = new Man_Catalog();
    $array_id_block = explode('_', $id_block);
    $page = Get::req('page', DOTY_INT, 0);
    if ($page == 0) {
        $page = $this->getBlockPage($array_id_block[0]);
    }
    cout(getTitleArea($title) . '<div class="std_block">');
    $catalogue = $man_cat->getCatalogueForBlock($array_id_block[0]);
    $all_course = false;
    if (array_search(0, $catalogue) !== false) {
        unset($catalogue[array_search(0, $catalogue)]);
        $all_course = true;
    }
    $id_catalogue = Get::req('id_catalogue', DOTY_INT, -2);
    if ($id_catalogue == -2) {
        if (count($catalogue)) {
            if (isset($catalogue[0])) {
                $id_catalogue = $catalogue[0]['id_catalogue'];
            } else {
                $id_catalogue = $catalogue[1]['id_catalogue'];
            }
        } else {
            $id_catalogue = 0;
        }
    }
    $id_category = Get::req('id_cat', DOTY_INT, 0);
    $number_courses = $man_cat->getCourseNumberForBlock($array_id_block[0], $id_catalogue, $id_category, $all_course);
    $nav_bar = new NavBar('ini', Get::sett('visuItem'), $number_courses);
    $nav_bar->setLink('index.php?pag=' . $page . '&amp;id_catalogue=' . $id_catalogue . ($id_category != 0 ? '&amp;id_cat=' . $id_category : ''));
    $ini = $nav_bar->getSelectedPage();
    $limit = ($ini - 1) * Get::sett('visuItem');
    cout($nav_bar->getNavBar() . '<div id="demo" class="yui-navset">' . '<ul class="yui-nav">');
    foreach ($catalogue as $catalogue_info) {
        cout('<li ' . ($catalogue_info['id_catalogue'] == $id_catalogue ? ' class="selected"' : '') . '><a href="index.php?pag=' . $page . '&amp;id_catalogue=' . $catalogue_info['id_catalogue'] . '"><em>' . $catalogue_info['name'] . '</em></a></li>');
    }
    cout('<li ' . ($id_catalogue == 0 ? ' class="selected"' : '') . '><a href="index.php?pag=' . $page . '&amp;id_catalogue=0"><em>' . $lang->def('_ALL_COURSES') . '</em></a></li>' . '<li ' . ($id_catalogue == -1 ? ' class="selected"' : '') . '><a href="index.php?pag=' . $page . '&amp;id_catalogue=-1"><em>' . $lang->def('_CATEGORY') . '</em></a></li>');
    reset($catalogue);
    cout('</ul>');
    cout('<div class="yui-content">');
    if ($number_courses == 0 && $id_catalogue != -1) {
        cout('<p>' . $lang->def('_NO_COURSE_FOR_CATALOG') . '</p>');
    } elseif ($id_catalogue == -1) {
        //Category Visualization
        if ($id_category == 0) {
            $query = "SELECT ca.idCategory, ca.path, ca.lev, ca.iLeft, ca.iRight, COUNT(co.idCourse)" . " FROM " . $GLOBALS['prefix_lms'] . "_category AS ca" . " LEFT JOIN " . $GLOBALS['prefix_lms'] . "_course AS co ON co.idCategory = ca.idCategory" . " WHERE ca.lev = 1" . " GROUP BY ca.idCategory" . " ORDER BY ca.lev, ca.path";
        } else {
            $query = "SELECT iLeft, iRight" . " FROM " . $GLOBALS['prefix_lms'] . "_category" . " WHERE idCategory = " . $id_category;
            list($ileft, $iright) = sql_fetch_row(sql_query($query));
            $query = "SELECT ca.idCategory, ca.path, ca.lev, ca.iLeft, ca.iRight, COUNT(co.idCourse)" . " FROM " . $GLOBALS['prefix_lms'] . "_category AS ca" . " LEFT JOIN " . $GLOBALS['prefix_lms'] . "_course AS co ON co.idCategory = ca.idCategory" . " WHERE ca.iLeft >= " . $ileft . " AND ca.iRight <= " . $iright . " GROUP BY ca.idCategory" . " ORDER BY ca.lev, ca.path";
        }
        $result = sql_query($query);
        $first = true;
        $num_folder = sql_num_rows($result);
        cout('<div class="cat_nav">');
        while (list($id_cat, $path, $lev, $ileft, $iright, $courses) = sql_fetch_row($result)) {
            $cat_name = end(explode('/', $path));
            if ($id_category == $id_cat) {
                cout('<div class="cat_position">' . '<a href="index.php?pag=' . $page . '&id_catalogue=-1">' . $lang->def('_CATEGORY') . '</a>');
                if ($lev > 1) {
                    $query_parent = "SELECT idCategory, path" . " FROM " . $GLOBALS['prefix_lms'] . "_category" . " WHERE iLeft < " . $ileft . " AND iRight > " . $iright . " ORDER BY lev ASC";
                    $result_parent = sql_query($query_parent);
                    while (list($id_cat_pa, $path_pa) = sql_fetch_row($result_parent)) {
                        $pa_name = end(explode('/', $path_pa));
                        cout(' - <a href="index.php?pag=' . $page . '&id_catalogue=-1&amp;id_cat=' . $id_cat_pa . '">' . $pa_name . '</a>');
                    }
                }
                cout(' - ' . $cat_name . '</div>');
            }
            if ($first && $num_folder > 0) {
                $first = false;
                cout('<ul class="cat_nav_list">');
            }
            if ($id_category != $id_cat) {
                $sub_folder = ($iright - $ileft - 1) / 2;
                cout('<li>' . '<a href="index.php?pag=' . $page . '&id_catalogue=-1&amp;id_cat=' . $id_cat . '">' . $cat_name . '<br />' . ($sub_folder > 0 ? '<span class="cat_item_info">' . $lang->def("_CATEGORIES") . ' (' . $sub_folder . ')<br />' : '') . ($courses > 0 ? '<span class="cat_item_info">' . $lang->def("_COURSES") . ' (' . $courses . ')' : '') . '</a>' . '</li>');
            }
        }
        if ($num_folder > 0) {
            cout('</ul>');
        }
        cout('</div>');
        //Course visualization
        cout('<div class="course_list">');
        if ($number_courses == 0) {
            cout('<p>' . $lang->def('_NO_COURSE_FOR_CATEGORY') . '</p>');
        } else {
            $courses = $man_cat->getCourseForBlock($array_id_block[0], $limit, $id_catalogue, $id_category, $all_course);
            foreach ($courses as $course_info) {
                $action = $this->controlCourse($course_info, $page, $id_catalogue, $id_category, $ini);
                cout('<div class="course">' . '<div class="course_info">' . '<h3 class="course_title"><img src="' . getPathImage() . '/language/' . strtolower($course_info['lang_code']) . '.png" alt="" title="" /> ' . $course_info['name'] . '</h3>' . '<p class="course_description">' . $course_info['description'] . '</p>' . '</div>' . '<div class="course_action">' . $action . '</div>' . '</div>');
            }
        }
        cout('</div>');
    } else {
        //Course in catalogue visualization
        $courses = $man_cat->getCourseForBlock($array_id_block[0], $limit, $id_catalogue, $id_category, $all_course);
        foreach ($courses as $course_info) {
            $action = $this->controlCourse($course_info, $page, $id_catalogue, $id_category, $ini);
            cout('<div class="course">' . '<div class="course_info">' . '<h3 class="course_title"><img src="' . getPathImage() . '/language/' . strtolower($course_info['lang_code']) . '.png" alt="" title="" /> ' . $course_info['name'] . '</h3>' . '<p class="course_description">' . $course_info['description'] . '</p>' . '</div>' . '<div class="course_action">' . $action . '</div>' . '</div>');
        }
    }
    cout('</div>' . '</div>' . $nav_bar->getNavBar() . '</div>');
}
Ejemplo n.º 6
0
 function subscribeUserWithCode($code, $id_user, $level = 3)
 {
     require_once $GLOBALS['where_lms'] . '/lib/lib.subscribe.php';
     $subscriber = new CourseSubscribe_Management();
     $acl_man =& Docebo::user()->getAclManager();
     $query_course = "SELECT idCourse" . " FROM " . $GLOBALS['prefix_lms'] . "_course" . " WHERE autoregistration_code = '" . $code . "'" . " AND autoregistration_code <> ''";
     $result_course = sql_query($query_course);
     $query_course_active = "SELECT idCourse" . " FROM " . $GLOBALS['prefix_lms'] . "_course" . " WHERE autoregistration_code = '" . $code . "'" . " AND autoregistration_code <> ''" . " AND (                       \r\n                            (can_subscribe=2 AND (sub_end_date = '0000-00-00' OR sub_end_date >= '" . date('Y-m-d') . "') AND (sub_start_date = '0000-00-00' OR '" . date('Y-m-d') . "' >= sub_start_date)) OR\r\n                            (can_subscribe=1)\r\n                         ) ";
     $result_course_active = sql_query($query_course_active);
     $counter = 0;
     $subs = $this->getUserSubscriptionsInfo($id_user);
     if (!mysql_num_rows($result_course)) {
         return 0;
     }
     // return -2 if course subscription is not allowed
     if (!mysql_num_rows($result_course_active)) {
         return -2;
     }
     while (list($id_course) = sql_fetch_row($result_course)) {
         if (!isset($subs[$id_course])) {
             $result = $subscriber->subscribeUser($id_user, $id_course, $level);
             if ($result) {
                 $counter++;
             }
         }
     }
     if (mysql_num_rows($result_course) != 0 && $counter == 0) {
         return -1;
     }
     return $counter;
 }
Ejemplo n.º 7
0
 function confirmRegister($platform, $options)
 {
     $lang =& DoceboLanguage::createInstance('register', $platform);
     $acl_man =& Docebo::user()->getAclManager();
     $acl =& Docebo::user()->getAcl();
     if (!isset($_GET['random_code'])) {
     }
     $random_code = $_GET['random_code'];
     if (strpos($random_code, '?') !== false) {
         $random_code = substr($random_code, 0, strpos($random_code, '?'));
     }
     $request = $acl_man->getTempUserInfo(false, $random_code);
     if (time() > fromDatetimeToTimestamp($request['request_on']) + 3600 * (int) $options['hour_request_limit']) {
         $out = '<div class="reg_err_data">' . $lang->def('_REG_ELAPSEDREQUEST', 'register') . '</div>';
         $time_limit = time() - 3600 * (int) $options['hour_request_limit'];
         if (Get::sett('registration_code_type', '0') == 'code_module') {
             // free the code from the old association
             require_once _adm_ . '/lib/lib.code.php';
             $code_manager = new CodeManager();
             $code_manager->resetUserAssociation($code, $request['idst']);
         }
         $acl_man->deleteTempUser(false, false, $time_limit, true);
         return $out;
     }
     if ($options['register_type'] == 'self' || $options['register_type'] == 'self_optin') {
         if ($acl_man->registerUser(addslashes($request['userid']), addslashes($request['firstname']), addslashes($request['lastname']), $request['pass'], addslashes($request['email']), '', '', true, $request['idst'], '', '', $request['facebook_id'], $request['twitter_id'], $request['linkedin_id'], $request['google_id'])) {
             // $google_id
             // remove temporary enter
             $acl_man->deleteTempUser($request['idst'], false, false, false);
             $acl_man->updateUser($request['idst'], FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, date("Y-m-d H:i:s"));
             // subscribe to base group
             $idst_usergroup = $acl_man->getGroup(false, ADMIN_GROUP_USER);
             $idst_usergroup = $idst_usergroup[ACL_INFO_IDST];
             $idst_oc = $acl_man->getGroup(false, '/oc_0');
             $idst_oc = $idst_oc[ACL_INFO_IDST];
             $idst_ocd = $acl_man->getGroup(false, '/ocd_0');
             $idst_ocd = $idst_ocd[ACL_INFO_IDST];
             $acl_man->addToGroup($idst_usergroup, $request['idst']);
             $acl_man->addToGroup($idst_oc, $request['idst']);
             $acl_man->addToGroup($idst_ocd, $request['idst']);
             //  aggiunta notifica UserNewWaiting
             require_once _base_ . "/lib/lib.eventmanager.php";
             // set as recipients all who can approve a waiting user
             $msg_c_new = new EventMessageComposer();
             $msg_c_new->setSubjectLangText('email', '_TO_NEW_USER_SBJ', false);
             $msg_c_new->setBodyLangText('email', '_TO_NEW_USER_TEXT', array('[url]' => Get::sett('url')));
             $msg_c_new->setBodyLangText('sms', '_TO_NEW_USER_TEXT_SMS', array('[url]' => Get::sett('url')));
             $idst_approve = $acl->getRoleST('/framework/admin/directory/approve_waiting_user');
             $recipients = $acl_man->getAllRoleMembers($idst_approve);
             if (!empty($recipients)) {
                 createNewAlert('UserNewWaiting', 'directory', 'edit', '1', 'User waiting for approvation', $recipients, $msg_c_new);
             }
             // end
             $out = '<div class="reg_success">' . $lang->def('_REG_YOUR_ABI_TO_ACCESS', 'register') . '</div>';
             return $out;
         } else {
             $out = '<div class="reg_err_data">' . $lang->def('_REG_CONFIRM_FAILED', 'register') . '</div>';
             return $out;
         }
     } elseif ($options['register_type'] == 'moderate') {
         if ($acl_man->confirmTempUser($request['idst'])) {
             if (Get::sett('use_code_module') == 'on') {
                 require_once $GLOBALS['where_framework'] . '/lib/lib.code.php';
                 $code_manager = new CodeManager();
                 $code = $code_manager->getCodeAssociate($request['idst']);
                 if ($code !== false) {
                     $array_course = $code_manager->getCourseAssociateWithCode($code);
                     $array_folder = $code_manager->getOrgAssociateWithCode($code);
                     if (count($array_course)) {
                         foreach ($array_course as $id_course) {
                             require_once $GLOBALS['where_lms'] . '/lib/lib.subscribe.php';
                             $subscribe = new CourseSubscribe_Management();
                             $subscribe->subscribeUser($request['idst'], $id_course, '3');
                         }
                     }
                     if (count($array_folder)) {
                         foreach ($array_folder as $id_folder) {
                             $group = $acl_man->getGroup($id_folder, false);
                             $group_d = $acl_man->getGroup(false, '/ocd_' . str_replace('/oc_', '', $group[ACL_INFO_GROUPID]));
                             if ($group) {
                                 $acl_man->addToGroup($group[ACL_INFO_IDST], $request['idst']);
                             }
                             if ($group_d) {
                                 $acl_man->addToGroup($group_d[ACL_INFO_IDST], $request['idst']);
                             }
                         }
                     }
                 }
             }
             $out = '<div class="reg_success">' . Lang::t('_REG_WAIT_FOR_ADMIN_OK', 'register') . '</div>';
             // send alert to admin that can approve
             require_once _base_ . "/lib/lib.eventmanager.php";
             // set as recipients all who can approve a waiting user
             $msg_c_approve = new EventMessageComposer();
             $msg_c_approve->setSubjectLangText('email', '_TO_APPROVE_USER_SBJ', false);
             $msg_c_approve->setBodyLangText('email', '_TO_APPROVE_USER_TEXT', array('[url]' => Get::sett('url')));
             $msg_c_approve->setBodyLangText('sms', '_TO_APPROVE_USER_TEXT_SMS', array('[url]' => Get::sett('url')));
             $idst_approve = $acl->getRoleST('/framework/admin/directory/approve_waiting_user');
             $recipients = $acl_man->getAllRoleMembers($idst_approve);
             if (!empty($recipients)) {
                 createNewAlert('UserNewModerated', 'directory', 'edit', '1', 'User waiting for approvation', $recipients, $msg_c_approve);
             }
             return $out;
         } else {
             $out = '<div class="reg_err_data">' . $lang->def('_REG_CONFIRM_FAILED', 'register') . '</div>';
             return $out;
         }
     }
 }
Ejemplo n.º 8
0
function preAssessmentDispatch($op)
{
    Util::get_js(Get::rel_path('lms') . '/admin/modules/preassessment/ajax.preassessment.js', true, true);
    require_once _base_ . '/lib/lib.urlmanager.php';
    $url =& UrlManager::getInstance();
    $url->setStdQuery('modname=preassessment&op=assesmentlist');
    if (isset($_POST['undo'])) {
        $op = 'assesmentlist';
    }
    if (isset($_POST['cancelselector'])) {
        $op = 'assesmentlist';
    }
    switch ($op) {
        case "assesmentlist":
            assesmentlist($url);
            break;
        case "modassessment":
            modassessment($url);
            break;
        case "delassessment":
            delassessment($url);
            break;
            // user management ----------------------------------------
        // user management ----------------------------------------
        case "modassessuser":
            modassessuser($url);
            break;
        case "modassessadmin":
            modassessadmin($url);
            break;
            // manage management --------------------------------------
        // manage management --------------------------------------
        case "manageassessment":
            checkPerm('mod');
            $id_assessment = importVar('id_assess', true, 0);
            require_once $GLOBALS['where_lms'] . '/lib/lib.preassessment.php';
            $assess_man = new AssessmentList();
            if (!$assess_man->addAssessmentUser($id_assessment, USER_ASSES_TYPE_ADMIN, array(getLogUserId()))) {
                Util::jump_to($url->getUrl('result=error_assign'));
            } else {
                require_once $GLOBALS['where_lms'] . '/lib/lib.subscribe.php';
                $subs_man = new CourseSubscribe_Management();
                $subs_man->multipleUserSubscribe(getLogUserId(), array($id_assessment), 6);
                Docebo::user()->loadUserSectionST();
                Docebo::user()->SaveInSession();
                Util::jump_to($GLOBALS['where_lms_relative'] . '/index.php?modname=course&op=aula&idCourse=' . $id_assessment . '&from_admin=1');
            }
            break;
            // rule management ----------------------------------------
        // rule management ----------------------------------------
        case "modrule":
            modrule($url);
            break;
        case "assignrule":
            assignrule($url);
            break;
        case "saverule":
            saverule($url);
            break;
        case "delrule":
            delrule($url);
            break;
    }
}
Ejemplo n.º 9
0
 function addsubscriptionedition()
 {
     require_once _lms_ . '/lib/lib.subscribe.php';
     require_once _lms_ . '/lib/lib.coursepath.php';
     $cpath_man = new CoursePath_Manager();
     $subs_man = new CourseSubscribe_Management();
     $id_path = Get::req('id_path', DOTY_INT, 0);
     $user_selected = unserialize(urldecode(Get::req('users', DOTY_MIXED, array())));
     $courses = $cpath_man->getAllCourses(array($id_path));
     if (isset($_POST['undo']) || !isset($_POST['save'])) {
         Util::jump_to('index.php?modname=coursepath&amp;op=addsubscription&amp;id_path=' . $id_path);
     }
     $re = true;
     $query_pathlist = "\r\n\tSELECT path_name, subscribe_method\r\n\tFROM " . $GLOBALS['prefix_lms'] . "_coursepath\r\n\tWHERE id_path = '" . $id_path . "'\r\n\tORDER BY path_name ";
     list($path_name, $subscribe_method) = sql_fetch_row(sql_query($query_pathlist));
     if ($subscribe_method != 1 && !checkPerm('moderate', true)) {
         $waiting = 1;
     } else {
         $waiting = 0;
     }
     $users_subsc = array();
     $course_man = new Man_Course();
     $assessment = $course_man->getAllCourses(false, 'assessment', $courses);
     $classroom = $course_man->getAllCourses(false, 'classroom', $courses);
     $edition = $course_man->getAllCourses(false, 'edition', $courses);
     $array_id_date = array();
     $array_id_edition = array();
     if (!empty($classroom)) {
         foreach ($classroom as $id_course => $info) {
             if (Get::req('classroom_' . $id_course, DOTY_INT, 0) != 0) {
                 $array_id_date[Get::req('classroom_' . $id_course, DOTY_INT, 0)] = Get::req('classroom_' . $id_course, DOTY_INT, 0);
             }
         }
     }
     if (!empty($edition)) {
         foreach ($edition as $id_course => $info) {
             if (Get::req('edition_' . $id_course, DOTY_INT, 0) != 0) {
                 $array_id_edition[Get::req('edition_' . $id_course, DOTY_INT, 0)] = Get::req('edition_' . $id_course, DOTY_INT, 0);
             }
         }
     }
     require_once _lms_ . '/lib/lib.date.php';
     $date_man = new DateManager();
     require_once _lms_ . '/lib/lib.edition.php';
     $edition_man = new EditionManager();
     while (list(, $id_user) = each($user_selected)) {
         $text_query = "\r\n\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_coursepath_user\r\n\t\t( id_path, idUser, waiting, subscribed_by ) VALUES\r\n\t\t( '" . $id_path . "', '" . $id_user . "', '" . $waiting . "', '" . getLogUserId() . "' )";
         $re_s = sql_query($text_query);
         if ($re_s == true) {
             $users_subsc[] = $id_user;
         }
         $re &= $re_s;
         if (!empty($assessment)) {
             foreach ($assessment as $id_assessment => $assessment_info) {
                 sql_query("INSERT INTO %lms_assessment_user (id_assessment, id_user, type_of) VALUES ('" . $id_assessment . "', '" . $id_user . "', 'user')");
             }
             reset($assessment);
         }
         if (!empty($array_id_date)) {
             foreach ($array_id_date as $id_date) {
                 $date_man->addUserToDate($id_date, $id_user, Docebo::user()->getIdSt());
             }
             reset($array_id_date);
         }
         if (!empty($array_id_edition)) {
             foreach ($array_id_edition as $id_edition) {
                 $edition_man->addUserToEdition($id_edition, $id_user, Docebo::user()->getIdSt());
             }
             reset($array_id_edition);
         }
     }
     // now subscribe user to all the course
     if ($waiting == 0) {
         $re &= $subs_man->multipleSubscribe($users_subsc, $courses, 3);
     }
     Util::jump_to('index.php?modname=coursepath&amp;op=pathlist&result=' . ($re ? 'ok' : 'err'));
 }
Ejemplo n.º 10
0
 public function subscribeToCoursePath()
 {
     $id_path = Get::req('id_path', DOTY_INT, 0);
     $id_user = Docebo::user()->getIdSt();
     $query_pathlist = "\n\t\tSELECT path_name, subscribe_method\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_coursepath\n\t\tWHERE id_path = '" . $id_path . "'\n\t\tORDER BY path_name ";
     list($path_name, $subscribe_method) = sql_fetch_row(sql_query($query_pathlist));
     if ($subscribe_method == 1) {
         $waiting = 1;
     } else {
         $waiting = 0;
     }
     $text_query = "\n\t\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_coursepath_user\n\t\t\t( id_path, idUser, waiting, subscribed_by ) VALUES\n\t\t\t( '" . $id_path . "', '" . $id_user . "', '" . $waiting . "', '" . getLogUserId() . "' )";
     $re_s = sql_query($text_query);
     /////////////////////////
     if ($waiting == 0) {
         require_once _lms_ . '/lib/lib.subscribe.php';
         require_once _lms_ . '/lib/lib.coursepath.php';
         $cpath_man = new CoursePath_Manager();
         $subs_man = new CourseSubscribe_Management();
         $id_path = Get::req('id_path', DOTY_INT, 0);
         $user_selected = unserialize(urldecode(Get::req('users', DOTY_MIXED, array())));
         $courses = $cpath_man->getAllCourses(array($id_path));
         $users_subsc = array($id_user);
         $re &= $subs_man->multipleSubscribe($users_subsc, $courses, 3);
     }
     /*
     		qui non posso intervenire, si devono scegliere gli assesment e le edizioni... da admin ci sono form
     		$course_man = new Man_Course();
     		$assessment = $course_man->getAllCourses(false, 'assessment', $courses);
     		$classroom = $course_man->getAllCourses(false, 'classroom', $courses);
     		$edition = $course_man->getAllCourses(false, 'edition', $courses);
     		if(!empty($assessment))
     		{
     			foreach($assessment as $id_assessment => $assessment_info)
     				sql_query("INSERT INTO %lms_assessment_user (id_assessment, id_user, type_of) VALUES ('".$id_assessment."', '".$id_user."', 'user')");
     			reset($assessment);
     		}
     		if(!empty($array_id_date))
     		{
     			foreach($array_id_date as $id_date)
     				$date_man->addUserToDate($id_date, $id_user, Docebo::user()->getIdSt());
     			reset($array_id_date);
     		}
     		if(!empty($array_id_edition))
     		{
     			foreach($array_id_edition as $id_edition)
     				$edition_man->addUserToEdition($id_edition, $id_user, Docebo::user()->getIdSt());
     			reset($array_id_edition);
     		}
     */
     $res['success'] = true;
     if ($waiting == 1) {
         $res['new_status'] = '<p class="cannot_subscribe">' . Lang::t('_WAITING', 'catalogue') . '</p>';
     } else {
         $res['new_status'] = '<p class="cannot_subscribe">' . Lang::t('_USER_STATUS_SUBS', 'catalogue') . '</p>';
     }
     $res['message'] = $res['message'] = UIFeedback::info(Lang::t('_SUBSCRIPTION_CORRECT', 'catalogue'), true);
     echo $this->json->encode($res);
 }
function subscribe()
{
    checkPerm('view');
    require_once _base_ . '/lib/lib.form.php';
    $form = new Form();
    if (isset($_POST['course_autoregistration_code'])) {
        require_once _lms_ . '/lib/lib.course.php';
        $out =& $GLOBALS['page'];
        $out->setWorkingZone('content');
        $code = $_POST['course_autoregistration_code'];
        $code = strtoupper($code);
        $code = str_replace('-', '', $code);
        $registration_code_type = Get::sett('registration_code_type', '0');
        if ($registration_code_type == 'tree_course') {
            $code = substr($code, 10, 10);
        }
        $course_registration_result = false;
        $man_course_user = new Man_CourseUser();
        $course_registration_result = $man_course_user->subscribeUserWithCode($code, getLogUserId());
        $out->add(getTitleArea(Lang::t('_AUTOREGISTRATION', 'course_autoregistration')) . '<div class="std_block">');
        if ($course_registration_result > 0) {
            $out->add(str_replace('[course_added]', $course_registration_result, Lang::t('_OPERATION_SUCCESSFUL', 'course_autoregistration')));
            $out->add('<br/><a href="index.php?r=' . _after_login_ . '">' . Lang::t('_BACK_TO_COURSE', 'course_autoregistration') . '</a>');
        } else {
            if ($course_registration_result == -1) {
                $out->add(getErrorUi(Lang::t('_CODE_ALREDY_USED', 'course_autoregistration')));
                $out->add($form->openForm('course_autoregistration', 'index.php?modname=course_autoregistration&amp;op=course_autoregistration') . $form->openElementSpace() . $form->getTextfield(Lang::t('_COURSE_AUTOREGISTRATION_CODE', 'course_autoregistration'), 'course_autoregistration_code', 'course_autoregistration_code', '255', '') . $form->closeElementSpace() . $form->openButtonSpace() . $form->getButton('subscribe', 'subscribe', Lang::t('_SEND', 'course_autoregistration')) . $form->closeButtonSpace());
            } else {
                if ($course_registration_result == -2) {
                    $out->add(getErrorUi(Lang::t('_SUBSCRIPTION_NOT_ALLOWED_YET', 'course_autoregistration')));
                    $out->add($form->openForm('course_autoregistration', 'index.php?modname=course_autoregistration&amp;op=course_autoregistration') . $form->openElementSpace() . $form->getTextfield(Lang::t('_COURSE_AUTOREGISTRATION_CODE', 'course_autoregistration'), 'course_autoregistration_code', 'course_autoregistration_code', '255', '') . $form->closeElementSpace() . $form->openButtonSpace() . $form->getButton('subscribe', 'subscribe', Lang::t('_SEND', 'course_autoregistration')) . $form->closeButtonSpace());
                } else {
                    require_once _adm_ . '/lib/lib.code.php';
                    $code = $_POST['course_autoregistration_code'];
                    $code_manager = new CodeManager();
                    $valid_code = $code_manager->controlCodeValidity($code);
                    if ($valid_code == 1) {
                        $array_course = $code_manager->getAvailableCourseAssociateWithCode($code);
                        require_once _lms_ . '/lib/lib.course.php';
                        $man_course = new Man_Course();
                        $array_course_name = array();
                        $counter = 0;
                        require_once _lms_ . '/lib/lib.subscribe.php';
                        $subscribe = new CourseSubscribe_Management();
                        foreach ($array_course as $id_course) {
                            $query_control = "SELECT COUNT(*)" . " FROM %lms_courseuser" . " WHERE idCourse = " . $id_course . " AND idUser = "******"index.php?r=' . _after_login_ . '">' . Lang::t('_BACK_TO_COURSE', 'course_autoregistration') . '</a>');
                        } else {
                            if (sizeof($array_course) == 0) {
                                $out->add(getErrorUi(Lang::t('_SUBSCRIPTION_NOT_ALLOWED_YET', 'course_autoregistration')));
                            } else {
                                $out->add(getErrorUi(Lang::t('_ALREADY_SUBSCRIBED', 'course_autoregistration')));
                            }
                            $out->add($form->openForm('course_autoregistration', 'index.php?modname=course_autoregistration&amp;op=course_autoregistration') . $form->openElementSpace() . $form->getTextfield(Lang::t('_COURSE_AUTOREGISTRATION_CODE', 'course_autoregistration'), 'course_autoregistration_code', 'course_autoregistration_code', '255', '') . $form->closeElementSpace() . $form->openButtonSpace() . $form->getButton('subscribe', 'subscribe', Lang::t('_SEND', 'course_autoregistration')) . $form->closeButtonSpace());
                        }
                    } else {
                        if ($valid_code == 0) {
                            $out->add(getErrorUi(Lang::t('_CODE_ALREDY_USED', 'course_autoregistration')));
                        } else {
                            $out->add(getErrorUi(Lang::t('_CODE_NOT_VALID', 'course_autoregistration')));
                        }
                        $out->add($form->openForm('course_autoregistration', 'index.php?modname=course_autoregistration&amp;op=course_autoregistration') . $form->openElementSpace() . $form->getTextfield(Lang::t('_COURSE_AUTOREGISTRATION_CODE', 'course_autoregistration'), 'course_autoregistration_code', 'course_autoregistration_code', '255', '') . $form->closeElementSpace() . $form->openButtonSpace() . $form->getButton('subscribe', 'subscribe', Lang::t('_SEND', 'course_autoregistration')) . $form->closeButtonSpace());
                    }
                }
            }
        }
        $out->add('</div>');
    }
}