aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-05-12 22:00:27 +0000
committernickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-05-12 22:00:27 +0000
commit8618288ed51942c814f45c67354b14eec43c2422 (patch)
tree161e4d21f3e250d25ae288be3e483e64cabef72d
parent8ae46cff217a0ed97c0920099b505ddde3c5e431 (diff)
downloadelgg-8618288ed51942c814f45c67354b14eec43c2422.tar.gz
elgg-8618288ed51942c814f45c67354b14eec43c2422.tar.bz2
Creating a hook for plugin authors to register Walled Garden public sites.
git-svn-id: http://code.elgg.org/elgg/trunk@6016 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--account/register.php6
-rw-r--r--engine/lib/elgglib.php17
-rw-r--r--engine/lib/sites.php10
-rw-r--r--mod/sitepages/start.php13
4 files changed, 37 insertions, 9 deletions
diff --git a/account/register.php b/account/register.php
index 6da99fab2..f96494000 100644
--- a/account/register.php
+++ b/account/register.php
@@ -11,8 +11,14 @@
/**
* Start the Elgg engine
+ *
+ * WHY???? In the case this file is called thru a page handler: $CONFIG
+ * is not within the global scope (the page handler function does not include it).
+ * BUT, there _might_ exist direct calls to this file, requiring the engine
+ * to be started. Logic for both cases follow.
*/
require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
+global $CONFIG;
// check new registration allowed
if (!$CONFIG->allow_registration) {
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 4e141bb84..722e92ca0 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -3127,8 +3127,6 @@ function elgg_walled_garden_index() {
* @return unknown_type
*/
function elgg_boot() {
- global $CONFIG;
-
// Actions
register_action('comments/add');
register_action('comments/delete');
@@ -3138,11 +3136,6 @@ 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();
- }
}
/**
@@ -3301,6 +3294,15 @@ function elgg_http_url_is_identical($url1, $url2, $ignore_params = array('offset
return TRUE;
}
+function elgg_walled_garden() {
+ global $CONFIG;
+
+ // check for external page view
+ if (isset($CONFIG->site) && $CONFIG->site instanceof ElggSite) {
+ $CONFIG->site->check_walled_garden();
+ }
+}
+
/**
* Some useful constant definitions
*/
@@ -3318,3 +3320,4 @@ register_elgg_event_handler('boot', 'system', 'elgg_boot', 1000);
register_plugin_hook('unit_test', 'system', 'elgg_api_test');
register_elgg_event_handler('init', 'system', 'add_custom_menu_items', 1000);
+register_elgg_event_handler('init', 'system', 'elgg_walled_garden', 1000);
diff --git a/engine/lib/sites.php b/engine/lib/sites.php
index c976384c2..fb9b66725 100644
--- a/engine/lib/sites.php
+++ b/engine/lib/sites.php
@@ -270,18 +270,24 @@ class ElggSite extends ElggEntity {
}
// default public pages
- $public = array(
+ $defaults = array(
$CONFIG->url,
"{$CONFIG->url}action/login",
+ "{$CONFIG->url}pg/register/",
+ "{$CONFIG->url}action/register",
+ "{$CONFIG->url}account/forgotten_password.php",
+ "{$CONFIG->url}action/user/requestnewpassword",
+ "{$CONFIG->url}pg/resetpassword",
"{$CONFIG->url}upgrade.php",
);
// include a hook for plugin authors to include public pages
+ $plugins = trigger_plugin_hook('public_pages', 'walled_garden', NULL, array());
// lookup admin-specific public pages
// allow public pages
- if (in_array($url, $public)) {
+ if (in_array($url, array_merge($defaults, $plugins))) {
return TRUE;
}
diff --git a/mod/sitepages/start.php b/mod/sitepages/start.php
index afdff5635..2ce1d3312 100644
--- a/mod/sitepages/start.php
+++ b/mod/sitepages/start.php
@@ -46,6 +46,9 @@ function sitepages_init() {
// define our own ecml keywords and views
register_plugin_hook('get_keywords', 'ecml', 'sitepages_ecml_keyword_hook');
register_plugin_hook('get_views', 'ecml', 'sitepages_ecml_views_hook');
+
+ // hook into the walled garden pages
+ register_plugin_hook('public_pages', 'walled_garden', 'sitepages_public_pages');
register_action("sitepages/add", FALSE, $CONFIG->pluginspath . "sitepages/actions/add.php");
register_action("sitepages/addfront", FALSE, $CONFIG->pluginspath . "sitepages/actions/addfront.php");
@@ -215,5 +218,15 @@ function sitepages_ecml_views_hook($hook, $entity_type, $return_value, $params)
return $return_value;
}
+function sitepages_public_pages($hook, $type, $return_value, $params) {
+ global $CONFIG;
+
+ $return_value[] = "{$CONFIG->url}pg/sitepages/read/About/";
+ $return_value[] = "{$CONFIG->url}pg/sitepages/read/Terms/";
+ $return_value[] = "{$CONFIG->url}pg/sitepages/read/Privacy/";
+
+ return $return_value;
+}
+
register_elgg_event_handler('init', 'system', 'sitepages_init');
register_elgg_event_handler('pagesetup', 'system', 'sitepages_pagesetup'); \ No newline at end of file