ElggSite::checkWalledGarden PHP Method

checkWalledGarden() public method

Halts bootup and redirects to the site front page if site is in walled garden mode, no user is logged in, and the URL is not a public page.
Since: 1.8.0
public checkWalledGarden ( ) : void
return void
    public function checkWalledGarden()
    {
        global $CONFIG;
        // command line calls should not invoke the walled garden check
        if (PHP_SAPI === 'cli') {
            return;
        }
        if ($CONFIG->walled_garden) {
            if ($CONFIG->default_access == ACCESS_PUBLIC) {
                $CONFIG->default_access = ACCESS_LOGGED_IN;
            }
            _elgg_services()->hooks->registerHandler('access:collections:write', 'all', '_elgg_walled_garden_remove_public_access', 9999);
            if (!_elgg_services()->session->isLoggedIn()) {
                // override the front page
                elgg_register_page_handler('', '_elgg_walled_garden_index');
                if (!$this->isPublicPage()) {
                    if (!elgg_is_xhr()) {
                        _elgg_services()->session->set('last_forward_from', current_page_url());
                    }
                    register_error(_elgg_services()->translator->translate('loggedinrequired'));
                    forward('', 'walled_garden');
                }
            }
        }
    }