Changeset 1496 for trunk/contactcenter/inc/class.ui_data.inc.php
- Timestamp:
- 10/06/09 10:27:46 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/contactcenter/inc/class.ui_data.inc.php
r1419 r1496 123 123 124 124 $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')); 125 126 $GLOBALS['phpgw']->template->set_var('cc_reset',lang('Reset')); 126 127 … … 175 176 $GLOBALS['phpgw']->template->set_var('cc_msg_group',lang('Group')); 176 177 $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]')); 177 179 $GLOBALS['phpgw']->template->set_var('cc_msg_contact_qa',lang('Contact [Quick Add]')); 178 180 $GLOBALS['phpgw']->template->set_var('cc_contact_title',lang('Contact Center').' - '.lang('Contacts')); … … 320 322 return $this->post_full_add(); 321 323 324 case 'post_full_add_shared' : 325 return $this->post_full_add_shared(); 326 322 327 case 'post_photo': 323 328 return $this->post_photo((int) $_GET['id'] ? (int) $_GET['id'] : '_new_'); … … 586 591 unset($ids); 587 592 $this->page_info['changed'] = false; 588 589 593 switch ($this->page_info['actual_catalog']['class']) 590 594 { … … 592 596 case 'bo_people_catalog': 593 597 $field_name = 'id_contact'; 594 595 598 if ($letter !== 'number') 596 599 { … … 602 605 ) 603 606 ); 604 if($this->page_info['actual_catalog']['class'] == 'bo_people_catalog'){ 607 608 //Tratamento de permissão de escrita no compartilhamento de catalogo 609 $so_contact = CreateObject('contactcenter.so_contact', $GLOBALS['phpgw_info']['user']['account_id']); 610 $relacionados = $so_contact->get_relations(); 611 612 $perms_relacao = array(); 613 614 foreach($relacionados as $uid_relacionado => $tipo_relacionamento) { 615 $aclTemp = CreateObject("phpgwapi.acl",$uid_relacionado); 616 $aclTemp->read(); 617 $perms_relacao[$uid_relacionado] = $aclTemp->get_specific_rights($GLOBALS['phpgw_info']['user']['account_id'],'contactcenter'); //Preciso verificar as permissões que o contato relacionado deu para o atual 618 } 619 620 $validos = array(); 621 $count = 0; 622 foreach($perms_relacao as $uid_relacionado => $val){ 623 if ($perms_relacao[$uid_relacionado]&2) 624 { 625 $validos[$uid_relacionado] = $perms_relacao[$uid_relacionado]; 626 $count++; 627 } 628 } 629 $prop_names = array(); 630 if($validos) { 631 $filtro = "(|"; 632 foreach($validos as $i => $prop) { 633 $filtro .= "(uidNumber=".$i.")"; 634 } 635 $filtro .= ")"; 636 637 if(!$this->bo->catalog->src_info) { 638 $ldaps = CreateObject('contactcenter.bo_ldap_manager'); 639 $this->bo->catalog->src_info = $ldaps->srcs[1]; 640 } 641 $s = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], false); 642 $n=$this->bo->catalog->src_info['dn']; 643 $apenasThese = array("cn","uidnumber","uid"); 644 $r = ldap_search($s,$n, $filtro,$apenasThese); 645 $infos = ldap_get_entries($s, $r); 646 ldap_close($s); 647 for($z = 0; $z < $infos['count']; $z++) { 648 $prop_names[$infos[$z]['uidnumber'][0]] = array("cn" => $infos[$z]['cn'][0], "uid" => $infos[$z]['uid'][0]); 649 } 650 } 651 //-------------------------------------------------------------------------------- 652 if($this->page_info['actual_catalog']['class'] == 'bo_people_catalog') 653 { 605 654 $find_restric[0][1] = array( 606 655 'field' => 'contact.id_owner', … … 963 1012 964 1013 } 965 1014 966 1015 $result = $this->bo->find($find_field[0],$find_restric[0],$find_other[0]); 967 968 1016 $n_entries = count($result); 969 1017 … … 1084 1132 foreach($this->page_info['actual_entries'] as $key=>$tmp){ 1085 1133 $array_temp[] = $tmp; 1086 } 1087 1134 } 1135 1088 1136 for($i = $id_i; $i < $id_f and $i < $n_entries; $i++) 1089 1137 { … … 1098 1146 } 1099 1147 1100 1101 1148 // Carrega o nome completo dos donos dos objetos (contatos e grupos); 1102 1149 $owner_names = array(); … … 1108 1155 } 1109 1156 $filter .= ")"; 1110 1157 1111 1158 if(!$this->bo->catalog->src_info) { 1112 1159 $ldap = CreateObject('contactcenter.bo_ldap_manager'); … … 1129 1176 //} 1130 1177 /// 1131 1132 1178 $fields = $this->bo->catalog->get_fields(false); 1133 1179 if( $this->typeContact == 'groups' || $this->typeContact == 'shared_groups') { … … 1288 1334 $lnk_compose = "location.href=('../expressoMail1_2/index.php?to="; 1289 1335 $final[5] = '<span class="link" onclick="'.$lnk_compose; 1290 1336 $final[6] = $prop_names; 1337 $final[7] = $validos; 1338 $final[8] = $this->page_info['actual_catalog']['class']; 1339 $final[9] = $count; 1291 1340 1292 1341 $this->page_info['actual_letter'] = $letter; … … 2002 2051 } 2003 2052 2053 2054 function post_full_add_shared() 2055 { 2056 $data = $_POST['data']; 2057 // Exceptions!!! utf8 special chars. 2058 $data = preg_replace("/\%u2(\d+)(\d+)(\d+)/","-",$data); 2059 $data = unserialize(str_replace('\\"', '"', $data)); 2060 $this -> bo -> catalog = CreateObject('contactcenter.bo_shared_people_manager'); 2061 2062 if (!is_array($data)) 2063 { 2064 echo serialize(array( 2065 'msg' => lang('<p>Some problem receiving data from browser. This is probably a bug in ContactCenter<br>'. 2066 'Please go to eGroupWare Bug Reporting page and report this bug.<br>'. 2067 'Sorry for the inconvenient!<br><br>'. 2068 '<b><i>ContactCenter Developer Team</i></b></p>'), 2069 'status' => 'fatal' 2070 )); 2071 return; 2072 } 2073 // print_r($data); 2074 // echo '<br><br>'; 2075 2076 $replacer = $data['commercialAnd']; 2077 unset($data['commercialAnd']); 2078 if (!is_string($replacer) or strpos($replacer, "'") or strpos($replacer, '"')) 2079 { 2080 echo serialize(array( 2081 'msg' => lang('Invalid \'&\' replacer! This may be an attempt to bypass Security! Action aborted!'), 2082 'status' => 'fatal' 2083 )); 2084 2085 return; 2086 } 2087 2088 if ($data['id_contact']) 2089 { 2090 $id = $data['id_contact']; 2091 $id_photo = $id; 2092 unset($data['id_contact']); 2093 } 2094 else 2095 { 2096 $id_photo = '_new_'; 2097 } 2098 2099 if ($data['owner']) 2100 { 2101 $owner = $data['owner']; 2102 unset($data['owner']); 2103 } 2104 /* 2105 * Process Photo, if available 2106 */ 2107 $sleep_count = 0; 2108 $photo_ok = $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter'); 2109 while($photo_ok[0]{0} !== 'o' and $photo_ok[1]{0} === 'y') 2110 { 2111 sleep(1); 2112 $photo_ok = $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter'); 2113 $sleep_count++; 2114 2115 if ($sleep_count > 35) 2116 { 2117 // TODO 2118 return; 2119 } 2120 } 2121 $GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('wait', 'n')); 2122 2123 if (isset($this->page_info['photos'][$id_photo])) 2124 { 2125 if (array_search($this->page_info['photos'][$id_photo]['status'], array('changed', 'sync')) === false) 2126 { 2127 echo serialize(array( 2128 'msg' => $this->page_info['photos'][$id_photo]['msg'], 2129 'status' => $this->page_info['photos'][$id_photo]['status'] 2130 )); 2131 2132 return; 2133 } 2134 2135 $data['photo'] = $this->page_info['photos'][$id_photo]['content']; 2136 unset($this->page_info['photos'][$id_photo]); 2137 $this->save_session(); 2138 } 2139 2140 /* 2141 * Arrange Date so it gets inserted correctly 2142 */ 2143 2144 $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; 2145 2146 $j = 0; 2147 for ($i = 0; $i < 5; $i+=2) 2148 { 2149 switch($dateformat{$i}) 2150 { 2151 case 'Y': 2152 $date[$j]['size'] = 4; 2153 $date[$j]['digit'] = 'Y'; 2154 break; 2155 2156 case 'm': 2157 case 'M': 2158 $date[$j]['size'] = 2; 2159 $date[$j]['digit'] = 'M'; 2160 break; 2161 2162 case 'd': 2163 $date[$j]['size'] = 2; 2164 $date[$j]['digit'] = 'D'; 2165 } 2166 $j++; 2167 } 2168 $datecount = 0; 2169 2170 /* Verify Data and performs insertion/update */ 2171 foreach($data as $field => &$value) 2172 { 2173 if ($value == '' or is_null($value)) 2174 { 2175 unset($data[$field]); 2176 continue; 2177 } 2178 2179 switch($field) 2180 { 2181 case 'alias': 2182 case 'given_names': 2183 case 'family_names': 2184 case 'names_ordered': 2185 case 'pgp_key': 2186 case 'notes': 2187 case 'photo': 2188 $value = urldecode( $value ); 2189 /* Do Nothing. This is just to make sure no invalid field is passed */ 2190 break; 2191 2192 case 'id_status': 2193 case 'id_prefix': 2194 case 'id_suffix': 2195 if ($data[$field] == 0) 2196 { 2197 unset($data[$field]); 2198 } 2199 break; 2200 2201 case 'birthdate_0': 2202 case 'birthdate_1': 2203 case 'birthdate_2': 2204 2205 switch($date[$datecount]['digit']) 2206 { 2207 case 'Y': 2208 $date['value'][2] = (int) $data[$field]; 2209 break; 2210 2211 case 'M': 2212 $date['value'][0] = (int) $data[$field]; 2213 break; 2214 2215 case 'D': 2216 $date['value'][1] = (int) $data[$field]; 2217 break; 2218 } 2219 unset($data[$field]); 2220 $datecount++; 2221 2222 if ($datecount != 3) 2223 { 2224 break; 2225 } 2226 2227 if (!checkdate($date['value'][0], $date['value'][1], $date['value'][2])) 2228 { 2229 echo serialize(array( 2230 'msg' => lang('Invalid Date'), 2231 'status' => 'invalid_data' 2232 )); 2233 return; 2234 } 2235 2236 $data['birthdate'] = $date['value'][2].'-'.$date['value'][0].'-'.$date['value'][1]; 2237 break; 2238 2239 case 'sex': 2240 if ($data[$field] !== 'M' and $data[$field] !== 'F') 2241 { 2242 echo serialize(array( 2243 'msg' => lang('Invalid Sex'), 2244 'status' => 'invalid_data' 2245 )); 2246 return; 2247 } 2248 break; 2249 2250 2251 case 'addresses': 2252 /* Insert new cities/states */ 2253 if (isset($value['new_states'])) 2254 { 2255 foreach($value['new_states'] as $type => $state_info) 2256 { 2257 $index = 'address'.$type; 2258 2259 $id_state = $this->bo->catalog->add_state($state_info); 2260 $data['addresses'][$index]['id_state'] = $id_state; 2261 2262 if ($value['new_cities'][$type]) 2263 { 2264 $value['new_cities'][$type]['id_state'] = $id_state; 2265 } 2266 } 2267 2268 unset($data['addresses']['new_states']); 2269 } 2270 2271 if (isset($value['new_cities'])) 2272 { 2273 foreach($value['new_cities'] as $type => $city_info) 2274 { 2275 $index = 'address'.$type; 2276 2277 $id_city = $this->bo->catalog->add_city($city_info); 2278 $data['addresses'][$index]['id_city'] = $id_city; 2279 } 2280 2281 unset($data['addresses']['new_cities']); 2282 } 2283 2284 break; 2285 2286 case 'connections': 2287 /* Does nothing... */ 2288 break; 2289 2290 default: 2291 echo serialize(array( 2292 'msg' => lang('Invalid field: ').$field, 2293 'status' => 'invalid_data' 2294 )); 2295 return; 2296 } 2297 } 2298 2299 $code = '$id = $this->bo->catalog->'; 2300 2301 if (!is_null($id) and $id !== '') 2302 { 2303 $code .= $code.'update_single_info($id, $data);'; 2304 $result = array( 2305 'msg' => lang('Updated Successfully!'), 2306 'status' => 'ok' 2307 ); 2308 } 2309 else 2310 { 2311 $code .= 'add_single_entry($data,'.$owner.');'; 2312 $result = array( 2313 'msg' => lang('Entry Added Successfully!'), 2314 'status' => 'ok' 2315 ); 2316 } 2317 2318 eval($code); 2319 2320 if (!($id)) 2321 { 2322 $result = array( 2323 'msg' => lang('Some problem occured when trying to insert/update contact information.<br>'. 2324 'Report the problem to the Administrator.'), 2325 'status' => 'fail' 2326 ); 2327 } 2328 2329 echo serialize($result); 2330 } 2004 2331 /*! 2005 2332
Note: See TracChangeset
for help on using the changeset viewer.