Skip to content

Commit

Permalink
Merge branch 'MDL46116_IMSCP_container_items.updates_2014-11-11' of h…
Browse files Browse the repository at this point in the history
…ttps://github.com/Dave-B/moodle

Conflicts:
	mod/imscp/module.js
  • Loading branch information
Sam Hemelryk authored and danpoltawski committed Dec 4, 2014
2 parents 13e0300 + c57617d commit 1013481
Show file tree
Hide file tree
Showing 19 changed files with 280 additions and 200 deletions.
25 changes: 14 additions & 11 deletions mod/imscp/backup/moodle1/lib.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -27,6 +26,9 @@

/**
* imscp conversion handler. This resource handler is called by moodle1_mod_resource_handler
*
* @copyright 2011 Andrew Davis <andrew@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class moodle1_mod_imscp_handler extends moodle1_resource_successor_handler {

Expand All @@ -44,7 +46,7 @@ public function process_legacy_resource(array $data, array $raw = null) {
$moduleid = $currentcminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $moduleid);

// prepare the new imscp instance record
// Prepare the new imscp instance record.
$imscp = array();
$imscp['id'] = $data['id'];
$imscp['name'] = $data['name'];
Expand All @@ -55,15 +57,15 @@ public function process_legacy_resource(array $data, array $raw = null) {
$imscp['structure'] = null;
$imscp['timemodified'] = $data['timemodified'];

// prepare a fresh new file manager for this instance
// Prepare a fresh new file manager for this instance.
$this->fileman = $this->converter->get_file_manager($contextid, 'mod_imscp');

// convert course files embedded into the intro
// Convert course files embedded into the intro.
$this->fileman->filearea = 'intro';
$this->fileman->itemid = 0;
$imscp['intro'] = moodle1_converter::migrate_referenced_files($imscp['intro'], $this->fileman);

// migrate package backup file
// Migrate package backup file.
if ($data['reference']) {
$packagename = basename($data['reference']);
$packagepath = $this->converter->get_tempdir_path().'/moddata/resource/'.$data['id'].'/'.$packagename;
Expand All @@ -76,24 +78,25 @@ public function process_legacy_resource(array $data, array $raw = null) {
}
}

// migrate extracted package data
// Migrate extracted package data.
$this->fileman->filearea = 'content';
$this->fileman->itemid = 1;
$this->fileman->migrate_directory('moddata/resource/'.$data['id']);

// parse manifest
$structure = $this->parse_structure($this->converter->get_tempdir_path().'/moddata/resource/'.$data['id'].'/imsmanifest.xml', $imscp, $contextid);
// Parse manifest.
$structure = $this->parse_structure($this->converter->get_tempdir_path().
'/moddata/resource/'.$data['id'].'/imsmanifest.xml', $imscp, $contextid);
$imscp['structure'] = is_array($structure) ? serialize($structure) : null;

// write imscp.xml
// Write imscp.xml.
$this->open_xml_writer("activities/imscp_{$moduleid}/imscp.xml");
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $moduleid,
'modulename' => 'imscp', 'contextid' => $contextid));
$this->write_xml('imscp', $imscp, array('/imscp/id'));
$this->xmlwriter->end_tag('activity');
$this->close_xml_writer();

// write inforef.xml
// Write inforef.xml.
$this->open_xml_writer("activities/imscp_{$moduleid}/inforef.xml");
$this->xmlwriter->begin_tag('inforef');
$this->xmlwriter->begin_tag('fileref');
Expand All @@ -105,7 +108,7 @@ public function process_legacy_resource(array $data, array $raw = null) {
$this->close_xml_writer();
}

/// internal implementation details follow /////////////////////////////////
// Internal implementation details follow.

/**
* Parse the IMS package structure for the $imscp->structure field
Expand Down
18 changes: 10 additions & 8 deletions mod/imscp/backup/moodle2/backup_imscp_activity_task.class.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -30,6 +29,9 @@

/**
* Provides the steps to perform one complete backup of the IMSCP instance
*
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class backup_imscp_activity_task extends backup_activity_task {

Expand All @@ -55,15 +57,15 @@ protected function define_my_steps() {
static public function encode_content_links($content) {
global $CFG;

$base = preg_quote($CFG->wwwroot,"/");
$base = preg_quote($CFG->wwwroot, "/");

// Link to the list of imscps
$search="/(".$base."\/mod\/imscp\/index.php\?id\=)([0-9]+)/";
$content= preg_replace($search, '$@IMSCPINDEX*$2@$', $content);
// Link to the list of imscps.
$search = "/(" . $base . "\/mod\/imscp\/index.php\?id\=)([0-9]+)/";
$content = preg_replace($search, '$@IMSCPINDEX*$2@$', $content);

// Link to imscp view by moduleid
$search="/(".$base."\/mod\/imscp\/view.php\?id\=)([0-9]+)/";
$content= preg_replace($search, '$@IMSCPVIEWBYID*$2@$', $content);
// Link to imscp view by moduleid.
$search = "/(" . $base . "\/mod\/imscp\/view.php\?id\=)([0-9]+)/";
$content = preg_replace($search, '$@IMSCPVIEWBYID*$2@$', $content);

return $content;
}
Expand Down
30 changes: 13 additions & 17 deletions mod/imscp/backup/moodle2/backup_imscp_stepslib.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -27,39 +26,36 @@

/**
* Define the complete imscp structure for backup, with file and id annotations
*
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class backup_imscp_activity_structure_step extends backup_activity_structure_step {

protected function define_structure() {

// To know if we are including userinfo
// To know if we are including userinfo.
$userinfo = $this->get_setting_value('userinfo');

// Define each element separated
// Define each element separated.
$imscp = new backup_nested_element('imscp', array('id'), array(
'name', 'intro', 'introformat', 'revision',
'keepold', 'structure', 'timemodified'));

// Build the tree
// (love this)
// Build the tree.

// Define sources
// Define sources.
$imscp->set_source_table('imscp', array('id' => backup::VAR_ACTIVITYID));

// Define id annotations
// (none)
// Define id annotations - (none).

// Define file annotations
$imscp->annotate_files('mod_imscp', 'intro', null); // This file area hasn't itemid
$imscp->annotate_files('mod_imscp', 'backup', null); // This file area hasn't itemid
/**
* I don't like itemid used for "imaginative" things like "revisions"!
* I don't like itemid used for "imaginative" things like "revisions"!
* I don't like itemid used for "imaginative" things like "revisions"!
*/
$imscp->annotate_files('mod_imscp', 'content', null); // Horrible use of itemid here. Ignoring for backup/restore purposes
$imscp->annotate_files('mod_imscp', 'intro', null); // This file area hasn't itemid.
$imscp->annotate_files('mod_imscp', 'backup', null); // This file area hasn't itemid.
// Eloy Lafuente: I don't like itemid used for "imaginative" things like "revisions"!
$imscp->annotate_files('mod_imscp', 'content', null); // Horrible use of itemid here. Ignoring for backup/restore purposes.

// Return the root element (imscp), wrapped into standard activity structure
// Return the root element (imscp), wrapped into standard activity structure.
return $this->prepare_activity_structure($imscp);
}
}
21 changes: 12 additions & 9 deletions mod/imscp/backup/moodle2/restore_imscp_activity_task.class.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand All @@ -16,34 +15,38 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* @package mod_imscp
* Defines restore_imscp_activity_task class
*
* @package mod_imscp
* @subpackage backup-moodle2
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

require_once($CFG->dirroot . '/mod/imscp/backup/moodle2/restore_imscp_stepslib.php'); // Because it exists (must)
require_once($CFG->dirroot . '/mod/imscp/backup/moodle2/restore_imscp_stepslib.php');

/**
* imscp restore task that provides all the settings and steps to perform one
* complete restore of the activity
* Provides the settings and steps to perform one complete restore of the activity
*
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class restore_imscp_activity_task extends restore_activity_task {

/**
* Define (add) particular settings this activity can have
*/
protected function define_my_settings() {
// No particular settings for this activity
// No particular settings for this activity.
}

/**
* Define (add) particular steps this activity can have
*/
protected function define_my_steps() {
// imscp only has one structure step
// Module imscp only has one structure step.
$this->add_step(new restore_imscp_activity_structure_step('imscp_structure', 'imscp.xml'));
}

Expand Down
24 changes: 10 additions & 14 deletions mod/imscp/backup/moodle2/restore_imscp_stepslib.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand All @@ -16,18 +15,19 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Define all the restore steps that will be used by the restore_imscp_activity_task
*
* @package mod_imscp
* @subpackage backup-moodle2
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

/**
* Define all the restore steps that will be used by the restore_imscp_activity_task
*/

/**
* Structure step to restore one imscp activity
*
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class restore_imscp_activity_structure_step extends restore_activity_structure_step {

Expand All @@ -36,7 +36,7 @@ protected function define_structure() {
$paths = array();
$paths[] = new restore_path_element('imscp', '/activity/imscp');

// Return the paths wrapped into standard activity structure
// Return the paths wrapped into standard activity structure.
return $this->prepare_activity_structure($paths);
}

Expand All @@ -48,19 +48,15 @@ protected function process_imscp($data) {
$data->course = $this->get_courseid();
$data->timemodified = $this->apply_date_offset($data->timemodified);

// insert the imscp record
// Insert the imscp record.
$newitemid = $DB->insert_record('imscp', $data);
// immediately after inserting "activity" record, call this
// Immediately after inserting "activity" record, call this.
$this->apply_activity_instance($newitemid);
}

protected function after_execute() {
// Add imscp related files, no need to match by itemname (just internally handled context)
/**
* I don't like itemid used for "imaginative" things like "revisions"!
* I don't like itemid used for "imaginative" things like "revisions"!
* I don't like itemid used for "imaginative" things like "revisions"!
*/
// Add imscp related files, no need to match by itemname (just internally handled context).
// Eloy Lafuente: I don't like itemid used for "imaginative" things like "revisions"!
$this->add_related_files('mod_imscp', 'intro', null);
$this->add_related_files('mod_imscp', 'backup', null);
$this->add_related_files('mod_imscp', 'content', null);
Expand Down
4 changes: 3 additions & 1 deletion mod/imscp/db/install.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -30,6 +29,9 @@

defined('MOODLE_INTERNAL') || die();

/**
* Stub for database installation.
*/
function xmldb_imscp_install() {
global $CFG;

Expand Down
11 changes: 5 additions & 6 deletions mod/imscp/db/log.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -27,8 +26,8 @@
defined('MOODLE_INTERNAL') || die();

$logs = array(
array('module'=>'imscp', 'action'=>'view', 'mtable'=>'imscp', 'field'=>'name'),
array('module'=>'imscp', 'action'=>'view all', 'mtable'=>'imscp', 'field'=>'name'),
array('module'=>'imscp', 'action'=>'update', 'mtable'=>'imscp', 'field'=>'name'),
array('module'=>'imscp', 'action'=>'add', 'mtable'=>'imscp', 'field'=>'name'),
);
array('module' => 'imscp', 'action' => 'view', 'mtable' => 'imscp', 'field' => 'name'),
array('module' => 'imscp', 'action' => 'view all', 'mtable' => 'imscp', 'field' => 'name'),
array('module' => 'imscp', 'action' => 'update', 'mtable' => 'imscp', 'field' => 'name'),
array('module' => 'imscp', 'action' => 'add', 'mtable' => 'imscp', 'field' => 'name'),
);
21 changes: 10 additions & 11 deletions mod/imscp/db/upgrade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand All @@ -25,27 +24,27 @@

defined('MOODLE_INTERNAL') || die();

/**
* Stub for database upgrade.
* @param int $oldversion
*/
function xmldb_imscp_upgrade($oldversion) {
global $CFG, $DB;

$dbman = $DB->get_manager();

// Moodle v2.2.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v2.2.0 release upgrade line
// Put any upgrade step following this

// Moodle v2.3.0 release upgrade line
// Put any upgrade step following this


// Moodle v2.4.0 release upgrade line
// Put any upgrade step following this
// Moodle v2.3.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v2.4.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v2.5.0 release upgrade line.
// Put any upgrade step following this.


// Moodle v2.6.0 release upgrade line.
// Put any upgrade step following this.

Expand Down
Loading

0 comments on commit 1013481

Please sign in to comment.