From 1c4e5dd4d201b599094a40e908ebcaa6de40ac05 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Mon, 03 Mar 2008 03:52:50 -0500
Subject: [PATCH] Some more bugfixes for the install script

---
 installer/config.php |  106 ++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 93 insertions(+), 13 deletions(-)

diff --git a/installer/config.php b/installer/config.php
index c110276..5b365a5 100644
--- a/installer/config.php
+++ b/installer/config.php
@@ -5,8 +5,20 @@
 ini_set('display_errors', 1);
 require_once 'include/rcube_html.inc';
 
-$RCI->load_config();
+// also load the default config to fill in the fields
 $RCI->load_defaults();
+
+// register these boolean fields
+$RCI->config_props = array(
+  'ip_check' => 1,
+  'enable_caching' => 1,
+  'enable_spellcheck' => 1,
+  'auto_create_user' => 1,
+  'smtp_log' => 1,
+  'prefer_html' => 1,
+  'preview_pane' => 1,
+  'htmleditor' => 1,
+);
 
 if (!empty($_POST['submit'])) {
   
@@ -20,6 +32,9 @@
   
   echo '<div style="margin-top:1em"><em>db.inc.php</em></div>';
   echo $textbox->show($RCI->create_config('db'));
+
+  echo '<p class="hint">Of course there are more options to configure.
+    Have a look at the config files or visit <a href="http://trac.roundcube.net/wiki/Howto_Config">Howto_Config</a> to find out.</p>';
 
   echo '<p><input type="button" onclick="location.href=\'./index.php?_step=3\'" value="CONTINUE" /></p>';
   
@@ -187,15 +202,15 @@
 
 $dsnw = DB::parseDSN($RCI->getprop('db_dsnw'));
 
-echo $select_dbtype->show($_POST['_dbtype'] ? $_POST['_dbtype'] : $dsnw['phptype']);
+echo $select_dbtype->show($RCI->is_post ? $_POST['_dbtype'] : $dsnw['phptype']);
 echo '<label for="cfgdbtype">Database type</label><br />';
-echo $input_dbhost->show($_POST['_dbhost'] ? $_POST['_dbhost'] : $dsnw['hostspec']);
+echo $input_dbhost->show($RCI->is_post ? $_POST['_dbhost'] : $dsnw['hostspec']);
 echo '<label for="cfgdbhost">Database server</label><br />';
-echo $input_dbname->show($_POST['_dbname'] ? $_POST['_dbname'] : $dsnw['database']);
+echo $input_dbname->show($RCI->is_post ? $_POST['_dbname'] : $dsnw['database']);
 echo '<label for="cfgdbname">Database name</label><br />';
-echo $input_dbuser->show($_POST['_dbuser'] ? $_POST['_dbuser'] : $dsnw['username']);
+echo $input_dbuser->show($RCI->is_post ? $_POST['_dbuser'] : $dsnw['username']);
 echo '<label for="cfgdbuser">Database user name (needs write permissions)</label><br />';
-echo $input_dbpass->show($_POST['_dbpass'] ? $_POST['_dbpass'] : $dsnw['password']);
+echo $input_dbpass->show($RCI->is_post ? $_POST['_dbpass'] : $dsnw['password']);
 echo '<label for="cfgdbpass">Database password</label><br />';
 
 ?>
@@ -235,12 +250,16 @@
 <div id="defaulthostlist">
 <?php
 
-$default_hosts = array_unique((array)$RCI->getprop('default_host'));
 $text_imaphost = new textfield(array('name' => '_default_host[]', 'size' => 30));
+$default_hosts = $RCI->get_hostlist();
 
-for ($i=0; $i < count($default_hosts); $i++) {
-  echo '<div id="defaulthostentry'.$i.'">' . $text_imaphost->show($default_hosts[$i]);
-  if ($i > 0)
+if (empty($default_hosts))
+  $default_hosts = array('');
+
+$i = 0;
+foreach ($default_hosts as $host) {
+  echo '<div id="defaulthostentry'.$i.'">' . $text_imaphost->show($host);
+  if ($i++ > 0)
     echo '<a href="#" onclick="removehostfield(this.parentNode);return false" class="removelink" title="Remove this entry">remove</a>';
   echo '</div>';
 }
@@ -249,7 +268,7 @@
 </div>
 <div><a href="javascript:addhostfield()" class="addlink" title="Add another field">add</a></div>
 
-<p class="hint">Leave blank to show a textbox at login</p>
+<p class="hint">Leave blank to show a textbox at login. To use SSL/IMAPS connection, type ssl://hostname</p>
 </dd>
 
 <dt class="propname">default_port</dt>
@@ -411,7 +430,7 @@
 
 
 <fieldset>
-<legend>Display settings</legend>
+<legend>Display settings &amp; user prefs</legend>
 <dl class="configblock" id="cgfblockdisplay">
 
 <dt class="propname">locale_string</dt>
@@ -426,12 +445,73 @@
 <p class="hint">Enter a <a href="http://www.faqs.org/rfcs/rfc1766">RFC1766</a> formatted locale name. Examples: en_US, de, de_CH, fr, pt_BR</p>
 </dd>
 
+<dt class="propname">pagesize <span class="userconf">*</span></dt>
+<dd>
+<?php
+
+$input_pagesize = new textfield(array('name' => '_pagesize', 'size' => 6, 'id' => "cfgpagesize"));
+echo $input_pagesize->show($RCI->getprop('pagesize'));
+
+?>
+<div>Show up to X items in list view.</div>
+</dd>
+
+<dt class="propname">prefer_html <span class="userconf">*</span></dt>
+<dd>
+<?php
+
+$check_htmlview = new checkbox(array('name' => '_prefer_html', 'id' => "cfghtmlview", 'value' => 1));
+echo $check_htmlview->show(intval($RCI->getprop('prefer_html')));
+
+?>
+<label for="cfghtmlview">Prefer displaying HTML messages</label><br />
+</dd>
+
+<dt class="propname">preview_pane <span class="userconf">*</span></dt>
+<dd>
+<?php
+
+$check_prevpane = new checkbox(array('name' => '_preview_pane', 'id' => "cfgprevpane", 'value' => 1));
+echo $check_prevpane->show(intval($RCI->getprop('preview_pane')));
+
+?>
+<label for="cfgprevpane">If preview pane is enabled</label><br />
+</dd>
+
+<dt class="propname">htmleditor <span class="userconf">*</span></dt>
+<dd>
+<?php
+
+$check_htmlcomp = new checkbox(array('name' => '_htmleditor', 'id' => "cfghtmlcompose", 'value' => 1));
+echo $check_htmlcomp->show(intval($RCI->getprop('htmleditor')));
+
+?>
+<label for="cfghtmlcompose">Compose HTML formatted messages</label><br />
+</dd>
+
+<dt class="propname">draft_autosave <span class="userconf">*</span></dt>
+<dd>
+<label for="cfgautosave">Save compose message every</label>
+<?php
+
+$select_autosave = new select(array('name' => '_draft_autosave', 'id' => 'cfgautosave'));
+$select_autosave->add('never', 0);
+foreach (array(3, 5, 10) as $i => $min)
+  $select_autosave->add("$min min", $min*60);
+
+echo $select_autosave->show(intval($RCI->getprop('draft_autosave')));
+
+?>
+</dd>
+
 </dl>
+
+<p class="hint"><span class="userconf">*</span>&nbsp; These settings are defaults for the user preferences</p>
 </fieldset>
 
 <?php
 
-echo '<p><input type="submit" name="submit" value="UPDATE" ' . ($RCI->failures ? 'disabled' : '') . ' /></p>';
+echo '<p><input type="submit" name="submit" value="' . ($RCI->configured ? 'UPDATE' : 'CREATE') . ' CONFIG" ' . ($RCI->failures ? 'disabled' : '') . ' /></p>';
 
 ?>
 </form>

--
Gitblit v1.9.1