|
| 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 | + * Update script for lifecyclestep_adminapprove plugin |
| 19 | + * |
| 20 | + * @package lifecyclestep_adminapprove |
| 21 | + * @copyright 2025 Thomas Niedermaier University of Münster |
| 22 | + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
| 23 | + */ |
| 24 | + |
| 25 | +/** |
| 26 | + * Update script for lifecyclestep_adminapprove. |
| 27 | + * @param int $oldversion Version id of the previously installed version. |
| 28 | + * @return bool |
| 29 | + * @throws ddl_exception |
| 30 | + * @throws ddl_field_missing_exception |
| 31 | + * @throws ddl_table_missing_exception |
| 32 | + * @throws dml_exception |
| 33 | + * @throws downgrade_exception |
| 34 | + * @throws upgrade_exception |
| 35 | + */ |
| 36 | +function xmldb_lifecyclestep_adminapprove_upgrade($oldversion) { |
| 37 | + |
| 38 | + global $DB; |
| 39 | + $dbman = $DB->get_manager(); |
| 40 | + if ($oldversion < 2025032400) { |
| 41 | + |
| 42 | + // Define table lifecyclestep_adminapprove to be created. |
| 43 | + $table = new xmldb_table('lifecyclestep_adminapprove'); |
| 44 | + |
| 45 | + // Adding fields to table lifecyclestep_adminapprove. |
| 46 | + $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); |
| 47 | + $table->add_field('processid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); |
| 48 | + $table->add_field('status', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0'); |
| 49 | + |
| 50 | + // Adding keys to table lifecyclestep_adminapprove. |
| 51 | + $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']); |
| 52 | + $table->add_key('processid_fk-u', XMLDB_KEY_FOREIGN_UNIQUE, ['processid'], 'tool_lifecycle_process', ['id']); |
| 53 | + |
| 54 | + // Conditionally launch create table for lifecyclestep_adminapprove. |
| 55 | + if (!$dbman->table_exists($table)) { |
| 56 | + $dbman->create_table($table); |
| 57 | + } |
| 58 | + |
| 59 | + // Adminapprove savepoint reached. |
| 60 | + upgrade_plugin_savepoint(true, 2025032400, 'lifecyclestep', 'adminapprove'); |
| 61 | + } |
| 62 | + return true; |
| 63 | +} |
0 commit comments