Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/blocks/html/db/upgrade.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 function xmldb_block_html_upgrade($oldversion) {
00033     global $CFG, $DB;
00034 
00035     $dbman = $DB->get_manager();
00036 
00037     if ($oldversion < 2010071900) {
00038         $params = array();
00039         $sql = "SELECT * FROM {block_instances} b WHERE b.blockname = :blockname";
00040         $params['blockname'] = 'html';
00041         $rs = $DB->get_recordset_sql($sql, $params);
00042         foreach ($rs as $record) {
00043             $config = unserialize(base64_decode($record->configdata));
00044             if (!empty($config) && is_object($config)) {
00045                 if (!empty($config->text) && is_array($config->text)) {
00046                     // fix bad data
00047                     $data = clone($config);
00048                     $config->text = $data->text['text'];
00049                     $config->format = $data->text['format'];
00050                     $record->configdata = base64_encode(serialize($config));
00051                     $DB->update_record('block_instances', $record);
00052                 } else if (empty($config->format)) {
00053                     // add format parameter to 1.9
00054                     $config->format = FORMAT_HTML;
00055                     $record->configdata = base64_encode(serialize($config));
00056                     $DB->update_record('block_instances', $record);
00057                 }
00058             }
00059         }
00060         $rs->close();
00061 
00063         upgrade_block_savepoint(true, 2010071900, 'html');
00064     }
00065 
00066     // Moodle v2.1.0 release upgrade line
00067     // Put any upgrade step following this
00068 
00069     // Moodle v2.2.0 release upgrade line
00070     // Put any upgrade step following this
00071 
00072     return true;
00073 }
 All Data Structures Namespaces Files Functions Variables Enumerations