Bug 454574 LDAP account preferences don't update r=philor r+a=Standard8
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Sun, 14 Sep 2008 19:50:22 +0100
changeset 329 75f806a2fe317122ba21f6dd8e1a040b1c733fa1
parent 328 80aa66c5e7d98a6f0b0a3cb034b6473aefca0553
child 330 6ac5fb23522e368a5934013422c623ea2837d1c0
push idunknown
push userunknown
push dateunknown
reviewersphilor
bugs454574
Bug 454574 LDAP account preferences don't update r=philor r+a=Standard8
mailnews/base/prefs/resources/content/am-addressing.js
mailnews/base/prefs/resources/content/am-addressingOverlay.xul
--- a/mailnews/base/prefs/resources/content/am-addressing.js
+++ b/mailnews/base/prefs/resources/content/am-addressing.js
@@ -47,144 +47,59 @@ function onLoad()
 
 function onInit(aPageId, aServerId) 
 {
   onInitCompositionAndAddressing();
 }
 
 function onInitCompositionAndAddressing()
 {
-  setupDirectoriesList();
   enabling();
   quoteEnabling();
 }
 
 function onEditDirectories()
 {
   window.openDialog("chrome://messenger/content/addressbook/pref-editdirectories.xul",
                     "editDirectories", "chrome,modal=yes,resizable=no", null);
 }
 
-function setupDirectoriesList()
-{
-  var override = document.getElementById("identity.overrideGlobalPref").getAttribute("value");
-  var autocomplete = document.getElementById("ldapAutocomplete");
-  // useGlobalFlag is set when user changes the selectedItem on the radio button and switches
-  // to a different pane and switches back in Mail/news AccountSettings
-  var useGlobalFlag = document.getElementById("overrideGlobalPref").getAttribute("value");
-  // directoryServerFlag is set when user changes the server to None and switches
-  // to a different pane and switches back in Mail/news AccountSettings
-  var directoryServerFlag = document.getElementById("directoryServer").getAttribute("value");
-
-  if(override == "true" && !useGlobalFlag)
-    autocomplete.selectedItem = document.getElementById("directories");
-  else
-    autocomplete.selectedItem = document.getElementById("useGlobalPref");
-
-  var directoriesList = document.getElementById("directoriesList");
-  var directoryServer =
-        document.getElementById("identity.directoryServer").getAttribute('value');
-  if (directoryServerFlag) {
-    document.getElementById("identity.directoryServer").setAttribute("value", "");
-    directoryServer = "";
-  }
-  directoriesList.value = directoryServer;
-}
-
 function onPreInit(account, accountValues)
 {
   gIdentity = account.defaultIdentity;
 }
 
 function enabling()
 {
-  var autocomplete = document.getElementById("ldapAutocomplete");
-  var directoriesList =  document.getElementById("directoriesList"); 
-  var directoriesListPopup = document.getElementById("directoriesListPopup");
+  var autocomplete = document.getElementById("identity.overrideGlobal_Pref");
+  var directoriesList = document.getElementById("identity.directoryServer");
   var editButton = document.getElementById("editButton");
 
-  // this is the hidden text element that assigned a value from the prefs
-  var overrideGlobalPref = document.getElementById("identity.overrideGlobalPref");
-
-  switch(autocomplete.value)
+  switch (autocomplete.value)
   {
-    case "0":
+    case "false":
       directoriesList.setAttribute("disabled", true);
-      directoriesListPopup.setAttribute("disabled", true);
       editButton.setAttribute("disabled", true);
       break;
-    case "1":
-        directoriesList.removeAttribute("disabled");
-        directoriesListPopup.removeAttribute("disabled");
-        editButton.removeAttribute("disabled");
+    case "true":
+      directoriesList.removeAttribute("disabled");
+      editButton.removeAttribute("disabled");
       break;      
   }
 
   if (!gPrefInt) {
     gPrefInt = Components.classes["@mozilla.org/preferences-service;1"]
                            .getService(Components.interfaces.nsIPrefBranch);
   }
 
-  // If the default per-identity directory preferences are locked 
-  // disable the corresponding elements.
-  if (gIdentity && gPrefInt.prefIsLocked("mail.identity." + gIdentity.key + ".overrideGlobal_Pref")) {
-    document.getElementById("useGlobalPref").setAttribute("disabled", "true");
-    document.getElementById("directories").setAttribute("disabled", "true");
-  }
-  else
-  {
-    document.getElementById("useGlobalPref").removeAttribute("disabled");
-    document.getElementById("directories").removeAttribute("disabled");
-  }
   if (gIdentity && gPrefInt.prefIsLocked("mail.identity." + gIdentity.key + ".directoryServer")) {
-    document.getElementById("directoriesList").setAttribute("disabled", "true");
-    document.getElementById("directoriesListPopup").setAttribute("disabled", "true");
+    directoriesList.setAttribute("disabled", "true");
   }
 }
 
-function onSave()
-{
-  onSaveCompositionAndAddressing();
-}
-
-function onSaveCompositionAndAddressing()
-{
-  var override = document.getElementById("identity.overrideGlobalPref");
-  var autocomplete = document.getElementById("ldapAutocomplete");
-  var directoryServer = document.getElementById("identity.directoryServer");
-  var directoriesList = 
-      document.getElementById("directoriesList").getAttribute('value');
-
-  // When switching between panes, 
-  // if we save the value of an element as null
-  // we will be forced to get the value from preferences when we get back.
-  // We are saving the value as "" for the radio button and also for
-  // the directory server if the selected directory is "None"
-  // So, we need the two elements overrideGlobalPref and directoryServer
-  // to save the state when the directory is 
-  // set to none and the first radio button is selected.
-  switch(autocomplete.value)
-  {
-    case "0":
-      override.setAttribute('value', "");
-      document.getElementById("overrideGlobalPref").setAttribute("value", "0");
-      document.getElementById("directoryServer").setAttribute("value", "");
-      break;
-    case "1":
-      override.setAttribute('value', true);
-      directoryServer.setAttribute("value", directoriesList);
-      document.getElementById("overrideGlobalPref").setAttribute("value", "");
-      if(directoriesList == "")
-        document.getElementById("directoryServer").setAttribute("value", "none");
-      else
-        document.getElementById("directoryServer").setAttribute("value", "");
-      break;
-  } 
-}
-
 function quoteEnabling()
 {
   var quotebox = document.getElementById("thenBox");
   var placebox = document.getElementById("placeBox");
   var quotecheck = document.getElementById("identity.autoQuote");
 
   if (quotecheck.checked && !quotecheck.disabled &&
       document.getElementById("identity.attachSignature").checked &&
--- a/mailnews/base/prefs/resources/content/am-addressingOverlay.xul
+++ b/mailnews/base/prefs/resources/content/am-addressingOverlay.xul
@@ -43,24 +43,16 @@
 
 <overlay xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
          xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">                                                       
 
   <script type="application/x-javascript" src="chrome://messenger/content/am-addressing.js"/>
 
   <vbox flex="1" id="compositionAndAddressing">
     <stringbundle id="bundle_addressBook" src="chrome://messenger/locale/addressbook/addressBook.properties"/>
-    <label hidden="true" wsm_persist="true" id="identity.directoryServer"
-          pref="true" preftype="string" prefattribute="value"
-          prefstring="mail.identity.%identitykey%.directoryServer"/>
-    <label hidden="true" wsm_persist="true" id="identity.overrideGlobalPref"
-          pref="true" preftype="bool" prefattribute="value"
-          prefstring="mail.identity.%identitykey%.overrideGlobal_Pref"/>
-    <label hidden="true" wsm_persist="true" id="overrideGlobalPref" value=""/>
-    <label hidden="true" wsm_persist="true" id="directoryServer" value=""/>
     <checkbox hidden="true" wsm_persist="true" id="identity.attachSignature"
           pref="true" preftype="bool" prefattribute="value"
           prefstring="mail.identity.%identitykey%.attach_signature"/>
 
     <groupbox>
       <caption label="&compositionGroupTitle.label;"/>
       <hbox align="center">
         <checkbox wsm_persist="true" id="identity.composeHtml" label="&useHtml.label;"
@@ -113,27 +105,31 @@
                   accesskey="&autocompleteToMyDomain.accesskey;"
                   prefattribute="value"
                   prefstring="mail.identity.%identitykey%.autocompleteToMyDomain"/>
       </hbox>
 
       <separator class="thin"/>
 #endif
 
-      <label control="ldapAutocomplete">&addressingText.label;</label>
-      <radiogroup class="indent" id="ldapAutocomplete" wsm_persist="true" oncommand="enabling();">
-        <observes element="identity.overrideGlobalPref" attribute="disabled"/>
-        <radio id="useGlobalPref" value="0" label="&useGlobal.label;"
+      <label control="identity.overrideGlobal_Pref">&addressingText.label;</label>
+      <radiogroup id="identity.overrideGlobal_Pref" class="indent"
+                  oncommand="enabling();" wsm_persist="true"
+                  genericattr="true" preftype="bool"
+                  prefstring="mail.identity.%identitykey%.overrideGlobal_Pref">
+        <radio value="false" label="&useGlobal.label;"
                accesskey="&useGlobal.accesskey;"/>
-        <radio id="directories" value="1" label="&directories.label;"
+        <radio id="directories" value="true" label="&directories.label;"
                accesskey="&directories.accesskey;"/>
         <hbox class="indent">
-          <menulist id="directoriesList" wsm_persist="true"
+          <menulist id="identity.directoryServer"
+                    wsm_persist="true" preftype="string"
+                    prefstring="mail.identity.%identitykey%.directoryServer"
                     style="min-width: 16em;" aria-labelledby="directories">
-            <menupopup id="directoriesListPopup" class="addrbooksPopup"
+            <menupopup class="addrbooksPopup"
                        none="&directoriesNone.label;"
                        remoteonly="true" value="dirPrefId"/>
           </menulist>
           <button id="editButton" label="&editDirectories.label;"
                   accesskey="&editDirectories.accesskey;"
                   oncommand="onEditDirectories();"/>
         </hbox>
       </radiogroup>