Changeset 379
- Timestamp:
- 07/28/08 17:02:28 (16 years ago)
- Location:
- trunk/expressoAdmin1_2
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoAdmin1_2/inc/class.functions.inc.php
r355 r379 755 755 "88888888888","99999999999","00000000000"); 756 756 757 /* formato do CPF */ 758 if (!(ereg("^[0-9]{3}[.][0-9]{3}[.][0-9]{3}[-][0-9]{2}$",$cpf))) 759 return false; 760 757 761 /* Retira todos os caracteres que nao sejam 0-9 */ 758 762 $cpf = ereg_replace("[^0-9]", "", $cpf); -
trunk/expressoAdmin1_2/inc/class.ldap_functions.inc.php
r355 r379 308 308 } 309 309 310 //Begin: Check CPF 311 if (!empty($cpf)) 312 { 313 if (!$this->functions->checkCPF($cpf)) 314 { 315 $result['status'] = false; 316 $result['msg'] = $this->functions->lang('Field CPF is invalid') . '.'; 317 return $result; 318 } 319 else 320 { 321 $local_ldap_connection = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 322 if ($ldap_connection) 310 //Begin: Check CPF, only if the manager has access to this field. 311 if ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'manipulate_corporative_information')) 312 { 313 if (!empty($cpf)) 314 { 315 if (!$this->functions->checkCPF($cpf)) 323 316 { 324 ldap_set_option($local_ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3);325 ldap_set_option($local_ldap_connection, LDAP_OPT_REFERRALS, false);326 ldap_bind($local_ldap_connection, $GLOBALS['phpgw_info']['server']['ldap_root_dn'], $GLOBALS['phpgw_info']['server']['ldap_root_pw']);317 $result['status'] = false; 318 $result['msg'] = $this->functions->lang('Field CPF is invalid') . '.'; 319 return $result; 327 320 } 328 321 else 329 322 { 330 $result['status'] = false; 331 $result['msg'] = 'Falha na conexao com o ldap.'; 332 return $result; 333 } 334 335 $filter = "(&(phpgwAccountType=u)(cpf=$cpf))"; 336 $justthese = array("cn","uid"); 337 $search = ldap_search($local_ldap_connection, $context, $filter, $justthese); 338 $entries = ldap_get_entries($local_ldap_connection,$search); 339 340 if ( ($entries['count'] == 1) && (strcasecmp($uid, $entries[0]['uid'][0]) == 0) ) 341 {} 342 else 343 { 344 if ($entries['count'] > 0) 323 //retira caracteres que não são números. 324 $cpf = ereg_replace("[^0-9]", "", $cpf); 325 326 $local_ldap_connection = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 327 if ($ldap_connection) 345 328 { 346 $result['question'] = $this->functions->lang('Field CPF used by') . ":\n"; 347 for ($i=0; $i<$entries['count']; $i++) 348 { 349 if (strcasecmp($uid, $entries[$i]['uid'][0]) != 0) 350 $result['question'] .= "- " . $entries[$i]['cn'][0] . "\n"; 351 } 352 $result['question'] .= $this->functions->lang("Do you want to continue anyway") . "?"; 329 ldap_set_option($local_ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3); 330 ldap_set_option($local_ldap_connection, LDAP_OPT_REFERRALS, false); 331 ldap_bind($local_ldap_connection, $GLOBALS['phpgw_info']['server']['ldap_root_dn'], $GLOBALS['phpgw_info']['server']['ldap_root_pw']); 332 } 333 else 334 { 335 $result['status'] = false; 336 $result['msg'] = 'Falha na conexao com o ldap.'; 353 337 return $result; 354 338 } 339 340 $filter = "(&(phpgwAccountType=u)(cpf=$cpf))"; 341 $justthese = array("cn","uid"); 342 $search = ldap_search($local_ldap_connection, $context, $filter, $justthese); 343 $entries = ldap_get_entries($local_ldap_connection,$search); 344 345 if ( ($entries['count'] != 1) && (strcasecmp($uid, $entries[0]['uid'][0]) != 0) ) 346 { 347 if ($entries['count'] > 0) 348 { 349 $result['question'] = $this->functions->lang('Field CPF used by') . ":\n"; 350 for ($i=0; $i<$entries['count']; $i++) 351 { 352 if (strcasecmp($uid, $entries[$i]['uid'][0]) != 0) 353 $result['question'] .= "- " . $entries[$i]['cn'][0] . "\n"; 354 } 355 $result['question'] .= $this->functions->lang("Do you want to continue anyway") . "?"; 356 return $result; 357 } 358 } 359 ldap_close($local_ldap_connection); 355 360 } 356 ldap_close($local_ldap_connection); 357 } 358 } 359 else if ($this->current_config['expressoAdmin_cpf_obligation']) 360 { 361 $result['status'] = false; 362 $result['msg'] = $this->functions->lang('Field CPF must be completed') . '.'; 363 return $result; 361 } 362 else if ($this->current_config['expressoAdmin_cpf_obligation']) 363 { 364 $result['status'] = false; 365 $result['msg'] = $this->functions->lang('Field CPF must be completed') . '.'; 366 return $result; 367 } 364 368 } 365 369 //End: Check CPF … … 1528 1532 if (ldap_errno($ldapMasterConnect) == '50') 1529 1533 { 1530 $result['msg'] = "Erro na funcao ldap_functions-> add_user2maillist.\n" .1534 $result['msg'] = "Erro na funcao ldap_functions->delete_user.\n" . 1531 1535 "O usuário utilizado para gravação no LDAP, DEVE ter direito de escrita.\n". 1532 1536 "O usuário " . $_SESSION['phpgw_info']['expresso']['cc_ldap_server']['acc'] . " não tem este direito.\n". 1533 "Edite \"Configuração Global do Catálogo\", no módulo Administrador, Catálogo de Endereços e adicione um usuário com direitos de escrita.";1537 "Edite \"Configuração Global do Catálogo\", no módulo Administrador, Catálogo de Endereços e adicione um usuário com direitos de escrita."; 1534 1538 } 1535 1539 else -
trunk/expressoAdmin1_2/inc/class.uiaccounts.inc.php
r369 r379 365 365 $disabled_edit_photo = 'disabled'; 366 366 $disabled_phonenumber = 'disabled'; 367 $disabled_group = 'disabled'; 367 368 368 369 $display_picture = 'none'; … … 395 396 $disabled_phonenumber = ''; 396 397 } 398 // SOMENTE GRUPOS 399 if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && ($this->functions->check_acl($manager_account_lid,'edit_groups'))) 400 { 401 $disabled = 'disabled'; 402 $disabled_group = ''; 403 } 397 404 // TOTAIS MENOS O SAMBA 398 405 if (($this->functions->check_acl($manager_account_lid,'edit_users')) && (!$this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes'))) … … 401 408 $disabled_password = ''; 402 409 $disabled_samba = 'disabled'; 410 $disabled_group = ''; 403 411 } 404 412 // TOTAIS … … 408 416 $disabled_password = ''; 409 417 $disabled_samba = ''; 418 $disabled_group = ''; 410 419 } 411 420 … … 421 430 $user_info = $this->user->get_user_info($_GET['account_id']); 422 431 432 // Formata o CPF 433 if ($user_info['corporative_information_cpf'] != '') 434 { 435 if (strlen($user_info['corporative_information_cpf']) < 11) 436 { 437 while (strlen($user_info['corporative_information_cpf']) < 11) 438 { 439 $user_info['corporative_information_cpf'] = '0' . $user_info['corporative_information_cpf']; 440 } 441 } 442 if (strlen($user_info['corporative_information_cpf']) == 11) 443 { 444 $cpf_tmp = str_split($user_info['corporative_information_cpf'], 3); 445 $user_info['corporative_information_cpf'] = $cpf_tmp[0] . '.' . $cpf_tmp[1] . '.' . $cpf_tmp[2] . '-' . $cpf_tmp[3]; 446 } 447 } 423 448 // JavaScript 424 449 $GLOBALS['phpgw']->js->validate_file("jscode","users","expressoAdmin1_2"); … … 606 631 'changequote_disabled' => $disabled_quote, 607 632 'disable_phonenumber' => $disabled_phonenumber, 633 'disable_group' => $disabled_group, 608 634 609 635 // Display ABAS -
trunk/expressoAdmin1_2/inc/class.user.inc.php
r355 r379 170 170 if ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'manipulate_corporative_information')) 171 171 { 172 //retira caracteres que não são números. 173 $params['corporative_information_cpf'] = ereg_replace("[^0-9]", "", $params['corporative_information_cpf']); 174 172 175 foreach ($params as $atribute=>$value) 173 176 { … … 279 282 280 283 $dn = 'uid=' . $old_values['uid'] . ',' . strtolower($old_values['context']); 284 285 //retira caracteres que não são números. 286 $new_values['corporative_information_cpf'] = ereg_replace("[^0-9]", "", $new_values['corporative_information_cpf']); 287 281 288 $diff = array_diff($new_values, $old_values); 282 289 … … 288 295 print_r($new_values); 289 296 echo '<br>'; 290 exit; 291 */297 exit;*/ 298 292 299 293 300 $manager_account_lid = $_SESSION['phpgw_session']['session_lid']; … … 766 773 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 767 774 // GROUPS 768 if ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'edit_users')) 769 { 775 if ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'edit_groups')) 776 { 777 // If the manager does not have the suficient access, the new_values.uid is empty. 778 if (empty($new_values['uid'])) 779 $user_uid = $old_values['uid']; 780 else 781 $user_uid = $new_values['uid']; 782 770 783 if (!$new_values['groups']) 771 784 $new_values['groups'] = array(); … … 781 794 { 782 795 $this->db_functions->add_user2group($gidnumber, $new_values['uidnumber']); 783 $this->ldap_functions->add_user2group($gidnumber, $ new_values['uid']);796 $this->ldap_functions->add_user2group($gidnumber, $user_uid); 784 797 $this->db_functions->write_log("adicionado usuario $dn ao grupo $gidnumber.",'','','',''); 785 798 } … … 795 808 { 796 809 $this->db_functions->remove_user2group($gidnumber, $new_values['uidnumber']); 797 $this->ldap_functions->remove_user2group($gidnumber, $ new_values['uid']);810 $this->ldap_functions->remove_user2group($gidnumber, $user_uid); 798 811 $this->db_functions->write_log("removido usuario $dn do grupo $gidnumber.",'','','',''); 799 812 } -
trunk/expressoAdmin1_2/js/jscode/expressoadmin.js
r180 r379 91 91 campo.value = vr.substr( 0, tam - 1 ); 92 92 } 93 94 function FormataCPF(event, campo) 95 { 96 if (event.keyCode == 8) 97 return; 93 98 99 vr = campo.value; 100 tam = vr.length; 101 102 var RegExp_onlyNumbers = new RegExp("[^0-9.-]+"); 103 if ( RegExp_onlyNumbers.test(campo.value) ) 104 campo.value = vr.substr( 0, (tam-1)); 105 106 if ( (campo.value.length == 3) || (campo.value.length == 7) ) 107 { 108 campo.value += '.'; 109 } 110 111 if (campo.value.length == 11) 112 campo.value += '-'; 113 return; 114 115 116 alert(campo.value); 117 return; 118 119 separador1 = '.'; 120 separador2 = '-'; 121 122 vr = campo.value; 123 tam = vr.length; 124 125 if ((tam == 1) && (( event.keyCode != 8 ) || ( event.keyCode != 46 ))) 126 campo.value = ''; 127 128 if ((tam == 3) && (( event.keyCode != 8 ) || ( event.keyCode != 46 ))) 129 campo.value = vr.substr( 0, tam - 1 ); 130 131 if (( tam <= 1 ) && ( event.keyCode != 8 ) && ( event.keyCode != 46 )) 132 campo.value = separador1 + vr; 133 134 if (( tam == 3 ) && ( event.keyCode != 8 ) && ( event.keyCode != 46 )) 135 campo.value = vr + separador2; 136 137 if (( tam == 8 ) && (( event.keyCode != 8 ) && ( event.keyCode != 46 ))) 138 campo.value = vr + separador3; 139 140 if ((( tam == 9 ) || ( tam == 8 )) && (( event.keyCode == 8 ) || ( event.keyCode == 46 ))) 141 campo.value = vr.substr( 0, tam - 1 ); 142 } -
trunk/expressoAdmin1_2/templates/default/accounts_form.tpl
r355 r379 130 130 <tr bgcolor={row_off}> 131 131 <td>{lang_cpf}:</td> 132 <td><input type="text" name="corporative_information_cpf" autocomplete="off" value="{corporative_information_cpf}" size="30" ></td>132 <td><input type="text" name="corporative_information_cpf" autocomplete="off" value="{corporative_information_cpf}" size="30" maxlength=14 onKeyUp="FormataCPF(event, this)"></td> 133 133 </tr> 134 134 <tr bgcolor={row_on}> … … 213 213 214 214 <td width="20%" align="center"> 215 <button type="button" {disable d} onClick="javascript:add_user2group();"><img src="expressoAdmin1_2/templates/default/images/add.png" style="vertical-align: middle;" > {lang_add}</button>215 <button type="button" {disable_group} onClick="javascript:add_user2group();"><img src="expressoAdmin1_2/templates/default/images/add.png" style="vertical-align: middle;" > {lang_add}</button> 216 216 <br><br> 217 <button type="button" {disable d} onClick="javascript:remove_user2group();"><img src="expressoAdmin1_2/templates/default/images/rem.png" style="vertical-align: middle;" > {lang_rem}</button>217 <button type="button" {disable_group} onClick="javascript:remove_user2group();"><img src="expressoAdmin1_2/templates/default/images/rem.png" style="vertical-align: middle;" > {lang_rem}</button> 218 218 </td> 219 219 … … 224 224 {lang_organizations}: 225 225 <br> 226 <select {disable d} id="ea_combo_org_groups" onchange="javascript:get_available_groups(this.value);">{combo_organizations}</select>226 <select {disable_group} id="ea_combo_org_groups" onchange="javascript:get_available_groups(this.value);">{combo_organizations}</select> 227 227 </td> 228 228 </tr> … … 231 231 <td> 232 232 Procurar grupo:<br> 233 <input {disable d} id="ea_input_searchGroup" size="35" autocomplete="off" onkeyup="javascript:optionFinderTimeout_group(this)"><br>233 <input {disable_group} id="ea_input_searchGroup" size="35" autocomplete="off" onkeyup="javascript:optionFinderTimeout_group(this)"><br> 234 234 <font color="red"><span id="ea_span_searching_group"> <span></font> 235 235 <br> … … 240 240 <td width="40%"> 241 241 {lang_available_groups}<br> 242 <select {disable d} id="ea_select_available_groups" size="10" style="width:300px" multiple></select>242 <select {disable_group} id="ea_select_available_groups" size="10" style="width:300px" multiple></select> 243 243 </td> 244 244 </tr>
Note: See TracChangeset
for help on using the changeset viewer.