From 2eb7943f2aeaec8efc74b16b7bedb56da9913abf Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Fri, 23 Apr 2010 07:25:37 -0400
Subject: [PATCH] - code cleanup (mostly identation fixes)

---
 program/include/rcube_template.php |   39 ++++++++++++++++++++++++---------------
 1 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/program/include/rcube_template.php b/program/include/rcube_template.php
index c622380..2f1740d 100755
--- a/program/include/rcube_template.php
+++ b/program/include/rcube_template.php
@@ -5,7 +5,7 @@
  | program/include/rcube_template.php                                    |
  |                                                                       |
  | This file is part of the RoundCube Webmail client                     |
- | Copyright (C) 2006-2009, RoundCube Dev. - Switzerland                 |
+ | Copyright (C) 2006-2010, RoundCube Dev. - Switzerland                 |
  | Licensed under the GNU GPL                                            |
  |                                                                       |
  | PURPOSE:                                                              |
@@ -536,7 +536,7 @@
     
     
     /**
-     *
+     * Inserts hidden field with CSRF-prevention-token into POST forms
      */
     private function alter_form_tag($matches)
     {
@@ -1024,7 +1024,7 @@
         $input_url    = new html_hiddenfield(array('name' => '_url', 'id' => 'rcmloginurl', 'value' => $url));
         $input_host   = null;
 
-        if (is_array($default_host)) {
+        if (is_array($default_host) && count($default_host) > 1) {
             $input_host = new html_select(array('name' => '_host', 'id' => 'rcmloginhost'));
 
             foreach ($default_host as $key => $value) {
@@ -1036,6 +1036,11 @@
                     break;
                 }
             }
+        }
+        else if (is_array($default_host) && ($host = array_pop($default_host))) {
+            $hide_host = true;
+            $input_host = new html_hiddenfield(array(
+                'name' => '_host', 'id' => 'rcmloginhost', 'value' => $host) + $attrib);
         }
         else if (empty($default_host)) {
             $input_host = new html_inputfield(array('name' => '_host', 'id' => 'rcmloginhost') + $attrib);
@@ -1054,7 +1059,7 @@
         $table->add(null, $input_pass->show());
 
         // add host selection row
-        if (is_object($input_host)) {
+        if (is_object($input_host) && !$hide_host) {
             $table->add('title', html::label('rcmloginhost', Q(rcube_label('server'))));
             $table->add(null, $input_host->show(get_input_value('_host', RCUBE_INPUT_POST)));
         }
@@ -1063,10 +1068,14 @@
         $out .= $input_tzone->show();
         $out .= $input_url->show();
         $out .= $table->show();
+        
+        if ($hide_host) {
+            $out .= $input_host->show();
+        }
 
         // surround html output with a form tag
         if (empty($attrib['form'])) {
-            $out = $this->form_tag(array('name' => $form_name, 'method' => "post"), $out);
+            $out = $this->form_tag(array('name' => $form_name, 'method' => 'post'), $out);
         }
 
         return $out;
@@ -1115,7 +1124,7 @@
             $attrib['id'] = 'rcmqsearchbox';
         }
         if ($attrib['type'] == 'search' && !$this->browser->khtml) {
-          unset($attrib['type'], $attrib['results']);
+            unset($attrib['type'], $attrib['results']);
         }
         
         $input_q = new html_inputfield($attrib);
@@ -1129,7 +1138,7 @@
                 'name' => "rcmqsearchform",
                 'onsubmit' => JS_OBJECT_NAME . ".command('search');return false;",
                 'style' => "display:inline"),
-              $out);
+                $out);
         }
 
         return $out;
@@ -1206,15 +1215,15 @@
         );
 
         if (!empty($_POST['_charset']))
-	    $set = $_POST['_charset'];
-	else if (!empty($attrib['selected']))
-	    $set = $attrib['selected'];
-	else
-	    $set = $this->get_charset();
+	        $set = $_POST['_charset'];
+	    else if (!empty($attrib['selected']))
+	        $set = $attrib['selected'];
+	    else
+	        $set = $this->get_charset();
 
-	$set = strtoupper($set);
-	if (!isset($charsets[$set]))
-	    $charsets[$set] = $set;
+	    $set = strtoupper($set);
+	    if (!isset($charsets[$set]))
+	        $charsets[$set] = $set;
 
         $select = new html_select($field_attrib);
         $select->add(array_values($charsets), array_keys($charsets));

--
Gitblit v1.9.1