cosmocode / virtualgroup

Create virtual user groups in DokuWiki
http://www.dokuwiki.org/plugin:virtualgroup
GNU General Public License v2.0
10 stars 5 forks source link

Groups Array contains duplicates after multiple reloads/changes of virtual groups #1

Closed einhirn closed 14 years ago

einhirn commented 14 years ago

I found out that the virtualgroup plugin adds the virtual groups for a user again and again and again. Check for yourself by adding a group via virtualgroup plugin and then "do=check". Reload. Reload...

Anyway: This is the patch - it just adds "array_unique" around the "array_merge" (in case the patch fails for any reason):

            --- action.php  2010-01-18 06:21:48.000000000 +0100
            +++ action.php  2010-01-25 09:41:12.000000000 +0100
            @@ -27,7 +27,7 @@
                            if (!isset($this->users[$_SERVER['REMOTE_USER']])) {
                                    return;
                            }
            -               $grps = array_merge($USERINFO['grps'],$this->users[$_SERVER['REMOTE_USER']]);
            +               $grps = array_unique(array_merge($USERINFO['grps'],$this->users[$_SERVER['REMOTE_USER']]));
                            $USERINFO['grps']               = $grps;
                            $auth->info['grps']     = $grps;
                            $auth->users[$_SERVER['REMOTE_USER']]['grps'] = $grps;
            @@ -39,7 +39,7 @@
                     * load the users -> group connection
                     */
                    function _load() {
            -               // determein the path to the data
            +               // determine the path to the data
                            $userFile = DOKU_INC . 'data/virtualgrp.php';

                            // if there is no file we hava no data ;-)
dom-mel commented 14 years ago

done see 256d00dc54f5f00ffbf7f18445b2cc6a45075633