diff --git a/repository/boxnet/db/upgrade.php b/repository/boxnet/db/upgrade.php new file mode 100644 index 00000000000..39fdb17608f --- /dev/null +++ b/repository/boxnet/db/upgrade.php @@ -0,0 +1,69 @@ +. + +/** + * Upgrade. + * + * @package repository_boxnet + * @copyright 2013 Frédéric Massart + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +/** + * Upgrade function. + * + * @param int $oldversion the version we are upgrading from. + * @return bool result + */ +function xmldb_repository_boxnet_upgrade($oldversion) { + global $CFG, $DB; + + $dbman = $DB->get_manager(); + + if ($oldversion < 2013110503) { + // Delete old user preferences containing auth tokens. + $DB->delete_records('user_preferences', array('name' => 'boxnet__auth_token')); + upgrade_plugin_savepoint(true, 2013110503, 'repository', 'boxnet'); + } + + if ($oldversion < 2013110504) { + require_once($CFG->dirroot . '/repository/lib.php'); + require_once($CFG->dirroot . '/repository/boxnet/db/upgradelib.php'); + + $params = array(); + $params['context'] = array(); + $params['onlyvisible'] = false; + $params['type'] = 'boxnet'; + $instances = repository::get_instances($params); + + // Notify the admin about the migration process if they are using the repo. + if (!empty($instances)) { + repository_boxnet_admin_upgrade_notification(); + } + + // Hide the repository. + $repositorytype = repository::get_type_by_typename('boxnet'); + if (!empty($repositorytype)) { + $repositorytype->update_visibility(false); + } + + upgrade_plugin_savepoint(true, 2013110504, 'repository', 'boxnet'); + } + + return true; +} diff --git a/repository/boxnet/db/upgradelib.php b/repository/boxnet/db/upgradelib.php new file mode 100644 index 00000000000..c0cf9de80d6 --- /dev/null +++ b/repository/boxnet/db/upgradelib.php @@ -0,0 +1,55 @@ +. + +/** + * Locallib. + * + * @package repository_boxnet + * @copyright 2013 Frédéric Massart + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +/** + * Send a message to the admin in regard with the APIv1 migration. + * + * @return void + */ +function repository_boxnet_admin_upgrade_notification() { + $admins = get_admins(); + + if (empty($admins)) { + return; + } + $a = new stdClass(); + $a->docsurl = get_docs_url('Box.net_APIv1_migration'); + + foreach ($admins as $admin) { + $message = new stdClass(); + $message->component = 'moodle'; + $message->name = 'notices'; + $message->userfrom = get_admin(); + $message->userto = $admin; + $message->smallmessage = get_string('apiv1migration_message_small', 'repository_boxnet'); + $message->subject = get_string('apiv1migration_message_subject', 'repository_boxnet'); + $message->fullmessage = get_string('apiv1migration_message_content', 'repository_boxnet', $a); + $message->fullmessagehtml = get_string('apiv1migration_message_content', 'repository_boxnet', $a); + $message->fullmessageformat = FORMAT_PLAIN; + $message->notification = 1; + message_send($message); + } +} diff --git a/repository/boxnet/lang/en/repository_boxnet.php b/repository/boxnet/lang/en/repository_boxnet.php index a2a447644ad..84c65929ec1 100644 --- a/repository/boxnet/lang/en/repository_boxnet.php +++ b/repository/boxnet/lang/en/repository_boxnet.php @@ -24,6 +24,9 @@ */ $string['apikey'] = 'API key'; +$string['apiv1migration_message_content'] = 'As part of the recent Moodle upgrade (2.6, 2.5.3, 2.4.7), the Box.net repository plugin has been disabled. To re-enable it, you need to re-configure it as described in the documentation {$a->docsurl}.'; +$string['apiv1migration_message_small'] = 'This plugin has been disabled, as it requires configuration as described in the documentation Box.net APIv1 migration.'; +$string['apiv1migration_message_subject'] = 'Important information regarding Box.net repository plugin'; $string['boxnet:view'] = 'View box.net repository'; $string['cannotcreatereference'] = 'Cannot create a reference, not enough permissions to share the file on Box.net.'; $string['clientid'] = 'Client ID'; diff --git a/repository/boxnet/version.php b/repository/boxnet/version.php index ec971839672..a32ea60af2b 100644 --- a/repository/boxnet/version.php +++ b/repository/boxnet/version.php @@ -26,6 +26,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX) +$plugin->version = 2013110504; // The current plugin version (Date: YYYYMMDDXX) $plugin->requires = 2013110500; // Requires this Moodle version $plugin->component = 'repository_boxnet'; // Full name of the plugin (used for diagnostics)