diff options
author | ewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-11-20 09:49:45 +0000 |
---|---|---|
committer | ewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-11-20 09:49:45 +0000 |
commit | deb2e286301f0b0472cd9d742fd4d0777035d5d4 (patch) | |
tree | dd54129d0a41cf0b612acf369a04814e57c897f7 | |
parent | e61a98c5dd04391db3eb7e3a087de633e2a6b0fe (diff) | |
download | elgg-deb2e286301f0b0472cd9d742fd4d0777035d5d4.tar.gz elgg-deb2e286301f0b0472cd9d742fd4d0777035d5d4.tar.bz2 |
Fixes #2237: Added 'reason' parameter to forward() to allow proper headers and more flexible destinations via plugin hooks. Also made use of this in core gatekeeper functions and in pagehandler.php
git-svn-id: http://code.elgg.org/elgg/trunk@7373 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/handlers/pagehandler.php | 5 | ||||
-rw-r--r-- | engine/lib/actions.php | 2 | ||||
-rw-r--r-- | engine/lib/elgglib.php | 5 | ||||
-rw-r--r-- | engine/lib/group.php | 2 | ||||
-rw-r--r-- | engine/lib/sessions.php | 4 |
5 files changed, 9 insertions, 9 deletions
diff --git a/engine/handlers/pagehandler.php b/engine/handlers/pagehandler.php index e824b5232..7d293c3e4 100644 --- a/engine/handlers/pagehandler.php +++ b/engine/handlers/pagehandler.php @@ -9,8 +9,7 @@ * * {@link page_handler()} explodes the pages string by / and sends it to * the page handler function as registered by {@link register_page_handler()}. - * If a valid page handler isn't found, the user will be forwarded to the site - * front page. + * If a valid page handler isn't found, plugins have a chance to provide a 404. * * @package Elgg.Core * @subpackage PageHandler @@ -23,5 +22,5 @@ $handler = get_input('handler'); $page = get_input('page'); if (!page_handler($handler, $page)) { - forward(); + forward('', '404'); }
\ No newline at end of file diff --git a/engine/lib/actions.php b/engine/lib/actions.php index bcc156e4f..bdd519458 100644 --- a/engine/lib/actions.php +++ b/engine/lib/actions.php @@ -268,7 +268,7 @@ function action_gatekeeper() { return TRUE; } - forward(); + forward('', 'csrf'); exit; } diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index fb7a4578b..3e09c118a 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -68,10 +68,11 @@ function elgg_register_class($class, $location) { * already been sent, returns FALSE. * * @param string $location URL to forward to browser to. Can be path relative to the network's URL. + * @param string $reason Short explanation for why we're forwarding * * @return False False if headers have been sent. Terminates execution if forwarding. */ -function forward($location = "") { +function forward($location = "", $reason = 'system') { global $CONFIG; if (!headers_sent()) { @@ -84,7 +85,7 @@ function forward($location = "") { // return new forward location or false to stop the forward or empty string to exit $current_page = current_page_url(); $params = array('current_url' => $current_page, 'forward_url' => $location); - $location = elgg_trigger_plugin_hook('forward', 'system', $params, $location); + $location = elgg_trigger_plugin_hook('forward', $reason, $params, $location); if ($location) { header("Location: {$location}"); diff --git a/engine/lib/group.php b/engine/lib/group.php index def82fa9c..dd2eff7f8 100644 --- a/engine/lib/group.php +++ b/engine/lib/group.php @@ -637,7 +637,7 @@ function group_gatekeeper($forward = true) { if ($forward && $allowed == false) { register_error(elgg_echo('membershiprequired')); - forward($url); + forward($url, 'member'); exit; } diff --git a/engine/lib/sessions.php b/engine/lib/sessions.php index c42af2ed3..5cb3e8260 100644 --- a/engine/lib/sessions.php +++ b/engine/lib/sessions.php @@ -497,7 +497,7 @@ function gatekeeper() { if (!isloggedin()) { $_SESSION['last_forward_from'] = current_page_url(); register_error(elgg_echo('loggedinrequired')); - forward(); + forward('', 'login'); } } @@ -512,7 +512,7 @@ function admin_gatekeeper() { if (!isadminloggedin()) { $_SESSION['last_forward_from'] = current_page_url(); register_error(elgg_echo('adminrequired')); - forward(); + forward('', 'admin'); } } |