mlanthaler: The introduction of the HTTPResponse object broke some of my code. It's fixed now.

There was also a bug in the Director class: Director::redirectBack() didn't work because it stopped the script before outputting the headers. 
(merged from branches/gsoc)


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@42092 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2007-09-16 15:31:44 +00:00
parent 3cacc11986
commit e9d323b0d8
3 changed files with 34 additions and 18 deletions

View File

@ -54,7 +54,10 @@ class Director {
// Save the updated session back // Save the updated session back
$_SESSION = $controllerObj->getSession()->inst_getAll(); $_SESSION = $controllerObj->getSession()->inst_getAll();
if(isset($_GET['debug_profile'])) Profiler::mark("Outputting to browser");
$response->output(); $response->output();
if(isset($_GET['debug_profile'])) Profiler::unmark("Outputting to browser");
} }
if(isset($_GET['debug_profile'])) Profiler::unmark("Director","direct"); if(isset($_GET['debug_profile'])) Profiler::unmark("Director","direct");
@ -336,35 +339,42 @@ class Director {
static $siteMode; static $siteMode;
static protected $mode_additions;
/** /**
* Sets the site mode (if it is the public site or the cms), * Sets the site mode (if it is the public site or the cms),
* and runs registered modules. * and runs registered modules.
*/ */
static protected $mode_additions;
/**
* Sets the site mode (if it is the public site or the cms),
* and runs registered modules.
*/
static function set_site_mode($mode) { static function set_site_mode($mode) {
Director::$siteMode = $mode; Director::$siteMode = $mode;
if(isset(self::$mode_additions[$mode])) if(isset(self::$mode_additions[$mode])) {
foreach(self::$mode_additions[$mode] as $extension) { foreach(self::$mode_additions[$mode] as $extension) {
call_user_func($extension); call_user_func($extension);
}
} }
} }
static function get_site_mode() { static function get_site_mode() {
return Director::$siteMode; return Director::$siteMode;
} }
/** /**
* Allows a module to register with the director to be run once * Allows a module to register with the director to be run once
* the controller is instantiated. The optional 'mode' parameter * the controller is instantiated. The optional 'mode' parameter
* can be either 'site' or 'cms', as those are the two values currently * can be either 'site' or 'cms', as those are the two values currently
* set by controllers. The callback function will be run at the * set by controllers. The callback function will be run at the
* initialization of the relavant controller. * initialization of the relavant controller.
*/ */
static function extend_site($function, $mode='site') { static function extendSite($function, $mode='site') {
self::$mode_additions[$mode][] = $function; self::$mode_additions[$mode][] = $function;
} }
static protected $environment_type; static protected $environment_type;
/** /**

View File

@ -128,6 +128,7 @@ class OpenIDAuthenticator extends Authenticator {
$redirect_url->message); $redirect_url->message);
} else { } else {
Director::redirect($redirect_url); Director::redirect($redirect_url);
return false;
} }
} else { } else {
@ -203,6 +204,9 @@ class OpenIDAuthenticator_Controller extends Controller {
* @param array $requestParams Passed request parameters * @param array $requestParams Passed request parameters
*/ */
function run($requestParams) { function run($requestParams) {
Controller::$currentController = $this;
$this->response = new HTTPResponse();
parent::init(); parent::init();
if(isset($_GET['debug_profile'])) if(isset($_GET['debug_profile']))
@ -281,6 +285,8 @@ class OpenIDAuthenticator_Controller extends Controller {
} }
} }
} }
return $this->response;
} }

View File

@ -372,7 +372,7 @@ class Security extends Controller {
} else { } else {
self::permissionFailure($this, self::permissionFailure($this,
'You must be logged in in order to change your password!'); 'You must be logged in in order to change your password!');
die(); return;
} }
} }
@ -423,7 +423,7 @@ class Security extends Controller {
*/ */
static function findAnAdministrator($username = 'admin', $password = 'password') { static function findAnAdministrator($username = 'admin', $password = 'password') {
$permission = DataObject::get_one("Permission", "`Code` = 'ADMIN'", true, "ID"); $permission = DataObject::get_one("Permission", "`Code` = 'ADMIN'", true, "ID");
$adminGroup = null; $adminGroup = null;
if($permission) $adminGroup = DataObject::get_one("Group", "`ID` = '{$permission->GroupID}'", true, "ID"); if($permission) $adminGroup = DataObject::get_one("Group", "`ID` = '{$permission->GroupID}'", true, "ID");