Ticket #628: addsharedcontacts_expresso20_backport.patch

File addsharedcontacts_expresso20_backport.patch, 48.0 KB (added by niltonneto, 13 years ago)

Backporting da implementação para versão 2.0

  • phpgwapi/inc/class.acl.inc.php

     
    632632 
    633633                        return $grants; 
    634634                } 
    635                  
     635 
     636                function get_rights_and_owners($user,$appname = False)  
     637                {  
     638                          
     639                        if (!$appname) $appname = $GLOBALS['phpgw_info']['flags']['currentapp'];  
     640  
     641                        if (!count($this->data) && $GLOBALS['phpgw_info']['server']['acl_default'] != 'deny')  
     642                        {  
     643                                return True;  
     644                        }  
     645                          
     646                        $db2 = clone($this->db);  
     647                        $db2->select($this->table_name,array('acl_account','acl_rights'),array(  
     648                                'acl_appname'  => $appname,  
     649                                'acl_location' => $user,  
     650                        ),__LINE__,__FILE__);  
     651                        $return = array();  
     652                        while ($db2->next_record())  
     653                        {  
     654                                $return[] = array(  
     655                                        'acl_rights' => $db2->f('acl_rights'),  
     656                                        'acl_account' =>  $db2->f('acl_account')  
     657                                        );                                
     658                        }  
     659                        return $return;  
     660                }  
     661              
    636662                /** 
    637663                 * Deletes all ACL entries for an account (user or group) 
    638664                 * 
  • contactcenter/inc/class.bo_shared_people_manager.inc.php

     
    1616                        'sex'           => true, 
    1717                        'pgp_key'       => true, 
    1818                        'notes'         => true, 
     19                        'corporate_name'=> true,  
     20                        'job_title'     => true,  
     21                        'department'    => true,  
     22                        'web_page'      => true,  
    1923                         
    2024                        /* Array fields */ 
    2125                        'companies'     => true, 
     
    930934 
    931935                        @return integer $id The Contact ID 
    932936                */       
    933                 function add_single_entry ( $data ) 
     937                function add_single_entry ( $data, $owner ) 
    934938                { 
    935939                        $permissions = $this->security->get_permissions(); 
    936940                         
     
    953957                                $altered = true; 
    954958                                switch($field) 
    955959                                { 
     960                                        case 'corporate_name':  
     961                                        case 'job_title':  
     962                                        case 'department':  
     963                                        case 'web_page': 
    956964                                        case 'photo': 
    957965                                        case 'alias': 
    958966                                        case 'id_prefix': 
     
    10531061                         
    10541062                        if ($altered) 
    10551063                        { 
    1056                                 $contact->set_field('id_owner',$GLOBALS['phpgw_info']['user']['account_id']); 
     1064                                if ($owner)  
     1065                                {         
     1066                                        $contact->set_field('id_owner',$owner);  
     1067                                }else  
     1068                                        $contact->set_field('id_owner',$GLOBALS['phpgw_info']['user']['account_id']);  
    10571069                                return $contact->commit(); 
    10581070                        } 
    10591071                         
     
    12991311                                $altered = true; 
    13001312                                switch($field) 
    13011313                                { 
     1314                                        case 'corporate_name':  
     1315                                        case 'job_title':  
     1316                                        case 'department':  
     1317                                        case 'web_page':  
    13021318                                        case 'photo': 
    13031319                                        case 'alias': 
    13041320                                        case 'id_prefix': 
  • contactcenter/inc/class.ui_api.inc.php

     
    4747                        $template->set_var('cc_msg_err_contacting_server',lang('Couldn\'t contact server or server response is invalid. Contact Admin.')); 
    4848                        $template->set_var('cc_msg_err_timeout',lang('Operation Timed Out.')); 
    4949                        $template->set_var('cc_msg_err_serialize_data_unknown',lang('Data to be serialized is of unknown type!')); 
     50                        $template->set_var('cc_msg_err_shared',lang('No shared catalog that has permission to add.')); 
    5051                        /* End Messages */ 
    5152 
    5253                        if ($preferences['displayConnector']) 
     
    233234                        $template->set_var('cc_contact_conns',lang('Connections')); 
    234235                        $template->set_var('emails_telephones', lang("E-Mails and Telephones")); 
    235236                        $template->set_var('cc_default', lang("Default")); 
     237  
     238                        $template->set_var('cc_contact_shared',lang('Add to catalog'));  
     239                        $template->set_var('cc_contact_shared_types',lang('Choose in wich catalog you would like to add...'));  
    236240 
    237241                        /* End Contact */ 
    238242                         
  • contactcenter/inc/class.ui_data.inc.php

     
    122122                        $GLOBALS['phpgw']->template->set_var('cc_personal',lang('Personal')); 
    123123                         
    124124                        $GLOBALS['phpgw']->template->set_var('cc_full_add_button',lang('Full Add')); 
     125                        $GLOBALS['phpgw']->template->set_var('cc_full_add_button_sh',lang('Full Add Shared')); 
    125126                        $GLOBALS['phpgw']->template->set_var('cc_reset',lang('Reset')); 
    126127                         
    127128                        $GLOBALS['phpgw']->template->set_var('cc_personal_data',lang('Personal Data')); 
     
    174175                        $GLOBALS['phpgw']->template->set_var('cc_del_relation',lang('Remove Selected Relations'));                       
    175176                        $GLOBALS['phpgw']->template->set_var('cc_msg_group',lang('Group')); 
    176177                        $GLOBALS['phpgw']->template->set_var('cc_msg_contact_full',lang('Contact [Full]')); 
     178                        $GLOBALS['phpgw']->template->set_var('cc_msg_contact_sh',lang('Contact [Shared]')); 
    177179                        $GLOBALS['phpgw']->template->set_var('cc_msg_contact_qa',lang('Contact [Quick Add]')); 
    178180                        $GLOBALS['phpgw']->template->set_var('cc_contact_title',lang('Contact Center').' - '.lang('Contacts')); 
    179181                        $GLOBALS['phpgw']->template->set_var('cc_window_views_title',lang('Contact Center').' - '.lang('Views')); 
     
    319321                                case 'post_full_add': 
    320322                                        return $this->post_full_add(); 
    321323 
     324                                case 'post_full_add_shared' :  
     325                                        return $this->post_full_add_shared();  
     326  
    322327                                case 'post_photo': 
    323328                                        return $this->post_photo((int) $_GET['id'] ? (int) $_GET['id'] : '_new_'); 
    324329 
     
    379384                                case 'export_contacts': 
    380385                                        return $this->export_contacts($_POST['typeExport']); 
    381386 
     387                                case 'get_qtds_compartilhado':  
     388                                        return $this->get_qtds_compartilhado();  
     389                                case 'get_list_owners_perms_add':  
     390                                        echo $this->get_list_owners_perms_add();  
     391                                        return;  
     392 
    382393                        } 
    383394                } 
    384395 
     
    556567                                'status' => 'fatal', 
    557568                                'msg'    => lang('Couldn\'t get the actual catalog.'), 
    558569                        ); 
     570                }  
     571  
     572                function get_qtds_compartilhado() {  
     573                        $so_contact = CreateObject('contactcenter.so_contact',  $GLOBALS['phpgw_info']['user']['account_id']);  
     574            $relacionados = $so_contact->get_relations();  
     575  
     576                        $perms_relacao = array();  
     577  
     578                foreach($relacionados as $uid_relacionado => $tipo_relacionamento) {  
     579                                $aclTemp = CreateObject("phpgwapi.acl",$uid_relacionado);  
     580                $aclTemp->read();  
     581                $perms_relacao[$uid_relacionado] = $aclTemp->get_specific_rights($GLOBALS['phpgw_info']['user']['account_id'],'contactcenter'); //Preciso verificar as permissõque o contato relacionado deu para o atual  
     582                        }  
     583  
     584                        $validos = array();  
     585                        $count = 0;  
     586                        foreach($perms_relacao as $uid_relacionado => $val){  
     587                                if ($perms_relacao[$uid_relacionado]&2)  
     588                                {  
     589                                        $validos[$uid_relacionado] = $perms_relacao[$uid_relacionado];  
     590                                        $count++;  
     591                                }  
     592                        }  
     593                        echo serialize(array(0=>$count));  
    559594                } 
    560595                 
    561596                /*! 
     
    601636                                                                        'value' => $letter !== 'all' ? $letter.'%' : '%' 
    602637                                                                )                                                                
    603638                                                        ); 
    604                                                         if($this->page_info['actual_catalog']['class'] == 'bo_people_catalog'){                                                          
     639  
     640                                                        //Tratamento de permissãde escrita no compartilhamento de catalogo  
     641                                                        $so_contact = CreateObject('contactcenter.so_contact',  $GLOBALS['phpgw_info']['user']['account_id']);  
     642                                                        $relacionados = $so_contact->get_relations();  
     643                                                          
     644                                                        $perms_relacao = array();                                 
     645  
     646                                                        foreach($relacionados as $uid_relacionado => $tipo_relacionamento) {  
     647                                                                $aclTemp = CreateObject("phpgwapi.acl",$uid_relacionado);  
     648                                                                $aclTemp->read();  
     649                                                                $perms_relacao[$uid_relacionado] = $aclTemp->get_specific_rights($GLOBALS['phpgw_info']['user']['account_id'],'contactcenter'); //Preciso verificar as permissõque o contato relacionado deu para o atual  
     650                                                        }  
     651  
     652                                                        $validos = array();  
     653                                                        $count = 0;  
     654                                                        foreach($perms_relacao as $uid_relacionado => $val){  
     655                                                                if ($perms_relacao[$uid_relacionado]&2)  
     656                                                                {  
     657                                                                        $validos[$uid_relacionado] = $perms_relacao[$uid_relacionado];  
     658                                                                        $count++;  
     659                                                                }  
     660                                                        }  
     661                                                        $prop_names = array();  
     662                                                        if($validos) {  
     663                                                                $filtro = "(|";  
     664                                                                foreach($validos as $i => $prop) {  
     665                                                                        $filtro .= "(uidNumber=".$i.")";  
     666                                                                }  
     667                                                                $filtro .= ")";  
     668  
     669                                                                if(!$this->bo->catalog->src_info) {  
     670                                                                        $ldaps = CreateObject('contactcenter.bo_ldap_manager');  
     671                                                                        $this->bo->catalog->src_info = $ldaps->srcs[1];  
     672                                                                }  
     673                                                                $s = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], false);  
     674                                                                $n=$this->bo->catalog->src_info['dn'];  
     675                                                                $apenasThese = array("cn","uidnumber","uid");  
     676                                                                $r = ldap_search($s,$n, $filtro,$apenasThese);                                          
     677                                                                $infos = ldap_get_entries($s, $r);  
     678                                                                ldap_close($s);                                                                         
     679                                                                for($z = 0; $z < $infos['count']; $z++) {  
     680                                                                        $prop_names[$infos[$z]['uidnumber'][0]] = array("cn" => $infos[$z]['cn'][0], "uid" => $infos[$z]['uid'][0]);  
     681                                                                }  
     682                                                        }  
     683                                                        //--------------------------------------------------------------------------------  
     684                                                        if($this->page_info['actual_catalog']['class'] == 'bo_people_catalog')  
     685                                                        {  
    605686                                                                $find_restric[0][1] = array( 
    606687                                                                                'field' => 'contact.id_owner', 
    607688                                                                                'type'  => '=', 
     
    12881369                                } 
    12891370                                $lnk_compose = "location.href=('../expressoMail1_2/index.php?to="; 
    12901371                                $final[5] = '<span class="link" onclick="'.$lnk_compose; 
     1372                                $final[6] = $prop_names;  
     1373                                $final[7] = $validos;  
     1374                                $final[8] = $this->page_info['actual_catalog']['class'];  
     1375                                $final[9] = $count;  
    12911376 
    1292  
    12931377                                $this->page_info['actual_letter'] = $letter; 
    12941378                                $this->page_info['actual_page'] = $page; 
    12951379                                 
     
    13071391                        $final[1] = $this -> typeContact; 
    13081392                        echo serialize($final); 
    13091393                } 
     1394 
     1395                function get_list_owners_perms_add(){  
     1396                        $acl = CreateObject('phpgwapi.acl');  
     1397                        $find_result = $acl->get_rights_and_owners($GLOBALS['phpgw_info']['user']['account_id'],'contactcenter');  
     1398                        if($find_result){  
     1399                                $owner_names = array();  
     1400                                $filter = "(|";  
     1401                                foreach($find_result as $owner) {  
     1402                                        if(($owner['acl_rights'] & PHPGW_ACL_ADD) == PHPGW_ACL_ADD){  
     1403                                                $filter .= "(uidNumber=".$owner['acl_account'].")";  
     1404                                        }  
     1405                                }  
     1406                                if(!$this->bo->catalog->src_info) {  
     1407                                        $ldap = CreateObject('contactcenter.bo_ldap_manager');  
     1408                                        $this->bo->catalog->src_info = $ldap->srcs[1];  
     1409                                }  
     1410                                $ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], false);  
     1411                                $filter .= ")";  
     1412                                $dn=$this->bo->catalog->src_info['dn'];  
     1413                                $justThese = array("cn","uidnumber","uid");  
     1414                                $sr = ldap_search($ds,$dn, $filter,$justThese);  
     1415                                $info = ldap_get_entries($ds, $sr);  
     1416                                for($z = 0; $z < $info['count']; $z++) {  
     1417                                        $owner_names[$info[$z]['uidnumber'][0]] = array("cn" => $info[$z]['cn'][0], "uid" => $info[$z]['uid'][0]);  
     1418                                }  
     1419                                ldap_close($ds);  
     1420                        }  
     1421                        echo serialize ($owner_names);    
     1422                }  
    13101423                 
    13111424                function get_visible_all_ldap() 
    13121425                { 
     
    19972110                        echo serialize($result); 
    19982111                } 
    19992112 
     2113                function post_full_add_shared()  
     2114                {  
     2115                        $data =  $_POST['data'];  
     2116                        // Exceptions!!! utf8 special chars.   
     2117                        $data = preg_replace("/\%u2(\d+)(\d+)(\d+)/","-",$data);  
     2118                        $data = unserialize(str_replace('\\"', '"', $data));  
     2119                        $this -> bo -> catalog = CreateObject('contactcenter.bo_shared_people_manager');  
     2120  
     2121                        if (!is_array($data))  
     2122                        {  
     2123                                echo serialize(array(  
     2124                                        'msg' => lang('<p>Some problem receiving data from browser. This is probably a bug in ContactCenter<br>'.  
     2125                                                  'Please go to eGroupWare Bug Reporting page and report this bug.<br>'.  
     2126                                                          'Sorry for the inconvenient!<br><br>'.  
     2127                                                          '<b><i>ContactCenter Developer Team</i></b></p>'),  
     2128                                        'status' => 'fatal'  
     2129                                ));  
     2130                                return;  
     2131                        }  
     2132//                      print_r($data);  
     2133//                      echo '<br><br>';  
     2134  
     2135                        $replacer = $data['commercialAnd'];  
     2136                        unset($data['commercialAnd']);  
     2137                        if (!is_string($replacer) or strpos($replacer, "'") or strpos($replacer, '"'))  
     2138                        {  
     2139                                echo serialize(array(  
     2140                                        'msg' => lang('Invalid \'&\' replacer! This may be an attempt to bypass Security! Action aborted!'),  
     2141                                        'status' => 'fatal'  
     2142                                ));  
     2143                                  
     2144                                return;  
     2145                        }  
     2146  
     2147                        if ($data['id_contact'])  
     2148                        {  
     2149                                $id = $data['id_contact'];  
     2150                                $id_photo = $id;  
     2151                                unset($data['id_contact']);  
     2152                        }  
     2153                        else  
     2154                        {  
     2155                                $id_photo = '_new_';  
     2156                        }  
     2157  
     2158                        if ($data['owner'])  
     2159                        {  
     2160                                $owner = $data['owner'];  
     2161                                unset($data['owner']);  
     2162                        }  
     2163                        /*   
     2164                         * Process Photo, if available   
     2165                         */  
     2166                        $sleep_count = 0;  
     2167                        $photo_ok = $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter');  
     2168                        while($photo_ok[0]{0} !== 'o' and $photo_ok[1]{0} === 'y')  
     2169                        {  
     2170                                sleep(1);  
     2171                                $photo_ok = $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter');  
     2172                                $sleep_count++;  
     2173  
     2174                                if ($sleep_count > 35)  
     2175                                {  
     2176                                        // TODO  
     2177                                        return;  
     2178                                }  
     2179                        }  
     2180                        $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('wait', 'n'));  
     2181                          
     2182                        if (isset($this->page_info['photos'][$id_photo]))  
     2183                        {  
     2184                                if (array_search($this->page_info['photos'][$id_photo]['status'], array('changed', 'sync')) === false)  
     2185                                {  
     2186                                        echo serialize(array(  
     2187                                                'msg' => $this->page_info['photos'][$id_photo]['msg'],  
     2188                                                'status' => $this->page_info['photos'][$id_photo]['status']  
     2189                                        ));  
     2190  
     2191                                        return;  
     2192                                }  
     2193  
     2194                                $data['photo'] = $this->page_info['photos'][$id_photo]['content'];  
     2195                                unset($this->page_info['photos'][$id_photo]);  
     2196                                $this->save_session();  
     2197                        }  
     2198                          
     2199                        /*  
     2200                         * Arrange Date so it gets inserted correctly  
     2201                         */  
     2202                           
     2203                        $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];  
     2204                  
     2205                        $j = 0;  
     2206                        for ($i = 0; $i < 5; $i+=2)  
     2207                        {  
     2208                                switch($dateformat{$i})  
     2209                                {  
     2210                                        case 'Y':  
     2211                                                $date[$j]['size'] = 4;  
     2212                                                $date[$j]['digit'] = 'Y';  
     2213                                                break;  
     2214  
     2215                                        case 'm':  
     2216                                        case 'M':  
     2217                                                $date[$j]['size'] = 2;  
     2218                                                $date[$j]['digit'] = 'M';  
     2219                                                break;  
     2220  
     2221                                        case 'd':  
     2222                                                $date[$j]['size'] = 2;  
     2223                                                $date[$j]['digit'] = 'D';  
     2224                                }  
     2225                                $j++;  
     2226                        }  
     2227                        $datecount = 0;  
     2228  
     2229                        /* Verify Data and performs insertion/update */  
     2230                        foreach($data as $field => &$value)  
     2231                        {  
     2232                                if ($value == '' or is_null($value))  
     2233                                {  
     2234                                        unset($data[$field]);  
     2235                                        continue;  
     2236                                }  
     2237                                  
     2238                                switch($field)  
     2239                                {  
     2240                                        case 'corporate_name':  
     2241                                        case 'job_title':  
     2242                                        case 'department':  
     2243                                        case 'web_page': 
     2244                                        case 'alias':  
     2245                                        case 'given_names':  
     2246                                        case 'family_names':  
     2247                                        case 'names_ordered':  
     2248                                        case 'pgp_key':  
     2249                                        case 'notes':  
     2250                                        case 'photo':  
     2251                                                $value = urldecode( $value );  
     2252                                                /* Do Nothing. This is just to make sure no invalid field is passed */  
     2253                                                break;  
     2254                                          
     2255                                        case 'id_status':  
     2256                                        case 'id_prefix':  
     2257                                        case 'id_suffix':  
     2258                                                if ($data[$field] == 0)  
     2259                                                {  
     2260                                                        unset($data[$field]);  
     2261                                                }  
     2262                                                break;  
     2263                                          
     2264                                        case 'birthdate_0':  
     2265                                        case 'birthdate_1':  
     2266                                        case 'birthdate_2':  
     2267                                          
     2268                                                switch($date[$datecount]['digit'])  
     2269                                                {  
     2270                                                        case 'Y':  
     2271                                                                $date['value'][2] = (int) $data[$field];  
     2272                                                                break;  
     2273  
     2274                                                        case 'M':  
     2275                                                                $date['value'][0] = (int) $data[$field];  
     2276                                                                break;  
     2277  
     2278                                                        case 'D':  
     2279                                                                $date['value'][1] = (int) $data[$field];  
     2280                                                                break;  
     2281                                                }  
     2282                                                unset($data[$field]);  
     2283                                                $datecount++;  
     2284  
     2285                                                if ($datecount != 3)  
     2286                                                {  
     2287                                                        break;  
     2288                                                }  
     2289                                                  
     2290                                                if (!checkdate($date['value'][0], $date['value'][1], $date['value'][2]))  
     2291                                                {  
     2292                                                        echo serialize(array(  
     2293                                                                'msg' => lang('Invalid Date'),  
     2294                                                                'status' => 'invalid_data'  
     2295                                                        ));  
     2296                                                        return;  
     2297                                                }  
     2298                                                  
     2299                                                $data['birthdate'] = $date['value'][2].'-'.$date['value'][0].'-'.$date['value'][1];  
     2300                                                break;  
     2301  
     2302                                        case 'sex':  
     2303                                                if ($data[$field] !== 'M' and $data[$field] !== 'F')  
     2304                                                {  
     2305                                                        echo serialize(array(  
     2306                                                                'msg' => lang('Invalid Sex'),  
     2307                                                                'status' => 'invalid_data'  
     2308                                                        ));  
     2309                                                        return;  
     2310                                                }  
     2311                                                break;  
     2312  
     2313  
     2314                                        case 'addresses':  
     2315                                                /* Insert new cities/states */  
     2316                                                if (isset($value['new_states']))  
     2317                                                {  
     2318                                                        foreach($value['new_states'] as $type => $state_info)  
     2319                                                        {  
     2320                                                                $index = 'address'.$type;  
     2321                                                                  
     2322                                                                $id_state = $this->bo->catalog->add_state($state_info);  
     2323                                                                $data['addresses'][$index]['id_state'] = $id_state;  
     2324  
     2325                                                                if ($value['new_cities'][$type])  
     2326                                                                {  
     2327                                                                        $value['new_cities'][$type]['id_state'] = $id_state;  
     2328                                                                }  
     2329                                                        }  
     2330  
     2331                                                        unset($data['addresses']['new_states']);  
     2332                                                }  
     2333  
     2334                                                if (isset($value['new_cities']))  
     2335                                                {  
     2336                                                        foreach($value['new_cities'] as $type => $city_info)  
     2337                                                        {  
     2338                                                                $index = 'address'.$type;  
     2339                                                                  
     2340                                                                $id_city = $this->bo->catalog->add_city($city_info);  
     2341                                                                $data['addresses'][$index]['id_city'] = $id_city;  
     2342                                                        }  
     2343  
     2344                                                        unset($data['addresses']['new_cities']);  
     2345                                                }  
     2346  
     2347                                        break;  
     2348  
     2349                                        case 'connections':  
     2350                                                /* Does nothing... */  
     2351                                                break;  
     2352  
     2353                                        default:  
     2354                                                echo serialize(array(  
     2355                                                        'msg' => lang('Invalid field: ').$field,  
     2356                                                        'status' => 'invalid_data'  
     2357                                                ));  
     2358                                                return;  
     2359                                }  
     2360                        }  
     2361  
     2362                        $code = '$id = $this->bo->catalog->';  
     2363  
     2364                        if (!is_null($id) and $id !== '')  
     2365                        {  
     2366                                $code .= $code.'update_single_info($id, $data);';  
     2367                                $result = array(  
     2368                                        'msg' => lang('Updated Successfully!'),  
     2369                                        'status' => 'ok'  
     2370                                );  
     2371                        }  
     2372                        else  
     2373                        {  
     2374                                $code .= 'add_single_entry($data,'.$owner.');';  
     2375                                $result = array(  
     2376                                        'msg' => lang('Entry Added Successfully!'),  
     2377                                        'status' => 'ok'  
     2378                                );  
     2379                        }  
     2380                          
     2381                        eval($code);  
     2382  
     2383                        if (!($id))  
     2384                        {  
     2385                                $result = array(  
     2386                                        'msg' => lang('Some problem occured when trying to insert/update contact information.<br>'.  
     2387                                                   'Report the problem to the Administrator.'),  
     2388                                        'status' => 'fail'  
     2389                                );  
     2390                        }  
     2391  
     2392                        echo serialize($result);  
     2393}  
     2394 
    20002395                /*! 
    20012396                 
    20022397                        @function post_photo 
  • contactcenter/js/cc.js

     
    3737*               GLOBALS VARIABLES               * 
    3838\***********************************************/ 
    3939 
     40var owners = new Array();  
     41var flag_compartilhado = false;  
     42var qtd_compartilhado = 0;  
     43 
    4044var CC_visual = 'table'; 
    4145/* Cards Variables */ 
    4246var CC_actual_letter = 'a'; 
     
    171175        Element("cc_conn_type_2").checked = false; 
    172176        Element("cc_conn_type_sel").disabled = true; 
    173177        Element("cc_conn_type_sel").selectedIndex = 0; 
     178        Element("cc_contact_sharing").style.display = 'none'; 
    174179} 
    175180 
     181function openFullAddShared(){  
     182        if (flag_compartilhado)  
     183        {  
     184                if(!fullAddWin && !is_ie)  
     185                        __f();  
     186 
     187                resetFullAdd();  
     188                populateFullAddConst();  
     189                fullAddWin.open();  
     190                tabs._showTab('cc_contact_tab_0');  
     191                Element("cc_conn_type_1").checked = false;  
     192                Element("cc_conn_type_2").checked = false;  
     193                Element("cc_conn_type_sel").disabled = true;  
     194                Element("cc_conn_type_sel").selectedIndex = 0;  
     195                Element("cc_contact_sharing").align = 'center';  
     196                Element("cc_contact_sharing").style.display = 'block';  
     197                Element("cc_contact_shared_types").disabled = true;  
     198                populateSharingSelect();  
     199        } else  
     200        {  
     201                if(qtd_compartilhado != 0)  
     202                {  
     203                        ccTree.select(0.2);  
     204                        ccTree.setCatalog(0.2);  
     205                        if(!fullAddWin && !is_ie)  
     206                                __f();  
     207                        resetFullAdd();  
     208                        populateFullAddConst();  
     209                        fullAddWin.open();  
     210                        tabs._showTab('cc_contact_tab_0');  
     211                        Element("cc_conn_type_1").checked = false;  
     212                        Element("cc_conn_type_2").checked = false;  
     213                        Element("cc_conn_type_sel").disabled = true;  
     214                        Element("cc_conn_type_sel").selectedIndex = 0;  
     215                        Element("cc_contact_sharing").aling = 'center';  
     216                        Element("cc_contact_sharing").style.display = 'block';  
     217                        Element("cc_contact_shared_types").disabled = true;  
     218                        populateSharingSelect();  
     219                } else  
     220                        showMessage(Element('cc_msg_err_shared').value);  
     221        }  
     222}  
     223 
    176224function closeFullAdd(){ 
    177225        fullAddWin.close(); 
    178226} 
    179227/********** New Contact *************/ 
    180228function newContact(){ 
    181229        openFullAdd(); 
    182 } 
     230}  
     231function newSharedContact(){  
     232        openFullAddShared();  
     233}  
    183234/************ Edit Contact *************/ 
    184235function editContact (id){ 
    185236        openFullAdd(); 
     
    201252/* 
    202253        Updates all the constant fields in the 
    203254        full add window, like Prefixes, Suffixes, 
    204         Countries and Types 
     255        Countries, Types and Shared catalogs 
    205256*/ 
     257  
     258function populateSharingSelect()  
     259{  
     260        var handler = function(responseText)  
     261        {  
     262                var data = unserialize(responseText);  
     263                var sharers = Element('cc_contact_shared_types');  
     264  
     265                if (typeof(data) != 'object')  
     266                {  
     267                        showMessage(Element('cc_msg_err_contacting_server').value);  
     268                        fullAddWin.close();  
     269                        return;  
     270                }else{  
     271                        sharers.disabled = false;  
     272                        j = 1;  
     273                        for (var i in data)  
     274                        {  
     275                                sharers.options[j] = new Option(data[i]['cn'], i);  
     276                                owners[j] = i;  
     277                                j++;  
     278                        }  
     279                        return; 
     280                } 
     281        };  
     282        Connector.newRequest('populateSharingSelect', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_list_owners_perms_add', 'POST', handler);  
     283}  
     284  
    206285function populateFullAddConst() 
    207286{ 
    208287        CC_full_add_const = false; 
     
    442521                CC_full_add_photo = true; 
    443522        } 
    444523 
    445         setTimeout('postFullAddInfo()', 100); 
     524        if (Element('cc_contact_sharing').style.display == 'none')  
     525                setTimeout('postFullAddInfo()', 100); 
     526        else 
     527                setTimeout('postFullAddInfoShared()', 100); 
    446528} 
    447529 
    448530function postFullAddInfo() 
     
    468550        }; 
    469551 
    470552        Connector.newRequest('postFullAddInfo', CC_url+'post_full_add', 'POST', handler, getFullAddData()); 
     553}  
     554  
     555function postFullAddInfoShared()  
     556{  
     557        var handler = function (responseText)  
     558        {  
     559                var data = unserialize(responseText);  
     560                if (typeof(data) != 'object')  
     561                {  
     562                        showMessage(Element('cc_msg_err_contacting_server').value);  
     563                        return;  
     564                }  
     565  
     566                if (data['status'] != 'ok')  
     567                {  
     568                        showMessage(data['msg']);  
     569                        return;  
     570                }  
     571  
     572                fullAddWin.close();  
     573                updateCards();  
     574        };  
     575        Connector.newRequest('postFullAddInfoShared', CC_url+'post_full_add_shared', 'POST', handler, getFullAddData());  
    471576} 
    472577 
    473578function getFullAddData() 
     
    484589                data.length++; 
    485590        } 
    486591 
     592        /* Owner do contato (Para o caso de adicao de contato compartilhado) */  
     593        if (Element('cc_contact_sharing').style.display == 'block')  
     594        {  
     595                var index = Element('cc_contact_shared_types').selectedIndex;  
     596                data['owner'] = replaceComAnd(owners[index], replacer);   
     597                data.length++;  
     598        }  
     599 
    487600        /* Status: Full Added */ 
    488601        data['id_status'] = CC_STATUS_FULL_ADD; 
    489602         
     
    579692                data['connections'].length++; 
    580693        } 
    581694 
     695        var serial = serialize(data); 
    582696        return 'data=' + escape(serialize(data)); 
    583697} 
    584698 
    585699function checkFullAdd() 
    586700{ 
     701  
     702        /* Checa se o listbox esta desativado ou éulo, ou seja, nãexiste catágos compartilhados com o user atual */  
     703  
     704        if (!(Element('cc_contact_sharing').style.display == 'none' ))  
     705        {  
     706                if (Element('cc_contact_shared_types').disabled == true)  
     707                {         
     708                        showMessage('Nenhum catágo compartilhado existente');  
     709                        return false;  
     710                }  
     711                if (Element('cc_contact_shared_types').selectedIndex == 0)  
     712                {  
     713                        showMessage('Nenhum catágo selecionado');  
     714                        return false;  
     715                }  
     716        }  
     717        
    587718        /* Check Personal Data */ 
    588719 
    589720        if (Element('cc_pd_given_names').value == '') 
     
    23372468{ 
    23382469        var data  = new Array(); 
    23392470 
     2471        flag_compartilhado = false; 
    23402472        if ( letter != CC_actual_letter ) 
    23412473        { 
    23422474                CC_actual_page = '1'; 
     
    23892521                 
    23902522                if (typeof(data[3]) == 'object') 
    23912523                { 
     2524                        if (data[8] == 'bo_shared_people_manager')  
     2525                        {  
     2526                                flag_compartilhado = true;  
     2527                        }  
     2528                        else  
     2529                        {  
     2530                                flag_compartilhado = false;  
     2531                        }  
     2532                        qtd_compartilhado = data[9]; 
    23922533                        CC_npages = parseInt(data[0]); 
    23932534                        CC_actual_page = parseInt(data[1]);                      
    23942535                        if(CC_visual == 'cards') 
  • contactcenter/js/ccMain.js

     
    5353                                else 
    5454                                { 
    5555                                        ccTree = new ccCatalogTree({name: 'ccTree', id_destination: 'cc_tree', afterSetCatalog: 'ccSearchHidePanel(); clearCards();'}); 
     56                                        var ccQtdCompartilhado = function(responseText) {                                         
     57                                                                                                                data = unserialize(responseText);  
     58                                                                                                                qtd_compartilhado = data[0];  
     59                                                                                                        }  
     60                                        Connector.newRequest('fulfilQtdCompartilhado', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_qtds_compartilhado', 'POST', ccQtdCompartilhado);  
    5661                                } 
    5762                        } 
    5863 
     
    9196                submenu = []; 
    9297                textmenu = []; 
    9398                         
    94                 textmenu[0] = ["cc_msg_contact_qa","cc_msg_contact_full","cc_msg_group"] 
    95                 textmenu[1] = ["cc_quick_add", "cc_full_add_button", "cc_add_group_button"];             
     99                textmenu[0] = ["cc_msg_contact_qa","cc_msg_contact_full","cc_msg_contact_sh","cc_msg_group"] 
     100                textmenu[1] = ["cc_quick_add", "cc_full_add_button", "cc_full_add_button_sh","cc_add_group_button"];             
    96101                function show(){ 
    97102                        clearTimeout(_timeout); 
    98103                        button = document.getElementById("cc_button_new"); 
     
    125130                ccQuickAdd.associateAsButton(Element('cc_quick_add')); 
    126131                ccAddGroup.associateAsButton(Element('cc_add_group_button')); 
    127132                Element("cc_full_add_button").onclick = newContact; 
    128                           
     133                Element("cc_full_add_button_sh").onclick = newSharedContact; 
    129134                         
    130135                ccQuickAdd.afterSave = function () 
    131136                { 
  • contactcenter/templates/classic/api_common.tpl

     
    1212<input id="cc_msg_err_contacting_server" type="hidden" value="{cc_msg_err_contacting_server}" /> 
    1313<input id="cc_msg_err_timeout" type="hidden" value="{cc_msg_err_timeout}" /> 
    1414<input id="cc_msg_err_serialize_data_unknown" type="hidden" value="{cc_msg_err_serialize_data_unknown}" /> 
     15<input id="cc_msg_err_shared" type="hidden" type="hidden" value="{cc_msg_err_shared}" /> 
    1516 
    1617<input id="cc_msg_err_empty_field" type="hidden" value="{cc_msg_err_empty_field}" /> 
    1718<input id="cc_msg_type_state" type="hidden" value="{cc_msg_type_state}" /> 
  • contactcenter/templates/classic/index.tpl

     
    2121<input id="cc_msg_card_edit" type="hidden" value="{cc_msg_card_edit}"> 
    2222<input id="cc_msg_group" type="hidden" value="{cc_msg_group}"> 
    2323<input id="cc_msg_contact_full" type="hidden" value="{cc_msg_contact_full}"> 
     24<input id="cc_msg_contact_sh" type="hidden" value="{cc_msg_contact_sh}"> 
    2425<input id="cc_msg_contact_qa" type="hidden" value="{cc_msg_contact_qa}"> 
    2526<input id="cc_msg_card_remove" type="hidden" value="{cc_msg_card_remove}"> 
    2627<input id="cc_msg_card_remove_confirm" type="hidden" value="{cc_msg_card_remove_confirm}"> 
     
    250251<script type="text/javascript" src="js/ccQuickAddContact.js"></script> 
    251252<script type="text/javascript" src="js/ccIEContacts.js"></script> 
    252253<script type="text/javascript" src="js/ccMain.js"></script> 
    253 <!-- END BOTTOM DETAILS-->                                               
    254  No newline at end of file 
     254<!-- END BOTTOM DETAILS-->                                               
  • contactcenter/templates/classic/full_add.tpl

     
    161161        <div style="z-index:10000;position: absolute;display:none; top: 170px; left: 78px;" id="div_cc_conn_is_default"> {cc_default} &nbsp;<select id="cc_email_default" name="cc_email_default" disabled style="display:none"></select><select id="cc_phone_default" name="cc_phone_default" disabled style="display:none"></select></div> 
    162162</div> 
    163163<!-- _BOTTOM BUTTONS --> 
    164 <div align="center" id="cc_contact_tab_buttons" style="position: absolute; visibility: hidden; top: 250px; left: 0px; width: 498px; height: 32px; border: 0px solid black">      
     164<div align="center" id="cc_contact_tab_buttons" style="position: absolute; visibility: hidden; top: 250px; left: 0px; width: 498px; height: 64px; border: 0px solid black">  
     165        <table class="row_off" align="center" width="498px" cellpadding="2" cellspacing="0" border="0">  
     166                <tr class="row_off" id="cc_contact_sharing">  
     167                        <td >{cc_contact_shared}: </td>  
     168                        <td colspan="2">  
     169                                        <select id="cc_contact_shared_types" name="{cc_contact_shared}" style="width: 390px;">  
     170                                                <option value="_NONE_">{cc_contact_shared_types}</option>  
     171                                        </select>  
     172                        </td>  
     173                </tr>  
     174        </table>  
    165175        <table class="row_off" align="center" width="498px" cellpadding="2" cellspacing="0" border="0"> 
    166176                <tr> 
    167177                        <td align="center"> 
     
    222232                                         'content_id': 'cc_contact_tab', 
    223233                                         'win_class': 'row_off', 
    224234                                         'width': '500px', 
    225                                          'height': '273px', 
     235                                         'height': '295px', 
    226236                                         'title_color': '#3978d6', 
    227237                                         'title': Element('cc_contact_title').value, 
    228238                                         'title_text_color': 'white', 
  • contactcenter/templates/default/api_common.tpl

     
    1212<input id="cc_msg_err_contacting_server" type="hidden" value="{cc_msg_err_contacting_server}" /> 
    1313<input id="cc_msg_err_timeout" type="hidden" value="{cc_msg_err_timeout}" /> 
    1414<input id="cc_msg_err_serialize_data_unknown" type="hidden" value="{cc_msg_err_serialize_data_unknown}" /> 
     15<input id="cc_msg_err_shared" type="hidden" type="hidden" value="{cc_msg_err_shared}" /> 
    1516 
    1617<input id="cc_msg_err_empty_field" type="hidden" value="{cc_msg_err_empty_field}" /> 
    1718<input id="cc_msg_type_state" type="hidden" value="{cc_msg_type_state}" /> 
  • contactcenter/templates/default/index.tpl

     
    2121<input id="cc_msg_card_edit" type="hidden" value="{cc_msg_card_edit}"> 
    2222<input id="cc_msg_group" type="hidden" value="{cc_msg_group}"> 
    2323<input id="cc_msg_contact_full" type="hidden" value="{cc_msg_contact_full}"> 
     24<input id="cc_msg_contact_sh" type="hidden" value="{cc_msg_contact_sh}"> 
    2425<input id="cc_msg_contact_qa" type="hidden" value="{cc_msg_contact_qa}"> 
    2526<input id="cc_msg_card_remove" type="hidden" value="{cc_msg_card_remove}"> 
    2627<input id="cc_msg_card_remove_confirm" type="hidden" value="{cc_msg_card_remove_confirm}"> 
  • contactcenter/templates/default/full_add.tpl

     
    161161        <div style="z-index:10000;position: absolute;display:none; top: 170px; left: 78px;" id="div_cc_conn_is_default"> {cc_default} &nbsp;<select id="cc_email_default" name="cc_email_default" disabled style="display:none"></select><select id="cc_phone_default" name="cc_phone_default" disabled style="display:none"></select></div> 
    162162</div> 
    163163<!-- _BOTTOM BUTTONS --> 
    164 <div align="center" id="cc_contact_tab_buttons" style="position: absolute; visibility: hidden; top: 250px; left: 0px; width: 498px; height: 32px; border: 0px solid black">      
     164<div align="center" id="cc_contact_tab_buttons" style="position: absolute; visibility: hidden; top: 250px; left: 0px; width: 498px; height: 64px; border: 0px solid black">  
     165        <table class="row_off" align="center" width="498px" cellpadding="2" cellspacing="0" border="0">  
     166                <tr class="row_off" id="cc_contact_sharing">  
     167                        <td >{cc_contact_shared}: </td>  
     168                        <td colspan="2">  
     169                                        <select id="cc_contact_shared_types" name="{cc_contact_shared}" style="width: 390px;">  
     170                                                <option value="_NONE_">{cc_contact_shared_types}</option>  
     171                                        </select>  
     172                        </td>  
     173                </tr>  
     174        </table>  
    165175        <table class="row_off" align="center" width="498px" cellpadding="2" cellspacing="0" border="0"> 
    166176                <tr> 
    167177                        <td align="center"> 
     
    222232                                         'content_id': 'cc_contact_tab', 
    223233                                         'win_class': 'row_off', 
    224234                                         'width': '500px', 
    225                                          'height': '273px', 
     235                                         'height': '295px', 
    226236                                         'title_color': '#3978d6', 
    227237                                         'title': Element('cc_contact_title').value, 
    228238                                         'title_text_color': 'white', 
  • preferences/inc/class.uiaclprefs.inc.php

     
    199199                        $this->template->set_var("cancel", lang("Cancel")); 
    200200                         
    201201                        if($acl_app=='contactcenter') { 
    202                                 $this->template->set_var("add_invisible", "style='display:none'"); 
     202                                //$this->template->set_var("add_invisible", "style='display:none'"); 
    203203                                $this->template->set_var("private_invisible", "style='display:none'");                           
    204204                        } 
    205205                        else {