Ignore:
Timestamp:
05/25/11 10:47:52 (13 years ago)
Author:
airton
Message:

Ticket #1926 - Permitir configurar mais atributos cadastrados de um contato para exibição

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/2.2.0.2/contactcenter/inc/class.ui_data.inc.php

    r4498 r4500  
    259259                        $GLOBALS['phpgw']->template->set_var('cc_msg_expresso_default_csv', lang('Export as Expresso (Default) CSV.')); 
    260260                        $GLOBALS['phpgw']->template->set_var('cc_msg_copy_to_catalog', lang('Copy to personal catalog.')); 
     261                        $GLOBALS['phpgw']->template->set_var('cc_msg_show_extra_detail', lang("Show extra contact's details.")); 
    261262                        $GLOBALS['phpgw']->template->set_var('cc_msg_add_contact_to_group', lang('You did not add any contact for this group.')); 
    262263                        $GLOBALS['phpgw']->template->set_var('cc_msg_fill_field_name', lang('Fill the field Full Name')); 
     
    289290                        $main .= $api->get_quick_add_plugin(); 
    290291                        $main .= $api->get_add_group(); 
     292                        $main .= $api->get_contact_details(); 
    291293                        $main .= $GLOBALS['phpgw']->template->get_var('out'); 
    292294 
     
    445447                                        return $this->export_contacts($_POST['typeExport']); 
    446448                                 
     449                                case 'get_contact_details': 
     450                                        return $this->get_contact_details($_GET['id']); 
     451 
    447452                                case 'get_qtds_compartilhado': 
    448453                                        return $this->get_qtds_compartilhado(); 
     454 
    449455                                case 'get_list_owners_perms_add': 
    450456                                        echo $this->get_list_owners_perms_add(); 
     
    13231329                                        ) 
    13241330                                ); 
    1325  
     1331                                //verifica se esta habilitado a opcao de exibir os detalhes extras 
     1332                                $objconfig = CreateObject('phpgwapi.config', 'contactcenter'); 
     1333                                $config = $objconfig->read_repository(); 
     1334                                $final[12] = isset($config['cc_allow_details'])? $config['cc_allow_details'] : false; 
    13261335                                //echo 'Page: '.$page.'<br>'; 
    13271336                                $n_entries = count($this->page_info['actual_entries']); 
     
    44344443                        echo serialize($return); 
    44354444                } 
     4445         
     4446                /*! 
     4447                 * @function get_contact_details 
     4448                 * @abstract Retorna os detalhes extras de um contato 
     4449                 * @author Luiz Carlos Viana Melo - Prognus 
     4450                 * @param (string) O ID do usuário do LDAP 
     4451                 */ 
     4452                function get_contact_details($id) 
     4453                { 
     4454                        $data = array(); 
     4455                         
     4456                        if(!$this->bo->catalog->src_info) { 
     4457                                $ldap = CreateObject('contactcenter.bo_ldap_manager'); 
     4458                                $this->bo->catalog->src_info = $ldap->srcs[1]; 
     4459                        } 
     4460                         
     4461                        $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true);                               
     4462                        $dn=$this->bo->catalog->src_info['dn']; 
     4463                         
     4464                        //buscar os atributos do ldap 
     4465                        $configobj = CreateObject('phpgwapi.config', 'contactcenter'); 
     4466                        $prefs = $configobj->read_repository(); 
     4467                        $attr_names = array(); 
     4468                        $attr_types = array(); 
     4469                        $justThese = array(); 
     4470                        foreach ($prefs as $pref_key => $pref_value) 
     4471                        { 
     4472                                if (stripos($pref_key, "cc_attribute_name_") !== false) 
     4473                                { 
     4474                                        $num = substr($pref_key, strlen("cc_attribute_name_")); 
     4475                                        $attr_names[] = $prefs["cc_attribute_name_$num"]; 
     4476                                        $attr_types[] = $prefs["cc_attribute_type_$num"]; 
     4477                                        $justThese[] = strtolower($prefs["cc_attribute_ldapname_$num"]); 
     4478                                } 
     4479                        } 
     4480                        $sr = ldap_read($ds,$id, "objectClass=*",$justThese);                                                    
     4481                        $info = ldap_get_entries($ds, $sr); 
     4482                        if ($info) 
     4483                        { 
     4484                                for ($i = 0; $i < count($justThese); $i++) 
     4485                                { 
     4486                                        $attr = array(); 
     4487                                        $attr['name'] = $attr_names[$i]; 
     4488                                        if ($attr_types[$i] == 'multivalues') 
     4489                                        { 
     4490                                                $attr['type'] = 'multivalues'; 
     4491                                                $attr['value'] = array(); 
     4492                                                for ($j = 0; $j < $info[0][$justThese[$i]]['count']; $j++) 
     4493                                                        $attr['value'][] = utf8_decode($info[0][$justThese[$i]][$j]); 
     4494                                        } 
     4495                                        else 
     4496                                        { 
     4497                                                $attr['type'] = 'text'; 
     4498                                                $attr['value'] = utf8_decode($info[0][$justThese[$i]][0]); 
     4499                                        } 
     4500                                        $data[] = $attr; 
     4501                                } 
     4502                        } 
     4503                        else 
     4504                                $data = 'error'; 
     4505                        ldap_close($ds); 
     4506                         
     4507                        echo serialize($data); 
     4508                } 
    44364509        } 
    44374510 
Note: See TracChangeset for help on using the changeset viewer.