[2] | 1 | /************************************************************************************\ |
---|
| 2 | * Expresso Administração * |
---|
| 3 | * by Joao Alfredo Knopik Junior (joao.alfredo@gmail.com, jakjr@celepar.pr.gov.br) * |
---|
| 4 | * ----------------------------------------------------------------------------------* |
---|
| 5 | * This program is free software; you can redistribute it and/or modify it * |
---|
| 6 | * under the terms of the GNU General Public License as published by the * |
---|
| 7 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
| 8 | * option) any later version. * |
---|
| 9 | \************************************************************************************/ |
---|
| 10 | |
---|
[414] | 11 | function load_lang(){ |
---|
| 12 | cExecute ('$this/inc/load_lang', handler_load_lang); |
---|
| 13 | } |
---|
| 14 | |
---|
| 15 | var global_langs = new Array(); |
---|
[1916] | 16 | var emailSugestion = 1; |
---|
[414] | 17 | |
---|
| 18 | function handler_load_lang(data) |
---|
| 19 | { |
---|
| 20 | global_langs = eval(data); |
---|
| 21 | } |
---|
| 22 | |
---|
[1991] | 23 | function get_associated_domain(context) |
---|
| 24 | { |
---|
| 25 | var handler_associated_domain = function(data) |
---|
| 26 | { |
---|
[6157] | 27 | if( document.forms[0].associated_domain ) |
---|
[1991] | 28 | { |
---|
[6157] | 29 | if ( data != null ) |
---|
| 30 | { |
---|
| 31 | document.forms[0].associated_domain.value = data; |
---|
| 32 | } |
---|
| 33 | else |
---|
| 34 | { |
---|
| 35 | |
---|
| 36 | document.forms[0].associated_domain.value = ''; |
---|
| 37 | } |
---|
[1991] | 38 | } |
---|
[5133] | 39 | }; |
---|
| 40 | cExecute ('$this.ldap_functions.get_associated_domain&context=' + context, handler_associated_domain); |
---|
[1991] | 41 | } |
---|
| 42 | |
---|
[5133] | 43 | function get_lang(key_raw) |
---|
| 44 | { |
---|
| 45 | key = key_raw.replace(/ /g,"_"); |
---|
| 46 | key = key.replace(/-/g,""); |
---|
| 47 | lang = eval("global_langs."+key.toLowerCase()); |
---|
| 48 | |
---|
| 49 | if (typeof(lang)=='undefined') |
---|
| 50 | return key_raw + '*'; |
---|
| 51 | else |
---|
| 52 | return lang; |
---|
| 53 | } |
---|
| 54 | |
---|
[1916] | 55 | function emailSugestion_expressoadmin2(email) { |
---|
| 56 | if ( email.value.indexOf('@', 0) < 0 ) emailSugestion = 1; |
---|
| 57 | if ( (email.value.indexOf('@', 0) == (email.value.length - 1)) && emailSugestion == 1 && email.value.length > 0 ) { |
---|
| 58 | var tmp; |
---|
| 59 | var context = ""; |
---|
| 60 | |
---|
[1991] | 61 | organization_context = Element('ea_combo_org').value.toLowerCase(); |
---|
[1916] | 62 | // Transformar os DN em User Friendly Naming format |
---|
| 63 | organization_name = organization_context.split(","); |
---|
| 64 | for (i in organization_name) { |
---|
| 65 | tmp = organization_name[i].split("="); |
---|
| 66 | context += tmp[1]; |
---|
| 67 | if( i < (organization_name.length - 1) ) context += '.'; |
---|
[1991] | 68 | } |
---|
[6157] | 69 | if( document.forms[0].associated_domain && document.forms[0].associated_domain.value != '' ) |
---|
[1991] | 70 | { |
---|
| 71 | associatedDomain_name = document.forms[0].associated_domain.value; |
---|
| 72 | email.value = email.value + associatedDomain_name; |
---|
| 73 | emailSugestion = 0; |
---|
| 74 | } else{ |
---|
| 75 | email.value = email.value + context; |
---|
| 76 | emailSugestion = 0; |
---|
| 77 | } |
---|
[1916] | 78 | } |
---|
| 79 | } |
---|
| 80 | |
---|
[2] | 81 | function emailSuggestion_expressoadmin(use_suggestion_in_logon_script, concatenateDomain) |
---|
| 82 | { |
---|
| 83 | if (concatenateDomain == 'true') |
---|
| 84 | { |
---|
[180] | 85 | // base_dn do LDAP Expresso |
---|
[2] | 86 | var ldap_context = document.forms[0].ldap_context.value.toLowerCase(); |
---|
[180] | 87 | |
---|
| 88 | // OU selecionada |
---|
[2] | 89 | organization_context = document.forms[0].context.value.toLowerCase(); |
---|
[180] | 90 | |
---|
[2] | 91 | select_orgs = document.getElementById('ea_combo_org_info'); |
---|
| 92 | for(var i=0; i<select_orgs.options.length; i++) |
---|
| 93 | { |
---|
| 94 | if(select_orgs.options[i].selected == true) |
---|
| 95 | { |
---|
| 96 | var x; |
---|
| 97 | var context = ''; |
---|
[180] | 98 | |
---|
| 99 | // OU selecionada |
---|
[2] | 100 | select_context = select_orgs.options[i].value.toLowerCase(); |
---|
[180] | 101 | |
---|
| 102 | // Transformar os DN em User Friendly Naming format |
---|
[2] | 103 | organization_name = organization_context.split(","); |
---|
| 104 | for (x in organization_name) |
---|
| 105 | { |
---|
| 106 | tmp = organization_name[x].split("="); |
---|
| 107 | context += tmp[1] + '.'; |
---|
| 108 | } |
---|
| 109 | } |
---|
| 110 | } |
---|
| 111 | domain_name = document.forms[0].defaultDomain.value; |
---|
| 112 | |
---|
[180] | 113 | // Retira o base_dn do valor do dn e retorna o numero de caracteres. |
---|
[2] | 114 | x=context.indexOf(ldap_context,0); |
---|
[180] | 115 | // Obtenho a string, sem o base_dn |
---|
[2] | 116 | org_name_par = context.substring(0,(x-1)); |
---|
[180] | 117 | // Obtenho o nome da organização: String entre pontos, anterior ao base_dn |
---|
[2] | 118 | org_name = org_name_par.split('.'); |
---|
| 119 | org_name = org_name[org_name.length-1]; |
---|
[1991] | 120 | |
---|
[2] | 121 | if (org_name != '') |
---|
[1991] | 122 | document.forms[0].mail1.value = document.forms[0].uid.value + '@' + org_name + '.' + domain_name; |
---|
[2] | 123 | else |
---|
| 124 | document.forms[0].mail1.value = document.forms[0].uid.value; |
---|
| 125 | } |
---|
| 126 | else |
---|
| 127 | { |
---|
| 128 | document.forms[0].mail1.value = document.forms[0].uid.value; |
---|
| 129 | } |
---|
| 130 | |
---|
| 131 | if (use_suggestion_in_logon_script == 'true') |
---|
| 132 | document.forms[0].sambalogonscript.value = document.forms[0].uid.value+'.bat'; |
---|
| 133 | document.forms[0].sambahomedirectory.value = '/home/'+document.forms[0].uid.value+'/'; |
---|
| 134 | } |
---|
| 135 | |
---|
[5133] | 136 | function loadAppended( id, values, name ) |
---|
| 137 | { |
---|
| 138 | if( !values ) return; |
---|
| 139 | |
---|
| 140 | |
---|
| 141 | if( typeof name === "undefined" || !name ) |
---|
| 142 | name = id + '[]'; |
---|
| 143 | |
---|
| 144 | for( var i = 0; i < values.length; i++ ) |
---|
| 145 | { |
---|
| 146 | if( !values[i] || values[i] === "" ) continue; |
---|
| 147 | |
---|
| 148 | var clone = addTextbox( name, id ); |
---|
| 149 | |
---|
| 150 | clone.value = values[i]; |
---|
| 151 | } |
---|
| 152 | } |
---|
| 153 | |
---|
| 154 | function addTextbox( name, targetId, id ) |
---|
| 155 | { |
---|
| 156 | var input = document.createElement( "input" ); |
---|
| 157 | input.type = "text"; |
---|
| 158 | input.id = ( typeof id === "undefined" )? "" : id; |
---|
| 159 | input.name = name; |
---|
| 160 | |
---|
| 161 | var target = document.getElementById( targetId ); |
---|
| 162 | |
---|
| 163 | target.appendChild( input ); |
---|
| 164 | |
---|
| 165 | removable( input ); |
---|
| 166 | |
---|
| 167 | return( input ); |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | function removable( target ) |
---|
| 171 | { |
---|
| 172 | with( target.parentNode ) |
---|
| 173 | { |
---|
| 174 | var minus = document.createElement( "span" ); |
---|
| 175 | var br = document.createElement( "br" ); |
---|
| 176 | |
---|
| 177 | minus.innerHTML = " -"; |
---|
| 178 | minus.style.cursor = "pointer"; |
---|
| 179 | minus.onclick = function(){ |
---|
| 180 | |
---|
| 181 | removeChild( target ); |
---|
| 182 | removeChild( minus ); |
---|
| 183 | removeChild( br ); |
---|
| 184 | } |
---|
| 185 | |
---|
| 186 | appendChild( minus ); |
---|
| 187 | appendChild( br ); |
---|
| 188 | } |
---|
| 189 | } |
---|
| 190 | |
---|
| 191 | function multiply( id, full ) |
---|
| 192 | { |
---|
| 193 | var target = document.getElementById( id ); |
---|
| 194 | |
---|
| 195 | var clone = target.cloneNode( false ); |
---|
| 196 | |
---|
| 197 | clone.id = ""; |
---|
| 198 | |
---|
| 199 | if( !full ) |
---|
| 200 | clone.value = ""; |
---|
| 201 | |
---|
| 202 | target.parentNode.appendChild( clone ); |
---|
| 203 | |
---|
| 204 | removable( clone ); |
---|
| 205 | |
---|
| 206 | return( clone ); |
---|
| 207 | } |
---|
| 208 | |
---|
| 209 | function appendClone( id, full ) |
---|
| 210 | { |
---|
| 211 | return multiply( id, full ); |
---|
| 212 | } |
---|
| 213 | |
---|
[2] | 214 | function FormataValor(event, campo) |
---|
| 215 | { |
---|
| 216 | separador1 = '('; |
---|
| 217 | separador2 = ')'; |
---|
| 218 | separador3 = '-'; |
---|
| 219 | |
---|
| 220 | vr = campo.value; |
---|
| 221 | tam = vr.length; |
---|
| 222 | |
---|
| 223 | if ((tam == 1) && (( event.keyCode != 8 ) || ( event.keyCode != 46 ))) |
---|
| 224 | campo.value = ''; |
---|
| 225 | |
---|
| 226 | if ((tam == 3) && (( event.keyCode != 8 ) || ( event.keyCode != 46 ))) |
---|
| 227 | campo.value = vr.substr( 0, tam - 1 ); |
---|
| 228 | |
---|
[5133] | 229 | if (( tam <= 1 ) && ( event.keyCode != 8 ) && ( event.keyCode != 46 )) |
---|
[2] | 230 | campo.value = separador1 + vr; |
---|
| 231 | |
---|
| 232 | if (( tam == 3 ) && ( event.keyCode != 8 ) && ( event.keyCode != 46 )) |
---|
| 233 | campo.value = vr + separador2; |
---|
| 234 | |
---|
| 235 | if (( tam == 8 ) && (( event.keyCode != 8 ) && ( event.keyCode != 46 ))) |
---|
| 236 | campo.value = vr + separador3; |
---|
| 237 | |
---|
| 238 | if ((( tam == 9 ) || ( tam == 8 )) && (( event.keyCode == 8 ) || ( event.keyCode == 46 ))) |
---|
| 239 | campo.value = vr.substr( 0, tam - 1 ); |
---|
| 240 | } |
---|
[379] | 241 | |
---|
| 242 | function FormataCPF(event, campo) |
---|
| 243 | { |
---|
| 244 | if (event.keyCode == 8) |
---|
| 245 | return; |
---|
| 246 | |
---|
| 247 | vr = campo.value; |
---|
| 248 | tam = vr.length; |
---|
| 249 | |
---|
| 250 | var RegExp_onlyNumbers = new RegExp("[^0-9.-]+"); |
---|
| 251 | if ( RegExp_onlyNumbers.test(campo.value) ) |
---|
| 252 | campo.value = vr.substr( 0, (tam-1)); |
---|
| 253 | |
---|
| 254 | if ( (campo.value.length == 3) || (campo.value.length == 7) ) |
---|
| 255 | { |
---|
| 256 | campo.value += '.'; |
---|
| 257 | } |
---|
| 258 | |
---|
| 259 | if (campo.value.length == 11) |
---|
| 260 | campo.value += '-'; |
---|
| 261 | return; |
---|
| 262 | |
---|
| 263 | |
---|
| 264 | alert(campo.value); |
---|
| 265 | return; |
---|
| 266 | |
---|
| 267 | separador1 = '.'; |
---|
| 268 | separador2 = '-'; |
---|
| 269 | |
---|
| 270 | vr = campo.value; |
---|
| 271 | tam = vr.length; |
---|
| 272 | |
---|
| 273 | if ((tam == 1) && (( event.keyCode != 8 ) || ( event.keyCode != 46 ))) |
---|
| 274 | campo.value = ''; |
---|
| 275 | |
---|
| 276 | if ((tam == 3) && (( event.keyCode != 8 ) || ( event.keyCode != 46 ))) |
---|
| 277 | campo.value = vr.substr( 0, tam - 1 ); |
---|
| 278 | |
---|
| 279 | if (( tam <= 1 ) && ( event.keyCode != 8 ) && ( event.keyCode != 46 )) |
---|
| 280 | campo.value = separador1 + vr; |
---|
| 281 | |
---|
| 282 | if (( tam == 3 ) && ( event.keyCode != 8 ) && ( event.keyCode != 46 )) |
---|
| 283 | campo.value = vr + separador2; |
---|
| 284 | |
---|
| 285 | if (( tam == 8 ) && (( event.keyCode != 8 ) && ( event.keyCode != 46 ))) |
---|
| 286 | campo.value = vr + separador3; |
---|
| 287 | |
---|
| 288 | if ((( tam == 9 ) || ( tam == 8 )) && (( event.keyCode == 8 ) || ( event.keyCode == 46 ))) |
---|
| 289 | campo.value = vr.substr( 0, tam - 1 ); |
---|
[414] | 290 | } |
---|
[3376] | 291 | load_lang(); |
---|