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

View File

@ -128,6 +128,7 @@ class OpenIDAuthenticator extends Authenticator {
$redirect_url->message);
} else {
Director::redirect($redirect_url);
return false;
}
} else {
@ -203,6 +204,9 @@ class OpenIDAuthenticator_Controller extends Controller {
* @param array $requestParams Passed request parameters
*/
function run($requestParams) {
Controller::$currentController = $this;
$this->response = new HTTPResponse();
parent::init();
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 {
self::permissionFailure($this,
'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') {
$permission = DataObject::get_one("Permission", "`Code` = 'ADMIN'", true, "ID");
$adminGroup = null;
if($permission) $adminGroup = DataObject::get_one("Group", "`ID` = '{$permission->GroupID}'", true, "ID");