*
* {@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
$page = get_input('page');
if (!page_handler($handler, $page)) {
- forward();
+ forward('', '404');
}
\ No newline at end of file
* 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()) {
// 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}");
if ($forward && $allowed == false) {
register_error(elgg_echo('membershiprequired'));
- forward($url);
+ forward($url, 'member');
exit;
}
if (!isloggedin()) {
$_SESSION['last_forward_from'] = current_page_url();
register_error(elgg_echo('loggedinrequired'));
- forward();
+ forward('', 'login');
}
}
if (!isadminloggedin()) {
$_SESSION['last_forward_from'] = current_page_url();
register_error(elgg_echo('adminrequired'));
- forward();
+ forward('', 'admin');
}
}