Skip to content

Commit

Permalink
Merge pull request #28 from hrimhari/release/1.4.3
Browse files Browse the repository at this point in the history
Fixes for release 1.4.3
  • Loading branch information
hrimhari authored Jul 9, 2019
2 parents 37d20d3 + 2b357bc commit bb9e278
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 67 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sql
25 changes: 15 additions & 10 deletions auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
}

require_once($CFG->libdir.'/authlib.php');
require_once($CFG->libdir.'/accesslib.php');
require_once($CFG->dirroot.'/user/profile/lib.php');
require_once('classes/message.class.php');

Expand All @@ -42,6 +43,7 @@ class auth_plugin_emailadmin extends auth_plugin_base {
*/
public function __construct() {
$this->authtype = 'emailadmin';
$this->config = get_config('auth_'.$this->authtype);
}

/* Backward compatible constructor. */
Expand Down Expand Up @@ -271,7 +273,7 @@ public function is_captcha_enabled() {
*/
public function send_confirmation_email_support($user) {
global $CFG;
$config = get_config('auth/emailadmin');
$config = $this->config;

$site = get_site();
$supportuser = core_user::get_support_user();
Expand Down Expand Up @@ -304,15 +306,20 @@ public function send_confirmation_email_support($user) {

// Directly email rather than using the messaging system to ensure its not routed to a popup or jabber.
$admins = get_admins();
$return = false;
$admin_found = false;

// Send message to fist admin (main) only. Remove "break" for all admins.
if (!isset($config->notif_strategy)) {
$config->notif_strategy = -1;
}

$config->notif_strategy = intval($config->notif_strategy);

if ($config->notif_strategy == -3 || $config->notif_strategy >= 0) {
$admins = array_merge($admins, get_users_by_capability(context_system::instance(), 'moodle/user:update'));
}

$return = false;
$admin_found = false;

// Send message to fist admin (main) only. Remove "break" for all admins.
$send_list = array();
foreach ($admins as $admin) {
error_log(print_r( $config->notif_strategy . ":" . $admin->id, true ));
Expand Down Expand Up @@ -389,11 +396,9 @@ public function list_custom_fields($user) {
global $CFG, $DB;

$result = '';
if ($fields = $DB->get_records('user_info_field')) {
foreach ($fields as $field) {
$fieldobj = new profile_field_base($field->id, $user->id);
$result .= format_string($fieldobj->field->name.':') . ' ' . $fieldobj->display_data() . PHP_EOL;
}
$fields = profile_get_user_fields_with_data($user->id);
foreach ($fields as $field) {
$result .= format_string($field->field->shortname.':') . ' ' . $field->display_data() . PHP_EOL;
}

return $result;
Expand Down
55 changes: 0 additions & 55 deletions config.html

This file was deleted.

17 changes: 17 additions & 0 deletions db/upgrade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
defined('MOODLE_INTERNAL') || die();
/**
* @param int $oldversion the version we are upgrading from
* @return bool result
*/
function xmldb_auth_emailadmin_upgrade($oldversion) {
global $CFG, $DB;

if ($oldversion < 2019070800) {
upgrade_fix_config_auth_plugin_names('emailadmin');
upgrade_fix_config_auth_plugin_defaults('emailadmin');
upgrade_plugin_savepoint(true, 2019070800, 'auth', 'emailadmin');
}

return true;
}
1 change: 1 addition & 0 deletions lang/en/auth_emailadmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,6 @@
$string['auth_emailadminnotif_strategy'] = 'Defines the strategy to send the registration notifications. Available options are "first" admin user, "all" admin users or one specific admin user.';
$string['auth_emailadminnotif_strategy_first'] = 'First admin user';
$string['auth_emailadminnotif_strategy_all'] = 'All admin users';
$string['auth_emailadminnotif_strategy_allupdate'] = 'All admins and users with user update capability';

$string['pluginname'] = 'Email-based self-registration with admin confirmation';
58 changes: 58 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Admin settings and defaults. Heavily based on auth/email/settings.php.
*
* @package auth_emailadmin
* @copyright 2019 Felipe Carasso
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die;

if ($ADMIN->fulltree) {

// Introductory explanation.
$settings->add(new admin_setting_heading('auth_emailadmin/pluginname', '',
new lang_string('auth_emailadmindescription', 'auth_emailadmin')));

$options = array(
new lang_string('no'),
new lang_string('yes'),
);

$settings->add(new admin_setting_configselect('auth_emailadmin/recaptcha',
new lang_string('auth_emailadminrecaptcha_key', 'auth_emailadmin'),
new lang_string('auth_emailadminrecaptcha', 'auth_emailadmin'), 0, $options));
$options = array('-1' => get_string("auth_emailadminnotif_strategy_first", "auth_emailadmin"),
'-2' => get_string("auth_emailadminnotif_strategy_all", "auth_emailadmin"),
'-3' => get_string("auth_emailadminnotif_strategy_allupdate", "auth_emailadmin")
);
$admins = array_merge(get_admins(), get_users_by_capability(context_system::instance(), 'moodle/user:update'));
foreach ($admins as $admin) {
$options[$admin->id] = $admin->username;
}

$settings->add(new admin_setting_configselect('auth_emailadmin/notif_strategy',
new lang_string('auth_emailadminnotif_strategy_key', 'auth_emailadmin'),
new lang_string('auth_emailadminnotif_strategy', 'auth_emailadmin'), -1, $options));

// Display locking / mapping of profile fields.
$authplugin = get_auth_plugin('emailadmin');
display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
get_string('auth_fieldlocks_help', 'auth'), false, false);
}
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

defined('MOODLE_INTERNAL') || die;

$plugin->version = 2019070400; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2019070802; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2015051101; // Requires this Moodle version.
$plugin->component = 'auth_emailadmin'; // Full name of the plugin (used for diagnostics).
$plugin->maturity = MATURITY_STABLE;
$plugin->release = '1.4.2';
$plugin->release = '1.4.3';

0 comments on commit bb9e278

Please sign in to comment.