xtra_code updates in compose, readbody and view_text scripts
[squirrelmail.git] / functions / options.php
index 3a3ed2ee247ea300606aa1ef97f9de6bb6ef9819..5ae717a04fa6f4bf2236436f860442296aeb53e7 100644 (file)
@@ -62,6 +62,7 @@ class SquirrelOption {
     var $type;
     var $refresh_level;
     var $size;
+    var $trailing_text;
     var $comment;
     var $script;
     var $post_script;
@@ -83,6 +84,7 @@ class SquirrelOption {
         $this->refresh_level = $refresh_level;
         $this->possible_values = $possible_values;
         $this->size = SMOPT_SIZE_MEDIUM;
+        $this->trailing_text = '';
         $this->comment = '';
         $this->script = '';
         $this->post_script = '';
@@ -124,6 +126,11 @@ class SquirrelOption {
         $this->size = $size;
     }
 
+    /* Set the trailing_text for this option. */
+    function setTrailingText($trailing_text) {
+        $this->trailing_text = $trailing_text;
+    }
+
     /* Set the comment for this option. */
     function setComment($comment) {
         $this->comment = $comment;
@@ -147,6 +154,12 @@ class SquirrelOption {
     function createHTMLWidget() {
         global $javascript_on;
 
+        // Use new value if available 
+        if (!empty($this->new_value)) {
+            $tempValue = $this->value;
+            $this->value = $this->new_value;
+        }
+
         /* Get the widget for this option type. */
         switch ($this->type) {
             case SMOPT_TYPE_STRING:
@@ -185,6 +198,11 @@ class SquirrelOption {
         /* Add the "post script" for this option. */
         $result .= $this->post_script;
         
+        // put correct value back if need be
+        if (!empty($this->new_value)) {
+            $this->value = $tempValue;
+        }
+
         /* Now, return the created widget. */
         return ($result);
     }
@@ -210,7 +228,7 @@ class SquirrelOption {
 
         $result = "<input type=\"text\" name=\"new_$this->name\" value=\"" .
             htmlspecialchars($this->value) . 
-            "\" size=\"$width\" $this->script />\n";
+            "\" size=\"$width\" $this->script />$this->trailing_text\n";
         return ($result);
     }
 
@@ -237,7 +255,7 @@ class SquirrelOption {
         }
 
         /* Close the select tag and return our happy result. */
-        $result .= "</select>\n";
+        $result .= "</select>$this->trailing_text\n";
         return ($result);
     }
 
@@ -436,6 +454,11 @@ function create_option_groups($optgrps, $optvals) {
                 $next_option->setSize($optset['size']);
             }
 
+            /* If provided, set the trailing_text for this option. */
+            if (isset($optset['trailing_text'])) {
+                $next_option->setTrailingText($optset['trailing_text']);
+            }
+
             /* If provided, set the comment for this option. */
             if (isset($optset['comment'])) {
                 $next_option->setComment($optset['comment']);