// indirectly calls the protected init() method is good here.
core_component::get_core_subsystems();
+if (is_major_upgrade_required() && isloggedin()) {
+ // A major upgrade is required.
+ // Terminate the session and redirect back here before anything DB-related happens.
+ redirect_if_major_upgrade_required();
+}
+
require_once($CFG->libdir.'/adminlib.php'); // various admin-only functions
require_once($CFG->libdir.'/upgradelib.php'); // general upgrade/install related functions
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500;
-$plugin->requires = 2016112900;
+$plugin->version = 2017051500;
+$plugin->requires = 2017050500;
$plugin->component = 'tool_assignmentupgrade';
-$plugin->dependencies = array('mod_assign' => 2016112900);
+$plugin->dependencies = array('mod_assign' => 2017050500);
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500;
-$plugin->requires = 2016112900;
+$plugin->version = 2017051500;
+$plugin->requires = 2017050500;
$plugin->component = 'tool_availabilityconditions';
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'tool_behat'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'tool_capability'; // Full name of the plugin (used for diagnostics).
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'tool_cohortroles'; // Full name of the plugin (used for diagnostics).
$plugin->dependencies = array(
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500;
-$plugin->requires = 2016112900;
+$plugin->version = 2017051500;
+$plugin->requires = 2017050500;
$plugin->component = 'tool_customlang'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'tool_dbtransfer'; // Full name of the plugin (used for diagnostics).
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500;
-$plugin->requires = 2016112900;
+$plugin->version = 2017051500;
+$plugin->requires = 2017050500;
$plugin->component = 'tool_filetypes';
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500;
-$plugin->requires = 2016112900;
+$plugin->version = 2017051500;
+$plugin->requires = 2017050500;
$plugin->component = 'tool_generator';
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'tool_health'; // Full name of the plugin (used for diagnostics)
$plugin->maturity = MATURITY_ALPHA; // this version's maturity level
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'tool_innodb'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
$plugin->component = 'tool_installaddon';
-$plugin->version = 2016120500;
-$plugin->requires = 2016112900;
+$plugin->version = 2017051500;
+$plugin->requires = 2017050500;
$plugin->maturity = MATURITY_STABLE;
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'tool_langimport'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'logstore_database'; // Full name of the plugin (used for diagnostics).
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'logstore_legacy'; // Full name of the plugin (used for diagnostics).
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'logstore_standard'; // Full name of the plugin (used for diagnostics).
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'tool_log'; // Full name of the plugin (used for diagnostics).
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'tool_lp'; // Full name of the plugin (used for diagnostics).
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'tool_lpimportcsv'; // Full name of the plugin (used for diagnostics).
-$plugin->dependencies = array('tool_lp' => 2016112900);
+$plugin->dependencies = array('tool_lp' => 2017050500);
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'tool_lpmigrate'; // Full name of the plugin (used for diagnostics).
$plugin->dependencies = array(
'tool_lp' => ANY_VERSION
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500;
-$plugin->requires = 2016112900;
+$plugin->version = 2017051500;
+$plugin->requires = 2017050500;
$plugin->component = 'tool_messageinbound';
*/
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2017041200; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'tool_mobile'; // Full name of the plugin (used for diagnostics).
$plugin->dependencies = array(
- 'webservice_rest' => 2016120500
+ 'webservice_rest' => 2017050500
);
defined('MOODLE_INTERNAL') || die;
-$plugin->version = 2017021300; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'tool_monitor'; // Full name of the plugin (used for diagnostics).
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'tool_multilangupgrade'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'tool_oauth2'; // Full name of the plugin (used for diagnostics).
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'tool_phpunit'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'tool_profiling'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'tool_recyclebin'; // Full name of the plugin (used for diagnostics).
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'tool_replace'; // Full name of the plugin (used for diagnostics)
$plugin->maturity = MATURITY_ALPHA; // this version's maturity level
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500;
-$plugin->requires = 2016112900;
+$plugin->version = 2017051500;
+$plugin->requires = 2017050500;
$plugin->component = 'tool_spamcleaner'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'tool_task'; // Full name of the plugin (used for diagnostics)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'tool_templatelibrary'; // Full name of the plugin (used for diagnostics).
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'tool_unsuproles'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'tool_uploadcourse'; // Full name of the plugin (used for diagnostics).
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'tool_uploaduser'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120501; // The current module version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current module version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'tool_usertours'; // Full name of the plugin (used for diagnostics).
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'tool_xmldb'; // Full name of the plugin (used for diagnostics)
if ($oldversion < 2017020700) {
// Convert info in config plugins from auth/cas to auth_cas.
upgrade_fix_config_auth_plugin_names('cas');
+ upgrade_fix_config_auth_plugin_defaults('cas');
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'cas');
}
}
// Display locking / mapping of profile fields.
- $authplugin = get_auth_plugin($this->name);
+ $authplugin = get_auth_plugin('cas');
$help = get_string('auth_ldapextrafields', 'auth_ldap');
$help .= get_string('auth_updatelocal_expl', 'auth');
$help .= get_string('auth_fieldlock_expl', 'auth');
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2017020700; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'auth_cas'; // Full name of the plugin (used for diagnostics)
-$plugin->dependencies = array('auth_ldap' => 2017020700);
+$plugin->dependencies = array('auth_ldap' => 2017050500);
if ($oldversion < 2017032800) {
// Convert info in config plugins from auth/db to auth_db
upgrade_fix_config_auth_plugin_names('db');
+ upgrade_fix_config_auth_plugin_defaults('db');
upgrade_plugin_savepoint(true, 2017032800, 'auth', 'db');
}
new lang_string('auth_dbupdateusers_description', 'auth_db'), 0, $yesno));
// Display locking / mapping of profile fields.
- $authplugin = get_auth_plugin($this->name);
+ $authplugin = get_auth_plugin('db');
display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
get_string('auth_dbextrafields', 'auth_db'),
true, true, $authplugin->get_custom_user_profile_fields());
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2017032800; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'auth_db'; // Full name of the plugin (used for diagnostics)
if ($oldversion < 2017020700) {
// Convert info in config plugins from auth/email to auth_email.
upgrade_fix_config_auth_plugin_names('email');
+ upgrade_fix_config_auth_plugin_defaults('email');
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'email');
}
new lang_string('auth_emailrecaptcha', 'auth_email'), 0, $options));
// Display locking / mapping of profile fields.
- $authplugin = get_auth_plugin($this->name);
+ $authplugin = get_auth_plugin('email');
display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
get_string('auth_fieldlocks_help', 'auth'), false, false);
}
defined('MOODLE_INTERNAL') || die;
-$plugin->version = 2017020700; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'auth_email'; // Full name of the plugin (used for diagnostics)
if ($oldversion < 2017020700) {
// Convert info in config plugins from auth/fc to auth_fc.
upgrade_fix_config_auth_plugin_names('fc');
+ upgrade_fix_config_auth_plugin_defaults('fc');
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'fc');
}
get_string('changepasswordhelp', 'auth'), '', PARAM_URL));
// Display locking / mapping of profile fields.
- $authplugin = get_auth_plugin($this->name);
+ $authplugin = get_auth_plugin('fc');
display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
get_string('auth_fieldlocks_help', 'auth'), false, false);
}
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2017020700; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'auth_fc'; // Full name of the plugin (used for diagnostics)
if ($oldversion < 2017020700) {
// Convert info in config plugins from auth/imap to auth_imap.
upgrade_fix_config_auth_plugin_names('imap');
+ upgrade_fix_config_auth_plugin_defaults('imap');
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'imap');
}
get_string('changepasswordhelp', 'auth'), '', PARAM_URL));
// Display locking / mapping of profile fields.
- $authplugin = get_auth_plugin($this->name);
+ $authplugin = get_auth_plugin('imap');
display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
get_string('auth_fieldlocks_help', 'auth'), false, false);
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2017020700; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'auth_imap'; // Full name of the plugin (used for diagnostics)
if ($oldversion < 2017020700) {
// Convert info in config plugins from auth/ldap to auth_ldap.
upgrade_fix_config_auth_plugin_names('ldap');
+ upgrade_fix_config_auth_plugin_defaults('ldap');
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'ldap');
}
}
// Display locking / mapping of profile fields.
- $authplugin = get_auth_plugin($this->name);
+ $authplugin = get_auth_plugin('ldap');
$help = get_string('auth_ldapextrafields', 'auth_ldap');
$help .= get_string('auth_updatelocal_expl', 'auth');
$help .= get_string('auth_fieldlock_expl', 'auth');
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2017020700; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'auth_ldap'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version (3.1).
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version (3.1).
$plugin->component = 'auth_lti'; // Full name of the plugin (used for diagnostics).
if ($oldversion < 2017020700) {
// Convert info in config plugins from auth/manual to auth_manual.
upgrade_fix_config_auth_plugin_names('manual');
+ upgrade_fix_config_auth_plugin_defaults('manual');
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'manual');
}
new lang_string('expiration_warning_desc', 'auth_manual'), 0, $expirationwarningoptions));
// Display locking / mapping of profile fields.
- $authplugin = get_auth_plugin($this->name);
+ $authplugin = get_auth_plugin('manual');
display_auth_lock_options($settings, $authplugin->authtype,
$authplugin->userfields, get_string('auth_fieldlocks_help', 'auth'), false, false);
}
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2017020700; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'auth_manual'; // Full name of the plugin (used for diagnostics)
if ($oldversion < 2017020700) {
// Convert info in config plugins from auth/mnet to auth_mnet.
upgrade_fix_config_auth_plugin_names('mnet');
+ upgrade_fix_config_auth_plugin_defaults('mnet');
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'mnet');
}
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2017020700; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'auth_mnet'; // Full name of the plugin (used for diagnostics)
if ($oldversion < 2017020700) {
// Convert info in config plugins from auth/nntp to auth_nntp.
upgrade_fix_config_auth_plugin_names('nntp');
+ upgrade_fix_config_auth_plugin_defaults('nntp');
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'nntp');
}
get_string('changepasswordhelp', 'auth'), '', PARAM_URL));
// Display locking / mapping of profile fields.
- $authplugin = get_auth_plugin($this->name);
+ $authplugin = get_auth_plugin('nntp');
display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
get_string('auth_fieldlocks_help', 'auth'), false, false);
}
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2017020700; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'auth_nntp'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'auth_nologin'; // Full name of the plugin (used for diagnostics)
if ($oldversion < 2017020700) {
// Convert info in config plugins from auth/none to auth_none.
upgrade_fix_config_auth_plugin_names('none');
+ upgrade_fix_config_auth_plugin_defaults('none');
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'none');
}
new lang_string('auth_nonedescription', 'auth_none')));
// Display locking / mapping of profile fields.
- $authplugin = get_auth_plugin($this->name);
+ $authplugin = get_auth_plugin('none');
display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
get_string('auth_fieldlocks_help', 'auth'), false, false);
}
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2017020700; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'auth_none'; // Full name of the plugin (used for diagnostics)
$userid = $USER->id;
}
+ if (linked_login::count_records(['username' => $userinfo['username']]) > 0) {
+ throw new moodle_exception('alreadylinked', 'auth_oauth2');
+ }
+
if (\core\session\manager::is_loggedinas()) {
throw new moodle_exception('notwhileloggedinas', 'auth_oauth2');
}
$record->issuerid = $issuer->get('id');
$record->username = $userinfo['username'];
$record->userid = $userid;
- $existing = linked_login::get_record((array)$record);
- if ($existing) {
- return false;
+ if (linked_login::count_records(['username' => $userinfo['username']]) > 0) {
+ throw new moodle_exception('alreadylinked', 'auth_oauth2');
}
$record->email = $userinfo['email'];
$record->confirmtoken = random_string(32);
require_once($CFG->dirroot.'/user/profile/lib.php');
require_once($CFG->dirroot.'/user/lib.php');
+ if (linked_login::count_records(['username' => $userinfo['username']]) > 0) {
+ throw new moodle_exception('alreadylinked', 'auth_oauth2');
+ }
+
$user = new stdClass();
$user->username = $userinfo['username'];
$user->email = $userinfo['email'];
$login->delete();
}
+
+ /**
+ * Delete linked logins for a user.
+ *
+ * @param \core\event\user_deleted $event
+ * @return boolean
+ */
+ public static function user_deleted(\core\event\user_deleted $event) {
+ global $DB;
+
+ $userid = $event->objectid;
+
+ return $DB->delete_records(linked_login::TABLE, ['userid' => $userid]);
+ }
}
--- /dev/null
+<?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/>.
+
+/**
+ * This file definies observers needed by the plugin.
+ *
+ * @package auth_oauth2
+ * @copyright 2017 Damyon Wiese
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+// List of observers.
+$observers = [
+ [
+ 'eventname' => '\core\event\user_deleted',
+ 'callback' => '\auth_oauth2\api::user_deleted',
+ ],
+];
$string['oauth2:managelinkedlogins'] = 'Manage own linked login accounts';
$string['plugindescription'] = 'This authentication plugin displays a list of the configured identity providers on the login page. Selecting an identity provider allows users to login with their credentials from an OAuth 2 provider.';
$string['pluginname'] = 'OAuth 2';
+$string['alreadylinked'] = 'This external account is already linked to an account on this site';
$userinfo = $client->get_userinfo();
if (!empty($userinfo)) {
- \auth_oauth2\api::link_login($userinfo, $issuer);
- redirect($PAGE->url, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS);
+ try {
+ \auth_oauth2\api::link_login($userinfo, $issuer);
+ redirect($PAGE->url, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS);
+ } catch (Exception $e) {
+ redirect($PAGE->url, $e->getMessage(), null, \core\output\notification::NOTIFY_ERROR);
+ }
} else {
redirect($PAGE->url, get_string('notloggedin', 'auth_oauth2'), null, \core\output\notification::NOTIFY_ERROR);
}
$warning = $OUTPUT->notification(get_string('createaccountswarning', 'auth_oauth2'), 'warning');
$settings->add(new admin_setting_heading('auth_oauth2/pluginname', '', $warning));
- $authplugin = get_auth_plugin($this->name);
+ $authplugin = get_auth_plugin('oauth2');
display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
get_string('auth_fieldlocks_help', 'auth'), false, false);
}
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2017032300; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051501; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'auth_oauth2'; // Full name of the plugin (used for diagnostics).
if ($oldversion < 2017020700) {
// Convert info in config plugins from auth/pam to auth_pam.
upgrade_fix_config_auth_plugin_names('pam');
+ upgrade_fix_config_auth_plugin_defaults('pam');
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'pam');
}
new lang_string('auth_pamdescription', 'auth_pam')));
// Display locking / mapping of profile fields.
- $authplugin = get_auth_plugin($this->name);
+ $authplugin = get_auth_plugin('pam');
display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
get_string('auth_fieldlocks_help', 'auth'), false, false);
}
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2017020700; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'auth_pam'; // Full name of the plugin (used for diagnostics)
if ($oldversion < 2017020700) {
// Convert info in config plugins from auth/pop3 to auth_pop3.
upgrade_fix_config_auth_plugin_names('pop3');
+ upgrade_fix_config_auth_plugin_defaults('pop3');
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'pop3');
}
get_string('changepasswordhelp', 'auth'), '', PARAM_URL));
// Display locking / mapping of profile fields.
- $authplugin = get_auth_plugin($this->name);
+ $authplugin = get_auth_plugin('pop3');
display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
get_string('auth_fieldlocks_help', 'auth'), false, false);
}
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2017020700; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'auth_pop3'; // Full name of the plugin (used for diagnostics)
if ($oldversion < 2017020700) {
// Convert info in config plugins from auth/shibboleth to auth_shibboleth.
upgrade_fix_config_auth_plugin_names('shibboleth');
+ upgrade_fix_config_auth_plugin_defaults('shibboleth');
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'shibboleth');
}
get_string('changepasswordhelp', 'auth'), '', PARAM_URL));
// Display locking / mapping of profile fields.
- $authplugin = get_auth_plugin($this->name);
+ $authplugin = get_auth_plugin('shibboleth');
display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
'', true, false, $authplugin->get_custom_user_profile_fields());
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2017020700; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'auth_shibboleth'; // Full name of the plugin (used for diagnostics)
=== 3.3 ===
-* Authentication plugins have been migrated to use the admin settings API.
- Plugins should use a settings.php file to manage configurations rather than using the config.html files.
- See how the helper function upgrade_fix_config_auth_plugin_names() can be used to convert the legacy settings to the
- new ones.
+* Authentication plugins have been migrated to use the admin settings API. Plugins should use a settings.php file to
+ manage configurations rather than using the old config.html files. See how the helper function
+ upgrade_fix_config_auth_plugin_names() can be used to convert the legacy settings to the new ones. Another helper
+ function upgrade_fix_config_auth_plugin_defaults() can be used to populate the settings with default values so that
+ they are not falsely reported as newly added ones.
* The function 'print_auth_lock_options' has been replaced by 'display_auth_lock_options' which uses the admin settings API.
See auth_manual as an exmple of how it can be used. More information can be found in MDL-12689.
* The list of supported identity providers (SSO IdP) returned by the 'loginpage_idp_list' method (used to render the
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'auth_webservice'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500;
-$plugin->requires = 2016112900;
+$plugin->version = 2017051500;
+$plugin->requires = 2017050500;
$plugin->component = 'availability_completion';
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500;
-$plugin->requires = 2016112900;
+$plugin->version = 2017051500;
+$plugin->requires = 2017050500;
$plugin->component = 'availability_date';
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500;
-$plugin->requires = 2016112900;
+$plugin->version = 2017051500;
+$plugin->requires = 2017050500;
$plugin->component = 'availability_grade';
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500;
-$plugin->requires = 2016112900;
+$plugin->version = 2017051500;
+$plugin->requires = 2017050500;
$plugin->component = 'availability_group';
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500;
-$plugin->requires = 2016112900;
+$plugin->version = 2017051500;
+$plugin->requires = 2017050500;
$plugin->component = 'availability_grouping';
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500;
-$plugin->requires = 2016112900;
+$plugin->version = 2017051500;
+$plugin->requires = 2017050500;
$plugin->component = 'availability_profile';
* point is backup when some behavior/approach channged, in order to allow
* conditional coding based on it.
*/
- const VERSION = 2016120500;
+ const VERSION = 2017051500;
/**
* Usually same than major release zero version, mainly for informative/historic purposes.
*/
$event = new backup_nested_element('event', array('id'), array(
'name', 'description', 'format', 'courseid', 'groupid', 'userid',
- 'repeatid', 'modulename', 'instance', 'eventtype', 'timestart',
- 'timeduration', 'visible', 'uuid', 'sequence', 'timemodified'));
+ 'repeatid', 'modulename', 'instance', 'type', 'eventtype', 'timestart',
+ 'timeduration', 'timesort', 'visible', 'uuid', 'sequence', 'timemodified',
+ 'priority'));
// Build the tree
$events->add_child($event);
AND (eventtype = 'course' OR eventtype = 'group')";
$calendar_items_params = array('courseid'=>backup::VAR_COURSEID);
$event->set_source_sql($calendar_items_sql, $calendar_items_params);
+ } else if ($this->name == 'activity_calendar') {
+ $params = array('instance' => backup::VAR_ACTIVITYID, 'modulename' => backup::VAR_MODNAME);
+ // If we don't want to include the userinfo in the backup then setting the courseid
+ // will filter out all of the user override events (which have a course id of zero).
+ if (!$this->get_setting_value('userinfo')) {
+ $params['courseid'] = backup::VAR_COURSEID;
+ }
+ $event->set_source_table('event', $params);
} else {
$event->set_source_table('event', array('courseid' => backup::VAR_COURSEID, 'instance' => backup::VAR_ACTIVITYID, 'modulename' => backup::VAR_MODNAME));
}
$data = (object)$data;
$oldid = $data->id;
$restorefiles = true; // We'll restore the files
+ // User overrides for activities are identified by having a courseid of zero with
+ // both a modulename and instance value set.
+ $isuseroverride = !$data->courseid && $data->modulename && $data->instance;
+
+ // If we don't want to include user data and this record is a user override event
+ // for an activity then we should not create it.
+ if (!$this->task->get_setting_value('userinfo') && $isuseroverride) {
+ return;
+ }
+
// Find the userid and the groupid associated with the event.
$data->userid = $this->get_mappingid('user', $data->userid);
if ($data->userid === false) {
'name' => $data->name,
'description' => $data->description,
'format' => $data->format,
- 'courseid' => $this->get_courseid(),
+ // User overrides in activities use a course id of zero. All other event types
+ // must use the mapped course id.
+ 'courseid' => $data->courseid ? $this->get_courseid() : 0,
'groupid' => $data->groupid,
'userid' => $data->userid,
'repeatid' => $this->get_mappingid('event', $data->repeatid),
'modulename' => $data->modulename,
+ 'type' => $data->type,
'eventtype' => $data->eventtype,
'timestart' => $this->apply_date_offset($data->timestart),
'timeduration' => $data->timeduration,
+ 'timesort' => $this->apply_date_offset($data->timesort),
'visible' => $data->visible,
'uuid' => $data->uuid,
'sequence' => $data->sequence,
- 'timemodified' => $this->apply_date_offset($data->timemodified));
+ 'timemodified' => $this->apply_date_offset($data->timemodified),
+ 'priority' => $data->priority);
if ($this->name == 'activity_calendar') {
$params['instance'] = $this->task->get_activityid();
} else {
WHERE " . $DB->sql_compare_text('name', 255) . " = " . $DB->sql_compare_text('?', 255) . "
AND courseid = ?
AND modulename = ?
+ AND instance = ?
AND timestart = ?
AND timeduration = ?
AND " . $DB->sql_compare_text('description', 255) . " = " . $DB->sql_compare_text('?', 255);
- $arg = array ($params['name'], $params['courseid'], $params['modulename'], $params['timestart'], $params['timeduration'], $params['description']);
+ $arg = array ($params['name'], $params['courseid'], $params['modulename'], $params['instance'], $params['timestart'], $params['timeduration'], $params['description']);
$result = $DB->record_exists_sql($sql, $arg);
if (empty($result)) {
$newitemid = $DB->insert_record('event', $params);
// Save id mapping for restoring associated events.
$this->set_mapping('course_completion_defaults', $oldid, $newid);
}
-}
\ No newline at end of file
+}
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_activity_modules'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'block_activity_results'; // Full name of the plugin (used for diagnostics).
\ No newline at end of file
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_admin_bookmarks'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'block_badges';
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_blog_menu'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_blog_recent'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_blog_tags'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_calendar_month'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_calendar_upcoming'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_comments'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_community'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'block_completionstatus';
-$plugin->dependencies = array('report_completion' => 2016112900);
+$plugin->dependencies = array('report_completion' => 2017050500);
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_course_list'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_course_summary'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_feedback'; // Full name of the plugin (used for diagnostics)
-$plugin->dependencies = array('mod_feedback' => 2016112900);
+$plugin->dependencies = array('mod_feedback' => 2017050500);
defined('MOODLE_INTERNAL') || die;
-$plugin->version = 2016120500;
-$plugin->requires = 2016112900;
+$plugin->version = 2017051500;
+$plugin->requires = 2017050500;
$plugin->component = 'block_globalsearch';
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_glossary_random'; // Full name of the plugin (used for diagnostics)
-$plugin->dependencies = array('mod_glossary' => 2016112900);
+$plugin->dependencies = array('mod_glossary' => 2017050500);
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_html'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_login'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500;
-$plugin->requires = 2016112900;
+$plugin->version = 2017051500;
+$plugin->requires = 2017050500;
$plugin->component = 'block_lp';
$plugin->dependencies = array(
'tool_lp' => ANY_VERSION
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_mentees'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_messages'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_mnet_hosts'; // Full name of the plugin (used for diagnostics)
var SELECTORS = {
EVENTS_BY_COURSE_CONTAINER: '[data-region="course-events-container"]',
+ EVENT_LIST_CONTAINER: '[data-region="event-list-container"]',
};
/**
return;
}
- var midnight = root.attr('data-midnight');
+ var eventList = courseBlocks.find(SELECTORS.EVENT_LIST_CONTAINER).first();
+ var midnight = eventList.attr('data-midnight');
var startTime = midnight - (14 * SECONDS_IN_DAY);
- var limit = courseBlocks.attr('data-limit');
+ var limit = eventList.attr('data-limit');
var courseIds = courseBlocks.map(function() {
return $(this).attr('data-course-id');
}).get();
Given I log in as "student1"
And I click on "Timeline" "link" in the "Course overview" "block"
When I click on "Sort by courses" "link" in the "Course overview" "block"
- Then I should see "Choice Test choice 1 closes" in the "Course overview" "block"
+ Then I should see "Choice Test choice 1 closes" in the "#myoverview_timeline_courses" "css_element"
And I should not see "0%" in the "Course overview" "block"
And I click on "Courses" "link" in the "Course overview" "block"
And I click on "In progress" "link" in the "Course overview" "block"
And I log out
And I log in as "student1"
And I click on "Sort by courses" "link" in the "Course overview" "block"
- And I should see "Choice Test choice 1 closes" in the "Course overview" "block"
+ And I should see "Choice Test choice 1 closes" in the "#myoverview_timeline_courses" "css_element"
And I should see "0%" in the "Course overview" "block"
And I click on "Courses" "link" in the "Course overview" "block"
When I click on "In progress" "link" in the "Course overview" "block"
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016122000; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'block_myoverview'; // Full name of the plugin (used for diagnostics).
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_myprofile'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_navigation'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_news_items'; // Full name of the plugin (used for diagnostics)
-$plugin->dependencies = array('mod_forum' => 2016112900);
+$plugin->dependencies = array('mod_forum' => 2017050500);
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_online_users'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_participants'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_private_files'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_quiz_results'; // Full name of the plugin (used for diagnostics)
-$plugin->dependencies = array('mod_quiz' => 2016112900);
+$plugin->dependencies = array('mod_quiz' => 2017050500);
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_recent_activity'; // Full name of the plugin (used for diagnostics)
$plugin->cron = 24*3600; // Cron interval 1 day.
\ No newline at end of file
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_rss_client'; // Full name of the plugin (used for diagnostics)
$plugin->cron = 300; // Set min time between cron executions to 300 secs (5 mins)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_search_forums'; // Full name of the plugin (used for diagnostics)
-$plugin->dependencies = array('mod_forum' => 2016112900);
+$plugin->dependencies = array('mod_forum' => 2017050500);
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_section_links'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_selfcompletion'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_settings'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_site_main_menu'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_social_activities'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_tag_flickr'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_tag_youtube'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'block_tags'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version
+$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version
$plugin->component = 'cachelock_file'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die;
-$plugin->version = 2016120500;
-$plugin->requires = 2016112900;
+$plugin->version = 2017051500;
+$plugin->requires = 2017050500;
$plugin->maturity = MATURITY_STABLE;
$plugin->component = 'cachestore_apcu';
defined('MOODLE_INTERNAL') || die;
-$plugin->version = 2016120500; // The current module version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'cachestore_file'; // Full name of the plugin.
\ No newline at end of file
defined('MOODLE_INTERNAL') || die;
-$plugin->version = 2016120500; // The current module version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'cachestore_memcache'; // Full name of the plugin.
defined('MOODLE_INTERNAL') || die;
-$plugin->version = 2016120500; // The current module version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'cachestore_memcached'; // Full name of the plugin.
\ No newline at end of file
defined('MOODLE_INTERNAL') || die;
-$plugin->version = 2016120500; // The current module version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'cachestore_mongodb'; // Full name of the plugin.
\ No newline at end of file
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2017031900;
-$plugin->requires = 2016112900; // Requires this Moodle version (3.0.4).
+$plugin->version = 2017051500;
+$plugin->requires = 2017050500; // Requires this Moodle version (3.0.4).
$plugin->maturity = MATURITY_STABLE;
$plugin->component = 'cachestore_redis';
$plugin->release = '3.0.4 (Build: 20160509)';
defined('MOODLE_INTERNAL') || die;
-$plugin->version = 2016120500; // The current module version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'cachestore_session'; // Full name of the plugin.
\ No newline at end of file
defined('MOODLE_INTERNAL') || die;
-$plugin->version = 2016120500; // The current module version (Date: YYYYMMDDXX)
-$plugin->requires = 2016112900; // Requires this Moodle version.
+$plugin->version = 2017051500; // The current module version (Date: YYYYMMDDXX)
+$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->component = 'cachestore_static'; // Full name of the plugin.
\ No newline at end of file
$cm = $instances[$dbrow->modulename][$dbrow->instance];
// If the module is not visible to the current user, we should ignore it.
- if (!$cm->uservisible) {
+ // We have to check enrolment here as well because the uservisible check
+ // looks for the "view" capability however some activities (such as Lesson)
+ // have that capability set on the "Authenticated User" role rather than
+ // on "Student" role, which means uservisible returns true even when the user
+ // is no longer enrolled in the course.
+ $modulecontext = \context_module::instance($cm->id);
+ // A user with the 'moodle/course:view' capability is able to see courses
+ // that they are not a participant in.
+ $canseecourse = (has_capability('moodle/course:view', $modulecontext) || is_enrolled($modulecontext));
+ if (!$cm->uservisible || !$canseecourse) {
return true;
}
true,
true,
function ($event) use ($course) {
- return $event instanceof action_event_interface && $event->get_course()->get_id() == $course->id;
+ return $event instanceof action_event_interface && $event->get_course()->get('id') == $course->id;
}
)
);
* @return event_interface|null
*/
protected function transform_from_database_record(\stdClass $record) {
- if ($record->courseid == 0 && $record->instance && $record->modulename) {
- list($course, $cm) = get_course_and_cm_from_instance($record->instance, $record->modulename);
- $record->courseid = $course->id;
- }
-
return $this->factory->create_instance($record);
}
namespace core_calendar\local\event\entities;
+use core_calendar\local\event\proxies\proxy_interface;
+
defined('MOODLE_INTERNAL') || die();
/**
use core_calendar\local\event\entities\event;
use core_calendar\local\event\entities\repeat_event_collection;
use core_calendar\local\event\exceptions\invalid_callback_exception;
-use core_calendar\local\event\proxies\module_std_proxy;
+use core_calendar\local\event\proxies\cm_info_proxy;
use core_calendar\local\event\proxies\std_proxy;
use core_calendar\local\event\value_objects\event_description;
use core_calendar\local\event\value_objects\event_times;
}
public function create_instance(\stdClass $dbrow) {
+ if ($dbrow->modulename && $dbrow->instance && $dbrow->courseid == 0) {
+ // Some events (for example user overrides) may contain module instance but not course id. Find course id.
+ $cm = calendar_get_module_cached($this->modulecachereference, $dbrow->modulename, $dbrow->instance);
+ $dbrow->courseid = $cm->course;
+ }
+
$bailcheck = $this->bailoutcheck;
$bail = $bailcheck($dbrow);
$module = null;
$subscription = null;
- if ($dbrow->courseid == 0 && !empty($dbrow->modulename)) {
- $cm = get_coursemodule_from_instance($dbrow->modulename, $dbrow->instance);
- $dbrow->courseid = get_course($cm->course)->id;
+ if ($dbrow->modulename && $dbrow->instance) {
+ $module = new cm_info_proxy($dbrow->modulename, $dbrow->instance, $dbrow->courseid);
}
$course = new std_proxy($dbrow->courseid, function($id) {
});
}
- if ($dbrow->instance && !empty($dbrow->modulename)) {
- $module = new module_std_proxy(
- $dbrow->modulename,
- $dbrow->instance,
- function($modulename, $instance) {
- return calendar_get_module_cached(
- $this->modulecachereference,
- $modulename,
- $instance
- );
- }
- );
- }
-
if ($dbrow->subscriptionid) {
$subscription = new std_proxy($dbrow->subscriptionid, function($id) {
return calendar_get_subscription($id);
'name' => $event->get_name(),
'description' => $event->get_description()->get_value(),
'format' => $event->get_description()->get_format(),
- 'courseid' => $event->get_course() ? $event->get_course()->get_id() : null,
- 'groupid' => $event->get_group() ? $event->get_group()->get_id() : null,
- 'userid' => $event->get_user() ? $event->get_user()->get_id() : null,
+ 'courseid' => $event->get_course() ? $event->get_course()->get('id') : null,
+ 'groupid' => $event->get_group() ? $event->get_group()->get('id') : null,
+ 'userid' => $event->get_user() ? $event->get_user()->get('id') : null,
'repeatid' => $event->get_repeats()->get_id(),
'modulename' => $event->get_course_module() ? $event->get_course_module()->get('modname') : null,
'instance' => $event->get_course_module() ? $event->get_course_module()->get('instance') : null,
'timesort' => $event->get_times()->get_sort_time()->getTimestamp(),
'visible' => $event->is_visible() ? 1 : 0,
'timemodified' => $event->get_times()->get_modified_time()->getTimestamp(),
- 'subscriptionid' => $event->get_subscription() ? $event->get_subscription()->get_id() : null,
+ 'subscriptionid' => $event->get_subscription() ? $event->get_subscription()->get('id') : null,
'actionname' => $action ? $action->get_name() : null,
'actionurl' => $action ? $action->get_url() : null,
'actionnum' => $action ? $action->get_item_count() : null,
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * Course module stdClass proxy.
+ * Course module cm_info proxy.
*
* @package core_calendar
* @copyright 2017 Cameron Ball <cameron@cameron1729.xyz>
* @copyright 2017 Cameron Ball <cameron@cameron1729.xyz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class module_std_proxy extends std_proxy implements proxy_interface {
+class cm_info_proxy implements proxy_interface {
+ /** @var \stdClass */
+ protected $base;
+ /** @var \cm_info */
+ protected $cm;
+
+ /**
+ * cm_info_proxy constructor.
+ *
+ * @param string $modname The module name.
+ * @param int $instance The module instance.
+ * @param int $courseid course id this module belongs to
+ */
+ public function __construct($modname, $instance, $courseid) {
+ $this->base = (object)['course' => $courseid, 'modname' => $modname, 'instance' => $instance];
+ }
/**
- * module_std_proxy constructor.
+ * Retrieve a member of the proxied class.
*
- * @param int $modulename The module name.
- * @param callable $instance The module instance.
- * @param callable $callback Callback to load the class.
- * @param \stdClass $base Class containing base values.
+ * @param string $member The name of the member to retrieve
+ * @return mixed The member.
*/
- public function __construct($modulename, $instance, callable $callback, \stdClass $base = null) {
- $this->modulename = $modulename;
- $this->instance = $instance;
- $this->callbackargs = [$modulename, $instance];
- $this->callback = $callback;
- $this->base = $base = is_null($base) ? new \stdClass() : $base;
- $this->base->modulename = $modulename;
- $this->base->instance = $instance;
+ public function get($member) {
+ if ($this->base && property_exists($this->base, $member)) {
+ return $this->base->{$member};
+ }
+
+ return $this->get_proxied_instance()->{$member};
}
- public function get_id() {
- return $this->get_proxied_instance()->id;
+ /**
+ * Get the full instance of the proxied class.
+ *
+ * @return \stdClass
+ */
+ public function get_proxied_instance() {
+ if (!$this->cm) {
+ $this->cm = get_fast_modinfo($this->base->course)->instances[$this->base->modname][$this->base->instance];
+ }
+ return $this->cm;
}
}
*/
public function get($member);
- /**
- * Retrieve the ID of the proxied class.
- * @return int The proxied class' ID.
- */
- public function get_id();
-
- /**
- * Set a member of the proxied class.
- *
- * @param string $member The name of the member to set
- * @param mixed $value The value to set the member to
- * @throws \core_calendar\local\event\exceptions\member_does_not_exist_exception If the proxied class does not have the
- * requested member.
- * @return void
- */
- public function set($member, $value);
-
/**
* Get the full instance of the proxied class.
*
$this->base = $base;
}
- public function get_id() {
- return $this->id;
- }
-
public function get($member) {
if ($member === 'id') {
- return $this->get_id();
+ return $this->id;
}
if ($this->base && property_exists($this->base, $member)) {
return $this->get_proxied_instance()->{$member};
}
- public function set($member, $value) {
- if (!property_exists($this->get_proxied_instance(), $member)) {
- throw new member_does_not_exist_exception(sprintf('Member %s does not exist', $member));
- }
-
- $this->get_proxied_instance()->{$member} = $value;
- }
-
public function get_proxied_instance() {
$callback = $this->callback;
return $this->class = $this->class ? $this->class : $callback(...$this->callbackargs);
namespace core_calendar;
+use calendar_event;
use DateInterval;
use DateTime;
use moodle_exception;
/**
* Create events for specified rrule.
*
- * @param \calendar_event $passedevent Properties of event to create.
+ * @param calendar_event $passedevent Properties of event to create.
* @throws moodle_exception
*/
public function create_events($passedevent) {
// Generate timestamps that obey the rrule.
$eventtimes = $this->generate_recurring_event_times($eventrec);
- // Adjust the parent event's timestart, if necessary.
+ // Update the parent event. Make sure that its repeat ID is the same as its ID.
+ $calevent = new calendar_event($eventrec);
+ $updatedata = new stdClass();
+ $updatedata->repeatid = $event->id;
+ // Also, adjust the parent event's timestart, if necessary.
if (count($eventtimes) > 0 && !in_array($eventrec->timestart, $eventtimes)) {
- $calevent = new \calendar_event($eventrec);
- $updatedata = (object)['timestart' => $eventtimes[0], 'repeatid' => $eventrec->id];
- $calevent->update($updatedata, false);
- $eventrec->timestart = $calevent->timestart;
+ $updatedata->timestart = reset($eventtimes);
}
+ $calevent->update($updatedata, false);
+ $eventrec->timestart = $calevent->timestart;
// Create the recurring calendar events.
$this->create_recurring_events($eventrec, $eventtimes);
$cloneevent->repeatid = $event->id;
$cloneevent->timestart = $time;
unset($cloneevent->id);
- \calendar_event::create($cloneevent, false);
+ // UUID should only be set on the first instance of the recurring events.
+ unset($cloneevent->uuid);
+ calendar_event::create($cloneevent, false);
}
// If COUNT rule is defined and the number of the generated event times is less than the the COUNT rule,
$ical = new iCalendar;
$ical->add_property('method', 'PUBLISH');
foreach($events as $event) {
- if (!empty($event->modulename)) {
- $cm = get_coursemodule_from_instance($event->modulename, $event->instance);
- if (!\core_availability\info_module::is_user_visible($cm, $userid, false)) {
+ if (!empty($event->modulename)) {
+ $instances = get_fast_modinfo($event->courseid, $userid)->get_instances_of($event->modulename);
+ if (empty($instances[$event->instance]->uservisible)) {
continue;
}
}
// User can see everything, no further check is needed.
$events[$eventid] = $event;
} else if (!empty($eventobj->modulename)) {
- $cm = get_coursemodule_from_instance($eventobj->modulename, $eventobj->instance);
- if (\core_availability\info_module::is_user_visible($cm, 0, false)) {
+ $courseid = $eventobj->courseid;
+ if (!$courseid) {
+ if (!$calendareventobj->context || !($context = $calendareventobj->context->get_course_context(false))) {
+ continue;
+ }
+ $courseid = $context->instanceid;
+ }
+ $instances = get_fast_modinfo($courseid)->get_instances_of($eventobj->modulename);
+ if (!empty($instances[$eventobj->instance]->uservisible)) {
$events[$eventid] = $event;
}
} else {
if (!empty($events)) {
foreach ($events as $eventid => $event) {
if (!empty($event->modulename)) {
- $cm = get_coursemodule_from_instance($event->modulename, $event->instance);
- if (!\core_availability\info_module::is_user_visible($cm, 0, false)) {
+ $instances = get_fast_modinfo($event->courseid)->get_instances_of($event->modulename);
+ if (empty($instances[$event->instance]->uservisible)) {
unset($events[$eventid]);
}
}
}
if ($events !== false) {
- $modinfo = get_fast_modinfo($COURSE);
foreach ($events as $event) {
if (!empty($event->modulename)) {
- if ($event->courseid == $COURSE->id) {
- if (isset($modinfo->instances[$event->modulename][$event->instance])) {
- $cm = $modinfo->instances[$event->modulename][$event->instance];
- if (!$cm->uservisible) {
- continue;
- }
- }
- } else {
- if (!$cm = get_coursemodule_from_instance($event->modulename, $event->instance)) {
- continue;
- }
- if (!\core_availability\info_module::is_user_visible($cm, 0, false)) {
- continue;
- }
+ $instances = get_fast_modinfo($event->courseid)->get_instances_of($event->modulename);
+ if (empty($instances[$event->instance]->uservisible)) {
+ continue;
}
}
/**
* Get a HTML link to a course.
*
- * @param int $courseid the course id
+ * @param int|stdClass $course the course id or course object
* @return string a link to the course (as HTML); empty if the course id is invalid
*/
-function calendar_get_courselink($courseid) {
- if (!$courseid) {
+function calendar_get_courselink($course) {
+ if (!$course) {
return '';
}
- calendar_get_course_cached($coursecache, $courseid);
- $context = \context_course::instance($courseid);
- $fullname = format_string($coursecache[$courseid]->fullname, true, array('context' => $context));
- $url = new \moodle_url('/course/view.php', array('id' => $courseid));
+ if (!is_object($course)) {
+ $course = calendar_get_course_cached($coursecache, $course);
+ }
+ $context = \context_course::instance($course->id);
+ $fullname = format_string($course->fullname, true, array('context' => $context));
+ $url = new \moodle_url('/course/view.php', array('id' => $course->id));
$link = \html_writer::link($url, $fullname);
return $link;
/**
* Get current module cache.
*
+ * Only use this method if you do not know courseid. Otherwise use:
+ * get_fast_modinfo($courseid)->instances[$modulename][$instance]
+ *
* @param array $modulecache in memory module cache
* @param string $modulename name of the module
* @param int $instance module instance number
if (!empty($event->modulename)) { // Activity event.
// The module name is set. I will assume that it has to be displayed, and
// also that it is an automatically-generated event. And of course that the
- // fields for get_coursemodule_from_instance are set correctly.
- $module = calendar_get_module_cached($coursecache, $event->modulename, $event->instance);
-
- if ($module === false) {
+ // instace id and modulename are set correctly.
+ $instances = get_fast_modinfo($event->courseid)->get_instances_of($event->modulename);
+ if (!array_key_exists($event->instance, $instances)) {
return;
}
+ $module = $instances[$event->instance];
- $modulename = get_string('modulename', $event->modulename);
+ $modulename = $module->get_module_type_name(false);
if (get_string_manager()->string_exists($event->eventtype, $event->modulename)) {
// Will be used as alt text if the event icon.
$eventtype = get_string($event->eventtype, $event->modulename);
} else {
$eventtype = '';
}
- $icon = $OUTPUT->image_url('icon', $event->modulename) . '';
- $event->icon = '<img src="' . $icon . '" alt="' . $eventtype . '" title="' . $modulename . '" class="icon" />';
- $event->referer = '<a href="' . $CFG->wwwroot . '/mod/' . $event->modulename . '/view.php?id=' .
- $module->id . '">' . $event->name . '</a>';
- $event->courselink = calendar_get_courselink($module->course);
+ $event->icon = '<img src="' . s($module->get_icon_url()) . '" alt="' . s($eventtype) .
+ '" title="' . s($modulename) . '" class="icon" />';
+ $event->referer = html_writer::link($module->url, $event->name);
+ $event->courselink = calendar_get_courselink($module->get_course());
$event->cmid = $module->id;
} else if ($event->courseid == SITEID) { // Site event.
$event->icon = '<img src="' . $OUTPUT->image_url('i/siteevent') . '" alt="' .
foreach($events as $eventid => $event) {
$event = new calendar_event($event);
if (!empty($event->modulename)) {
- $cm = get_coursemodule_from_instance($event->modulename, $event->instance);
- if (!\core_availability\info_module::is_user_visible($cm, 0, false)) {
+ $instances = get_fast_modinfo($event->courseid)->get_instances_of($event->modulename);
+ if (empty($instances[$event->instance]->uservisible)) {
unset($events[$eventid]);
}
}
--- /dev/null
+<?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/>.
+
+/**
+ * cm_info_proxy tests.
+ *
+ * @package core_calendar
+ * @copyright 2017 Cameron Ball <cameron@cameron1729.xyz>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+use core_calendar\local\event\proxies\cm_info_proxy;
+
+/**
+ * cm_info_proxy testcase.
+ *
+ * @copyright 2017 Cameron Ball <cameron@cameron1729.xyz>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class core_calendar_cm_info_proxy_testcase extends advanced_testcase {
+
+ /**
+ * Test creating cm_info_std_proxy, using getter and setter.
+ */
+ public function test_proxy() {
+ $this->resetAfterTest(true);
+
+ $course = $this->getDataGenerator()->create_course();
+ $module = $this->getDataGenerator()->create_module('forum',
+ ['course' => $course->id, 'idnumber' => '123456']);
+ $proxy = new cm_info_proxy(
+ 'forum',
+ $module->id,
+ $course->id
+ );
+
+ $this->assertEquals('forum', $proxy->get('modname'));
+ $this->assertEquals($module->id, $proxy->get('instance'));
+ $this->assertEquals($course->id, $proxy->get('course'));
+ $this->assertEquals('123456', $proxy->get('idnumber'));
+ $this->assertEquals($module->cmid, $proxy->get('id'));
+ $this->assertEquals('123456', $proxy->get_proxied_instance()->idnumber);
+ }
+}
$this->assertEquals($legacyevent->id, $event->get_id());
$this->assertEquals($dbrow->description, $event->get_description()->get_value());
$this->assertEquals($dbrow->format, $event->get_description()->get_format());
- $this->assertEquals($dbrow->courseid, $event->get_course()->get_id());
+ $this->assertEquals($dbrow->courseid, $event->get_course()->get('id'));
if ($dbrow->groupid == 0) {
$this->assertNull($event->get_group());
} else {
- $this->assertEquals($dbrow->groupid, $event->get_group()->get_id());
+ $this->assertEquals($dbrow->groupid, $event->get_group()->get('id'));
}
- $this->assertEquals($dbrow->userid, $event->get_user()->get_id());
+ $this->assertEquals($dbrow->userid, $event->get_user()->get('id'));
$this->assertEquals($legacyevent->id, $event->get_repeats()->get_id());
$this->assertEquals($dbrow->modulename, $event->get_course_module()->get('modname'));
$this->assertEquals($dbrow->instance, $event->get_course_module()->get('instance'));
if (!$dbrow->subscriptionid) {
$this->assertNull($event->get_subscription());
} else {
- $this->assertEquals($event->get_subscription()->get_id());
+ $this->assertEquals($event->get_subscription()->get('id'));
}
}
$this->assertNull($factory->create_instance($event));
}
+ /**
+ * Test that the event factory only returns an event if the logged in user
+ * is enrolled in the course.
+ */
+ public function test_event_factory_unenrolled_user() {
+ $user = $this->getDataGenerator()->create_user();
+ // Create the course we will be using.
+ $course = $this->getDataGenerator()->create_course();
+
+ // Add the assignment.
+ $generator = $this->getDataGenerator()->get_plugin_generator('mod_lesson');
+ $lesson = $generator->create_instance(array('course' => $course->id));
+
+ // Create a user override event for the lesson.
+ $event = new \stdClass();
+ $event->name = 'An event';
+ $event->description = 'Event description';
+ $event->format = FORMAT_HTML;
+ $event->eventtype = 'close';
+ $event->userid = $user->id;
+ $event->modulename = 'lesson';
+ $event->instance = $lesson->id;
+ $event->courseid = $course->id;
+ $event->groupid = 0;
+ $event->timestart = time();
+ $event->timesort = time();
+ $event->timemodified = time();
+ $event->timeduration = 0;
+ $event->subscriptionid = null;
+ $event->repeatid = 0;
+ $legacyevent = $this->create_event($event);
+
+ // Update the id of the event that was created.
+ $event->id = $legacyevent->id;
+
+ // Set the logged in user to the one we created.
+ $this->setUser($user);
+
+ // Create the factory we are going to be testing the behaviour of.
+ $factory = \core_calendar\local\event\container::get_event_factory();
+
+ // The result should be null since the user is not enrolled in the
+ // course the event is for.
+ $this->assertNull($factory->create_instance($event));
+
+ // Now enrol the user in the course.
+ $this->getDataGenerator()->enrol_user($user->id, $course->id);
+
+ // Check that we get the correct instance.
+ $this->assertInstanceOf(event_interface::class, $factory->create_instance($event));
+ }
+
/**
* Test getting the event mapper.
*/
'name' => 'test',
'description' => 'Test description',
'format' => 2,
- 'courseid' => $course->id,
+ 'courseid' => 0,
'groupid' => 1,
'userid' => 1,
'repeatid' => 0,
}
public function get($member) {
+ if ($member === 'id') {
+ return $this->id;
+ }
return isset($params[$member]) ? $params[$member] : null;
}
- public function get_id() {
- return $this->id;
- }
-
- public function set($member, $value) {
- }
-
public function get_proxied_instance() {
}
}
if (!empty($userid)) {
$prop->userid = $userid;
} else {
- return false;
+ $prop->userid = 0;
}
}
if (!isset($prop->courseid)) {
$this->assertNull($result['lastid']);
}
+ /**
+ * Test retrieving event that was overridden for a user
+ */
+ public function test_get_calendar_events_override() {
+ $user = $this->getDataGenerator()->create_user();
+ $teacher = $this->getDataGenerator()->create_user();
+ $anotheruser = $this->getDataGenerator()->create_user();
+ $course = $this->getDataGenerator()->create_course();
+ $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
+ $moduleinstance = $generator->create_instance(['course' => $course->id]);
+
+ $this->getDataGenerator()->enrol_user($user->id, $course->id);
+ $this->getDataGenerator()->enrol_user($teacher->id, $course->id, 'editingteacher');
+ $this->resetAfterTest(true);
+ $this->setAdminUser();
+
+ $params = [
+ 'type' => CALENDAR_EVENT_TYPE_ACTION,
+ 'modulename' => 'assign',
+ 'instance' => $moduleinstance->id,
+ ];
+
+ $now = time();
+ $event1 = $this->create_calendar_event('Base event', 0, 'due', 0, $now + DAYSECS, $params + ['courseid' => $course->id]);
+ $event2 = $this->create_calendar_event('User event', $user->id, 'due', 0, $now + 2*DAYSECS, $params + ['courseid' => 0]);
+
+ // Retrieve course events for teacher - only one "Base event" is returned.
+ $this->setUser($teacher);
+ $paramevents = array('courseids' => array($course->id));
+ $options = array ('siteevents' => true, 'userevents' => true);
+ $events = core_calendar_external::get_calendar_events($paramevents, $options);
+ $events = external_api::clean_returnvalue(core_calendar_external::get_calendar_events_returns(), $events);
+ $this->assertEquals(1, count($events['events']));
+ $this->assertEquals(0, count($events['warnings']));
+ $this->assertEquals('Base event', $events['events'][0]['name']);
+
+ // Retrieve events for user - both events are returned.
+ $this->setUser($user);
+ $events = core_calendar_external::get_calendar_events($paramevents, $options);
+ $events = external_api::clean_returnvalue(core_calendar_external::get_calendar_events_returns(), $events);
+ $this->assertEquals(2, count($events['events']));
+ $this->assertEquals(0, count($events['warnings']));
+ $this->assertEquals('Base event', $events['events'][0]['name']);
+ $this->assertEquals('User event', $events['events'][1]['name']);
+
+ // Retrieve events by id as a teacher, 'User event' should be returned since teacher has access to this course.
+ $this->setUser($teacher);
+ $paramevents = ['eventids' => [$event2->id]];
+ $events = core_calendar_external::get_calendar_events($paramevents, $options);
+ $events = external_api::clean_returnvalue(core_calendar_external::get_calendar_events_returns(), $events);
+ $this->assertEquals(1, count($events['events']));
+ $this->assertEquals(0, count($events['warnings']));
+ $this->assertEquals('User event', $events['events'][0]['name']);
+
+ // Retrieve events by id as another user, nothing should be returned.
+ $this->setUser($anotheruser);
+ $paramevents = ['eventids' => [$event2->id, $event1->id]];
+ $events = core_calendar_external::get_calendar_events($paramevents, $options);
+ $events = external_api::clean_returnvalue(core_calendar_external::get_calendar_events_returns(), $events);
+ $this->assertEquals(0, count($events['events']));
+ $this->assertEquals(0, count($events['warnings']));
+ }
+
/**
* Requesting calendar events within a given time range should return all events with
* a sort time between the lower and upper time bound (inclusive).
use core_calendar\local\event\entities\event;
use core_calendar\local\event\entities\repeat_event_collection;
use core_calendar\local\event\proxies\std_proxy;
+use core_calendar\local\event\proxies\cm_info_proxy;
use core_calendar\local\event\value_objects\action;
use core_calendar\local\event\value_objects\event_description;
use core_calendar\local\event\value_objects\event_times;
$subscription = null;
if ($record->instance && $record->modulename) {
- $modulename = $record->modulename;
- $module = new std_proxy($record->instance, function($id) use ($modulename) {
- return get_coursemodule_from_instance($modulename, $id);
- },
- (object)[
- 'modname' => $modulename,
- 'instance' => $record->instance
- ]);
+ $module = new cm_info_proxy($record->instance, $record->modulename, $record->courseid);
}
if ($record->subscriptionid) {
+++ /dev/null
-<?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/>.
-
-/**
- * module_std_proxy tests.
- *
- * @package core_calendar
- * @copyright 2017 Cameron Ball <cameron@cameron1729.xyz>
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die();
-
-use core_calendar\local\event\proxies\module_std_proxy;
-
-/**
- * std_proxy testcase.
- *
- * @copyright 2017 Cameron Ball <cameron@cameron1729.xyz>
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class core_calendar_module_std_proxy_testcase extends advanced_testcase {
- /**
- * @var \stdClass[] $objects Array of objects to proxy.
- */
- public $objects;
-
- /**
- * Sets up the fixture. This method is called before a test is executed.
- */
- public function setUp() {
- $this->objects = [
- 'somemodule_someinstance' => (object) [
- 'member1' => 'Hello',
- 'member2' => 1729,
- 'member3' => 'Something else'
- ],
- 'anothermodule_anotherinstance' => (object) [
- 'member1' => 'Hej',
- 'member2' => 87539319,
- 'member3' => 'nagot annat'
- ]
- ];
- }
-
- /**
- * Test proxying.
- *
- * @dataProvider test_proxy_testcases()
- * @param string $modulename Object module name.
- * @param string $instance Object instance.
- * @param string $member Object member to retrieve.
- * @param mixed $expected Expected value of member.
- */
- public function test_proxy($modulename, $instance, $member, $expected) {
- $proxy = new module_std_proxy(
- $modulename,
- $instance,
- function($modulename, $instance) {
- return $this->objects[$modulename . '_' . $instance];
- }
- );
-
- $this->assertEquals($proxy->get($member), $expected);
-
- // Test changing the value.
- $proxy->set($member, 'something even more else');
- $this->assertEquals($proxy->get($member), 'something even more else');
- }
-
- /**
- * Test setting values with a base class.
- *
- * @dataProvider test_proxy_testcases()
- * @param string $modulename Object module name.
- * @param string $instance Object instance.
- * @param string $member Object member to retrieve.
- * @param mixed $storedvalue Value as would be stored externally.
- */
- public function test_base_values($modulename, $instance, $member, $storedvalue) {
- $proxy = new module_std_proxy(
- $modulename,
- $instance,
- function($module, $instance) {
- return $this->objects[$module . '_' . $instance];
- },
- (object)['member1' => 'should clobber 1']
- );
-
- $expected = $member == 'member1' ? 'should clobber 1' : $storedvalue;
- $this->assertEquals($proxy->get($member), $expected);
- }
-
- /**
- * Test getting a non existant member.
- *
- * @dataProvider test_get_set_testcases()
- * @param string $modulename Object module name.
- * @param string $instance Object instance.
- */
- public function test_get_invalid_member($modulename, $instance) {
- $proxy = new module_std_proxy(
- $modulename,
- $instance,
- function($modulename, $instance) {
- return $this->objects[$modulename . '_' . $instance];
- }
- );
-
- $this->expectException('\core_calendar\local\event\exceptions\member_does_not_exist_exception');
- $proxy->get('thisdoesnotexist');
- }
-
- /**
- * Test setting a non existant member.
- *
- * @dataProvider test_get_set_testcases()
- * @param string $modulename Object module name.
- * @param string $instance Object instance.
- */
- public function test_set_invalid_member($modulename, $instance) {
- $proxy = new module_std_proxy(
- $modulename,
- $instance,
- function($modulename, $instance) {
- return $this->objects[$modulename . '_' . $instance];
- }
- );
-
- $this->expectException('\core_calendar\local\event\exceptions\member_does_not_exist_exception');
- $proxy->set('thisdoesnotexist', 'should break');
- }
-
- /**
- * Test get proxied instance.
- *
- * @dataProvider test_get_set_testcases()
- * @param string $modulename Object module name.
- * @param string $instance Object instance.
- */
- public function test_get_proxied_instance($modulename, $instance) {
- $proxy = new module_std_proxy(
- $modulename,
- $instance,
- function($modulename, $instance) {
- return $this->objects[$modulename . '_' . $instance];
- }
- );
-
- $this->assertEquals($proxy->get_proxied_instance(), $this->objects[$modulename . '_' . $instance]);
- }
-
- /**
- * Test cases for&n