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);
 }
 public function multimodTask()
 {
     if (!$this->permissions['mod_user']) {
         $output = array('success' => false, 'message' => $this->_getErrorMessage('no permission'));
         echo $this->json->encode($output);
         return;
     }
     $title = Lang::t('_MOD', 'admin_directory');
     $users_count = Get::req('users_count', DOTY_INT, 0);
     if ($users_count <= 0) {
         $output = array('success' => true, 'header' => $title, 'body' => Lang::t('_EMPTY_SELECTION', 'admin_directory'));
         echo $this->json->encode($output);
         return;
     }
     $acl_man = Docebo::user()->getAclManager();
     $level = ADMIN_GROUP_USER;
     $arr_levels = $acl_man->getAdminLevels();
     //index = idst; value = groupid;
     $levels = array();
     foreach ($arr_levels as $groupid_level => $idst_level) {
         $levels[$groupid_level] = Lang::t('_DIRECTORY_' . $groupid_level, 'admin_directory');
     }
     $info = array('firstname' => '', 'lastname' => '', 'email' => '', 'level' => '', 'facebook_id' => '', 'twitter_id' => '', 'linkedin_id' => '', 'google_id' => '');
     $language = getDefaultLanguage();
     $languages = Docebo::langManager()->getAllLanguages();
     require_once _base_ . '/lib/lib.platform.php';
     $pman =& PlatformManager::createInstance();
     // = new PlatformManager();
     $platforms = $pman->getPlatformList();
     require_once _adm_ . '/lib/lib.field.php';
     $fman = new FieldList();
     $field_list = $fman->getFlatAllFields(array_keys($platforms));
     $fields_to_exclude = $fman->getFieldsByType('upload');
     $preference = new UserPreferences(0);
     $modify_mask = $preference->getModifyMask('ui.', true, true);
     $fields_mask = $fman->playFieldsForUser(-1, false, false, true, false, true);
     //build edit mask
     $this->render('multimod', array('users_count' => $users_count, 'title' => $title, 'levels' => $levels, 'modify_mask' => $modify_mask, 'fields_mask' => $fields_mask, 'fields_to_exclude' => is_array($fields_to_exclude) ? $fields_to_exclude : array(), 'info' => $info, 'json' => $this->json));
 }