--- /dev/null
+<?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/>.
+
+/**
+ * @package moodlecore
+ * @subpackage backup-moodle2
+ * @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/**
+ * Specialised backup task for the html block
+ * (requires encode_content_links in some configdata attrs)
+ *
+ * TODO: Finish phpdocs
+ */
+class backup_html_block_task extends backup_block_task {
+
+ protected function define_my_settings() {
+ }
+
+ protected function define_my_steps() {
+ }
+
+ public function get_configdata_encoded_attributes() {
+ return array('text'); // We need to encode some attrs in configdata
+ }
+
+ static public function encode_content_links($content) {
+ return $content; // No special encoding of links
+ }
+}
+
--- /dev/null
+<?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/>.
+
+/**
+ * @package moodlecore
+ * @subpackage backup-moodle2
+ * @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+require_once($CFG->dirroot . '/blocks/rss_client/backup/moodle2/backup_rss_client_stepslib.php'); // We have structure steps
+
+/**
+ * Specialised backup task for the rss_client block
+ * (has own DB structures to backup)
+ *
+ * TODO: Finish phpdocs
+ */
+class backup_rss_client_block_task extends backup_block_task {
+ // Nothing to do, it's just the backup_block_task in action
+ // with required methods doing nothing special
+
+ protected function define_my_settings() {
+ }
+
+ protected function define_my_steps() {
+ // rss_client has one structure step
+ $this->add_step(new backup_rss_client_block_structure_step('rss_client_structure', 'rss_client.xml'));
+ }
+
+ public function get_configdata_encoded_attributes() {
+ return array(); // No special handling of configdata
+ }
+
+ static public function encode_content_links($content) {
+ return $content; // No special encoding of links
+ }
+}
+
--- /dev/null
+<?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/>.
+
+/**
+ * @package moodlecore
+ * @subpackage backup-moodle2
+ * @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/**
+ * Define all the backup steps that wll be used by the backup_rss_client_block_task
+ */
+
+/**
+ * Define the complete forum structure for backup, with file and id annotations
+ */
+class backup_rss_client_block_structure_step extends backup_block_structure_step {
+
+ protected function define_structure() {
+ global $DB;
+
+ // Get the block
+ $block = $DB->get_record('block_instances', array('id' => $this->task->get_blockid()));
+ // Extract configdata
+ $config = unserialize(base64_decode($block->configdata));
+ // Get array of used rss feeds
+ if (!empty($config->rssid)) {
+ $feedids = $config->rssid;
+ // Get the IN corresponding query
+ list($in_sql, $in_params) = $DB->get_in_or_equal($feedids);
+ // Define all the in_params as sqlparams
+ foreach ($in_params as $key => $value) {
+ $in_params[$key] = $this->is_sqlparam($value);
+ }
+ }
+
+ // Define each element separated
+
+ $rss_client = new backup_nested_element('rss_client', array('id'), null);
+
+ $feeds = new backup_nested_element('feeds');
+
+ $feed = new backup_nested_element('feed', array('id'), array(
+ 'title', 'preferredtitle', 'description', 'shared',
+ 'url'));
+
+ // Build the tree
+
+ $rss_client->add_child($feeds);
+ $feeds->add_child($feed);
+
+ // Define sources
+
+ $rss_client->set_source_array(array((object)array('id' => $this->task->get_blockid())));
+
+ // Only if there are feeds
+ if (!empty($config->rssid)) {
+ $feed->set_source_sql("
+ SELECT *
+ FROM {block_rss_client}
+ WHERE id $in_sql", $in_params);
+ }
+
+ // Annotations (none)
+
+ // Return the root element (rss_client), wrapped into standard block structure
+ return $this->prepare_block_structure($rss_client);
+ }
+}