MDL-42666 repository_boxnet: Tool to launch the migration
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Box.net migration CLI script.
|
||||
*
|
||||
* @package repository_boxnet
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
require(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir . '/clilib.php');
|
||||
require_once($CFG->dirroot . '/repository/boxnet/locallib.php');
|
||||
|
||||
// Now get cli options.
|
||||
list($options, $unrecognized) = cli_get_params(array(
|
||||
'help' => false,
|
||||
'confirm' => '',
|
||||
));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
$help =
|
||||
"Box.net APIv1 migration tool.
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
--confirm Proceed with the migration
|
||||
|
||||
Example:
|
||||
\$ sudo -u www-data /usr/bin/php admin/tool/boxnetv1migrationtool/cli/migrate.php --confirm=1
|
||||
";
|
||||
|
||||
if ($options['help'] || empty($options['confirm'])) {
|
||||
echo $help;
|
||||
die();
|
||||
}
|
||||
|
||||
if ($options['confirm']) {
|
||||
mtrace("Box.net migration running...");
|
||||
repository_boxnet_migrate_references_from_apiv1();
|
||||
}
|
||||
|
||||
@@ -32,10 +32,16 @@ $string['configplugin'] = 'Box.net configuration';
|
||||
$string['filesourceinfo'] = 'Box.net ({$a->fullname}): {$a->filename}';
|
||||
$string['information'] = 'Get a client ID and secret from the <a href="https://app.box.com/developers/services">Box.net developer page</a> for your Moodle site.';
|
||||
$string['invalidpassword'] = 'Invalid password';
|
||||
$string['migrationinfo'] = '<p>As part of the migration to the new API provided by Box.net, your file references have to be migrated. Unfortunately the reference system is not compatible with the API v2, so we are going to download them and convert them to real files.</p>
|
||||
<p>Please also be aware that the migration can <strong>take a very long time</strong>, depending on how many references are used, and how large their files are.</p>
|
||||
<p>You can run the migration tool by clicking the button below, or alternatively by executing the CLI script: repository/boxnet/cli/migrationv1.php.</p>
|
||||
<p>Find out more <a href="{$a->docsurl}">here</a>.</p>';
|
||||
$string['migrationtool'] = 'Box.net APIv1 migration tool';
|
||||
$string['nullfilelist'] = 'There are no files in this repository';
|
||||
$string['password'] = 'Password';
|
||||
$string['pluginname_help'] = 'Repository on Box.net';
|
||||
$string['pluginname'] = 'Box.net';
|
||||
$string['runthemigrationnow'] = 'Run the migration tool now';
|
||||
$string['saved'] = 'Box.net data saved';
|
||||
$string['shareurl'] = 'Share URL';
|
||||
$string['username'] = 'Username for Box.net';
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Box.net APIv1 migration tool.
|
||||
*
|
||||
* This tool is intended to migrate the references of the APIv1 of Box.net
|
||||
* as this API is going end of life in December 14th 2013. As there is no
|
||||
* way to support the references in the APIv2, we will convert those old
|
||||
* references to local files.
|
||||
*
|
||||
* This operation can take a long time depending on the number of references
|
||||
* used and their size.
|
||||
*
|
||||
* @package repository_boxnet
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @todo Deprecate/remove this tool after the 14th of December 2013.
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->dirroot . '/repository/boxnet/locallib.php');
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
|
||||
$title = get_string('migrationtool', 'repository_boxnet');
|
||||
$PAGE->set_context(context_system::instance());
|
||||
$PAGE->set_pagelayout('admin');
|
||||
$PAGE->set_title($title);
|
||||
$PAGE->set_heading($title);
|
||||
$PAGE->set_url(new moodle_url('/repository/boxnet/migrationv1.php'));
|
||||
$PAGE->navbar->add($title);
|
||||
|
||||
$confirm = optional_param('confirm', false, PARAM_BOOL);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading('Reference migration tool');
|
||||
|
||||
if (strtotime('15 December 2013') < time()) {
|
||||
echo html_writer::tag('p', 'Sorry, the API v1 has already reached its end of life, the migration is no more possible.');
|
||||
} else if ($confirm && confirm_sesskey()) {
|
||||
echo html_writer::start_tag('pre', array());
|
||||
repository_boxnet_migrate_references_from_apiv1();
|
||||
echo html_writer::end_tag('pre', array());
|
||||
} else {
|
||||
$a = new stdClass();
|
||||
$a->docsurl = get_docs_url('Box.net_APIv1_migration');
|
||||
echo html_writer::tag('p', get_string('migrationinfo', 'repository_boxnet', $a));
|
||||
$execurl = new moodle_url('/repository/boxnet/migrationv1.php', array('confirm' => 1, 'sesskey' => sesskey()));
|
||||
$button = new single_button($execurl, get_string('runthemigrationnow', 'repository_boxnet'));
|
||||
echo $OUTPUT->render($button);
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
Reference in New Issue
Block a user