Changeset 577 for trunk/admin


Ignore:
Timestamp:
01/07/09 17:14:51 (15 years ago)
Author:
niltonneto
Message:

Resolve #348

Location:
trunk/admin
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/inc/class.bocategories.inc.php

    r2 r577  
    9696                } 
    9797 
    98                 function get_list() 
     98                function get_list($id_group) 
    9999                { 
    100                         if($this->debug) { echo '<br>querying: "' . $this->query . '"'; } 
    101                         return $this->cats->return_sorted_array($this->start,True,$this->query,$this->sort,$this->order,True); 
     100                        if($this->debug) { echo '<br>querying: "' . $this->query . '"'; }                        
     101                        return $this->cats->return_sorted_array($this->start,True,$this->query,$this->sort,$this->order,True,'',$id_group); 
    102102                } 
    103103 
  • trunk/admin/inc/class.uicategories.inc.php

    r2 r577  
    6969 
    7070                        $dir = dir(PHPGW_SERVER_ROOT.'/phpgwapi/images'); 
     71 
    7172                        while($file = $dir->read()) 
    7273                        { 
     
    115116                        $this->template->set_var('lang_save',lang('Save')); 
    116117                        $this->template->set_var('lang_search',lang('Search')); 
     118                        $this->template->set_var('lang_group_name',lang('group name')); 
     119                        $this->template->set_var('lang_cat_name',lang('category name')); 
    117120                        $this->template->set_var('lang_sub',lang('Add sub')); 
    118121                        $this->template->set_var('lang_icon',lang('icon')); 
     
    129132                        $this->template->set_var('lang_color',lang('Color')); 
    130133                        $this->template->set_var('lang_icon',lang('Icon')); 
     134                        $this->template->set_var('lang_Loading',lang("Loading")); 
     135                        $this->template->set_var('lang_Searching', lang("search groups"));                               
     136                        $this->template->set_var('lang_typemoreletters',lang("Type more %1 letters.","X"));                                                                                                      
     137                        $this->template->set_var('lang_Search_for', lang("Search Groups"));                                                                      
     138                        $this->template->set_var('lang_cat_all', lang("All")); 
     139                        $this->template->set_var('lang_permission', lang("Permission")); 
     140                        $this->template->set_var('lang_Loading',lang("Loading")); 
     141                        $this->template->set_var('lang_Searching', lang("Search Groups")); 
     142                        $this->template->set_var('lang_Owner', lang("Owner (User/Group)")); 
     143                        $this->template->set_var('lang_Add', lang("Add")); 
     144                        $this->template->set_var('lang_Remove', lang("Remove"));                         
     145                        $this->template->set_var('lang_Search_for', lang("Search Groups")); 
     146                        $this->template->set_var('lang_typemoreletters',lang("Type more %1 letters.","X"));                              
    131147                } 
    132148 
     
    148164                                $GLOBALS['phpgw']->redirect_link('/admin/index.php'); 
    149165                        } 
    150  
     166         
     167                         
    151168                        $this->template->set_file(array('cat_list_t' => 'listcats.tpl')); 
    152169                        $this->template->set_block('cat_list_t','cat_list','list'); 
     
    164181                        echo parse_navbar(); 
    165182                        $this->set_langs(); 
     183 
    166184                        $this->template->set_var('query',$this->query); 
     185                         
     186                        // if ExpressoMail 1.2 has been installed and enabled, show the plugin using AJAX.  
     187                        if($GLOBALS['phpgw_info']['server']['cal_expressoMail']) { 
     188                                $this->template_dir = 'calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'];                                                     
     189                                $module_name = 'expressoMail'.(str_replace("1.","1_",$GLOBALS['phpgw_info']['server']['cal_expressoMail'])); 
     190                                if($GLOBALS['phpgw_info']['user']['apps'][$module_name]){                                                                
     191                                        $ldap_manager = CreateObject('contactcenter.bo_ldap_manager'); 
     192                                        $_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user'];                                
     193                                        $_SESSION['phpgw_info']['expressomail']['user']['owner'] = $GLOBALS['phpgw_info']['user']['account_id']; 
     194                                        $_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server']; 
     195                                        $_SESSION['phpgw_info']['expressomail']['ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null; 
     196                                        // Carrega todos scripts necessarios                             
     197                                        $scripts =      "<script src='".$module_name."/js/connector.js' type='text/javascript'></script>". 
     198                                                                "<script type='text/javascript'>var DEFAULT_URL = '".$module_name."/controller.php?action=';</script> ".                                                                                         
     199                                                                "<script src='".$this->template_dir."/js/search.js' type='text/javascript'></script>"; 
     200                                        // Fim 
     201                                } 
     202                                $this->template->set_var('scripts',$scripts);                    
     203                        } 
     204                        $this->template->set_var('template_set',$this->template_dir); 
    167205 
    168206                        $link_data['menuaction'] = 'admin.uicategories.index'; 
     
    173211                                $start = 0; 
    174212                        } 
    175  
    176                         $cats = $this->bo->get_list(); 
     213                        list($idgroup,$namegroup) = explode('.', @$_POST['group']);                       
     214                        if($this-> query || $namegroup) 
     215                                $result_search = lang("result")." :: ".lang("about")." <b>'".($this-> query ? $this-> query : $namegroup)."'</b> :: "; 
     216                        else 
     217                                $this->template->set_var('type_search_'.($_POST['typesearch'] ? $_POST['typesearch'] : 'a').'_checked', "checked");                                              
     218                        $cats = $this->bo->get_list($idgroup); 
     219 
    177220                        if (!is_array($cats)) $cats = array(); 
    178221 
     
    182225                        $this->template->set_var('right',$right); 
    183226 
    184                         $this->template->set_var('lang_showing',$this->nextmatchs->show_hits($this->bo->cats->total_records,$this->start)); 
    185  
    186                         $this->template->set_var('sort_name',$this->nextmatchs->show_sort_order($this->sort,'cat_name',$this->order,'/index.php',lang('Name'),$link_data)); 
    187                         $this->template->set_var('sort_description',$this->nextmatchs->show_sort_order($this->sort,'cat_description',$this->order,'/index.php',lang('Description'),$link_data)); 
     227                        $this->template->set_var('lang_showing',$result_search.$this->nextmatchs->show_hits($this->bo->cats->total_records,$this->start));                       
     228 
     229                        $this->template->set_var('sort_name', !$_POST['typesearch'] ? $this->nextmatchs->show_sort_order($this->sort,'cat_name',$this->order,'/index.php',lang('Name'),$link_data) : lang('Name')); 
     230                        $this->template->set_var('sort_description', !$_POST['typesearch'] ? $this->nextmatchs->show_sort_order($this->sort,'cat_description',$this->order,'/index.php',lang('Description'),$link_data) : lang('Description')); 
    188231 
    189232                        foreach($cats as $cat) 
     
    268311                                } 
    269312                                else 
    270                                 { 
     313                                {                                        
    271314                                        $this->template->set_var('edit',''); 
    272315                                } 
     
    283326 
    284327                                $data = unserialize($cat['data']); 
    285                                 $icon = $data['icon']; 
     328                                $icon = $data['icon'];                           
     329                                $permission = ($cat['owner'] == '-1' ? lang("all"): $cat['owner']); 
     330                                $this->template->set_var('permission', $permission); 
    286331                                $dir_img = $GLOBALS['phpgw_info']['server']['webserver_url'] . SEP . 'phpgwapi' . SEP . 'images' . SEP; 
    287                                 $this->template->set_var('icon', "<img src='". $dir_img . $icon  ."'>"); 
     332                                $this->template->set_var('icon', !$icon ? lang("None") : "<img src='". $dir_img . $icon  ."'>"); 
    288333 
    289334                                $this->template->fp('list','cat_list',True); 
     
    303348                        $cat_parent                     = (int)$_POST['cat_parent']; 
    304349                        $cat_name                       = $_POST['cat_name']; 
    305                         $cat_description        = $_POST['cat_description']; 
     350                        $cat_description                = $_POST['cat_description']; 
    306351                        $cat_data                       = $_POST['cat_data']; 
    307352                        $old_parent                     = (int)$_POST['old_parent']; 
     353                        $cat_group                      = $_POST['idgroup']; 
    308354                         
    309355                        if ($new_parent) 
     
    328374                        } 
    329375 
     376                         
    330377                        if ($_POST['save']) 
    331378                        { 
     
    337384                                        'descr'                 => $cat_description, 
    338385                                        'name'                  => $cat_name, 
     386                                        'group'                 => $cat_group, 
    339387                                        'access'                => 'public', 
    340388                                        'data'                  => $data 
     
    360408 
    361409                        $this->set_langs(); 
     410                // if ExpressoMail 1.2 has been installed and enabled, show the plugin using AJAX.  
     411                if($GLOBALS['phpgw_info']['server']['cal_expressoMail']) { 
     412                        $this->template_dir = 'calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'];                                                     
     413                        $module_name = 'expressoMail'.(str_replace("1.","1_",$GLOBALS['phpgw_info']['server']['cal_expressoMail'])); 
     414                        if($GLOBALS['phpgw_info']['user']['apps'][$module_name]){                                                                
     415                                $ldap_manager = CreateObject('contactcenter.bo_ldap_manager'); 
     416                                $_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user'];                                
     417                                $_SESSION['phpgw_info']['expressomail']['user']['owner'] = $GLOBALS['phpgw_info']['user']['account_id']; 
     418                                $_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server']; 
     419                                $_SESSION['phpgw_info']['expressomail']['ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null; 
     420                                // Carrega todos scripts necessarios                             
     421                                $scripts =      "<script src='".$module_name."/js/connector.js' type='text/javascript'></script>". 
     422                                                        "<script type='text/javascript'>var DEFAULT_URL = '".$module_name."/controller.php?action=';</script> ".                                                                                         
     423                                                        "<script src='".$this->template_dir."/js/search.js' type='text/javascript'></script>";                           
     424                                // Fim                                                           
     425                                $this->template->set_var('scripts',$scripts); 
     426                                $this->template->set_var('template_set', $this->template_dir); 
     427                        } 
     428                } 
     429                // FIM if. 
    362430 
    363431                        $this->template->set_file(array('form' => 'category_form.tpl')); 
     
    368436                                $cat['data'] = unserialize($cat['data']); 
    369437                        } 
     438                         
    370439                        else 
    371440                        { 
     
    373442                                $cat['parent'] = $_GET['cat_parent']; 
    374443                        } 
     444 
    375445                        // update the old calendar color format, color was added to the description 
    376446                        if (preg_match('/(#[0-9a-fA-F]{6})\n?$/',$cat['description'],$matches)) 
     
    381451 
    382452                        $hidden_vars = '<input type="hidden" name="cat_id" value="' . $this->cat_id . '">' . "\n" . 
    383                                 '<input type="hidden" name="old_parent" value="' . $cat['parent'] . '">' . "\n"; 
     453                                '<input type="hidden" name="old_parent" value="' . $cat['parent'] . '">' . "\n". 
     454                                '<input type="hidden" id="idgroup" name="idgroup" value="' . $cat['id_group'] . '">' . "\n"; 
    384455 
    385456                        $link_data['menuaction']        = 'admin.uicategories.edit'; 
     
    401472                        $this->template->set_var('cat_description',$GLOBALS['phpgw']->strip_html($cat['description'])); 
    402473                        $this->template->set_var('category_list',$this->bo->cats->formatted_list(array('selected' => $cat['parent'],'self' => $this->cat_id))); 
    403  
     474                        $this->template->set_var('category_namegroup',$GLOBALS['phpgw']->strip_html($cat['name_group'])); 
     475                        $this->template->set_var('bt_rem_id_group_visibility',$cat['name_group'] ? "visible" : "hidden"); 
    404476                        if (!is_object($GLOBALS['phpgw']->html)) 
    405477                        { 
     
    407479                        } 
    408480                        $this->template->set_var('color',$GLOBALS['phpgw']->html->inputColor('cat_data[color]',$cat['data']['color'],lang('Click to select a color'))); 
    409  
    410                         $options = '<option value=""'.(!$cat['data']['icon'] ? ' selected="1"':'').'>'.lang('none')."</options>\n"; 
     481                        $options = ''; 
     482                        //$options = '<option value="aanone.gif"'.(!$cat['data']['icon'] ? ' selected="1"':'').'>'.lang('none')."</options>\n"; 
    411483                        foreach ($this->icons as $icon) 
    412484                        { 
     485                                if(!$cat['data']['icon']){ 
     486                                        $cat['data']['icon'] = "aanone.gif"; 
     487                                } 
    413488                                $options .= '<option value="'.$icon.'"'.($icon == $cat['data']['icon'] ? ' selected="1"':'').'>'. 
    414                                         ucfirst(preg_replace('/\\.(png|gif|jpe?g)$/i','',$icon))."</option>\n"; 
     489                                        ucfirst(preg_replace('/\\.(png|gif|jpe?g)$/i','',$icon == 'aanone.gif' ? lang('none') : $icon))."</option>\n"; 
    415490                        } 
    416491                        $this->template->set_var('select_icon', '<select name="cat_data[icon]" onchange="document.images[\'icon\'].src=\''.$this->img_url.'\' + this.value;">'.$options."</select>\n"); 
    417                         $this->template->set_var('icon','<img id="icon" src="'. $this->img_url.$cat['data']['icon'] .'">'); 
     492                        $this->template->set_var('icon',  '<img id="icon" src="'. $this->img_url.$cat['data']['icon'] .'">'); 
    418493 
    419494                        $already_done = array('icon','color'); 
  • trunk/admin/templates/default/category_form.tpl

    r2 r577  
    1  
    21<!-- BEGIN form --> 
     2<input type="hidden" id="txt_loading" value="{lang_Loading}"> 
     3<input type="hidden" id="txt_searching" value="{lang_Searching}"> 
     4<input type="hidden" id="txt_multipleGroup" value="{lang_Groups}"> 
     5<input type="hidden" id="txt_typemoreletters" value="{lang_typemoreletters}"> 
    36<br> 
    47<center> 
     
    69<table border="0" width="80%" cellspacing="2" cellpadding="2">  
    710<form name="edit_cat" action="{actionurl}" method="POST"> 
     11{hidden_vars} 
    812        <tr class="th"> 
    913                <td colspan="2">{lang_parent}</td> 
     
    1822                <td colspan="2"><textarea name="cat_description" rows="4" cols="50" wrap="virtual">{cat_description}</textarea></td> 
    1923        </tr> 
     24        <tr class="row_on"> 
     25                <td colspan="2">{lang_Search_for}</td> 
     26            <td valign="center" colspan="2"><input type="text" id="search_group" size=30 autocomplete="off" onkeyup="javascript:search_object(this,'cal_span_searching','groupsfound','g')"/> 
     27            &nbsp;<font color="red"><span id="cal_span_searching">&nbsp;</span></font><br/> 
     28            <select id="groupsfound" style="width: 300px" size="4"></select> 
     29            <button type="button" onClick="javascript:add('groupsfound','group');"><img src="{template_set}/images/add.png" style="vertical-align: bottom;"/></button></td> 
     30        </tr> 
     31        <tr class="row_off"> 
     32                <td colspan="2">{lang_Owner}</td> 
     33                <td valign="center" colspan="2"><label id="namegroup" style="font-weight:bold">{category_namegroup}</label> 
     34                <button valign="top" style="visibility:{bt_rem_id_group_visibility}" id="bt_rem_idgroup" type="button" onClick="javascript:remove('group');"><img src="{template_set}/images/delete.png" style="vertical-align: middle;" /></button></td> 
     35        </tr> 
     36 
    2037        <tr class="row_on"> 
    2138                <td colspan="2">{lang_color}</td> 
     
    3249        </tr> 
    3350<!-- END data_row --> 
    34  
    3551        <tr valign="bottom" height="50"> 
    36                 <td> 
    37                         {hidden_vars} 
    38                         <input type="submit" name="save" value="{lang_save}"></form></td> 
    39                 <td> 
    40                         <form method="POST" action="{cancel_url}"> 
    41                         <input type="submit" name="cancel" value="{lang_cancel}"></form></td> 
     52                <td><input type="submit" name="save" value="{lang_save}"></td> 
     53                <td><form method="POST" action="{cancel_url}"><input type="submit" name="cancel" value="{lang_cancel}"></form></td> 
    4254                <td align="right">{delete}</td> 
    4355        </tr> 
    4456</table> 
     57</form> 
    4558</center> 
    4659 
    4760<!-- END form --> 
     61<script language="JavaScript" type="text/javascript"> 
     62function remove(to){ 
     63        document.getElementById("name"+to).innerHTML = ''; 
     64        document.getElementById("id"+to).value = '-1'; 
     65        show_button("id"+to); 
     66}  
     67function show_button(id){ 
     68        document.getElementById("bt_rem_"+id).style.visibility =  
     69                (document.getElementById(id).value != '-1'  ? 'visible' : 'hidden'); 
     70} 
     71function add(from, to){ 
     72        var sel_from = document.getElementById(from); 
     73        for (i = 0 ; i < sel_from.length; i++){ 
     74                if (sel_from[i].selected) { 
     75                        var name = document.getElementById("name"+to); 
     76                        var id = document.getElementById("id"+to); 
     77                        name.innerHTML = sel_from.options[i].text; 
     78                        id.value  = sel_from[i].value; 
     79                        show_button("id"+to); 
     80                        break; 
     81                } 
     82        } 
     83} 
     84</script> 
     85{scripts} 
  • trunk/admin/templates/default/listcats.tpl

    r2 r577  
    1  
    21        <center> 
    3                 <table border="0" cellspacing="2" cellpadding="2"> 
     2                <table border="0" cellspacing="1" cellpadding="2"> 
     3<!-- BEGIN search --> 
    44                        <tr> 
    5                                 <td colspan="5" align="left"> 
     5                                <td colspan="5" align="left" valign="top"><form name="form1" method="post" onSubmit="return on_submit()" action="{action_nurl}">&nbsp;                                   
     6                                        <input type="radio" onclick="javascript:changeElement();" name="typesearch" value="g" {type_search_g_checked}/>{lang_group_name}&nbsp; 
     7                                        <input type="radio" onclick="javascript:changeElement();" name="typesearch" value="c" {type_search_c_checked}/>{lang_cat_name}&nbsp; 
     8                                        <input type="radio" onclick="javascript:changeElement();" name="typesearch" value="a" {type_search_a_checked}/>{lang_cat_all}<br> 
     9                                        <div id="filterByGroup" style="display:none"><br> 
     10                                        {lang_Search_for}&nbsp;<input type="text" id="search_group" size=30 autocomplete="off" onkeyup="javascript:search_object(this,'cal_span_searching','groupsfound','g')"/><br> 
     11                                    &nbsp;<font color="red"><span id="cal_span_searching">&nbsp;</span></font><br/> 
     12                                    <input type="hidden" id="group" name="group"/> 
     13                                    <select id="groupsfound" style="width: 300px" size="4"></select>&nbsp;<input type="submit" value="{lang_search}"> 
     14                                        </div> 
     15                                        <div id="filterByName" style="display:none"><br> 
     16                                        <input id="query" type="text" name="query" value="">&nbsp;<input type="submit" value="{lang_search}"> 
     17                                        </form> 
     18                                </td> 
     19                        </tr> 
     20<!-- END search --> 
     21                 
     22                        <tr> 
     23                                <td colspan="6" align="left"> 
    624                                        <table border="0" width="100%"> 
    725                                                <tr> 
     
    1331                                </td> 
    1432                        </tr> 
    15 <!-- BEGIN search --> 
    16                         <tr> 
    17                                 <td colspan="5" align="right"> 
    18                                         <form method="post" action="{action_nurl}"> 
    19                                         <input type="text" name="query">&nbsp;<input type="submit" name="search" value="{lang_search}"></form></td> 
    20                         </tr> 
    21 <!-- END search --> 
    2233                        <tr class="th"> 
    2334                                <td width="20%">{sort_name}</td> 
    2435                                <td width="32%">{sort_description}</td> 
    25                                 <td>{lang_icon}</td> 
     36                                <td width="1%" align="center">{lang_icon}</td> 
     37                                <td width="8%" align="center">{lang_permission}</td> 
    2638                                <td width="8%" align="center">{lang_sub}</td> 
    2739                                <td width="8%" align="center">{lang_edit}</td> 
     
    3446                                <td>{name}</td> 
    3547                                <td>{descr}</td> 
    36                                 <td>{icon}</td> 
     48                                <td align="center">{icon}</td> 
     49                                <td align="center">{permission}</td> 
    3750                                <td align="center">{add_sub}</a></td> 
    3851                                <td align="center">{edit}</a></td> 
     
    5366                </table> 
    5467        </center> 
     68{scripts} 
     69<input type="hidden" id="txt_loading" value="{lang_Loading}"> 
     70<input type="hidden" id="txt_searching" value="{lang_Searching}"> 
     71<input type="hidden" id="txt_typemoreletters" value="{lang_typemoreletters}"> 
     72<script language="JavaScript" type="text/javascript"> 
     73        function on_submit(){ 
     74                var select_group = document.getElementById("groupsfound"); 
     75                if(document.getElementById("query").value == "" && select_group.value == ""){ 
     76                        return false; 
     77                } 
     78                else if(select_group.options.length == 0) 
     79                        return true;                     
     80                for(j in select_group.options){ 
     81                        if(select_group.selectedIndex == j) 
     82                                document.getElementById("group").value =  select_group.options[j].value+"."+select_group.options[j].text; 
     83                } 
     84                return true;             
     85        } 
     86        function changeElement(){ 
     87                var types =     document.form1.typesearch; 
     88                for(j in types){ 
     89                        if(types[j].checked){ 
     90                                if(types[j].value == 'a'){                               
     91                                        location.href = location.href.toString(); 
     92                                } 
     93                                document.getElementById('filterByGroup').style.display  = (types[j].value == 'g' ? '' : 'none'); 
     94                                document.getElementById('filterByName').style.display   = (types[j].value == 'g' || types[j].value == 'a' ? 'none' : ''); 
     95                        } 
     96                } 
     97        } 
     98</script> 
Note: See TracChangeset for help on using the changeset viewer.