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