From eeb7ccf06939636aeb28e979c9da7d51a53f9e1a Mon Sep 17 00:00:00 2001
From: Penny Leach <penny@liip.ch>
Date: Tue, 17 Nov 2009 15:59:26 +0000
Subject: [PATCH] Portfolio MDL-20872 adding some extra metadata into the
 portfolio log table so we can display nicer information about already
 completed transfers

---
 lib/db/install.xml |  4 +++-
 lib/db/upgrade.php | 30 ++++++++++++++++++++++++++++++
 version.php        |  2 +-
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/lib/db/install.xml b/lib/db/install.xml
index 381b5e4a55..f7cf812c94 100644
--- a/lib/db/install.xml
+++ b/lib/db/install.xml
@@ -1997,7 +1997,9 @@
         <FIELD NAME="caller_class" TYPE="char" LENGTH="150" NOTNULL="true" SEQUENCE="false" COMMENT="the name of the class used to create the transfer" PREVIOUS="portfolio" NEXT="caller_file"/>
         <FIELD NAME="caller_file" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="path to file to include where the class definition lives. (relative to dirroot)" PREVIOUS="caller_class" NEXT="caller_sha1"/>
         <FIELD NAME="caller_sha1" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="sha1 of exported content as far as the caller is concerned (before the portfolio plugin gets a hold of it)" PREVIOUS="caller_file" NEXT="tempdataid"/>
-        <FIELD NAME="tempdataid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" COMMENT="old id from portfolio_tempdata.  This is so that we can gracefully catch a race condition between an external system requesting a file and causing the tempdata to be deleted, before the user gets the &quot;your transfer is requested&quot; page" PREVIOUS="caller_sha1"/>
+        <FIELD NAME="tempdataid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" COMMENT="old id from portfolio_tempdata.  This is so that we can gracefully catch a race condition between an external system requesting a file and causing the tempdata to be deleted, before the user gets the &quot;your transfer is requested&quot; page" PREVIOUS="caller_sha1" NEXT="returnurl"/>
+        <FIELD NAME="returnurl" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="the original &quot;returnurl&quot; of the export - takes us to the moodle page we started from" PREVIOUS="tempdataid" NEXT="continueurl"/>
+        <FIELD NAME="continueurl" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="the url the external system has set to view the transfer" PREVIOUS="returnurl"/>
       </FIELDS>
       <KEYS>
         <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="userfk"/>
diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php
index 5aaec6ef03..341424d4e0 100644
--- a/lib/db/upgrade.php
+++ b/lib/db/upgrade.php
@@ -2796,6 +2796,36 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
         upgrade_main_savepoint($result, 2009111700);
     }
 
+    if ($result && $oldversion < 2009111701) {
+
+    /// Define field returnurl to be added to portfolio_log
+        $table = new xmldb_table('portfolio_log');
+        $field = new xmldb_field('returnurl', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'tempdataid');
+
+    /// Conditionally launch add field returnurl
+        if (!$dbman->field_exists($table, $field)) {
+            $dbman->add_field($table, $field);
+        }
+
+    /// Main savepoint reached
+        upgrade_main_savepoint($result, 2009111701);
+    }
+
+    if ($result && $oldversion < 2009111702) {
+
+    /// Define field continueurl to be added to portfolio_log
+        $table = new xmldb_table('portfolio_log');
+        $field = new xmldb_field('continueurl', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'returnurl');
+
+    /// Conditionally launch add field continueurl
+        if (!$dbman->field_exists($table, $field)) {
+            $dbman->add_field($table, $field);
+        }
+
+    /// Main savepoint reached
+        upgrade_main_savepoint($result, 2009111702);
+    }
+
 
     return $result;
 }
diff --git a/version.php b/version.php
index af1342b7b7..7997aaaf31 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 = 2009111700;  // YYYYMMDD   = date of the last version bump
+    $version = 2009111702;  // YYYYMMDD   = date of the last version bump
                             //         XX = daily increments
 
     $release = '2.0 dev (Build: 20091117)';  // Human-friendly version name
-- 
2.39.5