diff options
author | Andreas Gohr <andi@splitbrain.org> | 2019-07-14 20:50:16 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2019-07-14 20:50:16 +0200 |
commit | 2b9c4a056d6957ab3952515cfc795f8dd01cf5e6 (patch) | |
tree | e17a9cf8a473e7e21a04cffe477464547b4230bd /lib/plugins/authplain/auth.php | |
parent | 27f63a230ac7def28270ac72832681ef70e10853 (diff) | |
parent | 8902b37d8e5bd11eeb34c7cc6879533fd1a8702c (diff) | |
download | dokuwiki-2b9c4a056d6957ab3952515cfc795f8dd01cf5e6.tar.gz dokuwiki-2b9c4a056d6957ab3952515cfc795f8dd01cf5e6.zip |
Merge branch 'master' into psr2
* master: (34 commits)
fix color for noninstalled extensions
show disabled extensions in gray
warn about inaccessible repo api
bugfix: access check was never cached
First go on a CLI component for the extension manager
use strict type comparison
translation update
translation update
fix #dokuwiki__sitetools current item not in highlight due to Greebo change
authplain: Add tests for group retrieval
authplain: Add a simple method for retrieving user groups
translation update
Negative string offsets are allowed in PHP 7.1+ only
improve memory check output
fix and test php_to_byte() related to #2756 #2556
translation update
translation update
translation update
translation update
translation update
...
Diffstat (limited to 'lib/plugins/authplain/auth.php')
-rw-r--r-- | lib/plugins/authplain/auth.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/plugins/authplain/auth.php b/lib/plugins/authplain/auth.php index 374e7179c..d95c86de2 100644 --- a/lib/plugins/authplain/auth.php +++ b/lib/plugins/authplain/auth.php @@ -46,6 +46,7 @@ class auth_plugin_authplain extends DokuWiki_Auth_Plugin } $this->cando['getUsers'] = true; $this->cando['getUserCount'] = true; + $this->cando['getGroups'] = true; } $this->pregsplit_safe = version_compare(PCRE_VERSION, '6.7', '>='); @@ -319,6 +320,29 @@ class auth_plugin_authplain extends DokuWiki_Auth_Plugin } /** + * Retrieves groups. + * Loads complete user data into memory before searching for groups. + * + * @param int $start index of first group to be returned + * @param int $limit max number of groups to be returned + * @return array + */ + public function retrieveGroups($start = 0, $limit = 0) + { + $groups = []; + + if ($this->users === null) $this->_loadUserData(); + foreach($this->users as $user => $info) { + $groups = array_merge($groups, array_diff($info['grps'], $groups)); + } + + if($limit > 0) { + return array_splice($groups, $start, $limit); + } + return array_splice($groups, $start); + } + + /** * Only valid pageid's (no namespaces) for usernames * * @param string $user |