public function getclassroomdates()
 {
     $startIndex = Get::req('startIndex', DOTY_INT, 0);
     $results = Get::req('results', DOTY_INT, Get::sett('visuItem', 25));
     $sort = Get::req('sort', DOTY_STRING, "");
     $dir = Get::req('dir', DOTY_STRING, "asc");
     $date = Get::req('date_range', DOTY_STRING, "");
     $filter = Get::Req('filter_Text', DOTY_STRING, "");
     $id_classroom = Get::req('id_classroom', DOTY_INT, 0);
     if ($date == "false") {
         $date = date("n-Y");
     }
     $date_list = $this->model->getClassroomDates2date($id_classroom, $date, $startIndex, $results, $sort, $dir, $filter);
     $date_list_total = $this->model->getClassroomDateTotalDate($id_classroom, $date);
     $output = array('totalRecords' => $date_list_total, 'startIndex' => $startIndex, 'sort' => $sort, 'dir' => $dir, 'rowsPerPage' => 25, 'results' => count($date_list), 'records' => !empty($date_list) ? array_values($date_list) : array());
     echo $this->json->encode($output);
 }
 public function sel_users_coursepath_actionTask()
 {
     $id_path = Get::Req('id_path', DOTY_INT, 0);
     if ($id_path <= 0) {
         //...
         return;
     }
     $selection = Get::req('userselector_input', DOTY_MIXED, true);
     $new_selection = $selection['coursepath_subscriptions'];
     $old_selection = $this->model->getCoursePathSubscriptionsList($id_path);
     $new_selection = explode(",", $new_selection);
     $new_selection = $this->acl_man->getAllUsersFromSelection($new_selection);
     $_common = array_intersect($new_selection, $old_selection);
     $_to_add = array_diff($new_selection, $_common);
     $_to_del = array_diff($old_selection, $_common);
     $res = true;
     if (!$res) {
         $result = 'err_subscribe';
     } else {
         $result = 'ok_subcribe';
     }
     require_once _lms_ . '/lib/lib.coursepath.php';
     $path_man = new CoursePath_Manager();
     //1 - get list of the courses of the coursepath
     $base_url = 'index.php?r=' . $this->link . '/show_coursepath&id_path=' . (int) $id_path;
     $courses = $path_man->getAllCourses(array($id_path));
     if (empty($courses)) {
         Util::jump_to($base_url);
     }
     //2 - check if there are any editions or classrooms
     require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
     $course_man = new Man_Course();
     $classroom = $course_man->getAllCourses(false, 'classroom', $courses);
     $edition = $course_man->getAllCourses(false, 'edition', $courses);
     //3 - if yes, then make a second step in order to choose editions and classrooms
     if (!empty($classroom) || !empty($edition)) {
         $classroom_list = array();
         if (!empty($classroom)) {
             require_once _lms_ . '/lib/lib.date.php';
             $date_man = new DateManager();
             foreach ($classroom as $id_course => $info) {
                 $classrooms = $date_man->getCourseDate($id_course, true);
                 $classrooms_for_dropdown = array();
                 $classrooms_for_dropdown[0] = Lang::t('_NO_CLASSROOM_SUBSCRIPTION', 'coursepath');
                 foreach ($classrooms as $classroom_info) {
                     $classrooms_for_dropdown[$classroom_info['id_date']] = $classroom_info['code'] . ' - ' . $classroom_info['name'] . ' - ' . Format::date($classroom_info['date_begin'], 'date') . ' - ' . Format::date($classroom_info['date_end'], 'date');
                 }
                 $classroom_list[] = array('id_course' => $id_course, 'label' => $info['name'], 'list' => $classrooms_for_dropdown);
                 //cout(Form::getDropdown(Lang::t('_EDITION_SELECTION', 'coursepath').' : '.$info['code'].' - '.$info['name'], 'classroom_'.$id_course, 'classroom_'.$id_course, $edition_for_dropdown));
             }
         }
         $edition_list = array();
         if (!empty($edition)) {
             require_once _lms_ . '/lib/lib.edition.php';
             $edition_man = new EditionManager();
             foreach ($edition as $id_course => $info) {
                 $editions = $edition_man->getEditionsInfoByCourses($id_course);
                 $editions_for_dropdown = array();
                 $editions_for_dropdown[0] = Lang::t('_NONE', 'coursepath');
                 foreach ($editions[$id_course] as $edition_info) {
                     $editions_for_dropdown[$edition_info['id_edition']] = $edition_info['code'] . ' - ' . $edition_info['name'] . ' - ' . Format::date($edition_info['date_begin'], 'date') . ' - ' . Format::date($edition_info['date_end'], 'date');
                 }
                 $edition_list[] = array('id_course' => $id_course, 'label' => $info['name'], 'list' => $edition_for_dropdown);
                 //cout(Form::getDropdown(Lang::t('_EDITION_SELECTION', 'coursepath').' : '.$info['code'].' - '.$info['name'], 'edition_'.$id_course, 'edition_'.$id_course, $edition_for_dropdown));
             }
         }
         $this->render('choose_editions_coursepath', array('id_path' => $id_path, 'courses_list' => $courses, 'editions_list' => $edition_list, 'classrooms_list' => $classroom_list, 'users_to_add' => $_to_add, 'users_to_del' => $_to_del, 'path_name' => $this->model->getCoursepathNameForSubscription($id_path)));
     } else {
         $path_man->subscribeUserToCoursePath($id_path, $_to_add);
         require_once _lms_ . '/lib/lib.course.php';
         foreach ($courses as $id_course) {
             $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);
             }
             foreach ($_to_add as $id_user) {
                 $level = 3;
                 //student
                 $waiting = false;
                 //$this->acl_man->addToGroup($level_idst[$level], $id_user);
                 $this->_addToCourseGroup($level_idst[$level], $id_user);
                 $this->model->id_course = $id_course;
                 $this->model->subscribeUser($id_user, $level, $waiting);
             }
         }
         Util::jump_to('index.php?r=' . $this->link . '/show_coursepath&id_path=' . (int) $id_path . '&res=' . $result);
     }
 }
 public function competences_autocompleteTask()
 {
     $query = Get::req('query', DOTY_STRING, '');
     $results = Get::Req('results', DOTY_INT, Get::sett('visuItem', 25));
     $output = array('competences' => array());
     if ($query != "") {
         $competences = $this->model->searchCompetencesByName($query, $results, true);
         foreach ($competences as $competence) {
             $output['competences'][] = array('id_competence' => $competence->id_competence, 'name' => $competence->name, 'name_highlight' => Layout::highlight($competence->name, $query), 'type' => $competence->type, 'typology' => $competence->typology);
         }
     }
     echo $this->json->encode($output);
 }
 public function delete_waitingTask()
 {
     //check permissions
     if (!$this->permissions['approve_waiting_user']) {
         $output = array('success' => false, 'message' => $this->_getErrorMessage('no permission'));
         echo $this->json->encode($output);
         return;
     }
     $arr_users = array();
     $id_user = Get::req('id_user', DOTY_INT, -1);
     if ($id_user > 0) {
         $arr_users = array($id_user);
     } else {
         $str_users = trim(Get::Req('users', DOTY_STRING, ""));
         $arr_users = $str_users != "" ? explode(",", $str_users) : array();
     }
     $output = array();
     if (!is_array($arr_users) || empty($arr_users)) {
         $output['success'] = false;
         $output['message'] = UIFeedback::pnotice(Lang::t('_NO_USERS_SPECIFIED', 'admin_directory'));
         echo $this->json->encode($output);
         return;
     }
     $res = $this->model->deleteWaitingUsers($arr_users);
     if ($res) {
         $output['success'] = true;
     } else {
         $output['success'] = false;
         $output['message'] = UIFeedback::perror(Lang::t('_OPERATION_FAILURE', 'standard'));
     }
     echo $this->json->encode($output);
 }
 public function gettreedataTask()
 {
     $command = Get::req('command', DOTY_ALPHANUM, "");
     switch ($command) {
         case "expand":
             $node_id = Get::req('node_id', DOTY_INT, 0);
             $initial = Get::req('initial', DOTY_INT, 0) > 0 ? true : false;
             if ($initial) {
                 //get selected category from session and set the expanded tree
                 $node_id = $this->_getSessionValue('selected_node', 0);
                 $nodes = $this->model->getInitialCategories($node_id, false);
                 //set nodes action recursively
                 $this->_assignActions($nodes);
                 //set output
                 if (is_array($nodes)) {
                     $output = array('success' => true, 'nodes' => $nodes, 'initial' => $initial);
                 } else {
                     $output = array('success' => false);
                 }
             } else {
                 //extract node data
                 $nodes = $this->model->getCategories($node_id);
                 //if request is invalid, return error message ...
                 if (!is_array($nodes)) {
                     echo $this->json->encode(array('success' => false));
                     return;
                 }
                 //create actions for every node
                 for ($i = 0; $i < count($nodes); $i++) {
                     $nodes[$i]['options'] = $this->_getNodeActions($nodes[$i]);
                 }
                 //set output
                 $output = array('success' => true, 'nodes' => $nodes, 'initial' => $initial);
             }
             echo $this->json->encode($output);
             break;
         case "set_selected_node":
             $this->_setSessionValue('selected_node', Get::Req('node_id', DOTY_INT, 0));
             break;
         case "delete":
             //check permissions
             if (!$this->permissions['mod']) {
                 $output = array('success' => false, 'message' => $this->_getMessage('no permission'));
                 echo $this->json->encode($output);
                 return;
             }
             $output = array('success' => false);
             $id = Get::req('node_id', DOTY_INT, -1);
             if ($id > 0) {
                 $output['success'] = $this->model->deleteCategory($id);
             }
             echo $this->json->encode($output);
             break;
         case "movefolder":
             //check permissions
             if (!$this->permissions['mod']) {
                 $output = array('success' => false, 'message' => $this->_getMessage('no permission'));
                 echo $this->json->encode($output);
                 return;
             }
             $this->move_categoryTask();
             break;
     }
 }