فهرست منبع

Custom option page values now repopulate correctly when save action goes back to same options page

pdontthink 21 سال پیش
والد
کامیت
4ae9bd7cc1
2فایلهای تغییر یافته به همراه12 افزوده شده و 0 حذف شده
  1. 1 0
      ChangeLog
  2. 11 0
      functions/options.php

+ 1 - 0
ChangeLog

@@ -72,6 +72,7 @@ Version 1.5.1 -- CVS
   - Removed html_top and html_bottom hooks.  No longer used/needed.
   - Added "trailing text" for options built by SquirrelMail (text placed
     after text and select list inputs on options pages)
+  - Custom option page values now repopulate correctly
 
 Version 1.5.0
 --------------------

+ 11 - 0
functions/options.php

@@ -154,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:
@@ -192,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);
     }