MDL-29857 google apis: OAuth 2.0 repository plugins upgrade

We are disabling the plugins on upgrade and emailing admins
about this if they have a plugin configured.

This is required because OAuth 2 credentials are now required
in the plugin configuration.

NOTE: These strings are temporary and need to be improved.
This commit is contained in:
Dan Poltawski
2012-05-31 00:19:30 +08:00
parent 4560fd1b66
commit ce30ff5df0
6 changed files with 82 additions and 2 deletions
+37
View File
@@ -29,5 +29,42 @@ function xmldb_repository_googledocs_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2012051400, 'repository', 'googledocs');
}
if ($oldversion < 2012053000) {
require_once($CFG->dirroot.'/repository/lib.php');
$existing = $DB->get_record('repository', array('type' => 'googledocs'), '*', IGNORE_MULTIPLE);
if ($existing) {
$googledocsplugin = new repository_type('googledocs', array(), true);
$googledocsplugin->delete();
repository_googledocs_admin_upgrade_notification();
}
upgrade_plugin_savepoint(true, 2012053000, 'repository', 'googledocs');
}
return true;
}
function repository_googledocs_admin_upgrade_notification() {
$admins = get_admins();
if (empty($admins)) {
return;
}
$mainadmin = reset($admins);
foreach ($admins as $admin) {
$message = new stdClass();
$message->component = 'moodle';
$message->name = 'notices';
$message->userfrom = $mainadmin;
$message->userto = $admin;
$message->smallmessage = get_string('oauth2upgrade_message_small', 'repository_googledocs');
$message->subject = get_string('oauth2upgrade_message_subject', 'repository_googledocs');
$message->fullmessage = get_string('oauth2upgrade_message_content', 'repository_googledocs');
$message->fullmessagehtml = get_string('oauth2upgrade_message_content', 'repository_googledocs');
$message->fullmessageformat = FORMAT_PLAIN;
$message->notification = 1;
message_send($message);
}
}
@@ -26,6 +26,9 @@ $string['clientid'] = 'Client ID';
$string['configplugin'] = 'Configure Google Docs plugin';
$string['googledocs:view'] = 'View google docs repository';
$string['oauthinfo'] = '<p>To use the Google Docs repository you must be registered with Google. Instructions for registing your installation with Google are described in <a href="{$a->docsurl}">Moodle Docs</a>. The redirect url should be set to:</p><p>{$a->callbackurl}</p>';
$string['oauth2upgrade_message_subject'] = 'Important information regarding Google Docs repository plugin';
$string['oauth2upgrade_message_content'] = 'As part of the upgrade to Moodle 2.3, the Google Docs repository plugin has been disabled due to changes in Googles API. To re-enable your plugin, you must add and reconfigure configure oauth credentials of this plugin.';
$string['oauth2upgrade_message_small'] = 'The Google Docs repository plugin has been disabled until configured with OAuth2';
$string['pluginname'] = 'Google Docs';
$string['secret'] = 'Secret';
+1 -1
View File
@@ -25,6 +25,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2012051400; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2012053000; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2012051100; // Requires this Moodle version.
$plugin->component = 'repository_googledocs'; // Full name of the plugin (used for diagnostics).
+37
View File
@@ -29,5 +29,42 @@ function xmldb_repository_picasa_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2012051400, 'repository', 'picasa');
}
if ($oldversion < 2012053000) {
require_once($CFG->dirroot.'/repository/lib.php');
$existing = $DB->get_record('repository', array('type' => 'picasa'), '*', IGNORE_MULTIPLE);
if ($existing) {
$picasaplugin = new repository_type('picasa', array(), true);
$picasaplugin->delete();
repository_picasa_admin_upgrade_notification();
}
upgrade_plugin_savepoint(true, 2012053000, 'repository', 'picasa');
}
return true;
}
function repository_picasa_admin_upgrade_notification() {
$admins = get_admins();
if (empty($admins)) {
return;
}
$mainadmin = reset($admins);
foreach ($admins as $admin) {
$message = new stdClass();
$message->component = 'moodle';
$message->name = 'notices';
$message->userfrom = $mainadmin;
$message->userto = $admin;
$message->smallmessage = get_string('oauth2upgrade_message_small', 'repository_picasa');
$message->subject = get_string('oauth2upgrade_message_subject', 'repository_picasa');
$message->fullmessage = get_string('oauth2upgrade_message_content', 'repository_picasa');
$message->fullmessagehtml = get_string('oauth2upgrade_message_content', 'repository_picasa');
$message->fullmessageformat = FORMAT_PLAIN;
$message->notification = 1;
message_send($message);
}
}
@@ -25,6 +25,9 @@
$string['clientid'] = 'Client ID';
$string['configplugin'] = 'Picasa repository configuration';
$string['oauthinfo'] = '<p>To use the Picasa repository you must be registered with Google. Instructions for registing your installation with Google are described in <a href="{$a->docsurl}">Moodle Docs</a>. The redirect url should be set to:</p><p>{$a->callbackurl}</p>';
$string['oauth2upgrade_message_subject'] = 'Important information regarding Picasa repository plugin';
$string['oauth2upgrade_message_content'] = 'As part of the upgrade to Moodle 2.3, the Picasa repository plugin has been disabled due to changes in Googles API. To re-enable your plugin, you must add and reconfigure configure oauth credentials of this plugin.';
$string['oauth2upgrade_message_small'] = 'The Picasa repository plugin has been disabled until configured with OAuth2';
$string['picasa:view'] = 'View picasa repository';
$string['pluginname'] = 'Picasa web album';
$string['secret'] = 'Secret';
+1 -1
View File
@@ -26,6 +26,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2012051400; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2012053000; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2012051100; // Requires this Moodle version.
$plugin->component = 'repository_picasa'; // Full name of the plugin (used for diagnostics).