[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/theme/more/db/ -> upgrade.php (source)

   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   * Theme More upgrade.
  19   *
  20   * @package    theme_more
  21   * @copyright  2014 Frédéric Massart
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  /**
  28   * Theme_more upgrade function.
  29   *
  30   * @param  int $oldversion The version we upgrade from.
  31   * @return bool
  32   */
  33  function xmldb_theme_more_upgrade($oldversion) {
  34      global $CFG;
  35  
  36      if ($oldversion < 2014032400) {
  37  
  38          // Set the default background. If an image is already there then ignore.
  39          $fs = get_file_storage();
  40          $bg = $fs->get_area_files(context_system::instance()->id, 'theme_more', 'backgroundimage', 0);
  41  
  42          // Add default background image.
  43          if (empty($bg)) {
  44              $filerecord = new stdClass();
  45              $filerecord->component = 'theme_more';
  46              $filerecord->contextid = context_system::instance()->id;
  47              $filerecord->userid    = get_admin()->id;
  48              $filerecord->filearea  = 'backgroundimage';
  49              $filerecord->filepath  = '/';
  50              $filerecord->itemid    = 0;
  51              $filerecord->filename  = 'background.jpg';
  52              $fs->create_file_from_pathname($filerecord, $CFG->dirroot . '/theme/more/pix/background.jpg');
  53          }
  54  
  55          upgrade_plugin_savepoint(true, 2014032400, 'theme', 'more');
  56  
  57      }
  58  
  59      if ($oldversion < 2014032401) {
  60  
  61          // Set the default settings as they might already be set.
  62          set_config('textcolor', '#333366', 'theme_more');
  63          set_config('linkcolor', '#FF6500', 'theme_more');
  64          set_config('backgroundrepeat', 'repeat', 'theme_more');
  65          set_config('contentbackground', '#FFFFFF', 'theme_more');
  66          set_config('secondarybackground', '#FFFFFF', 'theme_more');
  67          set_config('invert', 1, 'theme_more');
  68          set_config('backgroundimage', '/background.jpg', 'theme_more');
  69  
  70          upgrade_plugin_savepoint(true, 2014032401, 'theme', 'more');
  71      }
  72  
  73      // Moodle v2.7.0 release upgrade line.
  74      // Put any upgrade step following this.
  75  
  76      // Moodle v2.8.0 release upgrade line.
  77      // Put any upgrade step following this.
  78  
  79      return true;
  80  }


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1