From 975341d16189f0c8d2d9e24347463100252b7a47 Mon Sep 17 00:00:00 2001 From: jerome mouneyrac Date: Fri, 6 Nov 2009 07:50:30 +0000 Subject: [PATCH] webservice MDL-17135 add timecreated + timemodified fields to the service table and save them in the service form --- admin/webservice/service.php | 5 ++++- lib/db/install.xml | 36 +++++++++++++++++++----------------- lib/db/upgrade.php | 24 ++++++++++++++++++++++++ version.php | 2 +- 4 files changed, 48 insertions(+), 19 deletions(-) diff --git a/admin/webservice/service.php b/admin/webservice/service.php index c231434434..422a9b2f78 100644 --- a/admin/webservice/service.php +++ b/admin/webservice/service.php @@ -72,11 +72,14 @@ if ($mform->is_cancelled()) { $data->requiredcapability = ""; } - //TODO: add timecreated+modified and maybe logging too if (empty($data->id)) { + $data->timecreated = mktime(); $DB->insert_record('external_services', $data); + //TODO: logging } else { + $data->timemodified = mktime(); $DB->update_record('external_services', $data); + //TODO: logging } redirect($returnurl); diff --git a/lib/db/install.xml b/lib/db/install.xml index 53cb9b029d..fee5cbc524 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1,5 +1,5 @@ - @@ -2229,7 +2229,7 @@ - +
@@ -2244,39 +2244,41 @@
- +
- - - - - + + + + + + + - +
- +
- - - - - + + + + + - +
- +
diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index bba12bca20..14580b7776 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -2746,6 +2746,30 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL"); upgrade_main_savepoint($result, 2009110400); } + if ($result && $oldversion < 2009110605) { + + /// Define field timecreated to be added to external_services + $table = new xmldb_table('external_services'); + $field = new xmldb_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'component'); + + /// Conditionally launch add field timecreated + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + + /// Define field timemodified to be added to external_services + $table = new xmldb_table('external_services'); + $field = new xmldb_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, 'timecreated'); + + /// Conditionally launch add field timemodified + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + + /// Main savepoint reached + upgrade_main_savepoint($result, 2009110605); + } + return $result; } diff --git a/version.php b/version.php index 9ba0f2a142..6b944074db 100644 --- a/version.php +++ b/version.php @@ -6,7 +6,7 @@ // This is compared against the values stored in the database to determine // whether upgrades should be performed (see lib/db/*.php) - $version = 2009110501; // YYYYMMDD = date of the last version bump + $version = 2009110605; // YYYYMMDD = date of the last version bump // XX = daily increments $release = '2.0 dev (Build: 20091106)'; // Human-friendly version name -- 2.39.5