mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
FEATURE: Default permission failure message set can be changed
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.2@65263 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
903326869a
commit
115d2a7b06
@ -65,6 +65,13 @@ class Security extends Controller {
|
||||
*/
|
||||
protected static $wordlist = '/usr/share/silverstripe/wordlist.txt';
|
||||
|
||||
/**
|
||||
* Default message set used in permission failures.
|
||||
*
|
||||
* @var array|string
|
||||
*/
|
||||
protected static $default_message_set = '';
|
||||
|
||||
/**
|
||||
* Get location of word list file
|
||||
*/
|
||||
@ -80,6 +87,15 @@ class Security extends Controller {
|
||||
static function set_word_list($wordListFile) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -109,21 +125,27 @@ class Security extends Controller {
|
||||
static function permissionFailure($controller = null, $messageSet = null) {
|
||||
// Prepare the messageSet provided
|
||||
if(!$messageSet) {
|
||||
$messageSet = array(
|
||||
'default' => _t(
|
||||
'Security.NOTEPAGESECURED',
|
||||
"That page is secured. Enter your credentials below and we will send you right along."
|
||||
),
|
||||
'alreadyLoggedIn' => _t(
|
||||
'Security.ALREADYLOGGEDIN',
|
||||
"You don't have access to this page. If you have another account that can access that page, you can log in below."
|
||||
),
|
||||
'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(self::$default_message_set) {
|
||||
$messageSet = self::$default_message_set;
|
||||
} else {
|
||||
$messageSet = array(
|
||||
'default' => _t(
|
||||
'Security.NOTEPAGESECURED',
|
||||
"That page is secured. Enter your credentials below and we will send you right along."
|
||||
),
|
||||
'alreadyLoggedIn' => _t(
|
||||
'Security.ALREADYLOGGEDIN',
|
||||
"You don't have access to this page. If you have another account that can access that page, you can log in below."
|
||||
),
|
||||
'logInAgain' => _t(
|
||||
'Security.LOGGEDOUT',
|
||||
"You have been logged out. If you would like to log in again, enter your credentials below."
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if(!is_array($messageSet)) {
|
||||
$messageSet = array('default' => $messageSet);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user