From 6c9cd495a2279b379173040dac1189f583797456 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Sun, 5 Mar 2017 16:13:53 +0800 Subject: [PATCH] MDL-58128 googledocs: Upgrade repo config Part of MDL-58220 --- repository/googledocs/db/upgrade.php | 17 +++++++++++++++++ repository/googledocs/version.php | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/repository/googledocs/db/upgrade.php b/repository/googledocs/db/upgrade.php index da8d731a947..2a5698ef3c1 100644 --- a/repository/googledocs/db/upgrade.php +++ b/repository/googledocs/db/upgrade.php @@ -48,6 +48,23 @@ function xmldb_repository_googledocs_upgrade($oldversion) { // Plugin savepoint reached. upgrade_plugin_savepoint(true, 2017011100, 'repository', 'googledocs'); } + if ($oldversion < 2017030500) { + $clientid = get_config('clientid', 'googledocs'); + $secret = get_config('secret', 'googledocs'); + + // Update from repo config to use an OAuth service. + if (!empty($clientid) && !empty($secret)) { + $issuer = \core\oauth2\api::create_standard_issuer('google'); + + $issuer->set('clientid', $clientid); + $issuer->set('secret', $secret); + + $issuer->update(); + + set_config('issuerid', $issuer->get('id'), 'googledocs'); + } + upgrade_plugin_savepoint(true, 2017030500, 'repository', 'googledocs'); + } return true; } diff --git a/repository/googledocs/version.php b/repository/googledocs/version.php index 04eaa0e8fab..ce8f197427a 100644 --- a/repository/googledocs/version.php +++ b/repository/googledocs/version.php @@ -25,6 +25,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2017011100; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2017030500; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2016112900; // Requires this Moodle version. $plugin->component = 'repository_googledocs'; // Full name of the plugin (used for diagnostics).