Example #1
0
function upstatus()
{
    funAccess('statuser', 'OP');
    if (!saveTrackStatusChange($_POST['idUser'], $_SESSION['idCourse'], $_POST['status'])) {
        UiFeedback::error(_OPERATION_FAILURE);
        return;
    }
    Util::jump_to('index.php?modname=stats&op=statuser');
}
 public function fast_subscribe_dialog_action()
 {
     require_once _lms_ . '/lib/lib.course.php';
     $man_course = new Man_Course();
     $acl_man = Docebo::user()->getAclManager();
     $id_user = Get::req('id_user', DOTY_INT, 0);
     $id_course = Get::Req('id_course', DOTY_INT, 0);
     $level = Get::Req('level', DOTY_INT, 3);
     //default: student level
     $userid = Get::req('userid', DOTY_STRING, "");
     $course = Get::req('course', DOTY_STRING, "");
     if ($course != "") {
         $course = trim(preg_replace('|^\\[([^\\]]*)\\][\\s]*|i', '', $course));
     }
     //eliminates che code from the course name
     $id_user = $acl_man->getUserST($userid);
     $id_course = $man_course->getCourseIdByName($course);
     //check if input is correct
     if ($id_user <= 0 || $id_course <= 0) {
         $output['success'] = false;
         $output['message'] = UiFeedback::perror(Lang::t('_INVALID_DATA', 'standard'));
         //'Invalid input. COURSE: '.$id_course.'; USER: '******'edition', DOTY_INT, 0);
     $classroom = Get::Req('classroom', DOTY_INT, 0);
     $cinfo = $man_course->getCourseInfo($id_course);
     if ($cinfo['course_edition'] > 0) {
         $classroom = 0;
     } else {
         $edition = 0;
     }
     if ($cinfo['course_type'] == 'classroom') {
         $edition = 0;
     }
     if ($cinfo['course_type'] == 'classroom' && $classroom <= 0) {
         $output['success'] = false;
         $output['message'] = UIFeedback::pnotice(Lang::t('_CLASSROOM', 'standard') . ': ' . Lang::t('_EMPTY_SELECTION', 'standard'));
         echo $this->json->encode($output);
         return;
     }
     $_model = new SubscriptionAlms($id_course, $edition > 0 ? $edition : false, $classroom > 0 ? $classroom : false);
     //check if user is already subscribed
     if ($_model->isUserSubscribed($id_user)) {
         $output['success'] = false;
         $output['message'] = UIFeedback::pnotice(Lang::t('_USER_ALREADY_SUBSCRIBED', 'course') . ': ' . $userid);
         echo $this->json->encode($output);
         return;
     }
     //subscribe user
     $res = $_model->subscribeUser($id_user, $level, false);
     if ($res) {
         $docebo_course = new DoceboCourse($id_course);
         $level_idst =& $docebo_course->getCourseLevel($id_course);
         if (count($level_idst) == 0 || $level_idst[1] == '') {
             $level_idst =& $docebo_course->createCourseLevel($id_course);
         }
         //$this->acl_man->addToGroup($level_idst[$level], $id_user);
         $this->_addToCourseGroup($level_idst[$level], $id_user);
     }
     $output['success'] = $res ? true : false;
     if (!$res) {
         $output['message'] = UIFeedback::perror(Lang::t('_ERROR_WHILE_SAVING', 'standard'));
     } else {
         $output['message'] = UIFeedback::pinfo(Lang::t('_GOTO_COURSE_T', 'course'));
     }
     echo $this->json->encode($output);
 }