diff --git a/system/Controllers/SettingsController.php b/system/Controllers/SettingsController.php index 236f067..226e6c2 100644 --- a/system/Controllers/SettingsController.php +++ b/system/Controllers/SettingsController.php @@ -645,7 +645,7 @@ class SettingsController extends Controller # use vue template for many users $totalusers = count($users); - if($totalusers > 2) + if($totalusers > 10) { $template = 'settings/userlistvue.twig'; } diff --git a/system/Models/User.php b/system/Models/User.php index a504aec..359d4f0 100644 --- a/system/Models/User.php +++ b/system/Models/User.php @@ -8,14 +8,12 @@ class User extends WriteYaml private $userDir = __DIR__ . '/../../settings/users'; public function getUsers() - { - $userDir = __DIR__ . '/../../settings/users'; - + { /* check if users directory exists */ - if(!is_dir($userDir)){ return array(); } + if(!is_dir($this->userDir)){ return array(); } /* get all user files */ - $userfiles = array_diff(scandir($userDir), array('..', '.', '.logins', 'tmuserindex-mail.txt', 'tmuserindex-role.txt')); + $userfiles = array_diff(scandir($this->userDir), array('..', '.', '.logins', 'tmuserindex-mail.txt', 'tmuserindex-role.txt')); $usernames = array(); foreach($userfiles as $key => $userfile) @@ -143,8 +141,24 @@ class User extends WriteYaml # accepts email with or without asterix and returns userdata public function findUsersByEmail($email) { - # get all user files - $usernames = $this->getUsers(); + $usernames = []; + + # Make sure that we scan only the first 11 files even if there are some thousand users. + if ($dh = opendir($this->userDir)) + { + $count = 1; + $exclude = array('..', '.', '.logins', 'tmuserindex-mail.txt', 'tmuserindex-role.txt'); + + while ( ($userfile = readdir($dh)) !== false && $count <= 11 ) + { + if(in_array($userfile, $exclude)){ continue; } + + $usernames[] = str_replace('.yaml', '', $userfile); + $count++; + } + + closedir($dh); + } $countusers = count($usernames); @@ -154,9 +168,9 @@ class User extends WriteYaml } # use a simple dirty search if there are less than 10 users (only in use for new user registrations) - if($countusers <= 4) + if($countusers <= 10) { - foreach($usernames as $key => $username) + foreach($usernames as $username) { $userdata = $this->getSecureUser($username); @@ -169,7 +183,7 @@ class User extends WriteYaml } # if there are more than 10 users, search with an index - $usermails = $this->getUserMailIndex($usernames); + $usermails = $this->getUserMailIndex(); # search with starting asterix, ending asterix or without asterix if($email[0] == '*') @@ -217,26 +231,25 @@ class User extends WriteYaml return false; } - public function getUserMailIndex($usernames) + public function getUserMailIndex() { - $userDir = __DIR__ . '/../../settings/users'; - - if(file_exists($userDir . DIRECTORY_SEPARATOR . 'tmuserindex-mail.txt')) + if(file_exists($this->userDir . DIRECTORY_SEPARATOR . 'tmuserindex-mail.txt')) { # read and return the file - $usermailindex = file($userDir . DIRECTORY_SEPARATOR . 'tmuserindex-mail.txt'); + $usermailindex = file($this->userDir . DIRECTORY_SEPARATOR . 'tmuserindex-mail.txt'); } - $usermailindex = array(); + $usernames = $this->getUsers(); + $usermailindex = []; - foreach($usernames as $key => $username) + foreach($usernames as $username) { $userdata = $this->getSecureUser($username); $usermailindex[$userdata['email']] = $username; } - file_put_contents($userDir . DIRECTORY_SEPARATOR . 'tmuserindex-mail.txt', var_export($usermailindex, TRUE)); + file_put_contents($this->userDir . DIRECTORY_SEPARATOR . 'tmuserindex-mail.txt', var_export($usermailindex, TRUE)); return $usermailindex; } @@ -244,10 +257,11 @@ class User extends WriteYaml # accepts email with or without asterix and returns usernames public function findUsersByRole($role) { + +/* # get all user files $usernames = $this->getUsers(); -/* $countusers = count($usernames); if($countusers == 0) @@ -276,7 +290,7 @@ class User extends WriteYaml return $userdata; } */ - $userroles = $this->getUserRoleIndex($usernames); + $userroles = $this->getUserRoleIndex(); if(isset($userroles[$role])) { @@ -286,26 +300,25 @@ class User extends WriteYaml return false; } - public function getUserRoleIndex($usernames) + public function getUserRoleIndex() { - $userDir = __DIR__ . '/../../settings/users'; - - if(file_exists($userDir . DIRECTORY_SEPARATOR . 'tmuserindex-role.txt')) + if(file_exists($this->userDir . DIRECTORY_SEPARATOR . 'tmuserindex-role.txt')) { # read and return the file - $userroleindex = file($userDir . DIRECTORY_SEPARATOR . 'tmuserindex-role.txt'); + $userroleindex = file($this->userDir . DIRECTORY_SEPARATOR . 'tmuserindex-role.txt'); } - - $userroleindex = array(); - foreach($usernames as $key => $username) + $usernames = $this->getUsers(); + $userroleindex = []; + + foreach($usernames as $username) { $userdata = $this->getSecureUser($username); $userroleindex[$userdata['userrole']][] = $username; } - file_put_contents($userDir . DIRECTORY_SEPARATOR . 'tmuserindex-role.txt', var_export($userroleindex, TRUE)); + file_put_contents($this->userDir . DIRECTORY_SEPARATOR . 'tmuserindex-role.txt', var_export($userroleindex, TRUE)); return $userroleindex; } diff --git a/system/author/js/vue-userlist.js b/system/author/js/vue-userlist.js index 7c0720d..e42e599 100644 --- a/system/author/js/vue-userlist.js +++ b/system/author/js/vue-userlist.js @@ -120,7 +120,7 @@ let userlist = new Vue({ holduserdata: false, userroles: userroles, pagenumber: 1, - pagesize: 3, + pagesize: 10, pages: 0, root: document.getElementById("main").dataset.url, error: false, diff --git a/themes/cyanine/cyanine.yaml b/themes/cyanine/cyanine.yaml index 7f310a4..4346854 100644 --- a/themes/cyanine/cyanine.yaml +++ b/themes/cyanine/cyanine.yaml @@ -1,5 +1,5 @@ name: Cyanine Theme -version: 1.1.2 +version: 1.1.3 description: Cyanine is a modern and flexible multi-purpose theme and the standard theme for typemill. author: Trendschau homepage: https://trendschau.net diff --git a/themes/cyanine/layout.twig b/themes/cyanine/layout.twig index 889ceb4..5f5154e 100644 --- a/themes/cyanine/layout.twig +++ b/themes/cyanine/layout.twig @@ -52,7 +52,7 @@ } .grid-main{ max-width: 56rem; - margin: auto; + margin: 0 auto; } } {% elseif settings.themes.cyanine.layoutsize == 'full' %}