Changeset 2974 for trunk


Ignore:
Timestamp:
06/28/10 11:52:02 (14 years ago)
Author:
adeildosantos
Message:

Ticket #1120 - Realizada a inlcusao da possibilidade de listar opcao extra no componente wf_select_ldap_users

Location:
trunk/workflow
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/workflow/inc/class.bo_utils.inc.php

    r2591 r2974  
    8686                        $ret_name = empty($params['name']) ? 'cn' : $params['name']; 
    8787 
     88                        $ret_complement = empty($params['complement']) ? '' : $params['complement'];  
     89 
    8890                        $ajaxConfig = &Factory::newInstance('ajax_config', 'contactcenter'); 
    8991                        $config = $ajaxConfig->read_repository(); 
     
    103105 
    104106                                $filter     = '(&(uid=*)(phpgwAccountType=u)(!(phpgwAccountVisible=-1))(cn=*' . $cn . '*))'; 
    105                                 $attrib_ret = array('cn', $ret_id, $ret_name); 
     107 
     108                                if($ret_complement != '') 
     109                                        $attrib_ret = array('cn', $ret_id, $ret_name, $ret_complement); 
     110                                else 
     111                                        $attrib_ret = array('cn', $ret_id, $ret_name); 
    106112 
    107113                                $r = ldap_search($ds, $ldapconfig['basedn'], $filter, $attrib_ret, 0, 0, 5); 
     
    114120                                                $result = ldap_get_entries($ds, $r); 
    115121                                                foreach($result as $value){ 
    116                                                         $output['values'][] = array( 
     122                                                  if($value[$ret_name][0] != ""){  
     123                                                        if($params['complement'] != ''){ 
     124                                                                        $complement = " >> " . $value[$ret_complement][0]; 
     125                                                                        $output['values'][] = array( 
     126                                                                        'id'   => $value[$ret_id], 
     127                                                                        'name' => trim(ucwords(strtolower($value[$ret_name][0]))) . $complement ); 
     128                                                                } 
     129                                                        else{ 
     130                                                                $output['values'][] = array( 
    117131                                                                'id'   => $value[$ret_id], 
    118132                                                                'name' => trim(ucwords(strtolower($value[$ret_name][0])))); 
     133                                                        } 
     134                                                  }      
    119135                                                } 
    120136 
  • trunk/workflow/inc/smarty/plugins/function.html_options.php

    r795 r2974  
    8989 
    9090    if(!empty($name)) { 
    91         $_html_result = '<select name="' . $name . '"' . $extra . '>' . "\n" . $_html_result . '</select>' . "\n"; 
     91        $_html_result = '<select name="' . $name . '"' . $extra . "\n" . $_html_result . '</select>' . "\n"; 
    9292    } 
    9393 
     
    9696} 
    9797 
     98function smarty_function_html_boxoptions($params, &$smarty) 
     99{ 
     100    require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); 
     101     
     102    $name = null; 
     103    $values = null; 
     104    $options = null; 
     105    $selected = array(); 
     106    $output = null; 
     107     
     108    $extra = ''; 
     109     
     110    foreach($params as $_key => $_val) { 
     111        switch($_key) { 
     112            case 'name': 
     113                $$_key = (string)$_val; 
     114                break; 
     115             
     116            case 'options': 
     117                $$_key = (array)$_val; 
     118                break; 
     119                 
     120            case 'values': 
     121            case 'output': 
     122                $$_key = array_values((array)$_val); 
     123                break; 
     124 
     125            case 'selected': 
     126                $$_key = array_map('strval', array_values((array)$_val)); 
     127                break; 
     128 
     129            default: 
     130                if(!is_array($_val)) { 
     131                    $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; 
     132                } else { 
     133                    $smarty->trigger_error("html_options: extra attribute '$_key' cannot be an array", E_USER_NOTICE); 
     134                } 
     135                break; 
     136        } 
     137    } 
     138 
     139    if (!isset($options) && !isset($values)) 
     140        return ''; /* raise error here? */ 
     141 
     142    $_html_result = ''; 
     143 
     144    if (isset($options)) { 
     145 
     146        foreach ($options as $_key=>$_val) 
     147            $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected); 
     148 
     149    } else { 
     150 
     151        foreach ($values as $_i=>$_key) { 
     152            $_val = isset($output[$_i]) ? $output[$_i] : ''; 
     153            $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected); 
     154        } 
     155 
     156    } 
     157 
     158    if(!empty($name)) { 
     159        $_html_result = '<select name="' . $name . '"' . $extra . ' style="height: 100px;" size="5">' . "\n" . $_html_result . '</select>' . "\n"; 
     160    } 
     161 
     162    return $_html_result; 
     163 
     164} 
    98165function smarty_function_html_options_optoutput($key, $value, $selected) { 
    99166    if(!is_array($value)) { 
  • trunk/workflow/inc/smarty/wf_plugins/function.wf_select_ldap_users.php

    r2591 r2974  
    2323 */ 
    2424function smarty_function_wf_select_ldap_users($params, &$smarty) 
    25 { 
     25{  
    2626    require_once $smarty->_get_plugin_filepath('function','html_options'); 
    2727        $imagesPath = substr(Factory::getInstance('TemplateServer')->generateImageLink(''), 0, -1); 
     
    4242                'class_btn', 
    4343                'opt_id', 
    44                 'opt_name'); 
     44                'opt_name', 
     45                'opt_complement'); 
    4546 
    4647        /* verifica se todos os parâmetros obrigatórios foram passados */ 
     
    7879        $output = <<<EOF 
    7980                <input type="text" id="$name_input" name="$name_input" size="$size_input" /> 
    80                 <input type="button" class="$class_btn" value="$value_btn" onclick="search_ldap_users_by_cn(document.getElementById('$name_input').value, '$name', '$opt_id', '$opt_name', $handleExpiredSessions)" /> 
     81                <input type="button" class="$class_btn" value="$value_btn" onclick="search_ldap_users_by_cn(document.getElementById('$name_input').value, '$name', '$opt_id', '$opt_name','$opt_complement', $handleExpiredSessions)" /> 
    8182                &nbsp;<img id="$name_img" border="0" src="$imagesPath/loading.gif" style="display:none"> 
    82                 <span id="$name_span" style="display:none">&nbsp;&nbsp;&nbsp;&nbsp;<b>Selecione o nome: </b> 
     83                <span id="$name_span" style="display:none">&nbsp;&nbsp;&nbsp;&nbsp;<b>Selecione um nome abaixo: </b><br><br> 
    8384EOF; 
    8485 
    85         $output .= smarty_function_html_options(array_merge(array( 
     86        $output .= smarty_function_html_boxoptions(array_merge(array( 
    8687                                                                                        'name'    => $name, 
    8788                                                                                        'id'      => $name, 
  • trunk/workflow/js/jscode/wf_select_ldap_users.js

    r795 r2974  
    99 * @param String opt_name Atributo que será atribuído ao name (innerHTML) das options da combo, por padrão é o 'cn' 
    1010 */ 
    11 function search_ldap_users_by_cn(cn, target, opt_id, opt_name, handleExpiredSessions) 
     11function search_ldap_users_by_cn(cn, target, opt_id, opt_name, opt_complement,  handleExpiredSessions) 
    1212{ 
    1313/* Método que trata o retorno da chamada Ajax. Atribui os valores retornados à combobox */ 
     
    4747 
    4848        var url = '$this.bo_utils.search_ldap_users_by_cn'; 
    49         var param = "cn=" + cn + "&target=" + target + "&id=" + opt_id + "&name=" + opt_name; 
     49        var param = "cn=" + cn + "&target=" + target + "&id=" + opt_id + "&name=" + opt_name + "&complement=" + opt_complement;  
    5050 
    5151        document.getElementById(target + "_img").show(); 
Note: See TracChangeset for help on using the changeset viewer.