user/plugins/simplesearch/simplesearch.php
/**
     * Filter the pages, and return only the pages the user has access to.
     * Implementation based on Login Plugin authorizePage() function.
     */
Filter the pages, and return only the pages the user has access to.
Implementation based on Login Plugin authorizePage() function.
Filter the pages and return only the pages the user has access to . Implementation based on Login Plugin authorizePage () function .
public function checkForPermissions($collection)
    {
        $returnCollection = new Collection();
        foreach ($collection as $page) {
            $header = $page->header();
            $rules = isset($header->access) ? (array)$header->access : [];
            if ($this->config->get('plugins.login.parent_acl')) {
                if (!$rules) {
                    $parent = $page->parent();
                    while (!$rules and $parent) {
                        $header = $parent->header();
                        $rules = isset($header->access) ? (array)$header->access : [];
                        $parent = $parent->parent();
                    }
                }
            }
            if (!$rules) {
                $returnCollection[$page->path()] = ['slug' => $page->slug()];
            } else {
                foreach ($rules as $rule => $value) {
                    if (is_array($value)) {
                        foreach ($value as $nested_rule => $nested_value) {
                            if ($user->authorize($rule . '.' . $nested_rule) == $nested_value) {
                                $returnCollection[$page->path()] = ['slug' => $page->slug()];
                                break;
                            }
                        }
                    } else {
                        if ($user->authorize($rule) == $value) {
                            $returnCollection[$page->path()] = ['slug' => $page->slug()];
                            break;
                        }
                    }
                }
            }
        }
        return $returnCollection;
    }
public function checkForPermissions ( $ collection ) { $ returnCollection = new Collection ( ) ; foreach ( $ collection as $ page ) { $ header = $ page -> header ( ) ; $ rules = isset ( $ header -> access ) ? ( array ) $ header -> access : [ ] ; if ( $ this -> config -> get ( 'plugins.login.parent_acl' ) ) { if ( ! $ rules ) { $ parent = $ page -> parent ( ) ; while ( ! $ rules and $ parent ) { $ header = $ parent -> header ( ) ; $ rules = isset ( $ header -> access ) ? ( array ) $ header -> access : [ ] ; $ parent = $ parent -> parent ( ) ; } } } if ( ! $ rules ) { $ returnCollection [ $ page -> path ( ) ] = [ 'slug' => $ page -> slug ( ) ] ; } else { foreach ( $ rules as $ rule => $ value ) { if ( is_array ( $ value ) ) { foreach ( $ value as $ nested_rule => $ nested_value ) { if ( $ user -> authorize ( $ rule . '.' . $ nested_rule ) == $ nested_value ) { $ returnCollection [ $ page -> path ( ) ] = [ 'slug' => $ page -> slug ( ) ] ; break ; } } } else { if ( $ user -> authorize ( $ rule ) == $ value ) { $ returnCollection [ $ page -> path ( ) ] = [ 'slug' => $ page -> slug ( ) ] ; break ; } } } } } return $ returnCollection ; }
Filter the pages, and return only the pages the user has access to.
Filter the pages and return only the pages the user has access to .
//$user = $this->grav['user']; // If page has no ACL rules, use its parent's rules // Continue to the page if it has no ACL rules. // Continue to the page if user is authorized to access the page.