public function gettimeperiodslistTask() { //read input data (table parameters and filter) $startIndex = Get::req('startIndex', DOTY_INT, 0); $results = Get::req('results', DOTY_INT, Get::sett('visuItem')); $rowsPerPage = Get::req('rowsPerPage', DOTY_INT, $results); $sort = Get::req('sort', DOTY_STRING, ""); $dir = Get::req('dir', DOTY_STRING, "asc"); $filter_text = Get::req('filter_text', DOTY_STRING, ''); $searchFilter = array('text' => $filter_text); //calculate total records to display $total = $this->model->getTimePeriodsTotal($searchFilter); if ($startIndex >= $total) { if ($total < $results) { $startIndex = 0; } else { $startIndex = $total - $results; } } //get records from DB and format data $list = $this->model->getTimePeriodsList($startIndex, $results, $sort, $dir, $searchFilter); $output_records = array(); if (is_array($list) && count($list) > 0) { foreach ($list as $record) { $output_records[] = array('id' => (int) $record->id_period, 'title' => Layout::highlight($record->title, $filter_text), 'label' => Layout::highlight($record->label, $filter_text), 'start_date' => Format::date($record->start_date, "date"), 'end_date' => Format::date($record->end_date, "date"), 'mod' => 'ajax.adm_server.php?r=alms/timeperiods/mod&id=' . (int) $record->id_period, 'del' => 'ajax.adm_server.php?r=alms/timeperiods/del&id=' . (int) $record->id_period); } } //prepare the output for the datatable $output = array('totalRecords' => $total, 'startIndex' => $startIndex, 'sort' => $sort, 'dir' => $dir, 'rowsPerPage' => $rowsPerPage, 'results' => count($output_records), 'records' => $output_records); echo $this->json->encode($output); }
public function getusertabledataTask() { $op = Get::req('op', DOTY_MIXED, false); switch ($op) { case "selectall": $this->_selectAllUsers(); return; break; } $idOrg = 0; //Get::req('id_org', DOTY_INT, 0); $descendants = false; //(Get::req('descendants', DOTY_INT, 0) > 0 ? true : false); $startIndex = Get::req('startIndex', DOTY_INT, 0); $results = Get::req('results', DOTY_INT, Get::sett('visuItem', 25)); $rowsPerPage = Get::req('rowsPerPage', DOTY_INT, $results); $sort = Get::req('sort', DOTY_STRING, ""); $dir = Get::req('dir', DOTY_STRING, "asc"); $learning_filter = Get::req('learning_filter', DOTY_STRING, 'none'); $var_fields = Get::req('_dyn_field', DOTY_MIXED, array()); if (stristr($sort, '_dyn_field_') !== false) { $index = str_replace('_dyn_field_', '', $sort); $sort = $var_fields[(int) $index]; } $filter_text = Get::req('filter_text', DOTY_STRING, ''); $searchFilter = array('text' => $filter_text, 'suspended' => Get::req('suspended', DOTY_INT, 1) > 0 ? true : false); $dyn_filter = $this->_getDynamicFilter(Get::req('dyn_filter', DOTY_STRING, '')); if ($dyn_filter !== false) { $searchFilter['dyn_filter'] = $dyn_filter; } $total = $this->user_model->getTotalUsers($idOrg, $descendants, $searchFilter, true, $learning_filter); if ($startIndex >= $total) { if ($total < $results) { $startIndex = 0; } else { $startIndex = $total - $results; } } $pagination = array('startIndex' => $startIndex, 'results' => $results, 'sort' => $sort, 'dir' => $dir); $list = $this->user_model->getUsersList($idOrg, $descendants, $pagination, $searchFilter, true, $learning_filter); //prepare the data for sending require_once _adm_ . '/lib/lib.field.php'; $fman = new FieldList(); $date_fields = $fman->getFieldsByType("date"); $acl_man = Docebo::user()->getAclManager(); $idst_org = $acl_man->getGroupST('/oc_' . (int) $idOrg); $output_results = array(); if (is_array($list) && count($list) > 0) { foreach ($list as $idst => $record) { $record_row = array('id' => (int) $record['idst'], 'userid' => Layout::highlight($acl_man->relativeId($record['userid']), $filter_text), 'firstname' => Layout::highlight($record['firstname'], $filter_text), 'lastname' => Layout::highlight($record['lastname'], $filter_text), 'email' => Layout::highlight($record['email'], $filter_text), 'register_date' => Format::date($record['register_date'], "datetime"), 'lastenter' => Format::date($record['lastenter'], "datetime"), 'unassoc' => $idOrg > 0 ? $record['is_descendant'] ? 0 : 1 : -1, 'valid' => $record['valid'], 'mod' => 'ajax.adm_server.php?r=adm/usermanagement/moduser&id=' . (int) $idst, 'del' => 'ajax.adm_server.php?r=adm/usermanagement/deluser&id=' . (int) $idst); foreach ($var_fields as $i => $value) { if (is_numeric($value)) { $name = '_custom_' . $value; } else { $name = $value; } //check if we must perform some post-format on retrieved field values $content = isset($record[$name]) ? $record[$name] : ''; if ($name == 'register_date') { $content = Format::date($content, 'datetime'); } if ($name == 'lastenter') { $content = Format::date($content, 'datetime'); } if ($name == 'level' && $content != '') { $content = Lang::t('_DIRECTORY_' . $content, 'admin_directory'); } if (!empty($date_fields) && in_array($value, $date_fields)) { $content = Format::date(substr($content, 0, 10), 'date'); } $record_row['_dyn_field_' . $i] = $content; } $output_results[] = $record_row; } } $output = array('totalRecords' => $total, 'startIndex' => $startIndex, 'sort' => $sort, 'dir' => $dir, 'rowsPerPage' => $rowsPerPage, 'results' => count($output_results), 'records' => $output_results); echo $this->json->encode($output); }
require_once _lms_ . '/lib/lib.edition.php'; require_once _lms_ . '/lib/lib.date.php'; require_once _base_ . '/lib/lib.json.php'; $ed_man = new EditionManager(); $dt_man = new DateManager(); $json = new Services_JSON(); $output = array('courses' => array()); $filter = Get::req('query', DOTY_STRING, ""); $results = Get::req('results', DOTY_INT, Get::sett('visuItem', 25)); if ($filter != "") { $query = "SELECT idCourse, code, name, course_type, course_edition FROM %lms_course " . " WHERE code LIKE '%" . $filter . "%' OR name LIKE '%" . $filter . "%' ORDER BY code, name " . ($results > 0 ? " LIMIT 0, " . (int) $results : ""); $res = sql_query($query); if ($res) { while (list($id_course, $code, $name, $course_type, $course_edition) = sql_fetch_row($res)) { //construct record for course instance $record = array('cname' => ($code != "" ? '[' . $code . '] ' : '') . $name, 'id_course' => $id_course, 'code' => $code, 'name' => $name, 'code_highlight' => Layout::highlight($code, $filter), 'name_highlight' => Layout::highlight($name, $filter)); //detect if the course is of type classroom or has editions //TO DO: optimization, do not put queries in iterations if ($course_type == 'elearning' && $course_edition > 0) { $record['has_editions'] = true; $_arr = array(); $_editions = $ed_man->getEdition($id_course); foreach ($_editions as $_edition) { $_arr[] = array('id' => $_edition['id_edition'], 'code' => $_edition['code'], 'name' => $_edition['name'], 'date_begin' => $_edition['date_begin'], 'date_end' => $_edition['date_end'], 'display_name' => '[' . $_edition['code'] . '] ' . $_edition['name'] . ' (' . Format::date($_edition['date_begin'], 'date') . ' - ' . Format::date($_edition['date_end'], 'date') . ')'); } $record['editions'] = $_arr; } if ($course_type == 'classroom') { $record['has_classrooms'] = true; $_arr = array(); $_dates = $dt_man->getCourseDate($id_course);
public function functionalroles_autocompleteTask() { $query = Get::req('query', DOTY_STRING, ''); $results = Get::req('results', DOTY_INT, Get::sett('visuItem', 25)); $output = array('fncroles' => array()); if ($query != "") { $fncroles = $this->model->searchFunctionalRolesByName($query, $results, false, true); foreach ($fncroles as $fncrole) { $output['fncroles'][] = array('id_fncrole' => $fncrole->id_fncrole, 'name' => $fncrole->name, 'name_highlight' => Layout::highlight($fncrole->name, $query)); } } echo $this->json->encode($output); }
public function gettabledataTask() { //read from input and prepare filter and pagination variables $startIndex = Get::req('startIndex', DOTY_INT, 0); $results = Get::req('results', DOTY_INT, Get::sett('visuItem', 25)); $rowsPerPage = Get::req('rowsPerPage', DOTY_INT, $results); $sort = Get::req('sort', DOTY_STRING, ""); $dir = Get::req('dir', DOTY_STRING, "asc"); $filter_text = Get::req('filter_text', DOTY_STRING, ''); $searchFilter = array('text' => $filter_text); //get total from database and validate the results count $total = $this->model->getQuestCategoriesTotal($searchFilter); if ($startIndex >= $total) { if ($total < $results) { $startIndex = 0; } else { $startIndex = $total - $rowsPerPage; } } //set pagination argument $pagination = array('startIndex' => $startIndex, 'results' => $rowsPerPage, 'sort' => $sort, 'dir' => $dir); //read records from database $list = $this->model->getQuestCategoriesList($pagination, $searchFilter); //prepare the data for sending $output_results = array(); if (is_array($list) && count($list) > 0) { //check if categories are used in any test or poll $id_list = array(); foreach ($list as $record) { $id_list[] = $record->idCategory; } $used_test_arr = $this->model->getUsedInTests($id_list); $used_poll_arr = $this->model->getUsedInPolls($id_list); foreach ($list as $record) { //format description field $description = strip_tags($record->description); if (strlen($description) > 100) { $description = substr($description, 0, 97) . '...'; } $used_test = isset($used_test_arr[$record->idCategory]) ? $used_test_arr[$record->idCategory] : 0; $used_poll = isset($used_poll_arr[$record->idCategory]) ? $used_poll_arr[$record->idCategory] : 0; $can_mod = $this->permissions['mod']; $can_del = $used_test <= 0 && $used_poll <= 0 && $this->permissions['del']; //prepare output record $output_results[] = array('id' => $record->idCategory, 'name' => Layout::highlight($record->name, $filter_text), 'description' => Layout::highlight($description, $filter_text), 'used_test' => (int) $used_test, 'used_poll' => (int) $used_poll, 'mod' => $can_mod ? 'ajax.adm_server.php?r=alms/questcategory/edit&id=' . (int) $record->idCategory : false, 'del' => $can_del ? 'ajax.adm_server.php?r=alms/questcategory/delete&id=' . (int) $record->idCategory : false); } } $output = array('totalRecords' => $total, 'startIndex' => $startIndex, 'sort' => $sort, 'dir' => $dir, 'rowsPerPage' => $rowsPerPage, 'results' => count($list), 'records' => $output_results); echo $this->json->encode($output); }
public function getAdmin() { //read input data $start_index = Get::req('startIndex', DOTY_INT, 0); $results = Get::req('results', DOTY_MIXED, Get::sett('visuItem', 25)); $sort = Get::req('sort', DOTY_MIXED, 'userid'); $dir = Get::req('dir', DOTY_MIXED, 'asc'); $filter_text = Get::req('filter_text', DOTY_STRING, $this->_getSessionValue('filter', "")); $this->_setSessionValue('filter', $filter_text); //retrieve records from model $total_group = $this->model->totalAdmin($filter_text); $array_group = $this->model->loadAdmin($start_index, $results, $sort, $dir, $filter_text); //extract admin info for data formatting $idst_list = $this->model->acl_man->getGroupMembers($this->model->idst_admin_group); $users_info = $this->model->preference->getMultipleAdminTree($idst_list); $courses_info = $this->model->preference->getMultipleAdminCourse($idst_list); $classlocations_info = $this->model->preference->getMultipleAdminClasslocation($idst_list); //format data retrieved from model $output_list = array(); foreach ($array_group as $value) { $id_user = $value['id_user']; $has_users = isset($users_info[$id_user]) && count($users_info[$id_user]) > 0; $has_courses = isset($courses_info[$id_user]) && (count($courses_info[$id_user]['course']) > 0 || count($courses_info[$id_user]['coursepath']) > 0 || count($courses_info[$id_user]['catalogue']) > 0 || count($courses_info[$id_user]['category']) > 0); $has_classlocations = isset($classlocations_info[$id_user]['classlocation']) && count($classlocations_info[$id_user]['classlocation']) > 0; $userid = $this->acl_man->relativeId($value['userid']); $output_list[] = array('id_user' => $id_user, 'userid' => Layout::highlight($userid, $filter_text), 'firstname' => Layout::highlight($value['firstname'], $filter_text), 'lastname' => Layout::highlight($value['lastname'], $filter_text), 'idst_profile' => $value['idst_profile'], 'user_profile' => $value['user_profile'] ? str_replace('/framework/adminrules/', '', $value['user_profile']) : false, 'has_users' => $has_users ? 1 : 0, 'has_courses' => $has_courses ? 1 : 0, 'has_classlocations' => $has_classlocations ? 1 : 0); } //produce output for datatable $output = array('totalRecords' => $total_group, 'startIndex' => $start_index, 'sort' => $sort, 'dir' => $dir, 'rowsPerPage' => $results, 'results' => count($output_list), 'records' => $output_list); echo $this->json->encode($output); }
function get_report_table($url = '') { checkPerm('view'); $can_mod = checkPerm('mod', true); require_once _base_ . '/lib/lib.table.php'; require_once _base_ . '/lib/lib.form.php'; $acl_man =& Docebo::user()->getACLManager(); $level = Docebo::user()->getUserLevelId(Docebo::user()->getIdst()); $lang =& DoceboLanguage::createInstance('report'); $output = ''; $is_admin = $level == ADMIN_GROUP_GODADMIN || $level == ADMIN_GROUP_ADMIN ? true : false; if ($is_admin || $can_mod) { //if ($can_mod) { cout('<script type="text/javascript"> var _FAILURE = "error"; var ajax_path = "' . Get::rel_path('lms') . '/ajax.adm_server.php?mn=report&plf=lms"; function public_report(o, id_rep) { o.disabled=true; //no more operations allowed on the checkbox while ajaxing var val_el=document.getElementById("enable_value_"+id_rep); var value=val_el.value; var data = "&op=public_rep&id="+id_rep+"&val="+value; var objAjax = YAHOO.util.Connect.asyncRequest("POST", ajax_path+data, { success:function(t) { var temp=o.src; if (value==1) { o.src=temp.replace("unpublish.png", "publish.png"); val_el.value=0; } if (value==0) { o.src=temp.replace("publish.png", "unpublish.png"); val_el.value=1; } o.disabled=false; }, failure:function(t) { o.disabled=false; alert(_FAILURE); //... } }); } function setReportFilter() { var el = document.createElement("INPUT"); el.type = "hidden"; el.name = "search"; el.value = "1"; var form = YAHOO.util.Dom.get("report_searchbox_form"); if (form) { form.appendChild(el); form.submit(); } } </script>', 'page_head'); } //filter by author YuiLib::load(); $current_user = $acl_man->getUser(Docebo::user()->getIdst(), false); //dropdown data arrays $authors = array(0 => '(' . $lang->def('_ALL') . ')', $current_user[ACL_INFO_IDST] => $acl_man->relativeId($current_user[ACL_INFO_USERID])); $query = "SELECT u.idst, u.userid FROM %lms_report_filter as r JOIN %adm_user as u ON (r.author=u.idst) WHERE u.idst<>" . Docebo::user()->getIdst() . " ORDER BY u.userid"; $res = sql_query($query); while ($row = sql_fetch_assoc($res)) { $authors[$row['idst']] = $acl_man->relativeId($row['userid']); } $arr_report_types = array(0 => '(' . $lang->def('_ALL') . ')'); //initializa session variable for filters if (!isset($_SESSION['report_admin_filter'])) { $_SESSION['report_admin_filter'] = array('author' => 0, 'name' => '', 'type' => 0); } if (Get::req('search', DOTY_MIXED, false) !== false) { $_SESSION['report_admin_filter']['author'] = Get::req('filter_author', DOTY_INT, (int) $_SESSION['report_admin_filter']['author']); $_SESSION['report_admin_filter']['name'] = Get::req('filter_name', DOTY_STRING, $_SESSION['report_admin_filter']['name']); $_SESSION['report_admin_filter']['type'] = Get::req('filter_type', DOTY_INT, (int) $_SESSION['report_admin_filter']['type']); } if (Get::req('reset', DOTY_MIXED, false) !== false) { $_SESSION['report_admin_filter']['author'] = 0; $_SESSION['report_admin_filter']['name'] = ''; $_SESSION['report_admin_filter']['type'] = 0; } $dropdown_onclick = 'onchange="javascript:setReportFilter();"'; $output .= Form::openForm('report_searchbox_form', 'index.php?modname=report&op=reportlist&of_platform=lms', false, 'POST'); $output .= Form::getHidden('op', 'op', 'reportlist'); $output .= Form::getHidden('modname', 'modname', 'report'); $output .= '<div class="quick_search_form"> <div> <div class="simple_search_box" id="report_searchbox_simple_filter_options" style="display: block;">' . Form::getInputDropdown('dropdown', 'report_searchbox_filter_author', 'filter_author', $authors, $_SESSION['report_admin_filter']['author'], $dropdown_onclick) . " " . Form::getInputTextfield("search_t", "report_searchbox_filter_name", "filter_name", $_SESSION['report_admin_filter']['name'], '', 255, '') . Form::getButton("report_searchbox_filter_set", "search", Lang::t('_SEARCH', 'standard'), "search_b") . Form::getButton("report_searchbox_filter_reset", "reset", Lang::t('_RESET', 'standard'), "reset_b") . '</div> </div> </div>'; $output .= Form::closeForm(); //end filter //compose search query $qconds = array(); $query = "SELECT t1.*, t2.userid FROM %lms_report_filter as t1 LEFT JOIN %adm_user as t2 ON t1.author=t2.idst "; switch ($level) { case ADMIN_GROUP_GODADMIN: if ($_SESSION['report_admin_filter']['author'] > 0) { $qconds[] = " t1.author = " . $_SESSION['report_admin_filter']['author'] . " "; } break; case ADMIN_GROUP_ADMIN: case ADMIN_GROUP_PUBLICADMIN: case ADMIN_GROUP_USER: default: if ($_SESSION['report_admin_filter']['author'] > 0) { $qconds[] = " ( t1.author = " . $_SESSION['report_admin_filter']['author'] . " AND t1.is_public = 1 ) "; } else { $qconds[] = " ( t1.author = " . Docebo::user()->getIdst() . " OR t1.is_public = 1 ) "; } break; } if (trim($_SESSION['report_admin_filter']['name']) != "") { $qconds[] = " t1.filter_name LIKE '%" . $_SESSION['report_admin_filter']['name'] . "%' "; } if (trim($_SESSION['report_admin_filter']['type']) > 0) { //$qconds[] = " t1.filter_name LIKE '".$_SESSION['report_admin_filter']['name']."' "; } if (!empty($qconds)) { $query .= " WHERE " . implode(" AND ", $qconds); } //$_SESSION['report_admin_filter']['type'] //end query $tb = new Table(Get::sett('visu_course')); $tb->initNavBar('ini', 'button'); $col_type = array('', '', 'align_center', 'image', 'image', 'img-cell', 'img-cell', 'image'); //,'image','image'); $col_content = array($lang->def('_NAME'), $lang->def('_TAB_REP_CREATOR'), $lang->def('_CREATION_DATE'), $lang->def('_TAB_REP_PUBLIC'), '<img src="' . getPathImage() . 'standard/view.png" alt="' . $lang->def('_VIEW') . '" title="' . $lang->def('_VIEW') . '" />', '<span class="ico-sprite subs_csv"><span>' . Lang::t('_EXPORT_CSV', 'report') . '</span></span>', '<span class="ico-sprite subs_xls"><span>' . Lang::t('_EXPORT_XLS', 'report') . '</span></span>', '<img src="' . getPathImage() . 'standard/wait_alarm.png" alt="' . $lang->def('_SCHEDULE') . '" title="' . $lang->def('_SCHEDULE') . '" />'); if ($is_admin || $can_mod) { $col_type[] = 'image'; $col_type[] = 'image'; $col_content[] = '<img src="' . getPathImage() . 'standard/edit.png" alt="' . $lang->def('_MOD') . '" title="' . $lang->def('_MOD') . '" />'; $col_content[] = '<img src="' . getPathImage() . 'standard/delete.png" alt="' . $lang->def('_DEL') . '" title="' . $lang->def('_DEL') . '" />'; } $tb->setColsStyle($col_type); $tb->addHead($col_content); if ($res = sql_query($query)) { while ($row = sql_fetch_assoc($res)) { $id = $row['id_filter']; $opn_link = '<a href="index.php?modname=report&op=show_results&idrep=' . $id . '" ' . ' title="' . $lang->def('_VIEW') . '">' . '<img src="' . getPathImage() . 'standard/view.png" alt="' . $lang->def('_VIEW') . '" />' . '</a>'; $sch_link = '<a href="index.php?modname=report&op=schedulelist&idrep=' . $id . '" ' . ' title="' . $lang->def('_SCHEDULE') . '">' . '<img src="' . getPathImage() . 'standard/wait_alarm.png" alt="' . $lang->def('_SCHEDULE') . '" />' . '</a>'; $mod_link = '<a href="' . $url . '&action=modify&idrep=' . $id . '" ' . ' title="' . $lang->def('_MOD') . '">' . '<img src="' . getPathImage() . 'standard/edit.png" alt="' . $lang->def('_MOD') . '" />' . '</a>'; $rem_link = '<a href="' . $url . '&action=delete&idrep=' . $id . '" ' . ' title="' . $lang->def('_DEL') . ' : ' . ($row['author'] == 0 ? $lang->def($row['filter_name']) : $row['filter_name']) . '">' . '<img src="' . getPathImage() . 'standard/delete.png" alt="' . $lang->def('_DEL') . '" />'; //. '</a>'; $can_public = $can_mod ? true : ($is_admin && $row['author'] == Docebo::user()->getIdst() ? true : false); $public = '<image ' . ($can_public ? 'class="handover"' : '') . ' src="' . getPathImage('lms') . 'standard/' . ($row['is_public'] == 1 ? '' : 'un') . 'publish.png' . '" ' . ($is_admin || $can_mod ? 'onclick="public_report(this, ' . $row['id_filter'] . ');" ' : '') . ' />' . '<input type="hidden" id="enable_value_' . $row['id_filter'] . '" ' . 'value="' . ($row['is_public'] == 1 ? '0' : '1') . '" />'; $export_url = 'index.php?modname=report&op=show_results&idrep=' . (int) $id; $export_link_csv = '<a class="ico-sprite subs_csv" href="' . $export_url . '&dl=csv" title="' . Lang::t('_EXPORT_CSV', 'report') . '"><span></span>' . Lang::t('_EXPORT_CSV', 'report') . '</a>'; $export_link_xls = '<a class="ico-sprite subs_xls" href="' . $export_url . '&dl=xls" title="' . Lang::t('_EXPORT_XLS', 'report') . '"><span></span>' . Lang::t('_EXPORT_XLS', 'report') . '</a>'; $_name = $row['author'] == 0 ? $lang->def($row['filter_name']) : $row['filter_name']; if (trim($_SESSION['report_admin_filter']['name']) != "") { $_name = Layout::highlight($_name, $_SESSION['report_admin_filter']['name']); } $tb_content = array(_REP_KEY_NAME => $_name, _REP_KEY_CREATOR => $row['author'] == 0 ? '<div class="align_center">-</div>' : $acl_man->relativeId($row['userid']), _REP_KEY_CREATION => Format::date($row['creation_date']), _REP_KEY_PUBLIC => $public, _REP_KEY_OPEN => $opn_link, $export_link_csv, $export_link_xls, _REP_KEY_SCHED => $sch_link); if ($is_admin || $can_mod) { if ($row['author'] == Docebo::user()->getIdst() || $can_mod) { $tb_content[_REP_KEY_MOD] = $mod_link; $tb_content[_REP_KEY_REM] = $rem_link; } else { $tb_content[_REP_KEY_MOD] = ' '; $tb_content[_REP_KEY_REM] = ' '; } } $tb->addBody($tb_content); } } if ($is_admin || $can_mod) { //if ($can_mod) { $tb->addActionAdd(' <a href="index.php?modname=report&op=report_category">' . '<img src="' . getPathImage() . 'standard/add.png" ' . 'title="' . $lang->def('_NEW') . '" /> ' . $lang->def('_NEW') . '</a>'); } $output .= $tb->getTable(); require_once _base_ . '/lib/lib.dialog.php'; setupHrefDialogBox('a[href*=delete]'); return $output; }
public function getusertabledataTask() { //read from input and prepare filter and pagination variables $id_group = Get::req('id_group', DOTY_INT, 0); //TO DO: if $id_group <= 0 ... $startIndex = Get::req('startIndex', DOTY_INT, 0); $results = Get::req('results', DOTY_INT, Get::sett('visuItem', 25)); $rowsPerPage = Get::req('rowsPerPage', DOTY_INT, $results); $sort = Get::req('sort', DOTY_STRING, ""); $dir = Get::req('dir', DOTY_STRING, "asc"); $filter_text = Get::req('filter_text', DOTY_STRING, ''); $searchFilter = array('text' => $filter_text); //get total from database and validate the results count $total = $this->model->getGroupUsersTotal($id_group, $searchFilter); if ($startIndex >= $total) { if ($total < $results) { $startIndex = 0; } else { $startIndex = $total - $results; } } //set pagination argument $pagination = array('startIndex' => $startIndex, 'results' => $results, 'sort' => $sort, 'dir' => $dir); //read records from database $list = $this->model->getGroupUsersList($id_group, $pagination, $searchFilter); //prepare the data for sending $acl_man = Docebo::user()->getAclManager(); $output_results = array(); if (is_array($list) && count($list) > 0) { foreach ($list as $idst => $record) { //prepare output record $output_results[] = array('id' => $record->idst, 'userid' => Layout::highlight($acl_man->relativeId($record->userid), $filter_text), 'lastname' => Layout::highlight($record->lastname, $filter_text), 'firstname' => Layout::highlight($record->firstname, $filter_text), 'del' => 'ajax.adm_server.php?r=' . $this->link . '/del_user&id_user='******'&id_group=' . (int) $id_group, 'is_group' => $record->is_group); } } $output = array('totalRecords' => $total, 'startIndex' => $startIndex, 'sort' => $sort, 'dir' => $dir, 'rowsPerPage' => $rowsPerPage, 'results' => count($list), 'records' => $output_results); echo $this->json->encode($output); }
public function getunsubscribetabledataTask() { $op = Get::req('op', DOTY_STRING, ""); if ($op == 'selectall') { $this->_getUnsubscribeSelectAll(); return; } $startIndex = Get::req('startIndex', DOTY_INT, 0); $results = Get::req('results', DOTY_MIXED, Get::sett('visuItem', 25)); $sort = Get::req('sort', DOTY_MIXED, 'userid'); $dir = Get::req('dir', DOTY_MIXED, 'asc'); $filter_text = Get::req('filter_text', DOTY_STRING, ""); $filter_course = Get::req('filter_course', DOTY_INT, 0); $filter = array(); if ($filter_text != "") { $filter['text'] = $filter_text; } $courses_filter = FALSE; $ulevel = Docebo::user()->getUserLevelId(); if ($ulevel != ADMIN_GROUP_GODADMIN) { require_once _base_ . '/lib/lib.preference.php'; $preference = new AdminPreference(); $view = $preference->getAdminCourse(Docebo::user()->idst); $all_courses = false; if (isset($view['course'][0])) { $all_courses = true; } elseif (isset($view['course'][-1])) { require_once _lms_ . '/lib/lib.catalogue.php'; $cat_man = new Catalogue_Manager(); $user_catalogue = $cat_man->getUserAllCatalogueId(Docebo::user()->getIdSt()); if (count($user_catalogue) > 0) { $courses = array(0); foreach ($user_catalogue as $id_cat) { $catalogue_course =& $cat_man->getCatalogueCourse($id_cat, true); $courses = array_merge($courses, $catalogue_course); } foreach ($courses as $id_course) { if ($id_course != 0) { $view['course'][$id_course] = $id_course; } } } elseif (Get::sett('on_catalogue_empty', 'off') == 'on') { $all_courses = true; } } else { $array_courses = array(); $array_courses = array_merge($array_courses, $view['course']); if (!empty($view['coursepath'])) { require_once _lms_ . '/lib/lib.coursepath.php'; $path_man = new Catalogue_Manager(); $coursepath_course =& $path_man->getAllCourses($view['coursepath']); $array_courses = array_merge($array_courses, $coursepath_course); } if (!empty($view['catalogue'])) { require_once _lms_ . '/lib/lib.catalogue.php'; $cat_man = new Catalogue_Manager(); foreach ($view['catalogue'] as $id_cat) { $catalogue_course =& $cat_man->getCatalogueCourse($id_cat, true); $array_courses = array_merge($array_courses, $catalogue_course); } } $view['course'] = array_merge($view['course'], $array_courses); } if (!$all_courses) { $courses_filter = $view['course']; } $filter['user_q'] = $preference->getAdminUsersQuery(Docebo::user()->getIdst(), 'user_id'); } if ($filter_course > 0) { if ($courses_filter === FALSE) { $courses_filter = (int) $filter_course; } else { if (!in_array($filter_course, $courses_filter)) { $courses_filter = array(); } else { $courses_filter = (int) $filter_course; } } } if (is_array($courses_filter)) { $filter['course'] = $courses_filter; } $total = $this->model->getUnsubscribeRequestsTotal($filter); if ($startIndex >= $total) { if ($total < $results) { $startIndex = 0; } else { $startIndex = $total - $results; } } $pagination = array('startIndex' => $startIndex, 'results' => $results, 'sort' => $sort, 'dir' => $dir); $list = $this->model->getUnsubscribeRequestsList($pagination, $filter); //format models' data $records = array(); if (is_array($list)) { foreach ($list as $record) { $id_unsub = (int) $record->user_id . '_' . $record->idCourse . '_' . $record->res_id . '_' . $record->r_type; $record->id = $id_unsub; $record->userid = Layout::highlight($this->acl_man->relativeId($record->userid), $filter_text); $record->firstname = Layout::highlight($record->firstname, $filter_text); $record->lastname = Layout::highlight($record->lastname, $filter_text); $record->request_date = Format::date($record->request_date, 'datetime'); $record->del = 'ajax.adm_server.php?r=alms/subscription/deny_unsubscribe_request&id=' . $id_unsub; $records[] = $record; } } if (is_array($records)) { $output = array('startIndex' => $startIndex, 'recordsReturned' => count($records), 'sort' => $sort, 'dir' => $dir, 'totalRecords' => $total, 'pageSize' => $results, 'records' => $records); } else { $output['success'] = false; } echo $this->json->encode($output); }
function gettabledataTask() { //read from input and prepare filter and pagination variables $id_category = Get::req('id_category', DOTY_INT, 0); $descendants = Get::req('descendants', DOTY_INT, 0) > 0 ? true : false; $startIndex = Get::req('startIndex', DOTY_INT, 0); $results = Get::req('results', DOTY_INT, Get::sett('visuItem', 25)); $rowsPerPage = Get::req('rowsPerPage', DOTY_INT, $results); $sort = Get::req('sort', DOTY_STRING, ""); $dir = Get::req('dir', DOTY_STRING, "asc"); $filter_text = Get::req('filter_text', DOTY_STRING, ''); $searchFilter = array('text' => $filter_text); //get total from database and validate the results count $total = $this->competences_model->getCompetencesTotal($id_category, $descendants, $searchFilter); if ($startIndex >= $total) { if ($total < $results) { $startIndex = 0; } else { $startIndex = $total - $results; } } //set pagination argument $pagination = array('startIndex' => $startIndex, 'results' => $results, 'sort' => $sort, 'dir' => $dir); //read records from database $list = $this->competences_model->getCompetencesList($id_category, $descendants, $pagination, $searchFilter); //prepare the data for sending $output_results = array(); if (is_array($list) && count($list) > 0) { foreach ($list as $idst => $record) { //format description field $description = strip_tags($record->description); if (strlen($description) > 200) { $description = substr($description, 0, 197) . '...'; } //prepare output record $output_results[] = array('id' => $record->id_competence, 'name' => Layout::highlight($record->name, $filter_text), 'description' => Layout::highlight($description, $filter_text), 'typology' => $record->typology, 'type' => $record->type); } } $output = array('totalRecords' => $total, 'startIndex' => $startIndex, 'sort' => $sort, 'dir' => $dir, 'rowsPerPage' => $rowsPerPage, 'results' => count($list), 'records' => $output_results); echo $this->json->encode($output); }
public function getwaitinguserstabledataTask() { //check permissions if (!$this->permissions['approve_waiting_user']) { $output = array('success' => false, 'message' => $this->_getErrorMessage('no permission')); echo $this->json->encode($output); return; } $op = Get::req('op', DOTY_STRING, ""); if ($op == 'selectall') { $filter = Get::req('filter', DOTY_STRING, ""); $output = $this->model->getWaitingUsersIds($filter); echo $this->json->encode($output); return; } $startIndex = Get::req('startIndex', DOTY_INT, 0); $results = Get::req('results', DOTY_INT, Get::sett('visuItem', 25)); $rowsPerPage = Get::req('rowsPerPage', DOTY_INT, $results); $sort = Get::req('sort', DOTY_STRING, ""); $dir = Get::req('dir', DOTY_STRING, "asc"); $filter = Get::req('filter', DOTY_STRING, ""); $total = $this->model->getWaitingUsersTotal($filter); if ($startIndex >= $total) { if ($total < $results) { $startIndex = 0; } else { $startIndex = $total - $results; } } $pagination = array('startIndex' => $startIndex, 'results' => $results, 'sort' => $sort, 'dir' => $dir); $list = $this->model->getWaitingUsersList($pagination, $filter); //format models' data $records = array(); $acl_man = Docebo::user()->getAclManager(); if (is_array($list)) { foreach ($list as $record) { $_userid = $acl_man->relativeId($record->userid); $_inserted_by = $record->inserted_by != "" ? $acl_man->relativeId($record->inserted_by) : ""; $records[] = array('id' => (int) $record->idst, 'userid' => Layout::highlight($_userid, $filter), 'firstname' => Layout::highlight($record->firstname, $filter), 'lastname' => Layout::highlight($record->lastname, $filter), 'email' => Layout::highlight($record->email, $filter), 'insert_date' => Format::date($record->insert_date, 'datetime'), 'inserted_by' => $_inserted_by, 'del' => 'ajax.adm_server.php?r=' . $this->link . '/delete_waiting&id_user='******'startIndex' => $startIndex, 'recordsReturned' => count($records), 'sort' => $sort, 'dir' => $dir, 'totalRecords' => $total, 'pageSize' => $rowsPerPage, 'records' => $records); echo $this->json->encode($output); }
?> <p class="course_support_info"> <?php echo Lang::t('_EXPIRED', 'course'); ?> </p> <?php } ?> <p class="course_support_info"> <?php if ($course['code']) { ?> <i style="font-size:.88em">[<?php echo $keyword != "" ? Layout::highlight($course['code'], $keyword) : $course['code']; ?> ]</i><?php } ?> </p> <?php $smodel = new SubscriptionAlms(); if ($smodel->isUserWaitingForSelfUnsubscribe(Docebo::user()->idst, $course['idCourse'])) { echo '<p style="padding:.4em">' . Lang::t('_UNSUBSCRIBE_REQUEST_WAITING_FOR_MODERATION', 'course') . '</p>'; } else { //auto unsubscribe management: create a link for the user in the course block $_can_unsubscribe = $course['auto_unsubscribe'] == 1 || $course['auto_unsubscribe'] == 2; $_date_limit = $course['unsubscribe_date_limit'] != "" && $course['unsubscribe_date_limit'] != "0000-00-00 00:00:00" ? $course['unsubscribe_date_limit'] : FALSE; if ($_can_unsubscribe) { ?>
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 gettabledataTask() { $startIndex = Get::req('startIndex', DOTY_INT, 0); $results = Get::req('results', DOTY_INT, Get::sett('visuItem')); $rowsPerPage = Get::req('rowsPerPage', DOTY_INT, $results); $sort = Get::req('sort', DOTY_STRING, ""); $dir = Get::req('dir', DOTY_STRING, "asc"); $id_course = Get::req('id_course', DOTY_INT, $_SESSION['idCourse']); $filter_text = Get::req('filter_text', DOTY_STRING, ""); $filter_selection = Get::req('filter_selection', DOTY_INT, 0); $filter_orgchart = Get::req('filter_orgchart', DOTY_INT, 0); $filter_groups = Get::req('filter_groups', DOTY_INT, 0); $filter_descendants = Get::req('filter_descendants', DOTY_INT, 0) > 0; $filter = array('text' => $filter_text, 'selection' => $filter_selection, 'orgchart' => $filter_orgchart, 'groups' => $filter_groups, 'descendants' => $filter_descendants); //get total from database and validate the results count $total = $this->model->getCourseStatsTotal($id_course, $filter); if ($startIndex >= $total) { if ($total < $results) { $startIndex = 0; } else { $startIndex = $total - $results; } } $pagination = array('startIndex' => $startIndex, 'results' => $results, 'sort' => $sort, 'dir' => $dir); $list = $this->model->getCourseStatsList($pagination, $id_course, $filter); require_once _lms_ . '/lib/lib.subscribe.php'; $cman = new CourseSubscribe_Manager(); $arr_status = $cman->getUserStatus(); $arr_level = $cman->getUserLevel(); //format models' data $records = array(); $acl_man = Docebo::user()->getAclManager(); if (is_array($list)) { $lo_list = $this->model->getCourseLOs($id_course); foreach ($list as $record) { $_userid = $acl_man->relativeId($record->userid); $row = array('id' => (int) $record->idst, 'userid' => Layout::highlight($_userid, $filter_text), 'firstname' => Layout::highlight($record->firstname, $filter_text), 'lastname' => Layout::highlight($record->lastname, $filter_text), 'status' => isset($arr_status[$record->status]) ? $arr_status[$record->status] : "", 'status_id' => $record->status, 'level' => isset($arr_level[$record->level]) ? $arr_level[$record->level] : ""); //get LO data $completed = 0; foreach ($lo_list as $idOrg => $lo) { if (isset($record->lo_status[$idOrg])) { $row['lo_' . $idOrg] = $record->lo_status[$idOrg]; if ($record->lo_status[$idOrg] == 'completed' || $record->lo_status[$idOrg] == 'passed') { $completed++; } } else { $row['lo_' . $idOrg] = ""; } } $row['completed'] = $completed; $records[] = $row; } } $output = array('startIndex' => $startIndex, 'recordsReturned' => count($records), 'sort' => $sort, 'dir' => $dir, 'totalRecords' => $total, 'pageSize' => $rowsPerPage, 'records' => $records); echo $this->json->encode($output); }
?> <a href="index.php?modname=course&op=aula&idCourse=<?php echo $course['idCourse']; ?> "> <?php echo $course['lang_code'] != 'none' ? Get::img('language/' . strtolower($course['lang_code']) . '.png', $course['lang_code']) : ''; ?> <?php echo $keyword != "" ? Layout::highlight($course['name'], $keyword) : $course['name']; ?> </a> <?php } else { echo Get::img('standard/locked.png', Lang::t('_' . strtoupper($course['can_enter']['reason']), 'standard')); echo ' ' . ($keyword != "" ? Layout::highlight($course['name'], $keyword) : $course['name']); } ?> </h2> <p class="course_support_info"> <?php echo Lang::t($this->ustatus[$course['user_status']], 'course') . '' . Lang::t('_USER_LVL', 'course', array('[level]' => '<b>' . $this->levels[$course['level']] . '</b>')); ?> </p> <!-- p class="course_support_info" --> <?php /* echo Lang::t('_COURSE_INTRO', 'course', array( '[course_type]' => $course['course_type'], '[create_date]' => $course['create_date'], '[enrolled]' => $course['enrolled'], '[course_status]' => Lang::t($this->cstatus[$course['course_status']], 'course')