From c65b6b41a95bad42c9dd6f05de61617443663101 Mon Sep 17 00:00:00 2001
From: Friederike Schwager <schwager@cil.rwth-aachen.de>
Date: Mon, 1 Jul 2019 11:06:24 +0200
Subject: [PATCH] bugfix db-update useprintcomments

---
 db/upgrade.php | 15 +++++++++++++++
 version.php    |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/db/upgrade.php b/db/upgrade.php
index 34f38f7..c8cdc55 100644
--- a/db/upgrade.php
+++ b/db/upgrade.php
@@ -559,6 +559,21 @@ function xmldb_pdfannotator_upgrade($oldversion) {
         // Pdfannotator savepoint reached.
         upgrade_mod_savepoint(true, 2019060300, 'pdfannotator');
     }
+    
+        if ($oldversion < 2019070100) {
+
+        // Define field useprintcomments to be added to pdfannotator.
+        $table = new xmldb_table('pdfannotator');
+        $field = new xmldb_field('useprintcomments', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'useprint');
+
+        // Conditionally launch add field useprintcomments.
+        if (!$dbman->field_exists($table, $field)) {
+            $dbman->add_field($table, $field);
+        }
+
+        // Pdfannotator savepoint reached.
+        upgrade_mod_savepoint(true, 2019030100, 'pdfannotator');
+    }
 
     return true;
 }
diff --git a/version.php b/version.php
index cee845b..dc76f61 100644
--- a/version.php
+++ b/version.php
@@ -25,7 +25,7 @@
 defined('MOODLE_INTERNAL') || die();
 
 $plugin->component = 'mod_pdfannotator'; // Full name of the plugin (used for diagnostics).
-$plugin->version   = 2019060300; // The current module version (Date: YYYYMMDDXX).
+$plugin->version   = 2019070100; // The current module version (Date: YYYYMMDDXX).
 $plugin->release  = 'PDF Annotator v1.1 release 1';
 $plugin->requires  = 2016112900; // Requires this Moodle version.
 $plugin->cron      = 0;          // Period for cron to check this module (secs).
-- 
GitLab