Changeset 4500 for sandbox


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

Location:
sandbox/2.2.0.2
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • sandbox/2.2.0.2/admin/inc/class.uiconfig.inc.php

    r3018 r4500  
    7979                                /* Load hook file with functions to validate each config (one/none/all) */ 
    8080                                $GLOBALS['phpgw']->hooks->single('config_validate',$appname); 
     81                                 
     82                                if (!isset($_POST['newsettings']['cc_allow_details'])) { 
     83                                        $_POST['newsettings']['cc_allow_details'] = "false"; 
     84                                } 
    8185 
    8286                                foreach($_POST['newsettings'] as $key => $config) 
    8387                                { 
    84                                         if ($config) 
    85                                         { 
    86                                                 if($GLOBALS['phpgw_info']['server']['found_validation_hook'] && function_exists($key)) 
    87                                                 { 
    88                                                         call_user_func($key,$config); 
    89                                                         if($GLOBALS['config_error']) 
     88                                         
     89                                        if ($config)   
     90                                        {                                                                                                                                                                                 // Código adicionado   
     91                                                if($GLOBALS['phpgw_info']['server']['found_validation_hook'] && (function_exists($key) || function_exists(substr($key,0,strrpos($key,'_')))) ) 
     92                                                { 
     93                                                        if(function_exists(substr($key,0,strrpos($key,'_')))) 
     94                                { 
     95                                call_user_func(substr($key,0,strrpos($key,'_')),&$config); 
     96                                }  
     97                                else  
     98                                { 
     99                                call_user_func($key,&$config); 
     100                                } 
     101 
     102                                if($GLOBALS['config_error']) 
    90103                                                        { 
    91104                                                                $errors .= lang($GLOBALS['config_error']) . ' '; 
     
    152165                        echo parse_navbar(); 
    153166 
     167                         
     168                        $campos = ''; 
     169                         
     170                        if($appname=="contactcenter")  
     171                        { 
     172                                 
     173                                foreach ($c->config_data as $key => $config)  
     174                                {                
     175                                        $parts = explode('_', $key); 
     176                        if (is_numeric($parts[3]) && $parts[1]=='attribute') 
     177                        { 
     178                        $fields[$parts[3]][$key] = $config; 
     179                        } 
     180                         
     181                         
     182                        if($key == 'cc_allow_details') { 
     183                                $checkedCoisa = 'value="details"'; 
     184                                if ($config=='true') { 
     185                                        $checkedCoisa = 'value="details" checked="checked"';  
     186                                } 
     187                        } 
     188                } 
     189                         
     190                 
     191                        foreach ($fields as $i => $line)  
     192                        { 
     193                        if ($line["cc_attribute_name_$i"] != '' && $line["cc_attribute_ldapname_$i"] != '') { 
     194                        $selectedText  = $line["cc_attribute_type_$i"] == 'text' ? 'selected="selected"' : ''; 
     195                        $selectedTMult = $line["cc_attribute_type_$i"] == 'multivalues' ? 'selected="selected"' : ''; 
     196                                 
     197                                $campos = $campos . "<div class=\"cc_attribute\"> 
     198                                <label>" . lang('Name') .":</label> 
     199                                <input type=\"text\" name=\"newsettings[cc_attribute_name_" . $i . "]\" value=\"".$line["cc_attribute_name_$i"]."\" />  
     200                                <label>" . lang('Corresponding LDAP') . ":</label> 
     201                                <input type=\"text\" name=\"newsettings[cc_attribute_ldapname_" . $i . "]\" value=\"".$line["cc_attribute_ldapname_$i"]."\" />  
     202                                <label>" . lang('Type') . ":</label> 
     203                                <select name=\"newsettings[cc_attribute_type_" . $i . "]\"> 
     204                                        <option value=\"text\" $selectedText>" . lang('Text') . "</option> 
     205                                        <option value=\"multivalues\" $selectedTMult>" . lang('Multivalued') ."</option> 
     206                                </select> 
     207                                <img src=\"contactcenter/templates/default/images/cc_x.png\" alt=\"". lang('Delete') . "\" style=\"width: 15px; height: 14px; cursor: pointer; position: relative; top: 3px;\" onclick=\"javascript:cc_attribute_delete(this)\"/>   
     208                        </div>"; 
     209                        } 
     210                        }  
     211                 
     212                            if ($campos == '') 
     213                        { 
     214                                $campos = "<div class=\"cc_attribute\"> 
     215                                <label>" . lang('Name') .":</label> 
     216                                <input type=\"text\" name=\"newsettings[cc_attribute_name_0]\" value=\"\" />  
     217                                <label>" . lang('Corresponding LDAP') . ":</label> 
     218                                <input type=\"text\" name=\"newsettings[cc_attribute_ldapname_0]\" value=\"\" />  
     219                                <label>" . lang('Type') . ":</label> 
     220                                <select name=\"newsettings[cc_attribute_type_0]\"> 
     221                                        <option value=\"text\">" . lang('Text') . "</option> 
     222                                        <option value=\"multivalues\">" . lang('Multivalued') . "</option> 
     223                                </select> 
     224                                <img src=\"contactcenter/templates/default/images/cc_x.png\" alt=\"". lang('Delete') ."\" style=\"width: 15px; height: 14px; cursor: pointer; position: relative; top: 3px;\" onclick=\"javascript:cc_attribute_delete(this)\"/>  
     225                        </div>"; 
     226                        } 
     227                         
     228                        $t->set_var('lang_add_button', lang('Add')); 
     229                                $t->set_var('lang_cc_Set_details_attributes',   lang('Details on the Global Catalog Address')); 
     230                        $t->set_var('lang_cc_Allow_view_details_label', lang('Enable display of contact details for the Global Catalog'));                               
     231                        $t->set_var('attribute_fields', $campos);                
     232                        $t->set_var('cc_config_js', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_config.js'); 
     233                        $t->set_var('cc_allow_view_details_value', $checkedCoisa); 
     234                        }  
     235                 
     236                         
    154237                        if($appname=="expressoAdmin1_2") { 
    155238                                /* Varre a pasta inc do admin do expresso procurando scripts de geração de login automático 
  • sandbox/2.2.0.2/contactcenter/inc/class.bo_ldap_manager.inc.php

    r4352 r4500  
    193193                /* 
    194194                 * @function get_external_ldap_fields_association 
    195                  * @author Mï¿œrio Cï¿œsar Kolling <mario.kolling@serpro.gov.br> 
     195                 * @author Mário César Kolling <mario.kolling@serpro.gov.br> 
    196196                 * @abstract get the fields association for an external ldap_source 
    197197                 * @return an array with attribute mappings 
     
    206206                /* 
    207207                 * @function test_connection 
    208                  * @author Mï¿œrio Cï¿œsar Kolling <mario.kolling@serpro.gov.br> 
     208                 * @author Mário César Kolling <mario.kolling@serpro.gov.br> 
    209209                 * @abstract Test if we can bind to a ldap server in a reasonable time 
    210210                 * @param (string) $host ldap server's hostname 
     
    291291                        @function get_external_ldap_tree 
    292292                        @abstract Returns the LDAP external tree corresponding to the specified level 
    293                         @author Mï¿œrio Cï¿œsar Kolling <mario.kolling@serpro.gov.br> 
     293                        @author Mário César Kolling <mario.kolling@serpro.gov.br> 
    294294                        @param (integer) $id_source The ID of the external LDAP source 
    295295                        @param (string)  $context The context to be used as root branch 
     
    458458                { 
    459459                        /* 
    460                          * Esta operaᅵᅵo resolve o problema causado pela conversï¿œo de caracteres acentuados realizada 
    461                          * pela funᅵᅵo ldap_explode_dn(). 
     460                         * Esta operação resolve o problema causado pela conversão de caracteres acentuados realizada 
     461                         * pela função ldap_explode_dn(). 
    462462                         */ 
    463463 
     
    539539                                list($group) = explode('=',$dn_parts_full[0]); 
    540540 
    541                                 //Faz a comparaᅵᅵo do branch como case insensitive 
     541                                //Faz a comparação do branch como case insensitive 
    542542                                if (strtolower($group) == strtolower($branch_dn) or $branch_dn === 'all') 
    543543                                { 
  • sandbox/2.2.0.2/contactcenter/inc/class.ui_api.inc.php

    r4498 r4500  
    183183                        $template->parse('out','search'); 
    184184 
     185                        return $template->get_var('out'); 
     186                } 
     187                 
     188                function get_contact_details() 
     189                { 
     190                        $template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); 
     191                        $template->set_file(array('details' => 'contact_details.tpl')); 
     192                         
     193                        if (!$this->commons_loaded) 
     194                        { 
     195                                $template->set_var('cc_api', $this->commons); 
     196                                $this->commons_loaded = true; 
     197                        } 
     198                        else 
     199                        { 
     200                                $template->set_var('cc_api', ''); 
     201                        } 
     202                         
     203                        //$template->set_var('ccContactDetails.js', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/ccContactDetails.js'); 
     204                        $template->set_var('cc_contact_details_title',lang("Contact's details")); 
     205                        $template->set_var('cc_contact_details_close',lang("Close")); 
     206                        $template->set_var('cc_contact_details_no_fields',lang("The extra details are not configured.")); 
     207                        $template->set_var('cc_contact_details_attr_name',lang("Attribute name")); 
     208                        $template->set_var('cc_contact_details_attr_value',lang("Value")); 
     209                        $template->parse('out','details'); 
    185210                        return $template->get_var('out'); 
    186211                } 
  • 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 
  • sandbox/2.2.0.2/contactcenter/inc/hook_config_validate.inc.php

    r2 r4500  
    4747                } 
    4848        } 
     49 
     50         
     51        /* 
     52         * @function cc_allow_details 
     53         * @abstract Recebe o valor do checkbox e forï¿œa a saï¿œda para TRUE ou FALSE 
     54         * @author Prognus software livre - http://www.prognus.com.br | prognus@prognus.com.br 
     55         * @param $value 
     56         */ 
     57        function cc_allow_details(&$value) { 
     58                if ($value == 'details') { 
     59                        $value = "true"; 
     60                } else { 
     61                        $value = "false"; 
     62                } 
     63        } 
    4964?> 
  • sandbox/2.2.0.2/contactcenter/js/cc.js

    r4498 r4500  
    227227function closeFullAdd(){ 
    228228        fullAddWin.close(); 
     229} 
     230/******** Contact details ***********/ 
     231function openContactDetails(id){ 
     232        // Build the ContactDetails Window. 
     233        if(!contactdetailsWin && !is_ie)  
     234                __cdWin(); 
     235 
     236        contactdetailsWin.open(); 
     237         
     238        populateContactDetails(id); 
     239} 
     240 
     241function populateContactDetails(id) 
     242{ 
     243        var handler = function(responseText) 
     244        { 
     245                var fieldsDiv = Element('id_cc_contact_details_fields'); 
     246                var data = unserialize(responseText); 
     247                //alert(responseText); 
     248                fieldsDiv.innerHTML = ""; 
     249                if (data && data.length > 0) 
     250                { 
     251                        //fieldsDiv.innerHTML = ""; 
     252                        var table = document.createElement("table"); 
     253                        table.border=0; 
     254                        //table.style.borderBottom = '1px solid #999'; 
     255                        //table.cellSpacing = '0'; 
     256                        table.width = '480px'; 
     257                        var attr_name_size = '50%'; 
     258                        var attr_value_size = '50%'; 
     259                        for(i = 0; i < data.length; i++) 
     260                        { 
     261                                var row = table.insertRow(i); 
     262                                if ((i % 2) == 0) 
     263                                        row.setAttribute('class', 'row_off'); 
     264                                else 
     265                                        row.setAttribute('class', 'row_on'); 
     266                                //row.style.borderBottom = '1px solid #999'; 
     267                                attr_name = row.insertCell(0); 
     268                                attr_value = row.insertCell(1); 
     269                                attr_name.style.width = attr_name_size; 
     270                                attr_value.style.width = attr_value_size; 
     271                                attr_name.innerHTML = data[i]['name']; 
     272                                if (data[i]['type'] == 'text') 
     273                                        attr_value.innerHTML = data[i]['value']; 
     274                                else 
     275                                { 
     276                                        var multivalue_div = document.createElement("div"); 
     277                                        multivalue_div.style.overflow = 'auto'; 
     278                                        multivalue_div.style.height = '100px'; 
     279                                        multivalue_div.style.border = '1px solid #999'; 
     280                                        //multivalue_div.style.backgroundColor = 'transparent'; 
     281                                        for (j = 0; j < data[i]['value'].length; j++) 
     282                                        { 
     283                                                multivalue_div.appendChild(document.createTextNode(data[i]['value'][j])); 
     284                                                multivalue_div.appendChild(document.createElement("br")); 
     285                                        } 
     286                                        attr_value.appendChild(multivalue_div); 
     287                                }        
     288                        } 
     289                        fieldsDiv.appendChild(table); 
     290                } 
     291                else 
     292                        fieldsDiv.innerHTML = Element('cc_contact_details_no_fields').value;  
     293        }; 
     294        Connector.newRequest('populateContactDetails', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_contact_details&id=' + id, 'GET', handler); 
     295} 
     296 
     297function closeContactDetails(){ 
     298        contactdetailsWin.close(); 
    229299} 
    230300/********** New Contact *************/ 
     
    23022372                                                                Element(id+':cc_photo').src = '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_photo' + (data[4][pos] != 0 ? '&id='+data[3][pos][k] : ''); 
    23032373                                                                if(ccTree.catalog_perms == 1) 
     2374                                                                { 
    23042375                                                                        Element(id+':cc_icon_data').innerHTML =  '<span title="'+Element('cc_msg_copy_to_catalog').value+'" id="' + id + ':ccQuickAdd" onmouseout="window.status=\'\';" onclick="ccQuickAddContact.showList(\''+ Element(id+':cc_id').value + '\');return true;" style="cursor: pointer; cursor: hand; z-index: 1"><img src="templates/default/images/address-conduit-16.png" align="center"></span>'; 
     2376                                                                        if (data[12] == true || data[12] == 'true') 
     2377                                                                                Element(id+':cc_icon_data').innerHTML += "  |  " + '<span title="'+ Element('cc_msg_show_extra_detail').value+'" id="' + id + ':ccContactDetails" onclick="javascript:openContactDetails(\'' + Element(id+':cc_id').value + '\');" style="cursor: pointer; cursor: hand; z-index: 1"><img src="templates/default/images/addressbook-mini.png" align="center"></span>'; 
     2378                                                                } 
    23052379                                                                break; 
    23062380 
  • sandbox/2.2.0.2/contactcenter/setup/phpgw_es-es.lang

    r4498 r4500  
    205205Not Allowed     contactcenter   es-es   Acceso negado 
    206206Unavailable function    contactcenter   es-es   Función no disponible 
     207Details on the Global Catalog Address   common  es-es   Detalles en el Catálogo Global de Direcciones 
     208Enable display of contact details for the Global Catalog        common  es-es   Permitir visualización de detalles para contactos del Catálogo Global 
     209Nome    common  es-es   Nombre   
     210Type    common  es-es   Tipo 
     211Delete  common  es-es   Borrar 
     212Add     common  es-es   Añadir 
     213The reported field was not found in LDAP        common  es-es   El campo reportado como correspondencia en LDAP no se encontró 
     214Text    common  es-es   Texto 
     215Multivalued     common  es-es   multivalor 
  • sandbox/2.2.0.2/contactcenter/templates/default/config.tpl

    r3262 r4500  
    11<!-- BEGIN header --> 
    2 <form method="POST" action="{action_url}"> 
     2<script type="text/javascript" src="{cc_config_js}"></script> 
     3<!-- Foi incluído essa parte no evento do form (onsubmit....) e foi incluído a linha de cima para usar o arquivo .js --> 
     4<form  onsubmit="javascript:cc_attribute_clear(this);" method="POST" action="{action_url}"> 
    35<table border="0" align="center"> 
    46        <tr class="th"> 
     
    7981                </td> 
    8082        </tr> 
    81         <tr class="th"> 
    82                 <td colspan="2">&nbsp;</td> 
    83         </tr> 
    84         <tr> 
    85                 <td></td> 
    86         </tr> 
    87         <tr> 
    88                 <td></td> 
    89         </tr> 
     83<tr class="th"> 
     84        <td colspan="2">&nbsp;<b>{lang_cc_Set_details_attributes}</b></td> 
     85    </tr> 
     86    <tr> 
     87                <td colspan="2" id="cc_attribute_fields"> 
     88                        <div> 
     89                                <input id="config_cc_allow_details" type="checkbox" name="newsettings[cc_allow_details]" {cc_allow_view_details_value} value="details"/>  
     90                                <label for="config_cc_allow_details" >{lang_cc_Allow_view_details_label}</label> 
     91                        
     92                        </div> 
     93                                                 
     94                                                <div align="right" id="cc_attribute_box_adder"> 
     95                                <input type="button" onclick="javascript:cc_attribute_add();" name="addattribute" value="{lang_add_button}" />  
     96                        </div> 
     97                                                 
     98                                                <br /> 
     99                                                        {attribute_fields}                         
     100                                </td> 
     101    </tr> 
    90102  <!-- <tr class="row_on"> 
    91103        <td>{lang_objectClass_to_be_used_as_a_Contact}:</td> 
  • sandbox/2.2.0.2/contactcenter/templates/default/index.tpl

    r3311 r4500  
    8686<input id="cc_msg_expresso_default_csv" type="hidden" value="{cc_msg_expresso_default_csv}"> 
    8787<input id="cc_msg_copy_to_catalog" type="hidden" value="{cc_msg_copy_to_catalog}"> 
     88<input id="cc_msg_show_extra_detail" type="hidden" value="{cc_msg_show_extra_detail}"> 
    8889<input id="cc_msg_fill_field_name" type="hidden" value="{cc_msg_fill_field_name}"> 
    8990<input id="cc_msg_add_contact_to_group" type="hidden" value="{cc_msg_add_contact_to_group}"> 
Note: See TracChangeset for help on using the changeset viewer.