Skip to content

Commit

Permalink
MDL-27953 auth: introduced new function can_be_manually_set() to the …
Browse files Browse the repository at this point in the history
…authentication base class
  • Loading branch information
mdjnelson committed Jul 29, 2013
1 parent bdd045c commit 9b29f68
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 5 deletions.
7 changes: 4 additions & 3 deletions admin/tool/uploaduser/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,13 @@ function uu_process_template_callback($username, $firstname, $lastname, $block)
* @return array type=>name
*/
function uu_supported_auths() {
// only following plugins are guaranteed to work properly
$whitelist = array('manual', 'nologin', 'none', 'email');
// Get all the enabled plugins.
$plugins = get_enabled_auth_plugins();
$choices = array();
foreach ($plugins as $plugin) {
if (!in_array($plugin, $whitelist)) {
$objplugin = get_auth_plugin($plugin);
// If the plugin can not be manually set skip it.
if (!$objplugin->can_be_manually_set()) {
continue;
}
$choices[$plugin] = get_string('pluginname', "auth_{$plugin}");
Expand Down
9 changes: 9 additions & 0 deletions auth/email/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,15 @@ function can_reset_password() {
return true;
}

/**
* Returns true if plugin can be manually set.
*
* @return bool
*/
function can_be_manually_set() {
return true;
}

/**
* Prints a form for configuring this authentication plugin.
*
Expand Down
9 changes: 9 additions & 0 deletions auth/ldap/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,15 @@ function can_reset_password() {
return !empty($this->config->stdchangepassword);
}

/**
* Returns true if plugin can be manually set.
*
* @return bool
*/
function can_be_manually_set() {
return true;
}

/**
* Returns true if plugin allows signup and user creation.
*
Expand Down
9 changes: 9 additions & 0 deletions auth/manual/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ function can_reset_password() {
return true;
}

/**
* Returns true if plugin can be manually set.
*
* @return bool
*/
function can_be_manually_set() {
return true;
}

/**
* Prints a form for configuring this authentication plugin.
*
Expand Down
8 changes: 8 additions & 0 deletions auth/nologin/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ function can_reset_password() {
return false;
}

/**
* Returns true if plugin can be manually set.
*
* @return bool
*/
function can_be_manually_set() {
return true;
}
}


9 changes: 9 additions & 0 deletions auth/none/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ function can_reset_password() {
return true;
}

/**
* Returns true if plugin can be manually set.
*
* @return bool
*/
function can_be_manually_set() {
return true;
}

/**
* Prints a form for configuring this authentication plugin.
*
Expand Down
17 changes: 15 additions & 2 deletions lib/authlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ class auth_plugin_base {
var $customfields = null;

/**
* This is the primary method that is used by the authenticate_user_login()
* function in moodlelib.php.
*
Expand Down Expand Up @@ -509,6 +508,21 @@ function is_captcha_enabled() {
return false;
}

/**
* Returns whether or not this authentication plugin can be manually set
* for users, for example, when bulk uploading users.
*
* This should be overriden by authentication plugins where setting the
* authentication method manually is allowed.
*
* @return bool
* @since 2.6
*/
function can_be_manually_set() {
// Override if needed.
return false;
}

/**
* Returns a list of potential IdPs that this authentication plugin supports.
* This is used to provide links on the login page.
Expand Down Expand Up @@ -550,7 +564,6 @@ public function get_custom_user_profile_fields() {

return $this->customfields;
}

}

/**
Expand Down

0 comments on commit 9b29f68

Please sign in to comment.