MDL-40613 auth: moved lang string to common auth file

Also fixed call to get_string() and defined var 'errorlogtag'
in base class.

AMOS BEGIN
 MOV [auth_dbusernotexist,auth_db],[auth_usernotexist,auth]
AMOS END
This commit is contained in:
Mark Nelson 2017-12-19 13:12:38 +08:00
parent 4e133e775c
commit 4afad1faeb
4 changed files with 11 additions and 3 deletions

View File

@ -42,6 +42,7 @@ class auth_plugin_db extends auth_plugin_base {
$this->authtype = 'db';
$this->config = get_config('auth_db');
$this->errorlogtag = '[AUTH DB] ';
if (empty($this->config->extencoding)) {
$this->config->extencoding = 'utf-8';
}

View File

@ -66,7 +66,6 @@ $string['auth_dbupdateusers_description'] = 'As well as inserting new users, upd
$string['auth_dbupdatinguser'] = 'Updating user {$a->name} id {$a->id}';
$string['auth_dbuser'] = 'Username with read access to the database';
$string['auth_dbuser_key'] = 'DB user';
$string['auth_dbusernotexist'] = 'Cannot update non-existent user: {$a}';
$string['auth_dbuserstoadd'] = 'User entries to add: {$a}';
$string['auth_dbuserstoremove'] = 'User entries to remove: {$a}';
$string['pluginname'] = 'External database';

View File

@ -64,6 +64,7 @@ $string['auth_updateremote_ldap'] = '<p><b>Note:</b> Updating external LDAP data
$string['auth_user_create'] = 'Enable user creation';
$string['auth_user_creation'] = 'New (anonymous) users can create user accounts on the external authentication source and confirmed via email. If you enable this , remember to also configure module-specific options for user creation.';
$string['auth_usernameexists'] = 'Selected username already exists. Please choose a new one.';
$string['auth_usernotexist'] = 'Cannot update non-existent user: {$a}';
$string['auto_add_remote_users'] = 'Auto add remote users';
$string['cannotmapfield'] = 'Field "{$a->fieldname}" can not be mapped because its short name "{$a->shortname}" is too long. To enable mapping reduce the profile field short name down to {$a->charlimit} characters. <a href="{$a->link}">Edit user profile fields</a>';
$string['createpassword'] = 'Generate password and notify user';

View File

@ -110,6 +110,13 @@ class auth_plugin_base {
*/
var $customfields = null;
/**
* The tag we want to prepend to any error log messages.
*
* @var string
*/
protected $errorlogtag = '';
/**
* This is the primary method that is used by the authenticate_user_login()
* function in moodlelib.php.
@ -641,8 +648,8 @@ class auth_plugin_base {
// Get the current user record.
$user = $DB->get_record('user', array('username' => $username, 'mnethostid' => $CFG->mnet_localhost_id));
if (empty($user)) { // Trouble.
error_log($this->errorlogtag.get_string('auth_dbusernotexist', 'auth_db', '', $username));
print_error('auth_dbusernotexist', 'auth_db', '', $username);
error_log($this->errorlogtag . get_string('auth_usernotexist', 'auth', $username));
print_error('auth_usernotexist', 'auth', '', $username);
die;
}