I’m making an authentication script with groups and roles. This function
checks if the groups the user belongs to specified groups and compares
them to the groups required. However, since this is a loop, the function
doesn’t return true or false as expected. If I call the function and
require 3 groups, and the user belongs to only one of them, he is still
accepted. Is this method right thinking? Should I make the function stop
somehow when it returns false for the first time? All suggestions and
comments are appreciated. Thanks.
This is the function:
            function require_groups() {
                        if (!isset($this->user['groups'])) {
                                    $this->user['groups'] =
                        $groups = func_get_args();
                        foreach ($groups as $value) {
(!isset($this->user['groups'][$value]) ||
!$this->user['groups'][$value]) {
                                                return false;
                                                return true;
And I call it like this: require_groups(“admins”,
This returns true. 
Sævar Öfjörð
þetta reddast - hönnunarlausnir
oft\Signatures\www.reddast.is> www.reddast.is

Reply via email to