public function sectionSites($includeMainSite = true, $mainSiteTitle = 'Main site', $member = null)
    {
        if ($mainSiteTitle == 'Main site') {
            $mainSiteTitle = _t('Subsites.MainSiteTitle', 'Main site');
        }

        // Rationalise member arguments
        if (!$member) {
            $member = Security::getCurrentUser();
        }
        if (!$member) {
            return ArrayList::create();
        }
        if (!is_object($member)) {
            $member = DataObject::get_by_id(Member::class, $member);
        }

        // Collect permissions - honour the LeftAndMain::required_permission_codes, current model requires
        // us to check if the user satisfies ALL permissions. Code partly copied from LeftAndMain::canView.
        $codes = [];
        $extraCodes = Config::inst()->get(get_class($this->owner), 'required_permission_codes');
        if ($extraCodes !== false) {
            if ($extraCodes) {
                $codes = array_merge($codes, (array)$extraCodes);
            } else {
                $codes[] = sprintf('CMS_ACCESS_%s', get_class($this->owner));
            }
        } else {
            // Check overriden - all subsites accessible.
            return Subsite::all_sites();
        }

        // Find subsites satisfying all permissions for the Member.
        $codesPerSite = [];
        $sitesArray = [];
        foreach ($codes as $code) {
            $sites = Subsite::accessible_sites($code, $includeMainSite, $mainSiteTitle, $member);
            foreach ($sites as $site) {
                // Build the structure for checking how many codes match.
                $codesPerSite[$site->ID][$code] = true;

                // Retain Subsite objects for later.
                $sitesArray[$site->ID] = $site;
            }
        }

        // Find sites that satisfy all codes conjuncitvely.
        $accessibleSites = new ArrayList();
        foreach ($codesPerSite as $siteID => $siteCodes) {
            if (count($siteCodes) == count($codes)) {
                $accessibleSites->push($sitesArray[$siteID]);
            }
        }

        return $accessibleSites;
    }
public function sectionSites($includeMainSite = true, $mainSiteTitle = 'Main site', $member = null)
    {
        if ($mainSiteTitle == 'Main site') {
            $mainSiteTitle = _t('Subsites.MainSiteTitle', 'Main site');
        }

        // Rationalise member arguments
        if (!$member) {
            $member = Security::getCurrentUser();
        }
        if (!$member) {
            return ArrayList::create();
        }
        if (!is_object($member)) {
            $member = DataObject::get_by_id(Member::class, $member);
        }

        // Collect permissions - honour the LeftAndMain::required_permission_codes, current model requires
        // us to check if the user satisfies ALL permissions. Code partly copied from LeftAndMain::canView.
        $codes = [];
        $extraCodes = Config::inst()->get(get_class($this->owner), 'required_permission_codes');
        if ($extraCodes !== false) {
            if ($extraCodes) {
                $codes = array_merge($codes, (array)$extraCodes);
            } else {
                $codes[] = sprintf('CMS_ACCESS_%s', get_class($this->owner));
            }
        } else {
            // Check overriden - all subsites accessible.
            return Subsite::all_sites();
        }

        // Find subsites satisfying all permissions for the Member.
        $codesPerSite = [];
        $sitesArray = [];
        foreach ($codes as $code) {
            $sites = Subsite::accessible_sites($code, $includeMainSite, $mainSiteTitle, $member);
            foreach ($sites as $site) {
                // Build the structure for checking how many codes match.
                $codesPerSite[$site->ID][$code] = true;

                // Retain Subsite objects for later.
                $sitesArray[$site->ID] = $site;
            }
        }

        // Find sites that satisfy all codes conjuncitvely.
        $accessibleSites = new ArrayList();
        foreach ($codesPerSite as $siteID => $siteCodes) {
            if (count($siteCodes) == count($codes)) {
                $accessibleSites->push($sitesArray[$siteID]);
            }
        }

        return $accessibleSites;
    }
public function sectionSites ( $ includeMainSite = true , $ mainSiteTitle = 'Main site' , $ member = null ) { if ( $ mainSiteTitle == 'Main site' ) { $ mainSiteTitle = _t ( 'Subsites.MainSiteTitle' , 'Main site' ) ; } // Rationalise member arguments if ( ! $ member ) { $ member = Security :: getCurrentUser ( ) ; } if ( ! $ member ) { return ArrayList :: create ( ) ; } if ( ! is_object ( $ member ) ) { $ member = DataObject :: get_by_id ( Member :: class , $ member ) ; } // Collect permissions - honour the LeftAndMain::required_permission_codes, current model requires // us to check if the user satisfies ALL permissions. Code partly copied from LeftAndMain::canView. $ codes = [ ] ; $ extraCodes = Config :: inst ( ) -> get ( get_class ( $ this -> owner ) , 'required_permission_codes' ) ; if ( $ extraCodes !== false ) { if ( $ extraCodes ) { $ codes = array_merge ( $ codes , ( array ) $ extraCodes ) ; } else { $ codes [ ] = sprintf ( 'CMS_ACCESS_%s' , get_class ( $ this -> owner ) ) ; } } else { // Check overriden - all subsites accessible. return Subsite :: all_sites ( ) ; } // Find subsites satisfying all permissions for the Member. $ codesPerSite = [ ] ; $ sitesArray = [ ] ; foreach ( $ codes as $ code ) { $ sites = Subsite :: accessible_sites ( $ code , $ includeMainSite , $ mainSiteTitle , $ member ) ; foreach ( $ sites as $ site ) { // Build the structure for checking how many codes match. $ codesPerSite [ $ site -> ID ] [ $ code ] = true ; // Retain Subsite objects for later. $ sitesArray [ $ site -> ID ] = $ site ; } } // Find sites that satisfy all codes conjuncitvely. $ accessibleSites = new ArrayList ( ) ; foreach ( $ codesPerSite as $ siteID => $ siteCodes ) { if ( count ( $ siteCodes ) == count ( $ codes ) ) { $ accessibleSites -> push ( $ sitesArray [ $ siteID ] ) ; } } return $ accessibleSites ; }
Find all subsites accessible for current user on this controller.

@param bool $includeMainSite
@param string $mainSiteTitle
@param null $member
@return ArrayList of <a href='psi_element://Subsite'>Subsite</a> instances.
instances.
Find all subsites accessible for current user on this controller .