Changeset 4504


Ignore:
Timestamp:
05/25/11 12:40:58 (13 years ago)
Author:
airton
Message:

Ticket #1929 - Validacao de campos do LDAP de acordo com os atributos extras de um contato

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/2.2.0.2/contactcenter/inc/hook_config_validate.inc.php

    r4500 r4504  
    2020 
    2121        /* Check all settings to validate input.  Name must be 'final_validation' */ 
    22         function final_validation($value='') 
     22        function final_validation(&$value='') 
    2323        { 
    2424                $error = false; 
    2525                 
    26                 if($value['cc_global_source0'] == 'ldap') 
    27                 { 
    28                         if (!$value['cc_ldap_host0']) 
    29                         { 
    30                                 $error[] = '<br>LDAP host must be set!'; 
     26//              if($value['cc_global_source0'] == 'ldap') 
     27//              { 
     28//                      if (!$value['cc_ldap_host0']) 
     29//                      { 
     30//                              $error[] = '<br>LDAP host must be set!'; 
     31//                      } 
     32//                       
     33//                      if(!$value['cc_ldap_context0']) 
     34//                      { 
     35//                              $error[] = '<br>There must be a Context'; 
     36//                      } 
     37//                       
     38//                      if(!$value['cc_ldap_browse_dn0']) 
     39//                      { 
     40//                              $error[] = '<br>The Browse Account must be set'; 
     41//                      }        
     42//              } 
     43                 
     44                foreach ($value as $attr_name => $attr_value) { 
     45                        if ($attr_value == '') { 
     46                                $v      = explode("_", $attr_name); 
     47                                $nums[] = $v[3]; 
    3148                        } 
     49                } 
     50                 
     51                foreach ($nums as $num) { 
     52                        //Deleta toda a tupla que contem o atributo vazio 
     53                        foreach ($value as $attr_name_x => $attr_value_x) { 
    3254                         
    33                         if(!$value['cc_ldap_context0']) 
    34                         { 
    35                                 $error[] = '<br>There must be a Context'; 
     55                                if (strpos($attr_name_x, $num) !== false) { 
     56                                        if (strpos($attr_name_x, 'cc_attribute_name') !== false) 
     57                                                $error[] = "<br/>" . lang("Could not find the LDAP attribute pointed by") . "  " . $attr_value_x;        
     58                                         
     59                                        unset($value[$attr_name_x]);     
     60                                         
     61                                } 
    3662                        } 
    37                          
    38                         if(!$value['cc_ldap_browse_dn0']) 
    39                         { 
    40                                 $error[] = '<br>The Browse Account must be set'; 
    41                         }        
    4263                } 
    4364                 
     
    5172        /* 
    5273         * @function cc_allow_details 
    53          * @abstract Recebe o valor do checkbox e forï¿œa a saï¿œda para TRUE ou FALSE 
     74         * @abstract Recebe o valor do checkbox e força a saída para TRUE ou FALSE 
    5475         * @author Prognus software livre - http://www.prognus.com.br | prognus@prognus.com.br 
    5576         * @param $value 
     
    6283                } 
    6384        } 
     85         
     86         
     87         
     88        /* 
     89         * @function cc_attribute_ldapname 
     90         * @abstract valida campo "Correspondente LDAP" se é um campo ldap válido 
     91         * @author Prognus Software Livre - http://www.prognus.com.br | prognus@prognus.com.br 
     92         * @param $value 
     93         */ 
     94        function cc_attribute_ldapname(&$value) { 
     95                $ldap = CreateObject('contactcenter.bo_ldap_manager'); 
     96                $ds = $GLOBALS['phpgw']->common->ldapConnect($ldap->srcs[1]['host'], $ldap->srcs[1]['acc'], $ldap->srcs[1]['pw'], true);                                 
     97                $dn=$ldap->srcs[1]['dn']; 
     98                $justThese = array('uid', 'cn', $value); 
     99                $sr = ldap_search($ds, $dn, "($value=*)", $justThese, 0, 1); 
     100                $info = ldap_get_entries($ds, $sr); 
     101                 
     102                if (!$info)   
     103                        $value = ""; 
     104                ldap_close($ds); 
     105        } 
    64106?> 
Note: See TracChangeset for help on using the changeset viewer.