[2] | 1 | // Variaveis Globais |
---|
| 2 | countFiles = 0; |
---|
| 3 | function validate_fields(type, restrictionsOnGroup) |
---|
| 4 | { |
---|
| 5 | document.forms[0].cn.value = document.forms[0].cn.value.toLowerCase(); |
---|
| 6 | document.forms[0].old_cn.value = document.forms[0].old_cn.value.toLowerCase(); |
---|
| 7 | |
---|
| 8 | if (document.forms[0].cn.value == ''){ |
---|
[414] | 9 | alert(get_lang('NAME field is empty') + '.'); |
---|
[2] | 10 | return; |
---|
| 11 | } |
---|
| 12 | |
---|
| 13 | if (document.forms[0].description.value == ''){ |
---|
[414] | 14 | alert(get_lang('DESCRIPTION field is empty') + '.'); |
---|
[2] | 15 | return; |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | if (restrictionsOnGroup == 'true') |
---|
| 19 | { |
---|
| 20 | cn_tmp = document.forms[0].cn.value.split("-"); |
---|
| 21 | if ( (cn_tmp.length < 3) || ((cn_tmp[0] != 'grupo') && (cn_tmp[0] != 'smb')) ){ |
---|
[309] | 22 | alert( |
---|
[414] | 23 | get_lang('NAME field is incomplete') + '.\n' + |
---|
| 24 | get_lang('the name field must be formed like') + ':\n' + |
---|
| 25 | get_lang('group') + '-' + get_lang('organization') + '-' + get_lang('group name') + '.\n' + |
---|
| 26 | get_lang('eg') + ': ' + 'grupo-celepar-rh.'); |
---|
[2] | 27 | return; |
---|
| 28 | } |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | var reCn = /^([a-zA-Z0-9_\-])+$/; |
---|
| 32 | var reDesc = /^([a-zA-Z0-9_\- .])+$/; |
---|
| 33 | |
---|
| 34 | if(!reCn.test(document.forms[0].cn.value)){ |
---|
[414] | 35 | alert(get_lang('NAME field contains characters not allowed') + '.'); |
---|
[2] | 36 | document.forms[0].cn.focus(); |
---|
| 37 | return; |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | if(!reDesc.test(document.forms[0].description.value)){ |
---|
[414] | 41 | alert(get_lang('DESCRIPTION field contains characters not allowed') + '.'); |
---|
[2] | 42 | document.forms[0].description.focus(); |
---|
| 43 | return; |
---|
| 44 | } |
---|
| 45 | |
---|
[46] | 46 | var reEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; |
---|
[309] | 47 | if ( (document.forms[0].email.value != '') && (!reEmail.test(document.forms[0].email.value)) ) |
---|
[46] | 48 | { |
---|
[414] | 49 | alert(get_lang('EMAIL field is empty') + '.'); |
---|
[46] | 50 | return false; |
---|
| 51 | } |
---|
| 52 | |
---|
[2] | 53 | var handler_validate_fields = function(data) |
---|
| 54 | { |
---|
| 55 | if (!data.status) |
---|
| 56 | alert(data.msg); |
---|
| 57 | else |
---|
| 58 | { |
---|
| 59 | if (type == 'create_group') |
---|
| 60 | cExecuteForm ("$this.group.create", document.forms[0], handler_create); |
---|
| 61 | else if (type == 'edit_group') |
---|
| 62 | cExecuteForm ("$this.group.save", document.forms[0], handler_save); |
---|
| 63 | } |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | // Needed select all options from select |
---|
| 67 | select_userInGroup = document.getElementById('ea_select_usersInGroup'); |
---|
| 68 | for(var i=0; i<select_userInGroup.options.length; i++) |
---|
| 69 | select_userInGroup.options[i].selected = true; |
---|
| 70 | |
---|
| 71 | // O CN do grupo foi alterado ou é um novo grupo. |
---|
| 72 | if ((document.forms[0].old_cn.value != document.forms[0].cn.value) || (type == 'create_group')){ |
---|
| 73 | cExecute ('$this.group.validate_fields&cn='+document.forms[0].cn.value, handler_validate_fields); |
---|
| 74 | } |
---|
| 75 | else if (type == 'edit_group') |
---|
| 76 | { |
---|
| 77 | cExecuteForm ("$this.group.save", document.forms[0], handler_save); |
---|
| 78 | } |
---|
| 79 | } |
---|
| 80 | |
---|
[5133] | 81 | function Element( id ) |
---|
| 82 | { |
---|
| 83 | return document.getElementById( id ); |
---|
| 84 | } |
---|
| 85 | |
---|
[2] | 86 | // HANDLER CREATE |
---|
| 87 | // É necessário 2 funcões de retorno por causa do cExecuteForm. |
---|
| 88 | function handler_create(data) |
---|
| 89 | { |
---|
| 90 | return_handler_create(data); |
---|
| 91 | } |
---|
| 92 | function return_handler_create(data) |
---|
| 93 | { |
---|
| 94 | if (!data.status) |
---|
| 95 | alert(data.msg); |
---|
| 96 | else{ |
---|
[482] | 97 | alert(get_lang('Group successful created') + '.'); |
---|
[2] | 98 | location.href="./index.php?menuaction=expressoAdmin1_2.uigroups.list_groups"; |
---|
| 99 | } |
---|
| 100 | return; |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | // HANDLER SAVE |
---|
| 104 | // É necessário 2 funcões de retorno por causa do cExecuteForm. |
---|
| 105 | function handler_save(data) |
---|
| 106 | { |
---|
| 107 | return_handler_save(data); |
---|
| 108 | } |
---|
| 109 | function return_handler_save(data) |
---|
| 110 | { |
---|
| 111 | if (!data.status) |
---|
| 112 | alert(data.msg); |
---|
| 113 | else{ |
---|
[482] | 114 | alert(get_lang('Group successful saved') + '.'); |
---|
[2] | 115 | location.href="./index.php?menuaction=expressoAdmin1_2.uigroups.list_groups"; |
---|
| 116 | } |
---|
| 117 | return; |
---|
| 118 | } |
---|
| 119 | |
---|
[5133] | 120 | function sinc_combos_org() |
---|
[2] | 121 | { |
---|
| 122 | combo_org_groups = document.getElementById('ea_combo_org_groups'); |
---|
| 123 | |
---|
| 124 | for (i=0; i<combo_org_groups.length; i++) |
---|
| 125 | { |
---|
| 126 | if (combo_org_groups.options[i].value == context) |
---|
| 127 | { |
---|
| 128 | combo_org_groups.options[i].selected = true; |
---|
[5133] | 129 | get_available_users(); |
---|
[2] | 130 | break; |
---|
| 131 | } |
---|
| 132 | } |
---|
| 133 | } |
---|
| 134 | |
---|
[5133] | 135 | function get_available_users() |
---|
[2] | 136 | { |
---|
[5133] | 137 | /* var sentence = Element('ea_input_searchUser').value; |
---|
[2] | 138 | |
---|
[5133] | 139 | var url = '$this.ldap_functions.get_available_users_and_shared_acounts&context=' |
---|
| 140 | + Element('ea_combo_org_info').value |
---|
| 141 | + '&sentence=' + sentence; |
---|
[2] | 142 | |
---|
[5133] | 143 | var fillHandler = function( fill ){ |
---|
[2] | 144 | |
---|
[5133] | 145 | Element('ea_select_available_users').innerHTML = fill; |
---|
| 146 | |
---|
| 147 | return( fill !== "" ); |
---|
[2] | 148 | } |
---|
| 149 | |
---|
[5133] | 150 | userFinder( sentence, fillHandler, url, 'ea_span_searching' );*/ |
---|
[2] | 151 | |
---|
[5133] | 152 | optionFind( 'ea_input_searchUser', 'ea_select_available_users', |
---|
| 153 | '$this.ldap_functions.get_available_users_and_shared_acounts', |
---|
| 154 | 'ea_combo_org_groups', 'ea_span_searching' ); |
---|
[2] | 155 | } |
---|
| 156 | |
---|
| 157 | function add_user2group() |
---|
| 158 | { |
---|
| 159 | var select_available_users = document.getElementById('ea_select_available_users'); |
---|
| 160 | var select_usersInGroup = document.getElementById('ea_select_usersInGroup'); |
---|
| 161 | |
---|
| 162 | var count_available_users = select_available_users.length; |
---|
| 163 | var count_usersInGroup = select_usersInGroup.options.length; |
---|
| 164 | var new_options = ''; |
---|
| 165 | |
---|
| 166 | for (i = 0 ; i < count_available_users ; i++) |
---|
| 167 | { |
---|
| 168 | if (select_available_users.options[i].selected) |
---|
| 169 | { |
---|
| 170 | if(document.all) |
---|
| 171 | { |
---|
| 172 | if ( (select_usersInGroup.innerHTML.indexOf('value='+select_available_users.options[i].value)) == '-1' ) |
---|
| 173 | { |
---|
| 174 | new_options += '<option value=' |
---|
| 175 | + select_available_users.options[i].value |
---|
| 176 | + '>' |
---|
| 177 | + select_available_users.options[i].text |
---|
| 178 | + '</option>'; |
---|
| 179 | } |
---|
| 180 | } |
---|
| 181 | else |
---|
| 182 | { |
---|
| 183 | if ( (select_usersInGroup.innerHTML.indexOf('value="'+select_available_users.options[i].value+'"')) == '-1' ) |
---|
| 184 | { |
---|
| 185 | new_options += '<option value=' |
---|
| 186 | + select_available_users.options[i].value |
---|
| 187 | + '>' |
---|
| 188 | + select_available_users.options[i].text |
---|
| 189 | + '</option>'; |
---|
| 190 | } |
---|
| 191 | } |
---|
| 192 | } |
---|
| 193 | } |
---|
| 194 | |
---|
| 195 | if (new_options != '') |
---|
| 196 | { |
---|
[86] | 197 | select_usersInGroup.innerHTML = ' ' + new_options + select_usersInGroup.innerHTML; |
---|
[2] | 198 | select_usersInGroup.outerHTML = select_usersInGroup.outerHTML; |
---|
[81] | 199 | document.getElementById('ea_input_searchUser').value = ""; |
---|
[2] | 200 | } |
---|
| 201 | } |
---|
| 202 | |
---|
| 203 | function remove_user2group() |
---|
| 204 | { |
---|
| 205 | select_usersInGroup = document.getElementById('ea_select_usersInGroup'); |
---|
| 206 | |
---|
| 207 | for(var i = 0;i < select_usersInGroup.options.length; i++) |
---|
| 208 | if(select_usersInGroup.options[i].selected) |
---|
| 209 | select_usersInGroup.options[i--] = null; |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | // Variaveis Locais |
---|
| 213 | if (document.getElementById('ea_select_available_users')) |
---|
| 214 | { |
---|
| 215 | var select_available_users = document.getElementById('ea_select_available_users'); |
---|
| 216 | var select_available_users_clone = select_available_users.cloneNode(true); |
---|
| 217 | } |
---|
| 218 | else |
---|
| 219 | { |
---|
| 220 | var select_available_users = ''; |
---|
| 221 | var select_available_users_clone = ''; |
---|
| 222 | } |
---|
| 223 | var finderTimeout = ''; |
---|
| 224 | |
---|
| 225 | // Funcoes |
---|
[5133] | 226 | function optionFinderTimeout(obj, event) |
---|
[2] | 227 | { |
---|
| 228 | |
---|
[5133] | 229 | if( event.keyCode == 13 ) |
---|
[2] | 230 | { |
---|
[5133] | 231 | limit = 0; |
---|
| 232 | optionFinder(obj.id); |
---|
[2] | 233 | } |
---|
[5133] | 234 | } |
---|
| 235 | function optionFinder(id) |
---|
| 236 | { |
---|
| 237 | get_available_users(); |
---|
[2] | 238 | } |
---|
| 239 | |
---|
| 240 | function delete_group(cn, gidnumber) |
---|
| 241 | { |
---|
[414] | 242 | if (confirm(get_lang('Do you really want delete the group') + ' ' + cn + " ??")) |
---|
[2] | 243 | { |
---|
| 244 | var handler_delete_group = function(data) |
---|
| 245 | { |
---|
| 246 | if (!data.status) |
---|
| 247 | alert(data.msg); |
---|
| 248 | else |
---|
[414] | 249 | alert(get_lang('Group success deleted') + '.'); |
---|
[2] | 250 | |
---|
| 251 | location.href="./index.php?menuaction=expressoAdmin1_2.uigroups.list_groups"; |
---|
| 252 | return; |
---|
| 253 | } |
---|
| 254 | cExecute ('$this.group.delete&gidnumber='+gidnumber+'&cn='+cn, handler_delete_group); |
---|
| 255 | } |
---|
| 256 | } |
---|
[33] | 257 | |
---|
| 258 | function use_samba_attrs(value) |
---|
| 259 | { |
---|
[46] | 260 | document.forms[0].sambasid.disabled = !value; |
---|
[33] | 261 | } |
---|
| 262 | |
---|
| 263 | function get_available_sambadomains(context, type) |
---|
| 264 | { |
---|
| 265 | if ((type == 'create_group') && (document.getElementById('ea_div_display_samba_options').style.display != 'none')) |
---|
| 266 | { |
---|
| 267 | var handler_get_available_sambadomains = function(data) |
---|
| 268 | { |
---|
| 269 | document.forms[0].use_attrs_samba.checked = data.status; |
---|
| 270 | use_samba_attrs(data.status); |
---|
| 271 | |
---|
| 272 | if (data.status) |
---|
| 273 | { |
---|
| 274 | combo_sambadomains = document.getElementById('ea_combo_sambadomains'); |
---|
| 275 | for (i=0; i<data.sambaDomains.length; i++) |
---|
| 276 | { |
---|
| 277 | for (j=0; j<combo_sambadomains.length; j++) |
---|
| 278 | { |
---|
| 279 | if (combo_sambadomains.options[j].text == data.sambaDomains[i]) |
---|
| 280 | { |
---|
| 281 | combo_sambadomains.options[j].selected = true; |
---|
| 282 | break; |
---|
| 283 | } |
---|
| 284 | } |
---|
| 285 | } |
---|
| 286 | |
---|
| 287 | } |
---|
| 288 | } |
---|
| 289 | cExecute ('$this.ldap_functions.exist_sambadomains_in_context&context='+context, handler_get_available_sambadomains); |
---|
| 290 | } |
---|
[46] | 291 | } |
---|
| 292 | |
---|
| 293 | function groupEmailSuggestion(concatenateDomain, type) |
---|
| 294 | { |
---|
[47] | 295 | if (document.forms[0].email.disabled) |
---|
| 296 | return; |
---|
| 297 | |
---|
[46] | 298 | if (type != 'create_group') |
---|
| 299 | return; |
---|
| 300 | |
---|
| 301 | if (concatenateDomain == 'true') |
---|
| 302 | { |
---|
| 303 | var ldap_context = document.forms[0].ufn_ldap_context.value.toLowerCase(); |
---|
| 304 | var organization_context = document.forms[0].context.value.toLowerCase(); |
---|
| 305 | var select_orgs = document.getElementById('ea_combo_org_info'); |
---|
| 306 | |
---|
| 307 | for(var i=0; i<select_orgs.options.length; i++) |
---|
| 308 | { |
---|
| 309 | if(select_orgs.options[i].selected == true) |
---|
| 310 | { |
---|
| 311 | var x; |
---|
| 312 | var context = ''; |
---|
| 313 | select_context = select_orgs.options[i].value.toLowerCase(); |
---|
| 314 | organization_name = organization_context.split(","); |
---|
| 315 | |
---|
| 316 | for (x in organization_name) |
---|
| 317 | { |
---|
| 318 | tmp = organization_name[x].split("="); |
---|
| 319 | context += tmp[1] + '.'; |
---|
| 320 | } |
---|
| 321 | } |
---|
| 322 | } |
---|
| 323 | domain_name = document.forms[0].defaultDomain.value; |
---|
| 324 | |
---|
| 325 | x=context.indexOf(ldap_context,0); |
---|
| 326 | org_name_par = context.substring(0,(x-1)); |
---|
| 327 | org_name = org_name_par.split('.'); |
---|
| 328 | org_name = org_name[org_name.length-1]; |
---|
[47] | 329 | |
---|
[46] | 330 | if (org_name != '') |
---|
[47] | 331 | document.forms[0].email.value = document.forms[0].cn.value + '@' + org_name + '.aaa' + domain_name; |
---|
[46] | 332 | else |
---|
| 333 | document.forms[0].email.value = document.forms[0].cn.value; |
---|
| 334 | } |
---|
| 335 | else |
---|
| 336 | { |
---|
| 337 | document.forms[0].email.value = document.forms[0].cn.value; |
---|
| 338 | } |
---|
[73] | 339 | } |
---|
| 340 | |
---|
[474] | 341 | function search_organization(key, element) |
---|
[73] | 342 | { |
---|
[474] | 343 | var organizations = document.getElementById(element); |
---|
[73] | 344 | var RegExp_org = new RegExp("\\b"+key, "i"); |
---|
| 345 | |
---|
| 346 | for(i = 0; i < organizations.length; i++) |
---|
| 347 | { |
---|
| 348 | if (RegExp_org.test(organizations[i].text)) |
---|
| 349 | { |
---|
| 350 | organizations[i].selected = true; |
---|
| 351 | return; |
---|
| 352 | } |
---|
| 353 | } |
---|
[640] | 354 | } |
---|
| 355 | |
---|
| 356 | function popup_group_info() |
---|
| 357 | { |
---|
| 358 | var select_usersInGroup = document.getElementById('ea_select_usersInGroup'); |
---|
| 359 | var count_usersInGroup = select_usersInGroup.options.length; |
---|
| 360 | var html = ''; |
---|
| 361 | |
---|
| 362 | for (i = 0 ; i < count_usersInGroup ; i++) |
---|
| 363 | { |
---|
| 364 | if(parseInt(select_usersInGroup.options[i].value) > 0) |
---|
| 365 | html += select_usersInGroup.options[i].text + '<br>'; |
---|
| 366 | } |
---|
| 367 | |
---|
| 368 | var window_group = window.open('','','width=300,height=400,resizable=yes,scrollbars=yes,left=100,top=100'); |
---|
| 369 | window_group.document.body.innerHTML = '<html><head></head><body><H1>'+ document.forms[0].cn.value + '</H1>'+html+'</body></html>'; |
---|
| 370 | window_group.document.close(); |
---|
| 371 | return true; |
---|
[33] | 372 | } |
---|