1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * @package block_rss_client 19 * @subpackage backup-moodle2 20 * @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} 21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 22 */ 23 24 /** 25 * Define all the backup steps that wll be used by the backup_rss_client_block_task 26 */ 27 28 /** 29 * Define the complete forum structure for backup, with file and id annotations 30 */ 31 class backup_rss_client_block_structure_step extends backup_block_structure_step { 32 33 protected function define_structure() { 34 global $DB; 35 36 // Get the block 37 $block = $DB->get_record('block_instances', array('id' => $this->task->get_blockid())); 38 // Extract configdata 39 $config = unserialize_object(base64_decode($block->configdata)); 40 // Get array of used rss feeds 41 if (!empty($config->rssid)) { 42 $feedids = $config->rssid; 43 // Get the IN corresponding query 44 list($in_sql, $in_params) = $DB->get_in_or_equal($feedids); 45 // Define all the in_params as sqlparams 46 foreach ($in_params as $key => $value) { 47 $in_params[$key] = backup_helper::is_sqlparam($value); 48 } 49 } 50 51 // Define each element separated 52 53 $rss_client = new backup_nested_element('rss_client', array('id'), null); 54 55 $feeds = new backup_nested_element('feeds'); 56 57 $feed = new backup_nested_element('feed', array('id'), array( 58 'title', 'preferredtitle', 'description', 'shared', 59 'url')); 60 61 // Build the tree 62 63 $rss_client->add_child($feeds); 64 $feeds->add_child($feed); 65 66 // Define sources 67 68 $rss_client->set_source_array(array((object)array('id' => $this->task->get_blockid()))); 69 70 // Only if there are feeds 71 if (!empty($config->rssid)) { 72 $feed->set_source_sql(" 73 SELECT * 74 FROM {block_rss_client} 75 WHERE id $in_sql", $in_params); 76 } 77 78 // Annotations (none) 79 80 // Return the root element (rss_client), wrapped into standard block structure 81 return $this->prepare_block_structure($rss_client); 82 } 83 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body