From a0b3ff92e75508d82417f5bea52d08efc983902b Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Sat, 16 Nov 2013 16:33:30 -0600
Subject: [PATCH] Add better description to the upgrader

Fix duplicate phone number (again)
---
 include/class.upgrader.php                    | 18 +++++++++++++++
 .../core/dad45ca2-61c9d5d7.cleanup.sql        | 10 ++++-----
 include/upgrader/upgrade.inc.php              | 22 +++++++++++--------
 scp/css/scp.css                               |  9 ++++++++
 4 files changed, 45 insertions(+), 14 deletions(-)

diff --git a/include/class.upgrader.php b/include/class.upgrader.php
index 245bfc150..69af4dfde 100644
--- a/include/class.upgrader.php
+++ b/include/class.upgrader.php
@@ -131,6 +131,11 @@ class Upgrader {
             return $this->getCurrentStream()->getErrors();
     }
 
+    function getUpgradeSummary() {
+        if ($this->getCurrentStream())
+            return $this->getCurrentStream()->getUpgradeSummary();
+    }
+
     function getNextAction() {
         if ($this->getCurrentStream())
             return $this->getCurrentStream()->getNextAction();
@@ -299,6 +304,19 @@ class StreamUpgrader extends SetupWizard {
         return $info;
     }
 
+    function getUpgradeSummary() {
+        $summary = '';
+        foreach ($this->getPatches() as $p) {
+            $info = $this->readPatchInfo($p);
+            $summary .= '<div class="patch">' . $info['version'];
+            if (isset($info['title']))
+                $summary .= ': <span class="patch-title">'.$info['title']
+                    .'</span>';
+            $summary .= '</div>';
+        }
+        return $summary;
+    }
+
     function getNextAction() {
 
         $action='Upgrade osTicket to '.$this->getVersion();
diff --git a/include/upgrader/streams/core/dad45ca2-61c9d5d7.cleanup.sql b/include/upgrader/streams/core/dad45ca2-61c9d5d7.cleanup.sql
index 18de0a28e..4688ad0de 100644
--- a/include/upgrader/streams/core/dad45ca2-61c9d5d7.cleanup.sql
+++ b/include/upgrader/streams/core/dad45ca2-61c9d5d7.cleanup.sql
@@ -11,10 +11,10 @@ INSERT INTO `%TABLE_PREFIX%form_entry_values` (
     `field_id`, `entry_id`, `value`)
     SELECT A3.`id`, A2.`id`, A1.`subject`
     FROM `%TABLE_PREFIX%ticket` A1
-        INNER JOIN `%TABLE_PREFIX%form` A4 ON (`type`='T')
         INNER JOIN `%TABLE_PREFIX%form_entry` A2 ON (A2.`object_id`
                 = A1.`ticket_id` AND A2.`object_type` = 'T')
-        INNER JOIN `%TABLE_PREFIX%form_field` A3 ON (A2.`form_id`
+        INNER JOIN `%TABLE_PREFIX%form` A4 ON (A4.`id` = A2.`form_id`)
+        INNER JOIN `%TABLE_PREFIX%form_field` A3 ON (A3.`form_id`
                 = A4.`id`)
     WHERE A3.`name` = 'subject';
 
@@ -23,10 +23,10 @@ INSERT INTO `%TABLE_PREFIX%form_entry_values` (
     `field_id`, `entry_id`, `value`, `value_id`)
     SELECT A3.`id`, A2.`id`, A5.`priority_desc`, A1.`priority_id`
     FROM `%TABLE_PREFIX%ticket` A1
-        INNER JOIN `%TABLE_PREFIX%form` A4 ON (`type`='T')
         INNER JOIN `%TABLE_PREFIX%form_entry` A2 ON (A2.`object_id`
                 = A1.`ticket_id` AND A2.`object_type` = 'T')
-        INNER JOIN `%TABLE_PREFIX%form_field` A3 ON (A2.`form_id`
+        INNER JOIN `%TABLE_PREFIX%form` A4 ON (A4.`id` = A2.`form_id`)
+        INNER JOIN `%TABLE_PREFIX%form_field` A3 ON (A3.`form_id`
                 = A4.`id`)
         INNER JOIN `%TABLE_PREFIX%ticket_priority` A5 ON (A5.`priority_id`
                 = A1.`priority_id`)
@@ -86,7 +86,7 @@ INSERT INTO `%TABLE_PREFIX%form_entry_values` (
         INNER JOIN `%TABLE_PREFIX%form_entry` A2 ON (A2.`object_id`
                 = A1.`ticket_id` AND A2.`object_type` = 'U')
         INNER JOIN `%TABLE_PREFIX%form` A4 ON (A4.`id` = A2.`form_id`)
-        INNER JOIN `%TABLE_PREFIX%form_field` A3 ON (A2.`form_id`
+        INNER JOIN `%TABLE_PREFIX%form_field` A3 ON (A3.`form_id`
                 = A4.`id`)
     WHERE A3.`name` = 'phone' AND LENGTH(A1.`phone`)
     GROUP BY A3.`id`, A2.`id`;
diff --git a/include/upgrader/upgrade.inc.php b/include/upgrader/upgrade.inc.php
index d2f355895..98b64607d 100644
--- a/include/upgrader/upgrade.inc.php
+++ b/include/upgrader/upgrade.inc.php
@@ -13,20 +13,24 @@ if(($mode = $ost->get_var('m', $_GET)) &&  $mode!=$upgrader->getMode()) {
 
 $action=$upgrader->getNextAction();
 ?>
-<h2>osTicket Upgrade</h2>
+    <h2>Migrate to osTicket <?php echo THIS_VERSION; ?></h2>
 <div id="upgrader">
     <div id="main">
             <div id="intro">
              <p>Thank you for taking the time to upgrade your osTicket intallation!</p>
-             <p>Please don't cancel or close the browser; any errors at this stage will be fatal.</p>
+             <p><strong>Please don't cancel or close the browser; any errors
+             at this stage will be fatal.</strong></p>
             </div>
-            <h2 id="task"><?php echo $action ?></h2>
-            <p>The upgrade wizard will now attempt to upgrade your database and core settings!</p>
-            <ul>
-                <li>Database enhancements</li>
-                <li>New and updated features</li>
-                <li>Enhanced settings and security</li>
-            </ul>
+            <h2 id="task">Applying updates to database stream:
+            <?php echo $upgrader->getCurrentStream()->name; ?></h2>
+            <p>In order to upgrade to this version of osTicket, a database
+            migration is required. This upgrader will automatically apply
+            the database patches shipped with osTicket since your last
+            upgrade.</p>
+            <p>The upgrade wizard will now attempt to upgrade your database and core settings!
+            Below is a summary of the database patches to be applied.
+            </p>
+            <?php echo $upgrader->getUpgradeSummary(); ?>
             <div id="bar">
                 <form method="post" action="upgrade.php" id="upgrade">
                     <?php csrf_token(); ?>
diff --git a/scp/css/scp.css b/scp/css/scp.css
index 3a3be70fc..684f2c981 100644
--- a/scp/css/scp.css
+++ b/scp/css/scp.css
@@ -1497,3 +1497,12 @@ input.dp {
 .icon-warning-sign {
     color: #d33;
 }
+
+div.patch {
+    border-bottom: 1px dotted #ccc;
+    padding: 0.1em;
+    margin-left: 1em;
+}
+.patch-title {
+    color: #555;
+}
-- 
GitLab