diff options
Diffstat (limited to 'engine/lib')
-rw-r--r-- | engine/lib/elgglib.php | 19 | ||||
-rw-r--r-- | engine/lib/sites.php | 45 | ||||
-rw-r--r-- | engine/lib/upgrades/2010050701.php | 2 |
3 files changed, 65 insertions, 1 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 9ee85c559..4e141bb84 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -3107,16 +3107,28 @@ function __elgg_shutdown_hook() { function elgg_init() { // Page handler for JS register_page_handler('js','js_page_handler'); - + // Register an event triggered at system shutdown register_shutdown_function('__elgg_shutdown_hook'); } +function elgg_walled_garden_index() { + global $CONFIG; + + $login = elgg_view('account/forms/login'); + $layout = elgg_view_layout('one_column', $login); + + echo page_draw('', $layout); + return TRUE; +} + /** * Boot Elgg * @return unknown_type */ function elgg_boot() { + global $CONFIG; + // Actions register_action('comments/add'); register_action('comments/delete'); @@ -3126,6 +3138,11 @@ function elgg_boot() { elgg_view_register_simplecache('css'); elgg_view_register_simplecache('js/friendsPickerv1'); elgg_view_register_simplecache('js/initialise_elgg'); + + // check for external page view + if (isset($CONFIG->site) && $CONFIG->site instanceof ElggSite) { + $CONFIG->site->check_walled_garden(); + } } /** diff --git a/engine/lib/sites.php b/engine/lib/sites.php index 13521a257..c976384c2 100644 --- a/engine/lib/sites.php +++ b/engine/lib/sites.php @@ -243,6 +243,51 @@ class ElggSite extends ElggEntity { 'url', )); } + + public function check_walled_garden() { + global $CONFIG; + + if ($CONFIG->walled_garden && !isloggedin()) { + register_plugin_hook('index', 'system', 'elgg_walled_garden_index'); + + if (!$this->is_public_page()) { + register_error(elgg_echo('walled_garden:private_page') . current_page_url()); + forward(); + } + } + } + + public function is_public_page($url='') { + global $CONFIG; + + if (empty($url)) { + $url = current_page_url(); + + // do not check against URL queries + if ($pos = strpos($url, '?')) { + $url = substr($url, 0, $pos); + } + } + + // default public pages + $public = array( + $CONFIG->url, + "{$CONFIG->url}action/login", + "{$CONFIG->url}upgrade.php", + ); + + // include a hook for plugin authors to include public pages + + // lookup admin-specific public pages + + // allow public pages + if (in_array($url, $public)) { + return TRUE; + } + + // non-public page + return FALSE; + } } /** diff --git a/engine/lib/upgrades/2010050701.php b/engine/lib/upgrades/2010050701.php index 33e4b5bae..4a02a77c6 100644 --- a/engine/lib/upgrades/2010050701.php +++ b/engine/lib/upgrades/2010050701.php @@ -8,8 +8,10 @@ $access = elgg_set_ignore_access(TRUE); if (is_plugin_enabled('walledgarden')) { disable_plugin('walledgarden'); set_config('allow_registration', FALSE); + set_config('walled_garden', TRUE); } else { set_config('allow_registration', TRUE); + set_config('walled_garden', FALSE); } elgg_set_ignore_access($access); |