Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-32880: Add moodle1 backup converter for rss_client block.

Creates a shell rss_client.xml file, which contains no feeds.  This makes it behave the same as restoring a Moodle 1.9 backup into a different 1.9 site - the block is created, its title is as per the original course, but it has no feeds selected (and none are added to the site's feed list).
  • Loading branch information...
commit 1ff2b563196768b129a817dafabd5e49092b7f13 1 parent 4d9b4e9
Paul Nicholls authored November 07, 2012 stronk7 committed December 11, 2012

Showing 1 changed file with 34 additions and 0 deletions. Show diff stats Hide diff stats

  1. 34  blocks/rss_client/backup/moodle1/lib.php
34  blocks/rss_client/backup/moodle1/lib.php
... ...
@@ -0,0 +1,34 @@
  1
+<?php
  2
+
  3
+/**
  4
+ * Provides support for the conversion of moodle1 backup to the moodle2 format
  5
+ *
  6
+ * @package    block_rss_client
  7
+ * @copyright  2012 Paul Nicholls
  8
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  9
+ */
  10
+
  11
+defined('MOODLE_INTERNAL') || die();
  12
+
  13
+/**
  14
+ * Block conversion handler for rss_client
  15
+ */
  16
+class moodle1_block_rss_client_handler extends moodle1_block_handler {
  17
+    public function process_block(array $data) {
  18
+        parent::process_block($data);
  19
+        $instanceid = $data['id'];
  20
+        $contextid = $this->converter->get_contextid(CONTEXT_BLOCK, $data['id']);
  21
+
  22
+        // Moodle 1.9 backups do not include sufficient data to restore feeds, so we need an empty shell rss_client.xml
  23
+        // for the restore process to find
  24
+        $this->open_xml_writer("course/blocks/{$data['name']}_{$instanceid}/rss_client.xml");
  25
+        $this->xmlwriter->begin_tag('block', array('id' => $instanceid, 'contextid' => $contextid, 'blockname' => 'rss_client'));
  26
+        $this->xmlwriter->begin_tag('rss_client', array('id' => $instanceid));
  27
+        $this->xmlwriter->full_tag('feeds', '');
  28
+        $this->xmlwriter->end_tag('rss_client');
  29
+        $this->xmlwriter->end_tag('block');
  30
+        $this->close_xml_writer();
  31
+
  32
+        return $data;
  33
+    }
  34
+}

0 notes on commit 1ff2b56

Please sign in to comment.
Something went wrong with that request. Please try again.