Fix for bug # 149758. Pre-configuring and locking ldap server preferences

r=rdayal, sr=sspitzer.
This commit is contained in:
srilatha%netscape.com 2002-06-14 01:56:45 +00:00
Родитель 3df1bfa24e
Коммит 508030fb15
7 изменённых файлов: 127 добавлений и 36 удалений

Просмотреть файл

@ -96,6 +96,30 @@ function fillSettings()
prefValue="";
}
document.getElementById("login").value = prefValue;
// check if any of the preferences for this server are locked.
//If they are locked disable them
DisableUriFields(gCurrentDirectoryString + ".uri");
DisableElementIfPrefIsLocked(gCurrentDirectoryString + ".description", "description");
DisableElementIfPrefIsLocked(gCurrentDirectoryString + ".disable_button_download", "download");
DisableElementIfPrefIsLocked(gCurrentDirectoryString + ".maxHits", "results");
DisableElementIfPrefIsLocked(gCurrentDirectoryString + ".auth.dn", "login");
}
function DisableElementIfPrefIsLocked(aPrefName, aElementId)
{
if (gPrefInt.prefIsLocked(aPrefName))
document.getElementById(aElementId).setAttribute('disabled', true);
}
// disables all the text fields corresponding to the .uri pref.
function DisableUriFields(aPrefName)
{
if (gPrefInt.prefIsLocked(aPrefName)) {
var lockedElements = document.getElementsByAttribute("disableiflocked", "true");
for (var i=0; i<lockedElements.length; i++)
lockedElements[i].setAttribute('disabled', 'true');
}
}
function onSecure()
@ -299,7 +323,7 @@ function onAccept()
}
function onCancel()
{
{
window.opener.gUpdate = false;
}

Просмотреть файл

@ -51,9 +51,9 @@
<tab label="&Offline.tab;"/>
<tab label="&Advanced.tab;"/>
</tabs>
<tabpanels id="directoryTabPanels" flex="1">
<vbox>
<vbox>
<grid flex="1">
<columns>
<column/>
@ -71,7 +71,7 @@
<row align="center">
<label value="&directoryHostname.label;" accesskey="&directoryHostname.accesskey;"
control="hostname"/>
<textbox id="hostname" flex="1"/>
<textbox id="hostname" flex="1" disableiflocked="true"/>
<spacer flex="1"/>
</row>
<row align="center">
@ -79,7 +79,7 @@
accesskey="&directoryBaseDN.accesskey;"
control="basedn"/>
<vbox>
<textbox id="basedn"/>
<textbox id="basedn" disableiflocked="true"/>
</vbox>
<button label="&findButton.label;"
accesskey="&findButton.accesskey;" disabled="true"/>
@ -89,13 +89,13 @@
accesskey="&portNumber.accesskey;"
control="port"/>
<hbox>
<textbox id="port" size="6"/>
<textbox id="port" size="6" disableiflocked="true"/>
</hbox>
</row>
<row align="center">
<label value="&directoryLogin.label;"
accesskey="&directoryLogin.accesskey;"
control="login"/>
accesskey="&directoryLogin.accesskey;"
control="login"/>
<textbox id="login" flex="1"/>
</row>
</rows>
@ -103,19 +103,19 @@
<separator/>
<checkbox id="secure" label="&directorySecure.label;"
accesskey="&directorySecure.accesskey;"
oncommand="onSecure();"/>
</vbox>
<vbox>
oncommand="onSecure();" disableiflocked="true"/>
</vbox>
<vbox>
<description>&offlineText.label;</description>
<separator/>
<hbox>
<button label="&downloadNowButton.label;"
<button id="download" label="&downloadNowButton.label;"
accesskey="&downloadNowButton.accesskey;"
oncommand="DownloadNow();"/>
<spacer flex="1"/>
</hbox>
</vbox>
<grid>
</vbox>
<grid>
<columns>
<column/>
<column flex="1"/>
@ -134,15 +134,17 @@
<row align="center">
<label value="&scope.label;" control="scope"/>
<radiogroup id="scope" orient="horizontal">
<radio id="one" value="1" label="&scopeOneLevel.label;"/>
<radio id="sub" value="2" label="&scopeSubtree.label;"/>
<radio id="one" value="1" label="&scopeOneLevel.label;"
disableiflocked="true"/>
<radio id="sub" value="2" label="&scopeSubtree.label;"
disableiflocked="true"/>
</radiogroup>
</row>
<row>
<label value="&searchFilter.label;"
accesskey="&searchFilter.accesskey;"
control="search"/>
<textbox multiline="true" id="search" flex="1"/>
<textbox multiline="true" id="search" flex="1" disableiflocked="true"/>
</row>
</rows>
</grid>

Просмотреть файл

@ -42,8 +42,16 @@ function enableAutocomplete()
// var autocompleteSkipDirectory = document.getElementById("autocompleteSkipDirectory");
if (autocompleteLDAP.checked) {
directoriesList.removeAttribute("disabled");
directoriesListPopup.removeAttribute("disabled");
// If the default directory preference is locked
// disable the list popup
if (gPrefInt.prefIsLocked("ldap_2.autoComplete.directoryServer")) {
directoriesList.setAttribute("disabled", true);
directoriesListPopup.setAttribute("disabled", true);
}
else {
directoriesList.removeAttribute("disabled");
directoriesListPopup.removeAttribute("disabled");
}
editButton.removeAttribute("disabled");
// autocompleteSkipDirectory.removeAttribute("disabled");
}
@ -289,9 +297,10 @@ function onInitEditDirectories()
{
var listbox = document.getElementById("directoriesList");
gFromGlobalPref = window.arguments[0].fromGlobalPref;
if (listbox) {
LoadDirectoriesList(listbox);
}
LoadDirectoriesList(listbox);
// If the pref is locked disable the "Add" button
if (gPrefInt.prefIsLocked("ldap_2.disable_button_add"))
document.getElementById("addButton").setAttribute('disabled', true);
}
function LoadDirectoriesList(listbox)
@ -318,9 +327,9 @@ function selectDirectory()
&& directoriesList.selectedItems.length)
{
gCurrentDirectoryServer =
directoriesList.selectedItems[0].getAttribute('label');
directoriesList.selectedItems[0].getAttribute('label');
gCurrentDirectoryServerId =
directoriesList.selectedItems[0].getAttribute('string');
directoriesList.selectedItems[0].getAttribute('string');
}
else
{
@ -332,7 +341,19 @@ function selectDirectory()
var removeButton = document.getElementById("removeButton");
if(gCurrentDirectoryServer && gCurrentDirectoryServerId) {
editButton.removeAttribute("disabled");
removeButton.removeAttribute("disabled");
// If the disable delete button pref for the selected directory is set
// disable the delete button for that directory.
var disable = false;
try {
disable = gPrefInt.getBoolPref(gCurrentDirectoryServerId + ".disable_delete");
}
catch(ex){
// if this preference is not set its ok.
}
if (disable)
removeButton.setAttribute("disabled", true);
else
removeButton.removeAttribute("disabled");
}
else {
editButton.setAttribute("disabled", true);

Просмотреть файл

@ -153,8 +153,27 @@ var DirPaneController =
case "button_delete":
if (command == "cmd_delete")
goSetMenuValue(command, "valueAddressBook");
if (dirTree && dirTree.currentIndex >= 0)
var selectedDir = GetSelectedDirectory();
if (selectedDir) {
// If the selected directory is an ldap directory
// and if the prefs for this directory are locked
// disable the delete button.
var ldapUrlPrefix = "moz-abldapdirectory://";
if ((selectedDir.indexOf(ldapUrlPrefix, 0)) == 0)
{
var prefName = selectedDir.substr(ldapUrlPrefix.length, selectedDir.length);
var disable = false;
try {
disable = gPrefs.getBoolPref(prefName + ".disable_delete");
}
catch(ex){
// if this preference is not set its ok.
}
if (disable)
return false;
}
return true;
}
else
return false;
case "button_edit":

Просмотреть файл

@ -149,12 +149,16 @@ function OnLoadAddressBook()
// FIX ME - later we will be able to use onload from the overlay
OnLoadCardView();
SetupAbCommandUpdateHandlers();
//workaround - add setTimeout to make sure dynamic overlays get loaded first
setTimeout('SelectFirstAddressBook()',0);
// if the pref is locked disable the menuitem New->LDAP directory
if (gPrefs.prefIsLocked("ldap_2.disable_button_add"))
document.getElementById("addLDAP").setAttribute("disabled", "true");
// add a listener, so we can switch directories if
// the current directory is deleted
var addrbookSession = Components.classes["@mozilla.org/addressbook/services/session;1"].getService().QueryInterface(Components.interfaces.nsIAddrBookSession);

Просмотреть файл

@ -142,7 +142,7 @@ Contributor(s):
<menuitem label="&newCard.label;" accesskey="&newCard.accesskey;" oncommand="AbNewCard('dirTree')"/>
<menuitem label="&newListCmd.label;" accesskey="&newListCmd.accesskey;" oncommand="AbNewList('dirTree')"/>
<menuitem label="&newAddressBookCmd.label;" accesskey="&newAddressBookCmd.accesskey;" oncommand="AbNewAddressBook()"/>
<menuitem label="&newLDAPDirectoryCmd.label;" accesskey="&newLDAPDirectoryCmd.accesskey;" oncommand="AbNewLDAPDirectory()"/>
<menuitem label="&newLDAPDirectoryCmd.label;" id="addLDAP" accesskey="&newLDAPDirectoryCmd.accesskey;" oncommand="AbNewLDAPDirectory()"/>
<menuseparator/>
<menuitem id="menu_newNavigator"/>
<menuitem id="menu_newEditor"/>

Просмотреть файл

@ -1,3 +1,6 @@
var gIdentity = null;
var gPrefInt = null;
function onLoad()
{
createDirectoriesList(false);
@ -10,6 +13,11 @@ function onInit()
enabling();
}
function onPreInit(account, accountValues)
{
gIdentity = account.defaultIdentity;
}
function enabling()
{
var autocomplete = document.getElementById("ldapAutocomplete");
@ -33,15 +41,28 @@ function enabling()
editButton.removeAttribute("disabled");
break;
}
var attrVal=overrideGlobalPref.getAttribute("disabled");
document.getElementById("ldapAutocomplete").disabled=attrVal;
// if the pref is locked, we'll need to disable the elements
if (overrideGlobalPref.getAttribute("disabled") == "true") {
directoriesList.setAttribute("disabled", true);
directoriesListPopup.setAttribute("disabled", true);
editButton.setAttribute("disabled", true);
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 (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 (gPrefInt.prefIsLocked("mail.identity." + gIdentity.key + ".directoryServer")) {
document.getElementById("directoriesList").setAttribute("disabled", "true");
document.getElementById("directoriesListPopup").setAttribute("disabled", "true");
}
gFromGlobalPref = false;
LoadDirectories(directoriesListPopup);
}