[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/mod/assign/feedback/editpdf/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   * Upgrade code for the feedback_editpdf module.
  19   *
  20   * @package   assignfeedback_editpdf
  21   * @copyright 2013 Jerome Mouneyrac
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  /**
  28   * EditPDF upgrade code
  29   * @param int $oldversion
  30   * @return bool
  31   */
  32  function xmldb_assignfeedback_editpdf_upgrade($oldversion) {
  33      global $CFG;
  34  
  35      if ($oldversion < 2013110800) {
  36  
  37          // Check that no stamps where uploaded.
  38          $fs = get_file_storage();
  39          $stamps = $fs->get_area_files(context_system::instance()->id, 'assignfeedback_editpdf',
  40              'stamps', 0, "filename", false);
  41  
  42          // Add default stamps.
  43          if (empty($stamps)) {
  44              // List of default stamps.
  45              $defaultstamps = array('smile.png', 'sad.png', 'tick.png', 'cross.png');
  46  
  47              // Stamp file object.
  48              $filerecord = new stdClass;
  49              $filerecord->component = 'assignfeedback_editpdf';
  50              $filerecord->contextid = context_system::instance()->id;
  51              $filerecord->userid    = get_admin()->id;
  52              $filerecord->filearea  = 'stamps';
  53              $filerecord->filepath  = '/';
  54              $filerecord->itemid    = 0;
  55  
  56              // Add all default stamps.
  57              foreach ($defaultstamps as $stamp) {
  58                  $filerecord->filename = $stamp;
  59                  $fs->create_file_from_pathname($filerecord,
  60                      $CFG->dirroot . '/mod/assign/feedback/editpdf/pix/' . $filerecord->filename);
  61              }
  62          }
  63  
  64          upgrade_plugin_savepoint(true, 2013110800, 'assignfeedback', 'editpdf');
  65      }
  66  
  67      // Moodle v2.6.0 release upgrade line.
  68      // Put any upgrade step following this.
  69  
  70      // Moodle v2.7.0 release upgrade line.
  71      // Put any upgrade step following this.
  72  
  73      // Moodle v2.8.0 release upgrade line.
  74      // Put any upgrade step following this.
  75  
  76      return true;
  77  }


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