/* Copyright(C) 2004-2007 INL Written by Jean Gillaux <jean@inl.fr> Vincent Deffontaines <vincent@inl.fr> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ var dragsort = ToolMan.dragsort() var junkdrawer = ToolMan.junkdrawer() /* * make acls list sortable * (called on page load) */ function init_acls_dnd(tab){ for (i=0; i<tab.length; i++){ bichain = tab[i].split('bi_')[1]; sortcatid="sortcat"; elt_sortcat = document.getElementById(sortcatid) if (elt_sortcat){ foo = dragsort.makeListSortable(document.getElementById(sortcatid)); } } } function numOrdA(a, b){ return (a-b); } /* This function tests if order has been modified and warns user */ function ask_user_acl(id){ var test = document.getElementById("sortcat"); if (test){ list = junkdrawer.serializeList(test); tab = list.split('|'); tab_sort = list.split('|'); tab_sort.sort(); for (i=0; i<tab.length; i++){ tab[i] = parseInt(tab[i]); tab_sort[i] = parseInt(tab_sort[i]); } tab_sort.sort(numOrdA); change = false; for (i=0; i<tab.length; i++){ if (tab_sort[i] != tab[i]){ change = true; break; } } if (tab == 'NaN') { change = false; } if(change == true){ res = confirm('L\'ordre des acls a été modifié. Poursuivre sans sauver?'); return res; } } return true; } /* This function takes array with DOM id bi_NAME and updates elts with id sortcat_NAME with corresponding list order list with id dndSort_NAME */ function aclHandle(bichain_t){ window.onbeforeunload=null; for (j=0; j<bichain_t.length; j++){ bich_name = bichain_t[j].split('bi_')[1]; dnd_name = 'dndSort_' + bich_name; sortcat_name = 'sortcat'; elts = document.getElementsByName(dnd_name) for (i=0; i<elts.length; i++){ elt = elts[i]; elt_sortcat = document.getElementById(sortcat_name); if (elt_sortcat){ new_value = junkdrawer.serializeList(elt_sortcat) elt.setAttribute('value', new_value); } } } return true; } function griser_gren(){ document.forms.acls.gr_enabled.disabled=true; } function get_duration_text(select) { var index = select.options.selectedIndex; if (index <= 0) return '--'; return select.options[index].text } function grey_on_auth() { if (!document.forms.acls) return; with(document.forms.acls) { if(auth.options[auth.options.selectedIndex].text=="--") { if (typeof(periodicity) != 'undefined') { periodicity.options.selectedIndex = 0; periodicity.disabled=true; } if (typeof(duration) != 'undefined') { duration.options.selectedIndex = 0; duration.disabled=true; } application.options.selectedIndex = 0; application.disabled=true; os.options.selectedIndex = 0; os.disabled=true; }else{ if (typeof(periodicity) != 'undefined') { if(get_duration_text(periodicity) != "--") { periodicity.disabled=false; duration.options.selectedIndex = 0; duration.disabled=true; } else if(get_duration_text(duration)!="--") { periodicity.options.selectedIndex = 0; periodicity.disabled=true; duration.disabled=false; } else { periodicity.disabled=false; duration.disabled=false; } } application.disabled=false; os.disabled=false; } } log_checkbox(); } function grey_on_periodicity() { with(document.forms.acls) { if(get_duration_text(periodicity) == "--") { duration.disabled=false; }else{ duration.options.selectedIndex = 0; duration.disabled=true; } } } function grey_on_duration() { with(document.forms.acls) { if(get_duration_text(duration) == "--") { periodicity.disabled=false; }else{ periodicity.options.selectedIndex = 0; periodicity.disabled=true; } } } function log_checkbox() { var log = document.getElementById('log'); var log_limit = document.getElementById('log_limit'); var log_prefix = document.getElementById('log_prefix'); var use_log = log.checked; var use_limit = use_log; try { var auth = document.forms.acls.auth; if (auth.options[auth.options.selectedIndex].text != "--") { log_limit.options.selectedIndex = (log_limit.options.length - 1); use_limit = false; } } catch (e) { /* local acl form has no auth field */ } log_limit.disabled = !use_limit; log_prefix.disabled = !use_log; }