Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/blocks/rss_client/backup/moodle2/backup_rss_client_stepslib.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00032 class backup_rss_client_block_structure_step extends backup_block_structure_step {
00033 
00034     protected function define_structure() {
00035         global $DB;
00036 
00037         // Get the block
00038         $block = $DB->get_record('block_instances', array('id' => $this->task->get_blockid()));
00039         // Extract configdata
00040         $config = unserialize(base64_decode($block->configdata));
00041         // Get array of used rss feeds
00042         if (!empty($config->rssid)) {
00043             $feedids = $config->rssid;
00044             // Get the IN corresponding query
00045             list($in_sql, $in_params) = $DB->get_in_or_equal($feedids);
00046             // Define all the in_params as sqlparams
00047             foreach ($in_params as $key => $value) {
00048                 $in_params[$key] = backup_helper::is_sqlparam($value);
00049             }
00050         }
00051 
00052         // Define each element separated
00053 
00054         $rss_client = new backup_nested_element('rss_client', array('id'), null);
00055 
00056         $feeds = new backup_nested_element('feeds');
00057 
00058         $feed = new backup_nested_element('feed', array('id'), array(
00059             'title', 'preferredtitle', 'description', 'shared',
00060             'url'));
00061 
00062         // Build the tree
00063 
00064         $rss_client->add_child($feeds);
00065         $feeds->add_child($feed);
00066 
00067         // Define sources
00068 
00069         $rss_client->set_source_array(array((object)array('id' => $this->task->get_blockid())));
00070 
00071         // Only if there are feeds
00072         if (!empty($config->rssid)) {
00073             $feed->set_source_sql("
00074                 SELECT *
00075                   FROM {block_rss_client}
00076                  WHERE id $in_sql", $in_params);
00077         }
00078 
00079         // Annotations (none)
00080 
00081         // Return the root element (rss_client), wrapped into standard block structure
00082         return $this->prepare_block_structure($rss_client);
00083     }
00084 }
 All Data Structures Namespaces Files Functions Variables Enumerations