Merged revisions 56719 via svnmerge from

svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.2.2

........
  r56719 | aoneil | 2008-06-23 16:00:25 +1200 (Mon, 23 Jun 2008) | 2 lines
  
  FEATURE: Deault permission failure message set can be changed.
........


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@56914 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Andrew O'Neil 2008-06-25 04:05:28 +00:00
parent 5da717ed1d
commit 3af8299b0b

View File

@ -66,6 +66,13 @@ class Security extends Controller {
*/
public static $template_main = 'Page';
/**
* Default message set used in permission failures.
*
* @var array|string
*/
protected static $default_message_set = '';
/**
* Get location of word list file
*/
@ -82,6 +89,15 @@ class Security extends Controller {
Security::$wordlist = $wordListFile;
}
/**
* Set the default message set used in permissions failures.
*
* @param string|array $messageSet
*/
static function set_default_message_set($messageSet) {
self::$default_message_set = $messageSet;
}
/**
* Register that we've had a permission failure trying to view the given page
@ -110,6 +126,9 @@ class Security extends Controller {
static function permissionFailure($controller = null, $messageSet = null) {
// Prepare the messageSet provided
if(!$messageSet) {
if(self::$default_message_set) {
$messageSet = self::$default_message_set;
} else {
$messageSet = array(
'default' => _t(
'Security.NOTEPAGESECURED',
@ -122,9 +141,12 @@ class Security extends Controller {
'logInAgain' => _t(
'Security.LOGGEDOUT',
"You have been logged out. If you would like to log in again, enter your credentials below."
),
)
);
} else if(!is_array($messageSet)) {
}
}
if(!is_array($messageSet)) {
$messageSet = array('default' => $messageSet);
}