From: mjollnir_ Date: Thu, 31 Jan 2008 22:02:44 +0000 (+0000) Subject: Merged from MOODLE_19_STABLE: MDL-12440: take out auth title and description into... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=2a5f4a885b63b91d946044fcc8a3aec95f69abbe;p=moodle.git Merged from MOODLE_19_STABLE: MDL-12440: take out auth title and description into base class, plugins can override. updated places that use get_string to call these methods. Credit: Luke Hudson --- diff --git a/admin/auth_config.php b/admin/auth_config.php index 6848e7c551..f7f7193ab3 100644 --- a/admin/auth_config.php +++ b/admin/auth_config.php @@ -51,15 +51,9 @@ if ($frm = data_submitted() and confirm_sesskey()) { $user_fields = array("firstname", "lastname", "email", "phone1", "phone2", "department", "address", "city", "country", "description", "idnumber", "lang"); /// Get the auth title (from core or own auth lang files) - $authtitle = get_string("auth_{$auth}title", "auth"); - if ($authtitle == "[[auth_{$auth}title]]") { - $authtitle = get_string("auth_{$auth}title", "auth_{$auth}"); - } + $authtitle = $authplugin->get_title(); /// Get the auth descriptions (from core or own auth lang files) - $authdescription = get_string("auth_{$auth}description", "auth"); - if ($authdescription == "[[auth_{$auth}description]]") { - $authdescription = get_string("auth_{$auth}description", "auth_{$auth}"); - } + $authdescription = $authplugin->get_description(); // output configuration form admin_externalpage_print_header(); diff --git a/lib/adminlib.php b/lib/adminlib.php index bc4332f3c9..0f0763248a 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -3480,10 +3480,7 @@ class admin_setting_special_registerauth extends admin_setting_configselect { continue; } // Get the auth title (from core or own auth lang files) - $authtitle = get_string("auth_{$auth}title", "auth"); - if ($authtitle == "[[auth_{$auth}title]]") { - $authtitle = get_string("auth_{$auth}title", "auth_{$auth}"); - } + $authtitle = $authplugin->get_title(); $this->choices[$auth] = $authtitle; } return true; @@ -3603,10 +3600,8 @@ class admin_setting_manageauths extends admin_setting { if (strpos($auth, $query) !== false) { return true; } - $authtitle = get_string("auth_{$auth}title", "auth"); - if ($authtitle == "[[auth_{$auth}title]]") { - $authtitle = get_string("auth_{$auth}title", "auth_{$auth}"); - } + $authplugin = get_auth_plugin($auth); + $authtitle = $authplugin->get_title(); if (strpos($textlib->strtolower($authtitle), $query) !== false) { return true; } @@ -3639,10 +3634,7 @@ class admin_setting_manageauths extends admin_setting { foreach ($authsenabled as $auth) { $authplugin = get_auth_plugin($auth); /// Get the auth title (from core or own auth lang files) - $authtitle = get_string("auth_{$auth}title", "auth"); - if ($authtitle == "[[auth_{$auth}title]]") { - $authtitle = get_string("auth_{$auth}title", "auth_{$auth}"); - } + $authtitle = $authplugin->get_title(); /// Apply titles $displayauths[$auth] = $authtitle; if ($authplugin->can_signup()) { @@ -3656,10 +3648,7 @@ class admin_setting_manageauths extends admin_setting { } $authplugin = get_auth_plugin($auth); /// Get the auth title (from core or own auth lang files) - $authtitle = get_string("auth_{$auth}title", "auth"); - if ($authtitle == "[[auth_{$auth}title]]") { - $authtitle = get_string("auth_{$auth}title", "auth_{$auth}"); - } + $authtitle = $authplugin->get_title(); /// Apply titles $displayauths[$auth] = $authtitle; if ($authplugin->can_signup()) { diff --git a/lib/authlib.php b/lib/authlib.php index ca942381e0..242d2cd3a4 100644 --- a/lib/authlib.php +++ b/lib/authlib.php @@ -320,6 +320,28 @@ class auth_plugin_base { //override if needed } + + /** + * Return the properly translated human-friendly title of this auth plugin + */ + function get_title() { + $authtitle = get_string("auth_{$this->authtype}title", "auth"); + if ($authtitle == "[[auth_{$this->authtype}title]]") { + $authtitle = get_string("auth_{$this->authtype}title", "auth_{$this->authtype}"); + } + return $authtitle; + } + + /** + * Get the auth description (from core or own auth lang files) + */ + function get_description() { + $authdescription = get_string("auth_{$this->authtype}description", "auth"); + if ($authdescription == "[[auth_{$this->authtype}description]]") { + $authdescription = get_string("auth_{$this->authtype}description", "auth_{$this->authtype}"); + } + return $authdescription; + } } ?>