From e107123780c12b4d43d0264cb9c6180fb02d9ab8 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Fri, 03 Oct 2008 16:58:23 -0400
Subject: [PATCH] Add methods to check and update local config files + show HTML output in installer test step

---
 installer/test.php |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/installer/test.php b/installer/test.php
index ca7c7ad..8af6a6a 100644
--- a/installer/test.php
+++ b/installer/test.php
@@ -27,6 +27,50 @@
   $RCI->fail('db.inc.php', 'Unable to read file. Did you create the config files?');
 }
 
+if ($RCI->configured && ($messages = $RCI->check_config())) {
+  
+  if (is_array($messages['missing'])) {
+    echo '<h3 class="warning">Missing config options</h3>';
+    echo '<p class="hint">The following config options are not present in the current configuration.<br/>';
+    echo 'Please check the default config files and add the missing properties to your local config files.</p>';
+    
+    echo '<ul class="configwarings">';
+    foreach ($messages['missing'] as $msg) {
+      echo html::tag('li', null, html::span('propname', $msg['prop']) . ($msg['name'] ? ':&nbsp;' . $msg['name'] : ''));
+    }    
+    echo '</ul>';
+  }
+
+  if (is_array($messages['replaced'])) {
+    echo '<h3 class="warning">Replaced config options</h3>';
+    echo '<p class="hint">The following config options have been replaced or renamed. ';
+    echo 'Please update them accordingly in your config files.</p>';
+    
+    echo '<ul class="configwarings">';
+    foreach ($messages['replaced'] as $msg) {
+      echo html::tag('li', null, html::span('propname', $msg['prop']) .
+        ' was replaced by ' . html::span('propname', $msg['replacement']));
+    }
+    echo '</ul>';
+  }
+
+  if (is_array($messages['obsolete'])) {
+    echo '<h3>Obsolete config options</h3>';
+    echo '<p class="hint">You still have some obsolete or inexistent properties set. This isn\'t a problem but should be noticed.</p>';
+    
+    echo '<ul class="configwarings">';
+    foreach ($messages['obsolete'] as $msg) {
+      echo html::tag('li', null, html::span('propname', $msg['prop']) . ($msg['name'] ? ':&nbsp;' . $msg['name'] : ''));
+    }
+    echo '</ul>';
+  }
+  
+  echo '<p class="suggestion">OK, lazy people can download the updated config files here: ';
+  echo html::a(array('href' => './?_mergeconfig=main'), 'main.inc.php') . ' &nbsp;';
+  echo html::a(array('href' => './?_mergeconfig=db'), 'db.inc.php');
+  echo "</p>";
+}
+
 ?>
 
 <h3>Check if directories are writable</h3>

--
Gitblit v1.9.1