]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #2237: Added 'reason' parameter to forward() to allow proper headers and more...
authorewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 20 Nov 2010 09:49:45 +0000 (09:49 +0000)
committerewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 20 Nov 2010 09:49:45 +0000 (09:49 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7373 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/handlers/pagehandler.php
engine/lib/actions.php
engine/lib/elgglib.php
engine/lib/group.php
engine/lib/sessions.php

index e824b523218f9b5537571509e67fea5e4652565e..7d293c3e4dd540dca069468525d0218ee2dc1271 100644 (file)
@@ -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
index bcc156e4f64f35a825a2469f64a2a627290715fc..bdd519458132fc5218cc24f84ff28d273e3eeac1 100644 (file)
@@ -268,7 +268,7 @@ function action_gatekeeper() {
                return TRUE;
        }
 
-       forward();
+       forward('', 'csrf');
        exit;
 }
 
index fb7a4578b978440ec046f18d1e4c65fe7a4b2de5..3e09c118ac34c43ee6bdce7f23481d8343c70438 100644 (file)
@@ -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}");
index def82fa9c18e69dddde7e9c9ec96036adfcfcf9b..dd2eff7f8a70adccc72942ba2ca25602da09d5a2 100644 (file)
@@ -637,7 +637,7 @@ function group_gatekeeper($forward = true) {
 
        if ($forward && $allowed == false) {
                register_error(elgg_echo('membershiprequired'));
-               forward($url);
+               forward($url, 'member');
                exit;
        }
 
index c42af2ed33e08317084d0923af3e2de0f42c295e..5cb3e8260379cce5ef9644bc27dcd26cb935ba4c 100644 (file)
@@ -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');
        }
 }