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);
 }
 public function changepwd_actionTask()
 {
     //check permissions
     if (!$this->permissions['mod_user']) {
         $output = array('success' => false, 'message' => $this->_getErrorMessage('no permission'));
         echo $this->json->encode($output);
         return;
     }
     if (Get::cfg('demo_mode')) {
         $output['success'] = false;
         $output['message'] = UIFeedback::perror('Cannot mod password during demo mode.');
         echo $this->json->encode($output);
         return;
     }
     $userid = Get::req('userid', DOTY_STRING, '');
     $idst = Get::req('idst', DOTY_INT, 0);
     $new_password = Get::req('new_password', DOTY_STRING, '');
     $confirm_password = Get::req('confirm_password', DOTY_STRING, '');
     $force_changepwd = Get::req('force_changepwd', DOTY_INT, 0);
     $output = array();
     $acl_man = Docebo::user()->getAclManager();
     if ($new_password == "" || $confirm_password == "") {
         $output['success'] = false;
         $output['message'] = UIFeedback::perror(Lang::t('_REG_PASS_MIN_CHAR', 'register', array('[min_char]' => 1)));
         echo $this->json->encode($output);
         return;
     }
     if ($new_password != $confirm_password) {
         $output['success'] = false;
         $output['message'] = UIFeedback::perror(Lang::t('_ERR_PASSWORD_NO_MATCH', 'register'));
         echo $this->json->encode($output);
         return;
     }
     if ($idst <= 0) {
         if ($userid == "") {
             $output['success'] = false;
             $output['message'] = UIFeedback::perror(Lang::t('_ERR_INVALID_USER', 'register'));
             echo $this->json->encode($output);
             return;
         }
         $idst = $acl_man->getUserST($userid);
         if ($idst === false) {
             $output['success'] = false;
             $output['message'] = UIFeedback::perror(Lang::t('_ERR_INVALID_USER', 'register'));
             echo $this->json->encode($output);
             return;
         }
     } else {
         $_userid = $acl_man->getUserid($idst);
         if ($_userid != $userid) {
             $idst = $acl_man->getUserST($userid);
             if (!$idst) {
                 $output['success'] = false;
                 $output['message'] = UIFeedback::perror(Lang::t('_OPERATION_FAILURE', 'standard'));
                 echo $this->json->encode($output);
                 return;
             }
         }
     }
     $res = $this->model->changePassword($idst, $new_password, $force_changepwd);
     if ($res) {
         $output['success'] = true;
         $output['message'] = UIFeedback::pinfo(Lang::t('_OPERATION_SUCCESSFUL', 'standard'));
     } else {
         $output['success'] = false;
         $output['message'] = UIFeedback::perror(Lang::t('_OPERATION_FAILURE', 'standard') . ': <b>' . $userid . '</b>');
     }
     echo $this->json->encode($output);
 }