Changeset 4929 for trunk/expressoMail1_2
- Timestamp:
- 08/16/11 15:46:38 (13 years ago)
- Location:
- trunk/expressoMail1_2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/inc/class.ldap_functions.inc.php
r4457 r4929 87 87 include_once("class.functions.inc.php"); 88 88 $functions = new functions; 89 89 90 // $search_for = utf8_encode($params['search_for']); 91 //Testa se a busca foi realizada com aspas 92 $search_for = utf8_encode($params['search_for']); 93 $search_len = (strlen($search_for)) - 1; 94 $quote_status=false; 95 96 if((($search_for{0}) == "\"") && (($search_for{$search_len}) == "\"")){ 97 $search_for{0} = " "; 98 $search_for{$search_len} = " "; 99 $quote_status=true; 100 } 101 102 103 90 104 $field = $params['field']; 91 105 $ID = $params['ID']; 92 106 93 107 $ldapService = ServiceLocator::getService('ldap'); 94 108 $filter = $ldapService->getSearchFilter($params['search_for']); 95 109 96 110 $contacts_result = array(); 97 111 $contacts_result['field'] = $field; … … 101 115 // follow the referral 102 116 $this->ldapConnect(true); 103 117 104 118 if ($this->ds) 105 { 106 $ldapService->connection = $this->ds; 119 { 120 if (($field != 'null') && ($ID != 'null')) 121 { 122 $filter="(& (&(|(phpgwAccountType=u)(phpgwAccountType=g)(phpgwAccountType=l))(mail=*)) (|(cn=*$search_for*)(mail=*$search_for*)) (!(phpgwaccountvisible=-1)) )"; 123 if($extendedinfo) 124 $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid", "employeeNumber", "ou"); 125 else 126 $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid"); 127 } 128 else 129 { 130 if($quote_status){ 131 $filter="(& (phpgwAccountType=u) (|(cn=* $search_for *)(cn=$search_for *)(cn=* $search_for)) (!(phpgwaccountvisible=-1)) )"; 132 } 133 else{ 134 $filter="(& (phpgwAccountType=u)(cn=*$search_for*) (!(phpgwaccountvisible=-1)) )"; 135 } 136 // $filter="(& (phpgwAccountType=u)(cn=*$search_for*) (!(phpgwaccountvisible=-1)) )"; 137 if($extendedinfo) 138 $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible","jpegPhoto", "uid", "employeeNumber", "ou"); 139 else 140 $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible","jpegPhoto", "uid"); 141 } 142 $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result + 1); 143 if(!$sr) 144 return null; 145 $count_entries = ldap_count_entries($this->ds,$sr); 107 146 108 147 $justthese = array("cn", "mail", "telephonenumber", "mobile", "phpgwaccountvisible", "uid", "employeenumber", "ou"); … … 110 149 111 150 if( $field == 'null' || $ID == 'null' ) 112 151 { 113 152 $justthese[] = "jpegphoto"; 114 153 $types = 'u'; … … 119 158 $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result); 120 159 121 if(!$sr)122 123 124 $count_entries = ldap_count_entries($this->ds,$sr);160 if(!$sr) 161 return null; 162 163 $count_entries = ldap_count_entries($this->ds,$sr); 125 164 126 165 $info = ldap_get_entries($this->ds, $sr); … … 130 169 { 131 170 $overload = $count_entries; 132 133 134 135 $catalogsNum=count($this->external_srcs);171 } 172 else 173 { 174 $catalogsNum=count($this->external_srcs); 136 175 for ($i=0; $i<=$catalogsNum; $i++) { 137 if ($this->external_srcs[$i]["quicksearch"]) {138 $this->ldapConnect(true,$i);139 $filter="(|(cn=*$search_for*)(mail=*$search_for*))";140 $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid","employeeNumber", "ou");141 $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result+1);142 if(!$sr)143 return null;144 $count_entries = ldap_count_entries($this->ds,$sr);145 $search = ldap_get_entries($this->ds, $sr);146 for ($j=0; $j<$search["count"]; $j++) {147 $info[] = $search[$j];148 }149 $info["count"] = count($info)-1;150 }151 }152 176 if ($this->external_srcs[$i]["quicksearch"]) { 177 $this->ldapConnect(true,$i); 178 $filter="(|(cn=*$search_for*)(mail=*$search_for*))"; 179 $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid","employeeNumber", "ou"); 180 $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result+1); 181 if(!$sr) 182 return null; 183 $count_entries = ldap_count_entries($this->ds,$sr); 184 $search = ldap_get_entries($this->ds, $sr); 185 for ($j=0; $j<$search["count"]; $j++) { 186 $info[] = $search[$j]; 187 } 188 $info["count"] = count($info)-1; 189 } 190 } 191 } 153 192 154 193 $tmp = array(); 155 194 $tmp_users_from_user_org = array(); 156 195 157 158 196 for ($i=0; $i<$info["count"]; $i++) 197 { 159 198 $key = $info[$i]["mail"][0] . '%' . $info[$i]["telephonenumber"][0] . '%'. $info[$i]["mobile"][0] . '%' . $info[$i]["uid"][0] . '%' . $info[$i]["jpegphoto"]['count'] . '%' . $info[$i]["employeenumber"][0] . '%' . $info[$i]["ou"][0]; 160 199 161 200 if (/*(!$quickSearch_only_in_userSector) &&*/ preg_match("/$user_sector_dn/i", $info[$i]['dn'])) 162 {201 { 163 202 $tmp_users_from_user_org[$key] = utf8_decode($info[$i]["cn"][0]); 164 203 continue; 165 }204 } 166 205 167 206 $tmp[$key] = utf8_decode($info[$i]["cn"][0]); 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 207 } 208 209 natcasesort($tmp_users_from_user_org); 210 natcasesort($tmp); 211 212 if (($field != 'null') && ($ID != 'null')) 213 { 214 $i = 0; 215 216 $tmp = array_merge($tmp, $tmp_users_from_user_org); 217 natcasesort($tmp); 218 219 foreach ($tmp as $info => $cn) 220 { 221 $contacts_result[$i] = array(); 222 $contacts_result[$i]["cn"] = $cn; 223 list ($contacts_result[$i]["mail"], $contacts_result[$i]["phone"], $contacts_result[$i]["mobile"], $contacts_result[$i]["uid"], $contacts_result[$i]["jpegphoto"], $contacts_result[$i]["employeenumber"], $contacts_result[$i]["ou"]) = split ('%', $info); 224 $i++; 225 } 226 $contacts_result['quickSearch_only_in_userSector'] = $quickSearch_only_in_userSector; 188 227 $contacts_result['maxResult'] = $ldapService->limit; 189 190 191 192 193 228 } 229 else 230 { 231 $options_users_from_user_org = ''; 232 $options = ''; 194 233 195 234 196 197 198 199 200 201 202 235 $i = 0; 236 foreach ($tmp_users_from_user_org as $info => $cn) 237 { 238 $contacts_result[$i] = array(); 239 $options_users_from_user_org .= $this->make_quicksearch_card($info, $cn); 240 $i++; 241 } 203 242 204 243 205 206 207 208 209 210 211 212 213 214 {215 216 217 218 219 220 221 222 223 224 225 226 227 228 244 foreach ($tmp as $info => $cn) 245 { 246 $contacts_result[$i] = array(); 247 $options .= $this->make_quicksearch_card($info, $cn); 248 $i++; 249 } 250 251 252 if (($options_users_from_user_org != '') && ($options != '')) 253 { 254 $head_option0 = 255 '<tr class="quicksearchcontacts_unselected">' . 256 '<td colspan="2" width="100%" align="center" style="background:#EEEEEE"><B>' . 257 $this->functions->getLang('Users from your organization') . '</B> ['.count($tmp_users_from_user_org).']'; 258 '</td>' . 259 '</tr>'; 260 261 $head_option1 = 262 '<tr class="quicksearchcontacts_unselected">' . 263 '<td colspan="2" width="100%" align="center" style="background:#EEEEEE"><B>' . 264 $this->functions->getLang('Users from others organizations') . '</B> ['.count($tmp).']'; 265 '</td>' . 266 '</tr>'; 267 } 229 268 230 269 $head_option = ''; … … 238 277 $contacts_result = $head_option.$head_option0 . $options_users_from_user_org . $head_option1. $options; 239 278 240 }241 242 243 244 245 279 } 280 } 281 282 ldap_close($this->ds); 283 284 return $contacts_result; 246 285 } 247 286 … … 385 424 //Busca usuarios de um contexto e ja retorna as options do select - usado por template serpro; 386 425 function search_users($params) 387 {388 426 { 427 $owner = $_SESSION['phpgw_info']['expressomail']['user']['owner']; 389 428 $ldapService = ServiceLocator::getService('ldap'); 390 429 $ldapService->connect($_SESSION['phpgw_info']['expressomail']['server']['ldap_host'], 391 430 $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_dn'], 392 431 $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_pw']); 393 432 394 433 $groups = $ldapService->accountSearch($params['filter'], array("gidNumber","cn"), $params['context'] , 'g', 'cn'); 395 434 $users = $ldapService->accountSearch($params['filter'], array("uidNumber","cn"), $params['context'] , 'u', 'cn'); … … 397 436 $user_options = array(); 398 437 foreach($groups as $group) 399 438 { 400 439 $group_options[] = '"'.$group['gidNumber'].'U'.'":"'.$group['cn'].'"'; 401 440 } 402 441 403 442 foreach($users as $user) 404 {443 { 405 444 if($owner != $user['uidNumber']) 406 445 $user_options[] = '"'.$user['uidNumber'].'U'.'":"'.$user['cn'].'"'; 407 408 446 } 447 409 448 $user_options = '{'.implode( ',', $user_options ).'}'; 410 449 $group_options = '{'.implode( ',', $group_options ).'}'; 411 450 412 451 return array("users" => $user_options, "groups" => $group_options); 413 }452 } 414 453 415 454 function catalogsearch($params) … … 420 459 $catalog = $params['catalog']; 421 460 $error = False; 422 461 423 462 //if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['extended_info']) 424 463 //$extendedinfo=true; … … 432 471 433 472 if ($this->ds) { 434 $justthese = array("cn", "mail", "phpgwaccounttype", "phpgwAccountVisible", "employeeNumber", "ou");473 $justthese = array("cn", "mail", "phpgwaccounttype", "phpgwAccountVisible", "employeeNumber", "ou"); 435 474 $sr=@ldap_search($this->ds, $user_context, $filter, $justthese, 0, $ldapService->limit+1); 436 475 437 476 if(!$sr) 438 477 return null; … … 571 610 $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_dn'], 572 611 $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_pw']); 573 612 574 613 $entries = $ldapService->accountSearch($params['sentence'], array('cn', 'uid'), $params['context'], 'u', 'cn'); 575 614 576 615 $options = array(); 577 616 578 617 foreach ($entries as $value) 579 618 $options[] = '"'.$value['uid'].'"'.':'.'"'.$value['cn'].'"'; 580 619 581 620 return "{".implode(',',$options)."}"; 582 }621 } 583 622 584 623 function uid2cn($uid) -
trunk/expressoMail1_2/js/common_functions.js
r4855 r4929 607 607 608 608 if (search_for.length < preferences.search_characters_number){ 609 alert(get_lang('Your search argument must be longer than %1 characters.', preferences.search_characters_number)); 609 //alert(get_lang('Your search argument must be longer than %1 characters.', preferences.search_characters_number)); 610 alert(get_lang('Your search argument must be longer than %1 characters. Use quotes to refine your search', preferences.search_characters_number)); 610 611 return false; 611 612 } -
trunk/expressoMail1_2/setup/phpgw_pt-br.lang
r4843 r4929 622 622 Your message was sent to queue expressoMail1_2 pt-br Sua mensagem foi enviada com sucesso para a fila 623 623 Your search argument must be longer than %1 characters. expressoMail1_2 pt-br Seus argumentos para a pesquisa precisam ter mais que %1 dígitos. 624 Your search argument must be longer than %1 characters. Use quotes to refine your search expressoMail1_2 pt-br Seus argumentos para a pesquisa precisam ter mais que %1 dígitos. Use aspas para refinar a sua pesquisa. 624 625 Your session could not be verified. expressoMail1_2 pt-br Sua sessão expirou. Entre novamente no Expresso. 625 626 Your Spam folder was empty. expressoMail1_2 pt-br Sua pasta Spam foi limpa.
Note: See TracChangeset
for help on using the changeset viewer.