Changeset 1280


Ignore:
Timestamp:
08/05/09 18:20:55 (15 years ago)
Author:
eduardoalex
Message:

Ticket #453 - Edição de grupos compartilhados.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/contactcenter/inc/class.bo_group.inc.php

    r702 r1280  
    3636                } 
    3737                 
    38                 function get_all_contacts($field = false){ 
     38                function get_all_contacts($field = false,$owner=null){ 
    3939                 
    40                         $result = $this-> so -> selectAllContacts($field); 
     40                        $result = $this-> so -> selectAllContacts($field,$owner); 
    4141                        return $result; 
    4242                } 
  • trunk/contactcenter/inc/class.so_group.inc.php

    r752 r1280  
    107107                } 
    108108                 
    109                  
    110                 function selectAllContacts( $field = false ) 
    111                 { 
    112                                                  
    113                         $query = 'select C.id_connection, A.id_contact, A.names_ordered, C.connection_value , B.id_typeof_contact_connection from phpgw_cc_contact A,'. 
    114                         'phpgw_cc_contact_conns B, phpgw_cc_connections C where '. 
    115                         'A.id_contact = B.id_contact and B.id_connection = C.id_connection and '. 
    116                         'A.id_owner ='.$this->owner.' and C.connection_is_default = true '; 
     109                //Owner = null means the owner setted on constructor. 
     110                function selectAllContacts( $field = false ,$shared_from=null) 
     111                { 
     112                        if($shared_from==null) {                 
     113                                $query = 'select C.id_connection, A.id_contact, A.names_ordered, C.connection_value , B.id_typeof_contact_connection from phpgw_cc_contact A,'. 
     114                                'phpgw_cc_contact_conns B, phpgw_cc_connections C where '. 
     115                                'A.id_contact = B.id_contact and B.id_connection = C.id_connection and '. 
     116                                'A.id_owner ='.$this->owner.' and C.connection_is_default = true '; 
     117                        } 
     118                        else { 
     119                                $sub_query = 'select A.id_related from phpgw_cc_contact_rels A,phpgw_acl B 
     120                                                          where B.acl_location!=\'run\' and A.id_contact = B.acl_location::bigint and A.id_related = B.acl_account and  
     121                                                          B.acl_appname = \'contactcenter\' and B.acl_rights & 1 <> 0  
     122                                                          and A.id_typeof_contact_relation=1 and A.id_contact = '.$shared_from.' and A.id_related='.$this->owner; 
     123                                 
     124                                $query = 'select C.id_connection, A.id_contact, A.names_ordered, C.connection_value , B.id_typeof_contact_connection from phpgw_cc_contact A,'. 
     125                                'phpgw_cc_contact_conns B, phpgw_cc_connections C where '. 
     126                                'A.id_contact = B.id_contact and B.id_connection = C.id_connection and '. 
     127                                'A.id_owner in ('.$shared_from.',('.$sub_query.'))'. 
     128                                ' and C.connection_is_default = true '; 
     129                        } 
    117130 
    118131                        if ( $field == 'only_email' ) 
     
    256269                        'A.id_contact = B.id_contact and B.id_connection = C.id_connection '. 
    257270                        'and B.id_typeof_contact_connection = 1 and '. 
    258                         'A.id_owner ='.$this->owner.' and D.id_connection = C.id_connection and D.id_group = '.$id_group. 
     271                        //'A.id_owner ='.$this->owner.' and D.id_connection = C.id_connection and D.id_group = '.$id_group. 
     272                        ' D.id_connection = C.id_connection and D.id_group = '.$id_group. //If I have the group ID, why ask about owner? 
    259273                        ' order by A.names_ordered'; 
    260274                                                 
  • trunk/contactcenter/inc/class.ui_data.inc.php

    r962 r1280  
    312312                                 
    313313                                case 'get_group': 
    314                                         return $this->get_group_data($_GET['id']); 
     314                                        return $this->get_group_data($_GET['id'],isset($_GET['shared_from'])?$_GET['shared_from']:null); 
    315315                                         
    316316                                case 'get_contact_full_add_const': 
     
    11601160                                                        $final[3][$i][5] = lang('Shared').": ".$owner_names[$owners[$i]]['cn']; 
    11611161                                                        $final[3][$i][6] = $owner_names[$owners[$i]]['uid']; 
     1162                                                        $final[3][$i][7] = $owners[$i]; //uidNumber 
    11621163                                                }                                                
    11631164                                                $i++;                                                    
     
    13131314                 
    13141315                */               
    1315                 function get_group_data($id) 
     1316                function get_group_data($id,$shared_from=null) 
    13161317                { 
    13171318                        $this->bo->catalog = CreateObject('contactcenter.bo_group_manager'); 
     
    13261327                        $boGroup = CreateObject('contactcenter.bo_group'); 
    13271328                                                 
    1328                         $all_contacts = $boGroup->get_all_contacts('only_email'); 
     1329                        $all_contacts = $boGroup->get_all_contacts('only_email',$shared_from); 
    13291330                         
    13301331                        $contact_options = ""; 
  • trunk/contactcenter/js/cc.js

    r880 r1280  
    195195} 
    196196 
    197 function editSharedGroup(id){ 
    198         populateEditGroup(id, 'shared');         
     197function editSharedGroup(id,shared){ 
     198        populateEditSharedGroup(id, shared);     
    199199} 
    200200 
     
    312312function populateEditGroup (id) 
    313313{ 
     314        populateEditSharedGroup(id,false); 
     315} 
     316 
     317function populateEditSharedGroup(id,shared) { 
    314318        var handler = function(responseText) 
    315319        {                        
     
    345349         
    346350        ccAddGroup.clear(true);                          
    347         Connector.newRequest('populateEditGroup', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_group&id='+id, 'GET', handler); 
     351        if(!shared) 
     352                Connector.newRequest('populateEditGroup', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_group&id='+id, 'GET', handler); 
     353        else 
     354                Connector.newRequest('populateEditGroup', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_group&id='+id+'&shared_from='+shared, 'GET', handler); 
    348355} 
    349356 
     
    20842091         
    20852092                                if (type == "shared_groups") { 
    2086                                         /* Edição de grupos compartilhados está com problema. Desabilitado temporariamente. 
     2093                                         
    20872094                                        if (data[3][pos][4] & 4) 
    2088                                                 eval("document.getElementById(id + ':cc_card_edit').onclick = function(){editSharedGroup(Element('"+id+"' + ':cc_id').value);};"); 
    2089                                         else 
    2090                                         */  
    2091                                         document.getElementById(id + ':cc_card_edit').onclick = function(){     alert(Element('cc_msg_unavailable').value); }; 
    2092                                          
     2095                                                eval("document.getElementById(id + ':cc_card_edit').onclick = function(){editSharedGroup(Element('"+id+"' + ':cc_id').value,"+data[3][pos][7]+");};"); 
     2096                                        else  
     2097                                                document.getElementById(id + ':cc_card_edit').onclick = function(){     alert(Element('cc_msg_not_allowed').value); }; 
     2098                                                                                 
    20932099                                        if (data[3][pos][4] & 8)  
    20942100                                                eval("document.getElementById(id + ':cc_card_remove').onclick = function(){removeEntry(Element('" + id + "' + ':cc_id').value,'groups');};"); 
  • trunk/phpgwapi/inc/class.acl.inc.php

    r2 r1280  
    194194                        return $this->data; 
    195195                } 
    196  
     196                 
     197                function persist_shared_groups($location) 
     198                { 
     199                        $this->db->persist_shared_groups($location,$this->account_id); 
     200                } 
     201                 
    197202                /*! 
    198203                @function delete 
  • trunk/phpgwapi/inc/class.db.inc.php

    r2 r1280  
    11341134                } 
    11351135 
     1136                function persist_shared_groups($location,$account_id) 
     1137                { 
     1138 
     1139                        $sql = "delete from phpgw_cc_contact_grps where oid in ( 
     1140                                select A.oid from phpgw_cc_contact_grps A inner join phpgw_cc_groups B on A.id_group=B.id_group  
     1141                                inner join phpgw_cc_contact_conns C on A.id_connection=C.id_connection  
     1142                                inner join phpgw_cc_contact D on C.id_contact=D.id_contact 
     1143                                where B.owner=$location and D.id_owner=$account_id );"; 
     1144 
     1145                        return $this->query($sql); 
     1146                } 
     1147 
    11361148                /** 
    11371149                * Updates the data of one or more rows in a table, all data is quoted according to it's type 
  • trunk/preferences/inc/class.uiaclprefs2.inc.php

    r496 r1280  
    101101                                $to_remove = unserialize(urldecode($processed)); 
    102102 
    103                                 for($i=0;$i<count($to_remove);$i++)                              
    104                                         $this->acl->delete($GLOBALS['phpgw_info']['flags']['currentapp'],$to_remove[$i]); 
    105                                  
     103                                /* User records */ 
     104                                $user_variable = $_POST['u_'.$GLOBALS['phpgw_info']['flags']['currentapp']]; 
    106105                                /* Group records */ 
    107106                                $group_variable = $_POST['g_'.$GLOBALS['phpgw_info']['flags']['currentapp']]; 
     107                                $keys_to_keep = array(); 
     108                                if(!empty($user_variable)) { 
     109                                        foreach($user_variable as $key_user=>$value) { 
     110                                                $temp = explode("_",$key_user); 
     111                                                $keys_to_keep[(int)$temp[0]] = 1; 
     112                                        } 
     113                                } 
     114                                 
     115                                for($i=0;$i<count($to_remove);$i++) { 
     116                                         
     117                                        if(!array_key_exists((int)$to_remove[$i],$keys_to_keep)) { 
     118                                                $this->acl->persist_shared_groups($to_remove[$i]); 
     119                                        }                
     120                                        $this->acl->delete($GLOBALS['phpgw_info']['flags']['currentapp'],$to_remove[$i]); 
     121                                } 
     122                                 
     123                                /* Group records */ 
     124                                //$group_variable = $_POST['g_'.$GLOBALS['phpgw_info']['flags']['currentapp']]; 
    108125 
    109126                                if (!$group_variable)                            
     
    120137                                        if($is_group) 
    121138                                                $rights &= ~PHPGW_ACL_PRIVATE; 
     139                                        if(array_key_exists($user_id,$keys_to_keep)) 
     140                                                if(($rights & 1) == 0) { 
     141                                                        $this->acl->persist_shared_groups($user_id); 
     142                                                } 
    122143                                        $this->acl->add($GLOBALS['phpgw_info']['flags']['currentapp'],$group_id,$rights); 
    123144                                } 
    124145 
    125146                                /* User records */ 
    126                                 $user_variable = $_POST['u_'.$GLOBALS['phpgw_info']['flags']['currentapp']]; 
     147                                //$user_variable = $_POST['u_'.$GLOBALS['phpgw_info']['flags']['currentapp']]; 
    127148 
    128149                                if (!$user_variable)                             
Note: See TracChangeset for help on using the changeset viewer.