From 6d590ef3d2864b5e033f90ca95b199f0fc0c657b Mon Sep 17 00:00:00 2001 From: pero1203 Date: Thu, 10 Dec 2020 13:09:02 +0100 Subject: [PATCH] =?UTF-8?q?Urejen=20vmesnik=20za=20pregled=20uporabnikov?= =?UTF-8?q?=20za=20managerje=20(pregled=20nad=20uporabniki,=20omejitev=20?= =?UTF-8?q?=C5=A1tevila=20ra=C4=8Dunov=20v=20pregledu...)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/survey/SurveyAdmin.php | 4 +- admin/survey/SurveyAdminAjax.php | 4 - admin/survey/SurveyAdminSettings.php | 401 +++++++----------- admin/survey/classes/class.Common.php | 4 +- admin/survey/classes/class.Dostop.php | 322 +++++++++----- admin/survey/classes/class.SurveyList.php | 43 +- admin/survey/index.php | 2 +- admin/survey/script/dostop.js | 35 -- admin/survey/script/script.js | 4 - lang/1.php | 24 +- lang/2.php | 22 +- public/css/admin.css | 12 +- .../sass/admin/main_page/survey_list.scss | 18 +- resources/sass/admin/users.scss | 2 +- 14 files changed, 455 insertions(+), 442 deletions(-) diff --git a/admin/survey/SurveyAdmin.php b/admin/survey/SurveyAdmin.php index ed364fc79..fea29b1c2 100644 --- a/admin/survey/SurveyAdmin.php +++ b/admin/survey/SurveyAdmin.php @@ -3383,11 +3383,11 @@ class SurveyAdmin elseif($_GET['m'] == 'odjavljeni'){ $sas->unsignedUsersList(); } - elseif(in_array($_GET['m'], ['all', 'my'])){ + elseif($_GET['m'] == 'all'){ $sas->allUsersList(); } else { - $sas->anketa_list_users(); + $sas->assignedUsersList(); } echo ''; diff --git a/admin/survey/SurveyAdminAjax.php b/admin/survey/SurveyAdminAjax.php index d60ad9e31..510632775 100644 --- a/admin/survey/SurveyAdminAjax.php +++ b/admin/survey/SurveyAdminAjax.php @@ -5134,10 +5134,6 @@ class SurveyAdminAjax { $s = sisplet_query("DELETE FROM srv_password WHERE ank_id='$this->anketa' AND password = '$password'"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); } - } elseif ($_GET['a'] == 'refreshUserDiagnostic') { - $sas = new SurveyAdminSettings(); - $sas->anketa_list_users(); - } elseif ($_GET['a'] == 'getDataStatusTitles') { global $lang; $return = array(); diff --git a/admin/survey/SurveyAdminSettings.php b/admin/survey/SurveyAdminSettings.php index 25b45ccae..20d029baf 100644 --- a/admin/survey/SurveyAdminSettings.php +++ b/admin/survey/SurveyAdminSettings.php @@ -7214,7 +7214,6 @@ class SurveyAdminSettings { $arrayTestni = array(); for ($i=1; $i<=$_POST['stevilo_vnosov']; $i++) { -// if(session_id() == '') {session_start();} session_start(); $_SESSION['progressBar'][$this->anketa]['current'] = $i; session_commit(); @@ -7982,28 +7981,12 @@ class SurveyAdminSettings { header("Location: index.php?anketa=$this->anketa&a=testiranje&m=testnipodatki"); } elseif ($_GET['delete_testdata'] == 1 || $_GET['delete_autogen_testdata'] == 1) { - - - // Komentarje moramo obdrzat - zato jih zacasno shranimo in na novo vstavimo - /*$comment_bck = array(); - $sqlComment = sisplet_query("SELECT dt.vre_id AS vre_id, dt.text AS text, dt.usr_id AS usr_id FROM srv_data_text".$this->db_table." dt, srv_user u WHERE u.ank_id='$this->anketa' AND u.testdata='1' AND dt.usr_id=u.id AND dt.spr_id='0'"); - while($rowComment = mysqli_fetch_array($sqlComment)){ - $comment_bck[] = $rowComment; - }*/ - if($_GET['delete_autogen_testdata'] == 1) sisplet_query("DELETE FROM srv_user WHERE ank_id='$this->anketa' AND testdata='2'"); else sisplet_query("DELETE FROM srv_user WHERE ank_id='$this->anketa' AND (testdata='1' OR testdata='2')"); - - // Komentarje nazaj vstavimo - /*foreach($comment_bck as $comment){ - $sqlComment = sisplet_query("INSERT INTO srv_data_text".$this->db_table." (spr_id, vre_id, text, usr_id) VALUES ('0', '".$comment['vre_id']."', '".$comment['text']."', NULL)"); - }*/ - - #datoteki z podatki moramo zgenerirati na novo sisplet_query("UPDATE srv_data_files SET head_file_time='0000-00-00', data_file_time='0000-00-00' WHERE sid='$this->anketa'"); sisplet_query("COMMIT"); @@ -8136,9 +8119,7 @@ class SurveyAdminSettings { echo ''; echo '

'.$lang['srv_testni_nakonec'].'

'; - - } - + } } } @@ -8267,205 +8248,6 @@ class SurveyAdminSettings { echo ''; } - function anketa_list_users() { - global $lang, $global_user_id, $admin_type; - - $_GET['show'] = isset($_POST['show']) && $_POST['show'] == 'all' ? 'all' : $_GET['show']; - $_GET['limit'] = isset($_POST['limit']) ? $_POST['limit'] : $_GET['limit']; - - if ($admin_type == 0) { - echo '

'; - - echo ''.$lang['srv_users_added'].''; - - echo '|'; - - echo ''.$lang['srv_users_all'].''; - - echo '

'; - - echo '

'; - } - - # povezava polj z polji iz baze za sortiranje - $sort_by_array = array( - 'name'=>'u.name', - 'email'=>'u.email', - 'type'=>'u.type', - //'cnt'=>'sa1.survey_count', - //'archive'=>'sa2.survey_archive', - 'cnt'=>'d1.dostop_survey_count', - 'archive'=>'d2.dostop_survey_archive', - 'registred'=>'u.when_reg', - 'login'=>'u.last_login' - ); - - $fields = array( - 'name'=>$lang['srv_survey_list_users_name'], - 'email'=>$lang['srv_survey_list_users_email'], - 'type'=>$lang['admin_type'], - 'cnt'=>$lang['srv_survey_list_users_survey_count'], - 'archive'=>$lang['srv_survey_list_users_survey_archive_count'], - 'registred'=>$lang['srv_survey_list_users_registred'], - 'login'=>$lang['srv_survey_list_users_last_login'], - ); - - - $srt_field = isset($sort_by_array[$_POST['field']]) ? $_POST['field'] : 'cnt'; - $srt_type = isset($_POST['type']) && $_POST['type'] == 'asc' ? 'asc' : 'desc'; - - # omejitev uporabnikov kateri nimajo anket - // pri managerjih naj bodo vsi, ker cene se ne vidijo novo dodani uporabniki - #if ($admin_type == 0) - # $limit_no_survey = ' WHERE sa1.survey_count > 0'; - #else - $limit_no_survey = ' WHERE 1=1'; - - # izvedemo poljubno sortiranje - $order_by = ' ORDER BY ' . $sort_by_array[$srt_field] . ' '. $srt_type; - - // managerji in admini vidijo tudi svoje uporabnike - if ($admin_type == 1 || $admin_type == 0) { - $user_condition = " AND (u.id = '".$global_user_id."' OR u.id IN (SELECT user FROM srv_dostop_manage WHERE manager='".$global_user_id."') )"; - - # ostali uporabniki lahko vidijo samo svoje ankete - } elseif ((int)$global_user_id > 0) { - $user_condition = " AND u.id = '".$global_user_id."'"; - } - - // Meta admini spet kao vidijo vse - //if ( Dostop::isMetaAdmin() ) - // opcija za vse admine - if ( $_GET['show'] == 'all') - $user_condition = ""; - - //} - # - - // Stevilo prikazanih - if(isset($_GET['limit'])){ - $limit = " LIMIT ".(int)$_GET['limit']; - $limit_cnt = (int)$_GET['limit']; - } - else{ - $limit = " LIMIT 100"; - $limit_cnt = 100; - } - - // Stran (ce ne prikazujemo vseh) - if(isset($_GET['page'])){ - $offset = " OFFSET ".(((int)$_GET['page']-1) * $limit_cnt); - } - else{ - $offset = " OFFSET 0"; - } - - // Ce imamo iskanje izvedemo drugacen query - if($admin_type == 0 && isset($_POST['search_users'])){ - // Po novem stejemo vse ankete z dostopom (ne samo tiste katerih je avtor) - $sql_string = "SELECT u.id, u.type, u.status, u.email, u.name, u.surname, date_format(u.when_reg, '%d.%m.%Y') as when_reg, d1.dostop_survey_count, d2.dostop_survey_archive, date_format(u.last_login, '%d.%m.%Y') as last_login FROM users AS u " - ." LEFT OUTER JOIN ( SELECT srv_dostop.ank_id, srv_dostop.uid, count(*) AS dostop_survey_count FROM srv_dostop, srv_anketa WHERE srv_anketa.id=srv_dostop.ank_id AND srv_anketa.backup='0' GROUP BY srv_dostop.uid ) AS d1 ON d1.uid = u.id " - ." LEFT OUTER JOIN ( SELECT srv_dostop.ank_id, srv_dostop.uid, count(*) AS dostop_survey_archive FROM srv_dostop, srv_anketa WHERE srv_anketa.id=srv_dostop.ank_id AND srv_anketa.backup>'0' GROUP BY srv_dostop.uid ) AS d2 ON d2.uid = u.id " - ." WHERE u.email LIKE '%".$_POST['search_users']."%' OR u.name LIKE '%".$_POST['search_users']."%' OR u.surname LIKE '%".$_POST['search_users']."%' " - . $order_by; - } - else{ - // Po novem stejemo vse ankete z dostopom (ne samo tiste katerih je avtor) - $sql_string = "SELECT u.id, u.type, u.status, u.email, u.name, u.surname, date_format(u.when_reg, '%d.%m.%Y') as when_reg, d1.dostop_survey_count, d2.dostop_survey_archive, date_format(u.last_login, '%d.%m.%Y') as last_login FROM users AS u " - ." LEFT OUTER JOIN ( SELECT srv_dostop.ank_id, srv_dostop.uid, count(*) AS dostop_survey_count FROM srv_dostop, srv_anketa WHERE srv_anketa.id=srv_dostop.ank_id AND srv_anketa.backup='0' GROUP BY srv_dostop.uid ) AS d1 ON d1.uid = u.id " - ." LEFT OUTER JOIN ( SELECT srv_dostop.ank_id, srv_dostop.uid, count(*) AS dostop_survey_archive FROM srv_dostop, srv_anketa WHERE srv_anketa.id=srv_dostop.ank_id AND srv_anketa.backup>'0' GROUP BY srv_dostop.uid ) AS d2 ON d2.uid = u.id " - . $limit_no_survey - . $user_condition - . $order_by - . $limit . $offset; - } - - $sql_query = sisplet_query($sql_string); - if (!$sql_query) echo mysqli_error($GLOBALS['connect_db']); - - $sqlu = sisplet_query("SELECT * FROM users WHERE id = '$global_user_id'"); - $rowu = mysqli_fetch_array($sqlu); - if ($admin_type == 0) { - echo '

'.$lang['administrator'].': '.$rowu['name'].' '.$rowu['surname'].'

'; - } elseif ($admin_type == 1) { - echo '

'.$lang['manager'].': '.$rowu['name'].' '.$rowu['surname'].'

'; - } - - - echo ''; - echo ''; - echo ''; - foreach ($fields AS $field => $title) { - echo ''; - } - echo ''; - - while ($row_query = mysqli_fetch_array($sql_query)) { - echo ''; - - echo ''; - - echo ''; - - if ( true /*$_GET['show'] == '' or Dostop::isMetaAdmin()*/ ) { - echo ''; - } else { - echo ''; - } - - if ($row_query['type'] == '0') $type = $lang['admin_admin']; - elseif ($row_query['type'] == '1') $type = $lang['admin_manager']; - elseif ($row_query['type'] == '2') $type = $lang['admin_clan']; - elseif ($row_query['type'] == '3') $type = $lang['admin_narocnik']; - - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - } - echo '
'; - if ($srt_field !== $field) { - $img_src = 'sort_unsorted'; - echo '
'.$title.'
'; - } else { - if ($srt_type == 'desc') { - $img_src = 'sort_descending'; - echo '
'.$title.'
'; - } else { - $img_src = 'sort_ascending'; - echo '
'.$title.'
'; - } - } - echo '
'; - echo ' '; - echo ''; - echo $row_query['name'].' '.$row_query['surname']; - echo '' . $row_query['email'] . '' . $row_query['email'] . '' . $type . ' '.($row_query['status']==0?'':'').''.(int)$row_query['dostop_survey_count'].''.(int)$row_query['dostop_survey_archive'].''.$row_query['when_reg'].''.$row_query['last_login'].'
'; - - - // poiscemo uporabnike, ki imajo managerski pregled na uporabnikovimi anketami - $sqlu = sisplet_query("SELECT u.id, u.name, u.surname, u.email FROM srv_dostop_manage m, users u WHERE u.id=m.manager AND m.user = '$global_user_id'"); - if ( mysqli_num_rows($sqlu) > 0 ) { - - echo '

'.$lang['srv_manager_manager'].':

'; - - while ($rowu = mysqli_fetch_assoc($sqlu)) { - - echo ' '.$rowu['email'].' - '.$rowu['name'].' '.$rowu['surname'].'
'; - - } - - } - - // managerji in admini lahko dodajajo uporabnike, ki jih nato managirajo - $this->dodeljeniUporabniki(); - - // admin lahko doda novega uporabnika - $this->dodajNovegaUporabnika(); - } - /** * Uporabnik (administrator, manager) lahko dodajata nove uporabnike in jim dodelita dostop */ @@ -8474,15 +8256,16 @@ class SurveyAdminSettings { global $lang; global $virtual_domain; - // admini in na virtualkah tudi managerji lahko dodajajo uporabnike, ki jih nato managirajo - if( !($admin_type == 0 || ($admin_type == 1 && $virtual_domain == true)) ) + // admini lahko dodajajo uporabnike, ki jih nato managirajo + if($admin_type != 0) return ''; + echo '
'; - echo ' | '.$lang['srv_users_add_new'].'
'; } - /** * Uporabnik (administrator, manager) lahko dodajata nove uporabnike in jim dodelita dostop */ @@ -8509,38 +8295,76 @@ class SurveyAdminSettings { global $admin_type; global $lang; global $global_user_id; + global $virtual_domain; // managerji in admini lahko dodajajo uporabnike, ki jih nato managirajo if( !($admin_type == 1 || $admin_type == 0) ) return ''; + // Na virtualkah imajo managerji omejitev st. dodeljenih uporabnikov + if(/*$virtual_domain && */$admin_type == 1){ - echo '

'.$lang['srv_invitation_system_validateAndAdd'].''; @@ -962,7 +968,7 @@ class Dostop { } } - //header("Location: index.php?a=diagnostics&t=uporabniki&m=my&error=" . ($error !== FALSE ? $error : '')); + header("Location: index.php?a=diagnostics&t=uporabniki".($error !== FALSE ? '&error='.$error : '')); } /** @@ -1043,120 +1049,104 @@ class Dostop { /** * Seznam vseh uporabnikov znotrja 1ke */ - function ajax_all_users_list($my = null) - { + function ajax_all_users_list(){ global $admin_languages; global $global_user_id; global $lang; - global $admin_type; + global $admin_type; + $seznam = []; $iskanjeSql = ""; if(!empty($_POST['search']['value'])){ $iskaniNiz = $_POST['search']['value']; $iskanjeSql = " AND (u.name LIKE '%".$iskaniNiz."%' OR u.surname LIKE '%".$iskaniNiz."%' OR u.email LIKE '%".$iskaniNiz."%' OR d1.dostop_survey_count LIKE '%".$iskaniNiz."%' OR d2.dostop_survey_archive LIKE '%".$iskaniNiz."%')"; - } - - // Pridobimo vse uporabnike - $sql ="SELECT u.id as id, u.type as type, u.status, u.email as email, u.name as name, u.surname as surname, u.lang as lang, u.eduroam as aai, date_format(u.when_reg, '%d.%m.%Y') as registriran, u.gdpr_agree as gdpr_agree, d1.dostop_survey_count as st_anket, d2.dostop_survey_archive as st_arhivskih, date_format(u.last_login, '%d.%m.%Y') as last_login, ue.email as second_email FROM users AS u ". - " LEFT OUTER JOIN ( SELECT srv_dostop.ank_id, srv_dostop.uid, count(*) AS dostop_survey_count FROM srv_dostop, srv_anketa WHERE srv_anketa.id=srv_dostop.ank_id AND srv_anketa.backup='0' GROUP BY srv_dostop.uid ) AS d1 ON d1.uid = u.id ". - " LEFT OUTER JOIN ( SELECT srv_dostop.ank_id, srv_dostop.uid, count(*) AS dostop_survey_archive FROM srv_dostop, srv_anketa WHERE srv_anketa.id=srv_dostop.ank_id AND srv_anketa.backup>'0' GROUP BY srv_dostop.uid ) AS d2 ON d2.uid = u.id ". - " LEFT OUTER JOIN (SELECT user_emails.email, user_emails.user_id FROM user_emails WHERE active=1) AS ue ON ue.user_id = u.id". - " WHERE u.email NOT LIKE ('D3LMD-%') AND u.email NOT LIKE ('UNSU8MD-%') ".$iskanjeSql; - - // Filter samo po lastnih uporabnikih - if(!empty($my)){ - // Med lastne uporabnike prikažemo tudi, tiste ki so bili registrirani z isto domeno - UserSetting :: getInstance()->Init($global_user_id); - $domena = UserSetting :: getInstance()->getUserSetting('manage_domain'); - - $isciPoDomeni = ''; - if(!empty($domena)){ - $isciPoDomeni = " OR u.email LIKE '%".$domena."'"; } + // Pridobimo vse uporabnike + $sql = "SELECT u.id as id, u.type as type, u.status, u.email as email, u.name as name, u.surname as surname, u.lang as lang, u.eduroam as aai, date_format(u.when_reg, '%d.%m.%Y') as registriran, u.gdpr_agree as gdpr_agree, d1.dostop_survey_count as st_anket, d2.dostop_survey_archive as st_arhivskih, date_format(u.last_login, '%d.%m.%Y') as last_login, ue.email as second_email FROM users AS u ". + " LEFT OUTER JOIN ( SELECT srv_dostop.ank_id, srv_dostop.uid, count(*) AS dostop_survey_count FROM srv_dostop, srv_anketa WHERE srv_anketa.id=srv_dostop.ank_id AND srv_anketa.backup='0' GROUP BY srv_dostop.uid ) AS d1 ON d1.uid = u.id ". + " LEFT OUTER JOIN ( SELECT srv_dostop.ank_id, srv_dostop.uid, count(*) AS dostop_survey_archive FROM srv_dostop, srv_anketa WHERE srv_anketa.id=srv_dostop.ank_id AND srv_anketa.backup>'0' GROUP BY srv_dostop.uid ) AS d2 ON d2.uid = u.id ". + " LEFT OUTER JOIN (SELECT user_emails.email, user_emails.user_id FROM user_emails WHERE active=1) AS ue ON ue.user_id = u.id". + " WHERE u.email NOT LIKE ('D3LMD-%') AND u.email NOT LIKE ('UNSU8MD-%') ".$iskanjeSql; - $sql .= " AND (u.id = '".$global_user_id."' OR u.id IN (SELECT user FROM srv_dostop_manage WHERE manager='".$global_user_id."') ".$isciPoDomeni.")"; - } + // Filtri, ki jih datatables pošilja in po katerih filtriramo + if($_POST['order'][0]['column'] < 10) { + $orderPolje = [ + "u.name ".$_POST['order'][0]['dir'].", u.surname", + "u.email", + "u.type", + "u.lang", + "u.eduroam", //AAI + "d1.dostop_survey_count", //st_anket + "d2.dostop_survey_archive", //st_arhivskih + "u.gdpr_agree", + "u.when_reg", + "u.last_login" + ]; + if($_POST['order'][0]['column'] == 7){ - // Filtri, ki jih datatables pošilja in po katerih filtriramo - if($_POST['order'][0]['column'] < 10) { - $orderPolje = [ - "u.name ".$_POST['order'][0]['dir'].", u.surname", - "u.email", - "u.type", - "u.lang", - "u.eduroam", //AAI - "d1.dostop_survey_count", //st_anket - "d2.dostop_survey_archive", //st_arhivskih - "u.gdpr_agree", - "u.when_reg", - "u.last_login" - ]; + $vrednost='u.gdpr_agree desc'; + if($_POST['order'][0]['dir'] == 'asc'){ + $vrednost= ' FIELD (u.gdpr_agree, 0, \'-1\', 1)'; + } - if($_POST['order'][0]['column'] == 7){ + $sql .= " ORDER BY ".$vrednost; + } + else { + $sql .= " ORDER BY ".$orderPolje[$_POST['order'][0]['column']]." ".$_POST['order'][0]['dir']; + } + } - $vrednost='u.gdpr_agree desc'; - if($_POST['order'][0]['dir'] == 'asc'){ - $vrednost= ' FIELD (u.gdpr_agree, 0, \'-1\', 1)'; - } + if($_POST['length'] != '-1') { + $sql .= " LIMIT ".$_POST['start'].", ".$_POST['length']; + } - $sql .= " ORDER BY ".$vrednost; - }else { - $sql .= " ORDER BY ".$orderPolje[$_POST['order'][0]['column']]." ".$_POST['order'][0]['dir']; - } - } - - if($_POST['length'] != '-1') { - $sql .= " LIMIT ".$_POST['start'].", ".$_POST['length']; - } - - $resultQuery = sisplet_query($sql); + $resultQuery = sisplet_query($sql); $resultU = lazyLoadSqlObj($resultQuery); - // Seznam uporabnikov vrne za administratorje vse za ostale pa samo tiste, ki smo jih dodali k uporabniku. - if (!empty($resultU) && ($this->jeAdministrator() || !$this->jeAdministrator() && !empty($my) )) { + // Seznam uporabnikov vrne za administratorje vse za ostale pa samo tiste, ki smo jih dodali k uporabniku. + if (!empty($resultU)) { - if (!empty($resultU->name)) { - $vsi[] = $resultU; - } else { - $vsi = $resultU; - } + if (!empty($resultU->name)) { + $vsi[] = $resultU; + } + else { + $vsi = $resultU; + } - foreach ($vsi as $uporabnik) { - $seznam[] = [ - iconv(mb_detect_encoding( $uporabnik->name, mb_detect_order(), true), "UTF-8", $uporabnik->name) .' '.iconv(mb_detect_encoding( $uporabnik->surname, mb_detect_order(), true), "UTF-8", $uporabnik->surname), - (!empty($uporabnik->second_email) ? iconv(mb_detect_encoding( $uporabnik->second_email, mb_detect_order(), true), "UTF-8", $uporabnik->second_email) : iconv(mb_detect_encoding( $uporabnik->email, mb_detect_order(), true), "UTF-8", $uporabnik->email)), - $this->userTypeToText($uporabnik->type), - $admin_languages[$uporabnik->lang], - (!empty($uporabnik->aai) ? $this->vrniDaNe($uporabnik->aai) : $lang['no1']), - (!empty($uporabnik->st_anket) ? $uporabnik->st_anket : 0), - (!empty($uporabnik->st_arhivskih) ? $uporabnik->st_arhivskih : 0), - $lang["users_gdpr".$uporabnik->gdpr_agree], - $uporabnik->registriran, - $uporabnik->last_login, - ''. - ' | '. - ' | ' - ]; + foreach ($vsi as $uporabnik) { + $seznam[] = [ + iconv(mb_detect_encoding( $uporabnik->name, mb_detect_order(), true), "UTF-8", $uporabnik->name) .' '.iconv(mb_detect_encoding( $uporabnik->surname, mb_detect_order(), true), "UTF-8", $uporabnik->surname), + (!empty($uporabnik->second_email) ? iconv(mb_detect_encoding( $uporabnik->second_email, mb_detect_order(), true), "UTF-8", $uporabnik->second_email) : iconv(mb_detect_encoding( $uporabnik->email, mb_detect_order(), true), "UTF-8", $uporabnik->email)), + $this->userTypeToText($uporabnik->type), + $admin_languages[$uporabnik->lang], + (!empty($uporabnik->aai) ? $this->vrniDaNe($uporabnik->aai) : $lang['no1']), + (!empty($uporabnik->st_anket) ? $uporabnik->st_anket : 0), + (!empty($uporabnik->st_arhivskih) ? $uporabnik->st_arhivskih : 0), + $lang["users_gdpr".$uporabnik->gdpr_agree], + $uporabnik->registriran, + $uporabnik->last_login, + ''. + ' | '. + ' | ' + ]; + } + } - } - } + $sql_recordsTotal = sisplet_query("SELECT count(id) as stVseh FROM users WHERE email NOT LIKE ('D3LMD-%') AND email NOT LIKE ('UNSU8MD-%')", "obj"); + + // Število vseh zadetkov, ki jih imamo v bazi + $recordsTotal = 0; + if(!empty($sql_recordsTotal)) { + $recordsTotal = $sql_recordsTotal->stVseh; + } - $sql_recordsTotal = sisplet_query("SELECT count(id) as stVseh FROM users WHERE email NOT LIKE ('D3LMD-%') AND email NOT LIKE ('UNSU8MD-%')", "obj"); - // Število vseh zadetkov, ki jih imamo v bazi - $recordsTotal = 0; - if(!empty($sql_recordsTotal) && is_null($my)) { - $recordsTotal = $sql_recordsTotal->stVseh; - } elseif(!is_null($my)) { - $recordsTotal = sizeof($vsi); - } - - // Število filtriranih zadetkov - $recordFiltered = $recordsTotal; - if(!empty($_POST['search']['value'])) - $recordFiltered = sizeof($vsi); + // Število filtriranih zadetkov + $recordFiltered = $recordsTotal; + if(!empty($_POST['search']['value'])) + $recordFiltered = sizeof($vsi); echo json_encode([ "draw" => (!empty($_POST['draw']) ? $_POST['draw'] : 1), @@ -1164,7 +1154,126 @@ class Dostop { "recordsFiltered" => $recordFiltered, "data" => $seznam // polje z vsebino ]); + } + + /** + * Seznam dodeljenih uporabnikov (manager in admin) + */ + function ajax_all_users_list_my(){ + global $admin_languages; + global $global_user_id; + global $lang; + global $admin_type; + + $seznam = []; + $iskanjeSql = ""; + if(!empty($_POST['search']['value'])){ + $iskaniNiz = $_POST['search']['value']; + $iskanjeSql = " AND (u.name LIKE '%".$iskaniNiz."%' OR u.surname LIKE '%".$iskaniNiz."%' OR u.email LIKE '%".$iskaniNiz."%' OR d1.dostop_survey_count LIKE '%".$iskaniNiz."%' OR d2.dostop_survey_archive LIKE '%".$iskaniNiz."%')"; + } + + // Pridobimo vse uporabnike + $sql = "SELECT u.id as id, u.type as type, u.status, u.email as email, u.name as name, u.surname as surname, u.lang as lang, u.eduroam as aai, date_format(u.when_reg, '%d.%m.%Y') as registriran, u.gdpr_agree as gdpr_agree, d1.dostop_survey_count as st_anket, d2.dostop_survey_archive as st_arhivskih, date_format(u.last_login, '%d.%m.%Y') as last_login, ue.email as second_email FROM users AS u ". + " LEFT OUTER JOIN ( SELECT srv_dostop.ank_id, srv_dostop.uid, count(*) AS dostop_survey_count FROM srv_dostop, srv_anketa WHERE srv_anketa.id=srv_dostop.ank_id AND srv_anketa.backup='0' GROUP BY srv_dostop.uid ) AS d1 ON d1.uid = u.id ". + " LEFT OUTER JOIN ( SELECT srv_dostop.ank_id, srv_dostop.uid, count(*) AS dostop_survey_archive FROM srv_dostop, srv_anketa WHERE srv_anketa.id=srv_dostop.ank_id AND srv_anketa.backup>'0' GROUP BY srv_dostop.uid ) AS d2 ON d2.uid = u.id ". + " LEFT OUTER JOIN (SELECT user_emails.email, user_emails.user_id FROM user_emails WHERE active=1) AS ue ON ue.user_id = u.id". + " WHERE u.email NOT LIKE ('D3LMD-%') AND u.email NOT LIKE ('UNSU8MD-%') ".$iskanjeSql; + + // Filter samo po lastnih uporabnikih + $isciPoDomeni = ''; + + // Med lastne uporabnike prikažemo tudi, tiste ki so bili registrirani z isto domeno + /*UserSetting :: getInstance()->Init($global_user_id); + $domena = UserSetting :: getInstance()->getUserSetting('manage_domain'); + if(!empty($domena)){ + $isciPoDomeni = " OR u.email LIKE '%".$domena."'"; + }*/ + + $sql .= " AND (u.id IN (SELECT user FROM srv_dostop_manage WHERE manager='".$global_user_id."') ".$isciPoDomeni.")"; + + + // Filtri, ki jih datatables pošilja in po katerih filtriramo + if($_POST['order'][0]['column'] < 10) { + $orderPolje = [ + "u.name ".$_POST['order'][0]['dir'].", u.surname", + "u.email", + "u.type", + "u.lang", + "u.eduroam", //AAI + "d1.dostop_survey_count", //st_anket + "d2.dostop_survey_archive", //st_arhivskih + "u.gdpr_agree", + "u.when_reg", + "u.last_login" + ]; + + if($_POST['order'][0]['column'] == 7){ + + $vrednost='u.gdpr_agree desc'; + if($_POST['order'][0]['dir'] == 'asc'){ + $vrednost= ' FIELD (u.gdpr_agree, 0, \'-1\', 1)'; + } + + $sql .= " ORDER BY ".$vrednost; + } + else { + $sql .= " ORDER BY ".$orderPolje[$_POST['order'][0]['column']]." ".$_POST['order'][0]['dir']; + } + } + + if($_POST['length'] != '-1') { + $sql .= " LIMIT ".$_POST['start'].", ".$_POST['length']; + } + + $resultQuery = sisplet_query($sql); + $resultU = lazyLoadSqlObj($resultQuery); + + // Seznam uporabnikov vrne za administratorje vse za ostale pa samo tiste, ki smo jih dodali k uporabniku. + if (!empty($resultU) && ($this->jeAdministrator() || !$this->jeAdministrator())) { + + if (!empty($resultU->name)) { + $vsi[] = $resultU; + } + else { + $vsi = $resultU; + } + + foreach ($vsi as $uporabnik) { + $seznam[] = [ + iconv(mb_detect_encoding( $uporabnik->name, mb_detect_order(), true), "UTF-8", $uporabnik->name) .' '.iconv(mb_detect_encoding( $uporabnik->surname, mb_detect_order(), true), "UTF-8", $uporabnik->surname), + (!empty($uporabnik->second_email) ? iconv(mb_detect_encoding( $uporabnik->second_email, mb_detect_order(), true), "UTF-8", $uporabnik->second_email) : iconv(mb_detect_encoding( $uporabnik->email, mb_detect_order(), true), "UTF-8", $uporabnik->email)), + $this->userTypeToText($uporabnik->type), + $admin_languages[$uporabnik->lang], + (!empty($uporabnik->aai) ? $this->vrniDaNe($uporabnik->aai) : $lang['no1']), + (!empty($uporabnik->st_anket) ? $uporabnik->st_anket : 0), + (!empty($uporabnik->st_arhivskih) ? $uporabnik->st_arhivskih : 0), + $lang["users_gdpr".$uporabnik->gdpr_agree], + $uporabnik->registriran, + $uporabnik->last_login, + ''. + ' | '. + ' | ' + ]; + + } + } + + // Število vseh zadetkov, ki jih imamo v bazi + $recordsTotal = 0; + $recordsTotal = sizeof($vsi); + + // Število filtriranih zadetkov + $recordFiltered = $recordsTotal; + if(!empty($_POST['search']['value'])) + $recordFiltered = sizeof($vsi); + + echo json_encode([ + "draw" => (!empty($_POST['draw']) ? $_POST['draw'] : 1), + "recordsTotal" => $recordsTotal, + "recordsFiltered" => $recordFiltered, + "data" => $seznam // polje z vsebino + ]); } /** @@ -1238,7 +1347,8 @@ class Dostop { $type = $lang['admin_manager']; break; case 2: - $type = $lang['admin_clan']; + case 3: + $type = $lang['admin_narocnik']; break; } diff --git a/admin/survey/classes/class.SurveyList.php b/admin/survey/classes/class.SurveyList.php index 8f775d879..8606d6c78 100644 --- a/admin/survey/classes/class.SurveyList.php +++ b/admin/survey/classes/class.SurveyList.php @@ -239,14 +239,26 @@ class SurveyList { echo '
'; if ($_GET['a']=='diagnostics') { - if ($_GET['t'] == 'uporabniki') { - if ($admin_type == 0) { + + if ($_GET['t'] == 'uporabniki') { + + // Admini imajo pregled nad vsemi zavihki uporabnikov + if ($admin_type == 0) { echo ''; + } + + // Menegerji imajo samo osnovni pregled svojih uporabnikov + if ($admin_type == 1) { - + echo ''; } - - } else { + } + else { + if ($admin_type == 0) { echo '
    '; #zavihek ankete @@ -701,7 +726,7 @@ class SurveyList { # ni smiselno da ostali uporabniki vidijo zavihek, ker so tako prikazane samo njihove ankete echo '
  •  
  • '; echo '
  • '; - echo ''; + echo ''; echo '
    '. $lang['hour_users'] . '
    '; echo '
    '; echo '
  • '; diff --git a/admin/survey/index.php b/admin/survey/index.php index 2a581d5a2..6c6076de3 100644 --- a/admin/survey/index.php +++ b/admin/survey/index.php @@ -113,7 +113,7 @@ if(isset($_GET['a']) && ($_GET['a'] == 'hierarhija_superadmin' || $_GET['a'] == 'hierarhija')){ echo ''; } - elseif($_GET['a'] == 'narocila' || ($_GET['t'] == 'uporabniki' && in_array($_GET['m'], ['all', 'my', 'izbrisani', 'nepotrjeni', 'odjavljeni']))){ + elseif($_GET['a'] == 'narocila' || $_GET['t'] == 'uporabniki'){ echo ''; } else{ diff --git a/admin/survey/script/dostop.js b/admin/survey/script/dostop.js index 9c3378152..de6712a70 100644 --- a/admin/survey/script/dostop.js +++ b/admin/survey/script/dostop.js @@ -293,41 +293,6 @@ $(document).ready(function () { deferRender: true, select: true, buttons: [ - { - extend: 'copy', - exportOptions: { - columns: ':visible' - } - }, - { - extend: 'print', - exportOptions: { - columns: ':visible' - } - }, - { - extend: 'csv', - bom: true, - exportOptions: { - columns: ':visible' - } - }, - { - extend: 'excel', - bom: true, - exportOptions: { - columns: ':visible' - } - }, - { - extend: 'pdf', - orientation: 'landscape', - pageSize: 'LEGAL', - exportOptions: { - columns: ':visible' - } - }, - 'colvis' ], language: { "url": siteUrl+"admin/survey/script/datatables/Slovenian.json" diff --git a/admin/survey/script/script.js b/admin/survey/script/script.js index c8440ed43..b79a1f5a8 100644 --- a/admin/survey/script/script.js +++ b/admin/survey/script/script.js @@ -4229,10 +4229,6 @@ function add_to_library(anketa,where) { $.post('ajax.php?a=add_to_library', {anketa:anketa, where:where}); } -function refresh_user_diagnostic(field, type, show, limit) { - $('#survey_list').load('ajax.php?a=refreshUserDiagnostic', {field:field, type:type, show:show, limit:limit}); -} - function create_archive_survey(anketa, msg) { $('#fade').fadeTo('slow', 1); $('#fullscreen').html('').fadeIn('slow').draggable({delay:100, cancel: 'input, textarea, select, .buttonwrapper'}); diff --git a/lang/1.php b/lang/1.php index 9d0ad0907..b60aae69b 100644 --- a/lang/1.php +++ b/lang/1.php @@ -174,7 +174,7 @@ $lang = array ( "logged_in_as" => "Prijavljeni ste kot", "administrator" => "Administrator", "manager" => "Manager", - "user" => "član", + "user" => "Uporabnik", "add_hor_link" => "Dodaj vodoravno povezavo", "send" => "Pošlji", "add_link" => "Dodaj povezavo", @@ -715,11 +715,12 @@ $lang = array ( "n_list" => "Spisek prejemnikov", "n_desc_list" => "     Zahtevali ste spisek prejemnikov. Preverite ga, ter potrdite
         oziroma popravite prejemnike.

         Spisek prejemnikov


    ", "n_list_users" => "Uporabniki", - "n_users_list_all" => "Seznam vseh", - "n_deleted_users" => "Izbrisani", - "n_unsigned_users" => "Odjavljeni", - "n_unconfirmed_users" => "Nepotrjeni", - "n_n_users" => "Obvestiti uporabnike", + "n_users_list" => "Pregled", + "n_users_list_all" => "Vsi", + "n_deleted_users" => "Izbrisani", + "n_unsigned_users" => "Odjavljeni", + "n_unconfirmed_users" => "Nepotrjeni", + "n_n_users" => "Obvestiti uporabnike", "n_no_users" => "Nihč ne bo prejel obvestila.", "n_maa" => "Managerji in administratorji", "n_no_admin" => "Noben manager ne bo prejel obvestila.", @@ -5607,7 +5608,9 @@ $lang = array ( "srv_manager_add_user4" => 'Uporabnik bo obveščen na e-mail', "srv_manager_rem_user2" => 'Odstranite uporabnika iz svojega pregleda', "srv_manager_manager" => 'Uporabniki, ki imajo managerski pregled nad vašimi anketami', - "srv_library_left" => 'Standardna vprašanja lahko dodajate v anketo', + "create" => 'Ustvari', + "create_add" => 'Ustvari in dodaj', + "srv_library_left" => 'Standardna vprašanja lahko dodajate v anketo', "srv_library_left_right" => 'Moja vprašanja, ki jih lahko dodajate v knjižnico in iz knjižnice v anketo', "srv_language_settings" => 'Jezikovne nastavitve', "srv_add_new_language" => 'Dodaj nov jezik', @@ -6217,8 +6220,11 @@ $lang = array ( 'srv_test_sett_txt' => 'Uredniške nastavitve testiranja in komentarjev', 'srv_users_viewing' => 'aktivnih urednikov', 'srv_users_viewing2' => 'Trenutno aktivni uredniki', - 'srv_users_add_new' => 'Dodaj novega uporabnika', - "srv_users_add_new_title" => 'Dodajte novega uporabnika v sistem
    Uporabnik bo obveščen na e-mail, da je bil registriran v sistem.', + 'srv_users_add_new' => 'Nov uporabnik', + "srv_users_add_new_title" => 'Ustvarite novega uporabnika v sistemu
    Uporabnik bo obveščen na e-mail, da je bil registriran v sistem.', + 'srv_users_add_assigned' => 'Dodajte pregled nad uporabniki', + "srv_users_add_assigned_title" => 'Ustvarite novega uporabnika nad katerim boste imeli pregled
    Uporabnik bo obveščen na e-mail, da je bil registriran v sistem.', + "srv_users_assigned_title" => 'Uporabniki nad katerimi imate pregled', 'srv_uredniske_nastavitve' => 'Uredniške nastavitve', 'srv_q_inicialke' => 'Respondenti naj vnesejo tudi svoje inicialke', 'srv_q_inicialke_alert' => 'Opozorilo za inicialke', diff --git a/lang/2.php b/lang/2.php index 28484da09..0e961f0f9 100644 --- a/lang/2.php +++ b/lang/2.php @@ -703,12 +703,13 @@ $lang = array ( "n_n_users" => "Notify users", "n_desc_list" => "     You requested listing of recipients. Check it
         and confirm or change the receivers.

         List of email recipients


    ", "n_list_users" => "Users", - "n_users_list_all" => "All users", - "n_deleted_users" => "Deleted users", - "n_unsigned_users" => "Unsigned users", - "n_unconfirmed_users" => "Unconfirmed users", - "n_no_users" => "No one will receive the notification.", - "n_maa" => "Managers and administrators", + "n_users_list" => "Overview", + "n_users_list_all" => "All users", + "n_deleted_users" => "Deleted users", + "n_unsigned_users" => "Unsigned users", + "n_unconfirmed_users" => "Unconfirmed users", + "n_no_users" => "No one will receive the notification.", + "n_maa" => "Managers and administrators", "n_no_admin" => "None of the administrators / managers will receive the notification.", "n_sent_admins" => "

    Notification has been sent to administrators' emails.
    ", "n_sent_now" => "

    Notification has been sent to all active users.
    ", @@ -5501,7 +5502,9 @@ $lang = array ( "srv_manager_add_user3" => 'Add existing user (you can add users with email %s)', "srv_manager_add_user4" => 'User will be notified with an e-mail', "srv_manager_rem_user2" => 'Remove user', - "srv_manager_manager" => 'Users with managing view of your surveys', + "srv_manager_manager" => 'Users with managing view of your surveys', + "create" => 'Create', + "create_add" => 'Create and add', "srv_library_left" => '', "srv_library_left_right" => '', "srv_language_settings" => 'Language settings', @@ -6107,7 +6110,10 @@ $lang = array ( 'srv_users_viewing' => 'active editors', 'srv_users_viewing2' => 'Currently active editors', 'srv_users_add_new' => 'Add new user', - "srv_users_add_new_title" => 'Add new user to the sistem
    User will be notified with an e-mail about this registration.', + "srv_users_add_new_title" => 'Create new user in the system
    User will be notified about this registration with an e-mail.', + 'srv_users_add_assigned' => 'Add assigned users', + "srv_users_add_assigned_title" => 'Create new user you will have overview on
    User will be notified about this registration with an e-mail.', + "srv_users_assigned_title" => 'Your assigned users', 'srv_uredniske_nastavitve' => 'Editor settings', 'srv_q_inicialke' => 'Respondents should enter their initials', 'srv_enter_inicialke' => 'Please enter your initials', diff --git a/public/css/admin.css b/public/css/admin.css index 4d3e0536a..956a600a6 100644 --- a/public/css/admin.css +++ b/public/css/admin.css @@ -12578,6 +12578,16 @@ ul #surveyList { .users_list_box { min-height: 250px !important; } +.users_list_box .add_user { + display: flex; + align-items: flex-start; +} +.users_list_box .add_user fieldset { + width: 500px; +} +.users_list_box .add_user fieldset.new_user { + margin: 40px 40px 0 0; +} #survey_list_inner { padding: 10px; @@ -17044,7 +17054,7 @@ form.manager_add_user label { } .dataTables_length { - padding: 5px 0; + padding: 5px 0 15px 0; } button.dt-button { diff --git a/resources/sass/admin/main_page/survey_list.scss b/resources/sass/admin/main_page/survey_list.scss index 47917f945..de9fd661f 100644 --- a/resources/sass/admin/main_page/survey_list.scss +++ b/resources/sass/admin/main_page/survey_list.scss @@ -123,8 +123,24 @@ ul { .survey_list_box { min-height: 250px !important; } + +// Seznami uporabnikov .users_list_box { - min-height: 250px !important; + min-height: 250px !important; + + + .add_user { + display: flex; + align-items: flex-start; + + fieldset{ + width: 500px; + + &.new_user{ + margin: 40px 40px 0 0; + } + } + } } #survey_list_inner { diff --git a/resources/sass/admin/users.scss b/resources/sass/admin/users.scss index a3b4c578f..05df956e3 100644 --- a/resources/sass/admin/users.scss +++ b/resources/sass/admin/users.scss @@ -68,7 +68,7 @@ form.manager_add_user { margin-bottom: 10px; } .dataTables_length { - padding: 5px 0; + padding: 5px 0 15px 0; } button.dt-button { cursor: pointer;