Changeset 379


Ignore:
Timestamp:
07/28/08 17:02:28 (16 years ago)
Author:
niltonneto
Message:
 
Location:
trunk/expressoAdmin1_2
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoAdmin1_2/inc/class.functions.inc.php

    r355 r379  
    755755                           "88888888888","99999999999","00000000000"); 
    756756 
     757                        /* formato do CPF */ 
     758                        if (!(ereg("^[0-9]{3}[.][0-9]{3}[.][0-9]{3}[-][0-9]{2}$",$cpf))) 
     759                                return false; 
     760 
    757761                        /* Retira todos os caracteres que nao sejam 0-9 */ 
    758762                        $cpf = ereg_replace("[^0-9]", "", $cpf); 
  • trunk/expressoAdmin1_2/inc/class.ldap_functions.inc.php

    r355 r379  
    308308                } 
    309309 
    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)) 
    323316                                { 
    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; 
    327320                                } 
    328321                                else 
    329322                                { 
    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) 
    345328                                        { 
    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.'; 
    353337                                                return $result; 
    354338                                        } 
     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); 
    355360                                } 
    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                        } 
    364368                } 
    365369                //End: Check CPF 
     
    15281532                                        if (ldap_errno($ldapMasterConnect) == '50') 
    15291533                                        { 
    1530                                                 $result['msg'] = "Erro na funcao ldap_functions->add_user2maillist.\n" . 
     1534                                                $result['msg'] = "Erro na funcao ldap_functions->delete_user.\n" . 
    15311535                                                                                 "O usuário utilizado para gravação no LDAP, DEVE ter direito de escrita.\n". 
    15321536                                                                                 "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."; 
    15341538                                        } 
    15351539                                        else 
  • trunk/expressoAdmin1_2/inc/class.uiaccounts.inc.php

    r369 r379  
    365365                        $disabled_edit_photo = 'disabled'; 
    366366                        $disabled_phonenumber = 'disabled'; 
     367                        $disabled_group = 'disabled'; 
    367368                         
    368369                        $display_picture = 'none'; 
     
    395396                                $disabled_phonenumber = ''; 
    396397                        } 
     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                        } 
    397404                        // TOTAIS MENOS O SAMBA 
    398405                        if (($this->functions->check_acl($manager_account_lid,'edit_users')) && (!$this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes'))) 
     
    401408                                $disabled_password = ''; 
    402409                                $disabled_samba = 'disabled'; 
     410                                $disabled_group = ''; 
    403411                        } 
    404412                        // TOTAIS 
     
    408416                                $disabled_password = ''; 
    409417                                $disabled_samba = ''; 
     418                                $disabled_group = ''; 
    410419                        } 
    411420                         
     
    421430                        $user_info = $this->user->get_user_info($_GET['account_id']); 
    422431                         
     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                        } 
    423448                        // JavaScript 
    424449                        $GLOBALS['phpgw']->js->validate_file("jscode","users","expressoAdmin1_2"); 
     
    606631                                'changequote_disabled'          => $disabled_quote, 
    607632                                'disable_phonenumber'           => $disabled_phonenumber, 
     633                                'disable_group'                         => $disabled_group, 
    608634                                 
    609635                                // Display ABAS 
  • trunk/expressoAdmin1_2/inc/class.user.inc.php

    r355 r379  
    170170                                if ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'manipulate_corporative_information')) 
    171171                                { 
     172                                        //retira caracteres que não são números. 
     173                                        $params['corporative_information_cpf'] = ereg_replace("[^0-9]", "", $params['corporative_information_cpf']); 
     174                                         
    172175                                        foreach ($params as $atribute=>$value) 
    173176                                        { 
     
    279282                         
    280283                        $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 
    281288                        $diff = array_diff($new_values, $old_values); 
    282289                         
     
    288295                        print_r($new_values); 
    289296                        echo '<br>'; 
    290                         exit; 
    291                         */ 
     297                        exit;*/ 
     298                         
    292299 
    293300                        $manager_account_lid = $_SESSION['phpgw_session']['session_lid']; 
     
    766773                        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
    767774                        // 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                                 
    770783                                if (!$new_values['groups']) 
    771784                                        $new_values['groups'] = array(); 
     
    781794                                        { 
    782795                                                $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); 
    784797                                                $this->db_functions->write_log("adicionado usuario $dn ao grupo $gidnumber.",'','','',''); 
    785798                                        } 
     
    795808                                                        { 
    796809                                                                $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); 
    798811                                                                $this->db_functions->write_log("removido usuario $dn do grupo $gidnumber.",'','','',''); 
    799812                                                        } 
  • trunk/expressoAdmin1_2/js/jscode/expressoadmin.js

    r180 r379  
    9191                campo.value = vr.substr( 0, tam - 1 ); 
    9292} 
     93 
     94function FormataCPF(event, campo) 
     95{ 
     96        if (event.keyCode == 8) 
     97                return; 
    9398         
     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  
    130130                <tr bgcolor={row_off}> 
    131131                        <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> 
    133133                </tr> 
    134134                <tr bgcolor={row_on}> 
     
    213213 
    214214                        <td width="20%" align="center"> 
    215                                 <button type="button" {disabled} onClick="javascript:add_user2group();"><img src="expressoAdmin1_2/templates/default/images/add.png" style="vertical-align: middle;" >&nbsp;{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;" >&nbsp;{lang_add}</button> 
    216216                                <br><br> 
    217                                 <button type="button" {disabled} onClick="javascript:remove_user2group();"><img src="expressoAdmin1_2/templates/default/images/rem.png" style="vertical-align: middle;" >&nbsp;{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;" >&nbsp;{lang_rem}</button> 
    218218                        </td> 
    219219 
     
    224224                                                        {lang_organizations}: 
    225225                                                        <br> 
    226                                                         <select {disabled} 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> 
    227227                                                </td> 
    228228                                        </tr> 
     
    231231                                                <td> 
    232232                                                        Procurar grupo:<br> 
    233                                                         <input {disabled} 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> 
    234234                                                        <font color="red"><span id="ea_span_searching_group">&nbsp;<span></font> 
    235235                                                        <br>                                                     
     
    240240                                                <td width="40%"> 
    241241                                                        {lang_available_groups}<br> 
    242                                                         <select {disabled} 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> 
    243243                                                </td> 
    244244                                        </tr> 
Note: See TracChangeset for help on using the changeset viewer.