[387] | 1 | <?php |
---|
[5509] | 2 | /*************************************************************************** |
---|
| 3 | * Expresso Livre * |
---|
| 4 | * http://www.expressolivre.org * |
---|
| 5 | * -------------------------------------------- * |
---|
| 6 | * This program is free software; you can redistribute it and/or modify it * |
---|
| 7 | * under the terms of the GNU General Public License as published by the * |
---|
| 8 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
| 9 | * option) any later version. * |
---|
| 10 | \**************************************************************************/ |
---|
| 11 | |
---|
[5399] | 12 | require_once(dirname(__FILE__).'/../../services/class.servicelocator.php'); |
---|
[176] | 13 | include_once("class.imap_functions.inc.php"); |
---|
[342] | 14 | include_once("class.functions.inc.php"); |
---|
[176] | 15 | |
---|
| 16 | function ldapRebind($ldap_connection, $ldap_url) |
---|
| 17 | { |
---|
| 18 | @ldap_bind($ldap_connection, $_SESSION['phpgw_info']['expressomail']['ldap_server']['acc'],$_SESSION['phpgw_info']['expressomail']['ldap_server']['pw']); |
---|
| 19 | } |
---|
[387] | 20 | |
---|
[2] | 21 | class ldap_functions |
---|
| 22 | { |
---|
| 23 | var $ds; |
---|
| 24 | var $ldap_host; |
---|
| 25 | var $ldap_context; |
---|
| 26 | var $imap; |
---|
[342] | 27 | var $external_srcs; |
---|
| 28 | var $max_result; |
---|
| 29 | var $functions; |
---|
[4457] | 30 | var $ldapService; |
---|
| 31 | |
---|
[342] | 32 | function ldap_functions(){ |
---|
| 33 | // todo: Page Configuration for External Catalogs. |
---|
| 34 | @include("../contactcenter/setup/external_catalogs.inc.php"); |
---|
[4457] | 35 | $this->ldapService = ServiceLocator::getService('ldap'); |
---|
[5134] | 36 | if(isset($external_srcs)) |
---|
[4457] | 37 | $this->external_srcs = $external_srcs; |
---|
| 38 | $this->max_result = $this->ldapService->limit; |
---|
[387] | 39 | $this->functions = new functions(); |
---|
| 40 | } |
---|
[342] | 41 | // Using ContactCenter configuration. |
---|
| 42 | function ldapConnect($refer = false,$catalog = 0){ |
---|
| 43 | if ($catalog > 0 && is_array($this->external_srcs)){ |
---|
| 44 | $this->ldap_host = $this->external_srcs[$catalog]['host']; |
---|
| 45 | $this->ldap_context = $this->external_srcs[$catalog]['dn']; |
---|
| 46 | $this->bind_dn = $this->external_srcs[$catalog]['acc']; |
---|
| 47 | $this->bind_dn_pw = $this->external_srcs[$catalog]['pw']; |
---|
| 48 | $this->object_class = $this->external_srcs[$catalog]['obj']; |
---|
| 49 | $this->base_dn = $this->external_srcs[$catalog]['dn']; |
---|
| 50 | $this->branch = $this->external_srcs[$catalog]['branch']; |
---|
| 51 | }else { |
---|
[325] | 52 | $this->ldap_host = $_SESSION['phpgw_info']['expressomail']['ldap_server']['host']; |
---|
| 53 | $this->ldap_context = $_SESSION['phpgw_info']['expressomail']['ldap_server']['dn']; |
---|
| 54 | $this->bind_dn = $_SESSION['phpgw_info']['expressomail']['ldap_server']['acc']; |
---|
| 55 | $this->bind_dn_pw = $_SESSION['phpgw_info']['expressomail']['ldap_server']['pw']; |
---|
[387] | 56 | $this->branch = 'ou'; |
---|
[325] | 57 | } |
---|
[387] | 58 | |
---|
[325] | 59 | $this->ds = ldap_connect($this->ldap_host); |
---|
[2] | 60 | ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3); |
---|
[37] | 61 | ldap_set_option($this->ds, LDAP_OPT_REFERRALS, $refer); |
---|
[342] | 62 | if ($refer) { |
---|
[176] | 63 | ldap_set_rebind_proc($this->ds, ldapRebind); |
---|
| 64 | } |
---|
[387] | 65 | @ldap_bind($this->ds,$this->bind_dn,$this->bind_dn_pw ); |
---|
[2] | 66 | } |
---|
| 67 | |
---|
[205] | 68 | //Teste jakjr retornando o DS |
---|
| 69 | function ldapConnect2($refer = false){ |
---|
| 70 | $ds = ldap_connect($_SESSION['phpgw_info']['expressomail']['ldap_server']['host']); |
---|
[387] | 71 | |
---|
[205] | 72 | if (!$ds) |
---|
| 73 | return false; |
---|
[387] | 74 | |
---|
[205] | 75 | ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); |
---|
| 76 | ldap_set_option($ds, LDAP_OPT_REFERRALS, $refer); |
---|
| 77 | if ($refer) |
---|
[5134] | 78 | ldap_set_rebind_proc($ds, 'rebind'); |
---|
[205] | 79 | @ldap_bind($ds, $_SESSION['phpgw_info']['expressomail']['ldap_server']['acc'],$_SESSION['phpgw_info']['expressomail']['ldap_server']['pw']); |
---|
[387] | 80 | |
---|
| 81 | return $ds; |
---|
[205] | 82 | } |
---|
| 83 | |
---|
| 84 | |
---|
[108] | 85 | // usa o host e context do setup. |
---|
[2] | 86 | function ldapRootConnect($refer = false){ |
---|
| 87 | $this->ldap_host = $_SESSION['phpgw_info']['expressomail']['server']['ldap_host']; |
---|
| 88 | $this->ldap_context = $_SESSION['phpgw_info']['expressomail']['server']['ldap_context']; |
---|
| 89 | |
---|
[7228] | 90 | if( isset($_SESSION['phpgw_info']['expressomail']['server']['ldap_master_host']) && |
---|
| 91 | isset($_SESSION['phpgw_info']['expressomail']['server']['ldap_master_root_dn']) && |
---|
| 92 | isset($_SESSION['phpgw_info']['expressomail']['server']['ldap_master_root_pw']) && |
---|
| 93 | $_SESSION['phpgw_info']['expressomail']['server']['ldap_master_host'] && |
---|
[5821] | 94 | $_SESSION['phpgw_info']['expressomail']['server']['ldap_master_root_dn'] && |
---|
| 95 | $_SESSION['phpgw_info']['expressomail']['server']['ldap_master_root_pw']) { |
---|
| 96 | $this->ds = ldap_connect($_SESSION['phpgw_info']['expressomail']['server']['ldap_master_host']); |
---|
| 97 | ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3); |
---|
| 98 | ldap_set_option($this->ds, LDAP_OPT_REFERRALS,0); |
---|
| 99 | ldap_bind($this->ds, $_SESSION['phpgw_info']['expressomail']['server']['ldap_master_root_dn'], $_SESSION['phpgw_info']['expressomail']['server']['ldap_master_root_pw']); |
---|
| 100 | }else{ |
---|
| 101 | $this->ds = ldap_connect($this->ldap_host); |
---|
| 102 | ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3); |
---|
| 103 | ldap_set_option($this->ds, LDAP_OPT_REFERRALS, $refer); |
---|
| 104 | ldap_bind($this->ds, $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_dn'],$_SESSION['phpgw_info']['expressomail']['server']['ldap_root_pw']); |
---|
| 105 | } |
---|
[2] | 106 | } |
---|
| 107 | |
---|
| 108 | function quicksearch($params) |
---|
[387] | 109 | { |
---|
[95] | 110 | include_once("class.functions.inc.php"); |
---|
[387] | 111 | $functions = new functions; |
---|
[4929] | 112 | |
---|
[2] | 113 | $field = $params['field']; |
---|
| 114 | $ID = $params['ID']; |
---|
[4929] | 115 | |
---|
[7228] | 116 | $ldapService = ServiceLocator::getService('ldap'); |
---|
| 117 | $filter = $ldapService->getSearchFilter($params['search_for']); |
---|
[4929] | 118 | |
---|
[2] | 119 | $contacts_result = array(); |
---|
| 120 | $contacts_result['field'] = $field; |
---|
| 121 | $contacts_result['ID'] = $ID; |
---|
[5199] | 122 | $search_for = utf8_encode($params['search_for']); |
---|
| 123 | |
---|
| 124 | if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['extended_info']) |
---|
| 125 | $extendedinfo=true; |
---|
| 126 | else |
---|
| 127 | $extendedinfo=false; |
---|
[5237] | 128 | |
---|
[2] | 129 | // follow the referral |
---|
| 130 | $this->ldapConnect(true); |
---|
[4929] | 131 | |
---|
[2] | 132 | if ($this->ds) |
---|
[4929] | 133 | { |
---|
[7228] | 134 | $ldapService->connection = $this->ds; |
---|
| 135 | if($extendedinfo) |
---|
| 136 | $justthese = array("cn", "mail", "telephonenumber", "uid","uidNumber", "mobile", "phpgwaccountvisible", "employeenumber", "ou"); |
---|
| 137 | else |
---|
| 138 | $justthese = array("cn", "mail", "telephoneNumber", "phpgwAccountVisible", "uidNumber","uid"); |
---|
| 139 | $types = false; |
---|
[387] | 140 | |
---|
[7228] | 141 | if( $field == 'null' || $ID == 'null' ) |
---|
[4929] | 142 | { |
---|
[7228] | 143 | $justthese[] = "jpegphoto"; |
---|
| 144 | $types = 'u'; |
---|
| 145 | } |
---|
[387] | 146 | |
---|
[4457] | 147 | $filter = $ldapService->getSearchFilter( $params['search_for'], $types ); |
---|
[387] | 148 | |
---|
[4457] | 149 | $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result); |
---|
| 150 | |
---|
[7228] | 151 | if(!$sr) |
---|
| 152 | return null; |
---|
[4457] | 153 | |
---|
[7228] | 154 | $count_entries = ldap_count_entries($this->ds,$sr); |
---|
[4457] | 155 | |
---|
[7228] | 156 | $info = ldap_get_entries($this->ds, $sr); |
---|
| 157 | |
---|
[4457] | 158 | // New search only on user sector |
---|
[5238] | 159 | if ($count_entries == $this->max_result) |
---|
[4457] | 160 | { |
---|
[7228] | 161 | $overload = $count_entries; |
---|
| 162 | } |
---|
| 163 | else |
---|
| 164 | { |
---|
| 165 | $catalogsNum=count($this->external_srcs); |
---|
| 166 | for ($i=0; $i<=$catalogsNum; $i++) { |
---|
[5245] | 167 | if ($this->external_srcs[$i]["quicksearch"]) { |
---|
[4929] | 168 | $this->ldapConnect(true,$i); |
---|
| 169 | $filter="(|(cn=*$search_for*)(mail=*$search_for*))"; |
---|
[5199] | 170 | if($extendedinfo) |
---|
[7228] | 171 | $justthese = array("cn", "mail", "telephonenumber", "uid","uidNumber", "mobile", "phpgwaccountvisible", "employeenumber", "ou"); |
---|
[5199] | 172 | else |
---|
[5245] | 173 | $justthese = array("cn", "mail", "telephoneNumber", "phpgwAccountVisible","uidNumber", "uid"); |
---|
[4929] | 174 | $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result+1); |
---|
| 175 | if(!$sr) |
---|
| 176 | return null; |
---|
| 177 | $count_entries = ldap_count_entries($this->ds,$sr); |
---|
| 178 | $search = ldap_get_entries($this->ds, $sr); |
---|
| 179 | for ($j=0; $j<$search["count"]; $j++) { |
---|
| 180 | $info[] = $search[$j]; |
---|
| 181 | } |
---|
| 182 | $info["count"] = count($info)-1; |
---|
| 183 | } |
---|
[108] | 184 | } |
---|
[95] | 185 | } |
---|
[387] | 186 | |
---|
[7228] | 187 | $tmp = array(); |
---|
| 188 | $tmp_users_from_user_org = array(); |
---|
[387] | 189 | |
---|
[7228] | 190 | for ($i=0; $i<$info["count"]; $i++) |
---|
| 191 | { |
---|
| 192 | $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]; |
---|
[7083] | 193 | |
---|
[7228] | 194 | if (/*(!$quickSearch_only_in_userSector) &&*/ preg_match("/$user_sector_dn/i", $info[$i]['dn'])) |
---|
[4929] | 195 | { |
---|
[7228] | 196 | $tmp_users_from_user_org[$key] = utf8_decode($info[$i]["cn"][0]); |
---|
| 197 | continue; |
---|
| 198 | } |
---|
[387] | 199 | |
---|
[7228] | 200 | $tmp[$key] = utf8_decode($info[$i]["cn"][0]); |
---|
| 201 | } |
---|
[342] | 202 | |
---|
[4929] | 203 | natcasesort($tmp_users_from_user_org); |
---|
| 204 | natcasesort($tmp); |
---|
[387] | 205 | |
---|
[4929] | 206 | if (($field != 'null') && ($ID != 'null')) |
---|
| 207 | { |
---|
| 208 | $i = 0; |
---|
[387] | 209 | |
---|
[4929] | 210 | $tmp = array_merge($tmp, $tmp_users_from_user_org); |
---|
| 211 | natcasesort($tmp); |
---|
[271] | 212 | |
---|
[4929] | 213 | foreach ($tmp as $info => $cn) |
---|
| 214 | { |
---|
| 215 | $contacts_result[$i] = array(); |
---|
| 216 | $contacts_result[$i]["cn"] = $cn; |
---|
[6057] | 217 | 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"]) = preg_split('/%/', $info); |
---|
[4929] | 218 | $i++; |
---|
| 219 | } |
---|
| 220 | $contacts_result['quickSearch_only_in_userSector'] = $quickSearch_only_in_userSector; |
---|
[7228] | 221 | $contacts_result['maxResult'] = $ldapService->limit; |
---|
[4929] | 222 | } |
---|
| 223 | else |
---|
| 224 | { |
---|
| 225 | $options_users_from_user_org = ''; |
---|
| 226 | $options = ''; |
---|
[271] | 227 | |
---|
[4457] | 228 | |
---|
[4929] | 229 | $i = 0; |
---|
| 230 | foreach ($tmp_users_from_user_org as $info => $cn) |
---|
| 231 | { |
---|
| 232 | $contacts_result[$i] = array(); |
---|
| 233 | $options_users_from_user_org .= $this->make_quicksearch_card($info, $cn); |
---|
| 234 | $i++; |
---|
| 235 | } |
---|
[387] | 236 | |
---|
[4457] | 237 | |
---|
[4929] | 238 | foreach ($tmp as $info => $cn) |
---|
| 239 | { |
---|
| 240 | $contacts_result[$i] = array(); |
---|
| 241 | $options .= $this->make_quicksearch_card($info, $cn); |
---|
| 242 | $i++; |
---|
| 243 | } |
---|
[271] | 244 | |
---|
[4457] | 245 | |
---|
[4929] | 246 | if (($options_users_from_user_org != '') && ($options != '')) |
---|
| 247 | { |
---|
| 248 | $head_option0 = |
---|
| 249 | '<tr class="quicksearchcontacts_unselected">' . |
---|
| 250 | '<td colspan="2" width="100%" align="center" style="background:#EEEEEE"><B>' . |
---|
| 251 | $this->functions->getLang('Users from your organization') . '</B> ['.count($tmp_users_from_user_org).']'; |
---|
| 252 | '</td>' . |
---|
| 253 | '</tr>'; |
---|
[4457] | 254 | |
---|
[4929] | 255 | $head_option1 = |
---|
| 256 | '<tr class="quicksearchcontacts_unselected">' . |
---|
| 257 | '<td colspan="2" width="100%" align="center" style="background:#EEEEEE"><B>' . |
---|
| 258 | $this->functions->getLang('Users from others organizations') . '</B> ['.count($tmp).']'; |
---|
| 259 | '</td>' . |
---|
| 260 | '</tr>'; |
---|
| 261 | } |
---|
[4457] | 262 | |
---|
| 263 | $head_option = ''; |
---|
| 264 | |
---|
| 265 | if( $overload ) |
---|
| 266 | $head_option = '<tr class="quicksearchcontacts_unselected">' . |
---|
| 267 | '<td colspan="2" width="100%" align="center" style="background:#EEEEEE; color: red;"><B>' .str_replace('%1', $this->max_result, $this->functions->getLang('More than %1 results. Please, try to refine your search.')) . '</B> '. |
---|
| 268 | '</td>' . |
---|
| 269 | '</tr>'; |
---|
| 270 | |
---|
| 271 | $contacts_result = $head_option.$head_option0 . $options_users_from_user_org . $head_option1. $options; |
---|
| 272 | |
---|
[4929] | 273 | } |
---|
| 274 | } |
---|
[4457] | 275 | |
---|
[4929] | 276 | ldap_close($this->ds); |
---|
| 277 | return $contacts_result; |
---|
[2] | 278 | } |
---|
| 279 | |
---|
[5075] | 280 | |
---|
| 281 | /** |
---|
| 282 | * Método que faz o roteamento entre os métodos de busca (Catálogo pessoal, global e todos) |
---|
| 283 | * @license http://www.gnu.org/copyleft/gpl.html GPL |
---|
| 284 | * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) |
---|
| 285 | * @sponsor Caixa Econômica Federal |
---|
| 286 | * @author Prognus Software Livre <airton@prognus.com.br | prognus@prognus.com.br> |
---|
| 287 | * @param <array> <$param> <parametros vindos do cliente> |
---|
| 288 | */ |
---|
| 289 | function quicksearchcontact($params) |
---|
| 290 | { |
---|
[5209] | 291 | if(array_key_exists('Type', $params)){ |
---|
[5196] | 292 | return $this->quickSearch($params); |
---|
| 293 | } |
---|
[5202] | 294 | |
---|
[5075] | 295 | $modal = false; |
---|
| 296 | if($params['catalog']) |
---|
| 297 | $modal = true; |
---|
| 298 | |
---|
[5316] | 299 | include_once dirname(__FILE__). '/../../header.inc.php'; |
---|
[5075] | 300 | |
---|
| 301 | if($modal) |
---|
| 302 | { |
---|
| 303 | if($params['catalog'] == "global") |
---|
| 304 | { |
---|
| 305 | return $this->quickSearchGlobal($params); |
---|
| 306 | } |
---|
| 307 | else |
---|
| 308 | { |
---|
| 309 | if($params['catalog'] == "personal") |
---|
| 310 | return $this->quickSearchPersonal($params); |
---|
| 311 | else |
---|
| 312 | return $this->quickSearchAll($params); |
---|
| 313 | } |
---|
| 314 | } |
---|
| 315 | else |
---|
| 316 | { |
---|
| 317 | if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['catalog_search'] == "global") |
---|
| 318 | { |
---|
| 319 | return $this->quickSearchGlobal($params); |
---|
| 320 | } |
---|
| 321 | else |
---|
| 322 | { |
---|
| 323 | if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['catalog_search'] == "personal") |
---|
| 324 | return $this->quickSearchPersonal($params); |
---|
| 325 | else |
---|
| 326 | //Veirifica se quem chamou foi o campo de pesquisa rápida Expresso_Mail |
---|
| 327 | if(($params['field'] == 'null') && ($params['ID'] == 'null')) |
---|
| 328 | return $this->quickSearch($params); |
---|
| 329 | else |
---|
[7228] | 330 | return $this->quickSearchAll($params); |
---|
[5075] | 331 | } |
---|
| 332 | } |
---|
| 333 | } |
---|
| 334 | |
---|
| 335 | |
---|
| 336 | |
---|
| 337 | /** |
---|
| 338 | * Método que faz a busca de usuários em todos os catálogos |
---|
| 339 | * @license http://www.gnu.org/copyleft/gpl.html GPL |
---|
| 340 | * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) |
---|
| 341 | * @sponsor Caixa Econômica Federal |
---|
[7228] | 342 | * @author ProgquickSearchAllnus Software Livre <airton@prognus.com.br | prognus@prognus.com.br> |
---|
[5075] | 343 | * @param <array> <$param> <parametros vindos do cliente> |
---|
| 344 | * @return <array> <$retorno> <Array com os usuários de todos os catálogos, de acordo com o parâmetro> |
---|
| 345 | */ |
---|
| 346 | function quickSearchAll($params) |
---|
| 347 | { |
---|
| 348 | |
---|
| 349 | $retorno_personal = $this->quickSearchPersonal($params); |
---|
| 350 | $retorno_global = $this->quickSearchGlobal($params); |
---|
| 351 | //$retorno = $retorno_personal + $retorno_global; |
---|
| 352 | $retorno = array_merge($retorno_personal, $retorno_global); |
---|
[5172] | 353 | |
---|
[5075] | 354 | $retorno['type_catalog'] = "A"; |
---|
[5172] | 355 | $retorno['search_for'] = $params['search_for']; |
---|
[5075] | 356 | return $retorno; |
---|
| 357 | } |
---|
| 358 | |
---|
| 359 | |
---|
| 360 | /** |
---|
| 361 | * Método que faz a busca de usuários no Catálogo Pessoal |
---|
| 362 | * @license http://www.gnu.org/copyleft/gpl.html GPL |
---|
| 363 | * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) |
---|
| 364 | * @sponsor Caixa Econômica Federal |
---|
| 365 | * @author Prognus Software Livre <airton@prognus.com.br | prognus@prognus.com.br> |
---|
| 366 | * @param <array> <$param> <parametros vindos do cliente> |
---|
| 367 | * @return <array> <$retorno> <Array com os usuários do Catálogo Pessoal, de acordo com o parâmetro> |
---|
| 368 | */ |
---|
| 369 | function quickSearchPersonal($params, $all=false) |
---|
| 370 | { |
---|
| 371 | $results = array(); |
---|
| 372 | $DBService = ServiceLocator::getService('db'); |
---|
| 373 | $results = $DBService->search_contacts($params['search_for']); |
---|
[5209] | 374 | $results2 = array(); |
---|
[5172] | 375 | $results2 = $DBService->search_groups($params['search_for']); |
---|
[5075] | 376 | |
---|
[5209] | 377 | if(is_array($results)){ |
---|
| 378 | if(is_array($results2)){ |
---|
| 379 | $results = array_merge($results, $results2); |
---|
| 380 | } |
---|
| 381 | } |
---|
| 382 | else if(is_array($results2)){ |
---|
| 383 | $results = $results2; |
---|
| 384 | } |
---|
| 385 | |
---|
[5075] | 386 | if(!$all) |
---|
| 387 | $results['type_catalog'] = "P"; |
---|
[5134] | 388 | |
---|
| 389 | foreach($results as $i=>$value) |
---|
| 390 | $results[$i]['type_contact'] = "P"; |
---|
| 391 | |
---|
[5172] | 392 | $results['search_for'] = $params['search_for']; |
---|
[5209] | 393 | |
---|
[5075] | 394 | return $results; |
---|
| 395 | } |
---|
| 396 | |
---|
| 397 | |
---|
| 398 | /** |
---|
| 399 | * Método que faz a busca de usuários no Catálogo Geral |
---|
| 400 | * @license http://www.gnu.org/copyleft/gpl.html GPL |
---|
| 401 | * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) |
---|
| 402 | * @sponsor Caixa Econômica Federal |
---|
| 403 | * @author Prognus Software Livre <airton@prognus.com.br | prognus@prognus.com.br> |
---|
| 404 | * @param <array> <$param> <parametros vindos do cliente> |
---|
| 405 | * @return <array> <$retorno> <Array com os usuários do Catálogo Global, de acordo com o parâmetro> |
---|
| 406 | */ |
---|
[7228] | 407 | function quickSearchGlobal($params, $all=false) |
---|
[5075] | 408 | { |
---|
[5316] | 409 | include_once dirname(__FILE__). '/../../header.inc.php'; |
---|
[5075] | 410 | $c = CreateObject('phpgwapi.config','contactcenter'); |
---|
| 411 | $all_data = $c->read_repository(); |
---|
| 412 | |
---|
| 413 | $searchable_fields = array(); |
---|
| 414 | foreach($all_data as $index => $value) |
---|
| 415 | { |
---|
| 416 | $parts = explode('_', $index); |
---|
| 417 | if (is_numeric($parts[3]) && $parts[1]=='attribute') |
---|
| 418 | { |
---|
[5134] | 419 | if($parts[2] == 'searchable' /*&& $value == 'true'*/) |
---|
[5075] | 420 | $searchable_fields[$all_data['cc_attribute_ldapname_' . $parts[3]]] = $all_data['cc_attribute_name_' . $parts[3]]; |
---|
| 421 | } |
---|
| 422 | } |
---|
| 423 | include_once("class.functions.inc.php"); |
---|
| 424 | $functions = new functions; |
---|
| 425 | $field = $params['field']; |
---|
| 426 | $ID = $params['ID']; |
---|
| 427 | $ldapService = ServiceLocator::getService('ldap'); |
---|
| 428 | $filter = $ldapService->getSearchFilter($params['search_for']); |
---|
| 429 | |
---|
| 430 | $contacts_result = array(); |
---|
| 431 | $contacts_result['field'] = $field; |
---|
| 432 | $contacts_result['ID'] = $ID; |
---|
| 433 | $search_for = utf8_encode($params['search_for']); |
---|
| 434 | |
---|
| 435 | $this->ldapConnect(true); |
---|
| 436 | if ($this->ds) |
---|
| 437 | { |
---|
| 438 | $ldapService->connection = $this->ds; |
---|
| 439 | $campos_extras = ''; |
---|
[6754] | 440 | $justthese = array("cn", "mail", "telephonenumber", "mobile", "phpgwaccountvisible", "uid", "employeenumber", "ou","vacationActive","vacationInfo"); |
---|
[5075] | 441 | foreach($searchable_fields as $fields_ldap => $value_field) |
---|
| 442 | { |
---|
| 443 | $campos_extras .= $fields_ldap . "|" . $value_field . "#"; |
---|
| 444 | array_push($justthese, $fields_ldap); |
---|
| 445 | } |
---|
| 446 | $types = false; |
---|
| 447 | |
---|
| 448 | $campos_extras = substr($campos_extras,0,-1); |
---|
| 449 | |
---|
| 450 | if($field == 'null' || $ID == 'null') |
---|
| 451 | { |
---|
| 452 | $justthese[] = "jpegphoto"; |
---|
| 453 | $types = 'u'; |
---|
| 454 | } |
---|
| 455 | $filter = $ldapService->getSearchFilter($params['search_for'], $types); |
---|
[5513] | 456 | // Retirei o this->max_result, que limitava a busca. Agora ta retornando tudo amigo. |
---|
| 457 | $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result); |
---|
[5075] | 458 | |
---|
| 459 | if(!$sr) |
---|
| 460 | return null; |
---|
| 461 | |
---|
| 462 | $count_entries = ldap_count_entries($this->ds,$sr); |
---|
| 463 | $info = ldap_get_entries($this->ds, $sr); |
---|
| 464 | $info_return = $info; |
---|
| 465 | //if($campos_extras != '') |
---|
| 466 | //array_push($info_return, $campos_extras); |
---|
| 467 | } |
---|
| 468 | ldap_close($this->ds); |
---|
[5199] | 469 | |
---|
[5075] | 470 | //Busca em Catalagos externos |
---|
| 471 | $catalogsNum=count($this->external_srcs); |
---|
| 472 | for ($i=0; $i<=$catalogsNum; $i++) { |
---|
| 473 | if ($this->external_srcs[$i]["quicksearch"]) |
---|
| 474 | { |
---|
| 475 | $this->ldapConnect(true,$i); |
---|
| 476 | $filter="(|(cn=*$search_for*)(mail=*$search_for*))"; |
---|
[6754] | 477 | $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid","employeeNumber", "ou","vacationActive","vacationInfo"); |
---|
[5075] | 478 | $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result+1); |
---|
| 479 | if(!$sr) |
---|
| 480 | return null; |
---|
| 481 | $count_entries = ldap_count_entries($this->ds,$sr); |
---|
| 482 | $search = ldap_get_entries($this->ds, $sr); |
---|
| 483 | for ($j=0; $j<$search["count"]; $j++) { |
---|
[7228] | 484 | $search[$j]['isExternal'] = true; |
---|
| 485 | $info_return[] = $search[$j]; |
---|
[5075] | 486 | } |
---|
| 487 | $info_return["count"] = count($info_return)-1; |
---|
| 488 | } |
---|
| 489 | } |
---|
| 490 | //---------------------------------------------------------------// |
---|
[7228] | 491 | |
---|
[5075] | 492 | if($all == false) |
---|
| 493 | $info_return['type_catalog'] = "G"; |
---|
| 494 | |
---|
| 495 | $info_return['extra_ldap_fields'] = $campos_extras; |
---|
[5134] | 496 | |
---|
[7228] | 497 | foreach($info_return as &$value){ |
---|
| 498 | $value['type_contact'] = "G"; |
---|
[7083] | 499 | |
---|
[7228] | 500 | //Converte a descrição dos filtros para ISO8859 corrigindo inconsitências com caractéres especiais |
---|
| 501 | if(isset($value['vacationinfo']) && isset($value['vacationinfo'][0]) && $value['vacationinfo'][0] != '') |
---|
| 502 | $value['vacationinfo'][0] = $this->toISO8859($value['vacationinfo'][0]); |
---|
| 503 | } |
---|
[7083] | 504 | |
---|
[5172] | 505 | $info_return['search_for'] = $params['search_for']; |
---|
[7228] | 506 | return $info_return; |
---|
[5075] | 507 | } |
---|
| 508 | |
---|
[6754] | 509 | /*Converte um parametro de UTF-8 para ISO8859*/ |
---|
| 510 | function toISO8859($data) |
---|
| 511 | { |
---|
| 512 | if(!is_array($data)) |
---|
| 513 | return mb_convert_encoding( $data , 'ISO-8859-1' , 'UTF-8 , ISO-8859-1' ); |
---|
| 514 | $return = array(); |
---|
| 515 | foreach ($data as $i => $v) |
---|
| 516 | $return[$this->toISO8859($i)] = $this->toISO8859($v); |
---|
| 517 | return $return; |
---|
| 518 | } |
---|
| 519 | |
---|
[271] | 520 | function make_quicksearch_card($info, $cn) |
---|
| 521 | { |
---|
| 522 | include_once("class.functions.inc.php"); |
---|
[387] | 523 | $functions = new functions; |
---|
| 524 | |
---|
[271] | 525 | $contacts_result = array(); |
---|
| 526 | $contacts_result["cn"] = $cn; |
---|
[3388] | 527 | if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['extended_info']) |
---|
| 528 | $extendedinfo=true; |
---|
| 529 | else |
---|
| 530 | $extendedinfo=false; |
---|
[387] | 531 | |
---|
[6057] | 532 | list ($contacts_result["mail"], $contacts_result["phone"], $contacts_result["mobile"], $contacts_result["uid"], $contacts_result["jpegphoto"], $contacts_result["employeenumber"], $contacts_result["ou"]) = preg_split('/%/', $info); |
---|
[3388] | 533 | |
---|
[271] | 534 | if ($contacts_result['jpegphoto']) |
---|
| 535 | $photo_link = '<img src="./inc/show_user_photo.php?mail='.$contacts_result['mail'].'">'; |
---|
| 536 | else |
---|
[1495] | 537 | $photo_link = '<img src="./templates/default/images/photo.jpg">'; |
---|
[387] | 538 | |
---|
[271] | 539 | $phoneUser = $contacts_result['phone']; |
---|
[6139] | 540 | $mobileUser = $contacts_result["mobile"]; |
---|
| 541 | if($mobileUser){ |
---|
| 542 | $phoneUser .= " / $mobileUser"; |
---|
| 543 | } |
---|
| 544 | |
---|
| 545 | if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['voip_enabled']) { |
---|
| 546 | $phoneUser = $contacts_result['phone']; |
---|
| 547 | if($phoneUser) |
---|
| 548 | $phoneUser = '<a title="'.$this->functions->getLang("Call to Comercial Number").'" href="#" onclick="InfoContact.connectVoip(\''.$phoneUser.'\',\'com\')">'.$phoneUser.'</a>'; |
---|
| 549 | if($mobileUser) |
---|
| 550 | $phoneUser .= ' / <a title="'.$this->functions->getLang("Call to Mobile Number").'" href="#" onclick="InfoContact.connectVoip(\''.$mobileUser.'\',\'mob\')">'.$mobileUser.'</a>'; |
---|
| 551 | } |
---|
[387] | 552 | |
---|
[6139] | 553 | $empNumber = $contacts_result["employeenumber"]; |
---|
| 554 | if($empNumber) { |
---|
| 555 | $empNumber = "$empNumber - "; |
---|
[271] | 556 | } |
---|
[6139] | 557 | $ou = $contacts_result["ou"]; |
---|
| 558 | if($ou) { |
---|
| 559 | $ou = "<br/>$ou" ; |
---|
| 560 | } |
---|
[3388] | 561 | |
---|
[644] | 562 | // Begin: nickname, firstname and lastname for QuickAdd. |
---|
| 563 | $fn = $contacts_result["cn"]; |
---|
| 564 | $array_name = explode(" ", $fn); |
---|
| 565 | if(count($array_name) > 1){ |
---|
| 566 | $fn = $array_name[0]; |
---|
| 567 | array_shift($array_name); |
---|
| 568 | $sn = implode(" ",$array_name); |
---|
| 569 | } |
---|
| 570 | // End: |
---|
[271] | 571 | $option = |
---|
| 572 | '<tr class="quicksearchcontacts_unselected">' . |
---|
| 573 | '<td class="cc" width="1%">' . |
---|
[6754] | 574 | '<a title="'.$this->functions->getLang("Write message").'" onClick="javascript:QuickSearchUser.create_new_message(\''.$contacts_result["cn"].'\', \''.$contacts_result["mail"].'\', \''.$contacts_result["uid"].'\')">' . |
---|
[271] | 575 | $photo_link . |
---|
| 576 | '</a>' . |
---|
| 577 | '</td>' . |
---|
| 578 | '<td class="cc">' . |
---|
[5245] | 579 | '<span name="cn">' . ($empNumber != "" ? $empNumber : $uid) . $contacts_result['cn'] . '</span>' . '<br>' . |
---|
[6754] | 580 | '<a title="'.$functions->getLang("Write message").'" onClick="javascript:QuickSearchUser.create_new_message(\''.$contacts_result["cn"].'\', \''.$contacts_result["mail"].'\', \''.$contacts_result["uid"].'\')">' . |
---|
[271] | 581 | '<font color=blue>' . |
---|
[644] | 582 | '<span name="mail">' . $contacts_result['mail'] . '</span></a></font>'. |
---|
| 583 | '<img src="templates/default/images/user_card.png" style="cursor: pointer;" title="'.$this->functions->getLang("Add Contact").'" onclick="javascript:connector.loadScript(\'ccQuickAdd\');ccQuickAddOne.showList(\''.$fn.','.$fn.','.$sn.','.$contacts_result["mail"].'\')">'. |
---|
| 584 | '<br>' . |
---|
[271] | 585 | $phoneUser . |
---|
[3388] | 586 | $ou . |
---|
[271] | 587 | '</td>' . |
---|
[644] | 588 | '</tr>'; |
---|
[271] | 589 | return $option; |
---|
| 590 | } |
---|
| 591 | |
---|
[387] | 592 | function get_catalogs(){ |
---|
[325] | 593 | $catalogs = array(); |
---|
[387] | 594 | $catalogs[0] = $this->functions->getLang("Global Catalog"); |
---|
| 595 | if($this->external_srcs) |
---|
[342] | 596 | foreach ($this->external_srcs as $key => $valor ){ |
---|
[325] | 597 | $catalogs[$key] = $valor['name']; |
---|
| 598 | } |
---|
| 599 | return $catalogs; |
---|
| 600 | } |
---|
[2] | 601 | function get_organizations($params){ |
---|
| 602 | $organizations = array(); |
---|
[325] | 603 | $params['referral']?$referral = $params['referral']:$referral = false; |
---|
| 604 | $cat = $params['catalog']; |
---|
[2] | 605 | |
---|
[325] | 606 | $this->ldapConnect($referral,$cat); |
---|
| 607 | |
---|
| 608 | if($this->branch != '') { |
---|
[1363] | 609 | $filter="(&(".$this->branch."=*)(!(phpgwAccountVisible=-1)))"; |
---|
[325] | 610 | $justthese = array("$this->branch"); |
---|
[342] | 611 | $sr = ldap_list($this->ds, $this->ldap_context, $filter, $justthese); |
---|
| 612 | $info = ldap_get_entries($this->ds, $sr); |
---|
[387] | 613 | |
---|
[3530] | 614 | if($info["count"] == 0) |
---|
| 615 | { |
---|
| 616 | $organizations[0]['ou'] = $this->ldap_context; |
---|
| 617 | } |
---|
| 618 | |
---|
[342] | 619 | for ($i=0; $i<$info["count"]; $i++) |
---|
| 620 | $organizations[$i] = $info[$i]["ou"][0]; |
---|
[325] | 621 | |
---|
[342] | 622 | ldap_close($this->ds); |
---|
[387] | 623 | sort($organizations); |
---|
[342] | 624 | return $organizations; |
---|
[325] | 625 | }else{ |
---|
| 626 | return null; |
---|
[2] | 627 | } |
---|
[342] | 628 | } |
---|
[2] | 629 | function get_organizations2($params){ |
---|
| 630 | $organizations = array(); |
---|
| 631 | $referral = $params['referral']; |
---|
| 632 | $this->ldapRootConnect($referral); |
---|
| 633 | if ($this->ds) { |
---|
[3530] | 634 | $filter="(&(objectClass=organizationalUnit)(!(phpgwAccountVisible=-1)))"; |
---|
[2] | 635 | $justthese = array("ou"); |
---|
| 636 | $sr = ldap_list($this->ds, $this->ldap_context, $filter, $justthese); |
---|
| 637 | $info = ldap_get_entries($this->ds, $sr); |
---|
[387] | 638 | |
---|
[3530] | 639 | |
---|
| 640 | if($info["count"] == 0) |
---|
[2] | 641 | { |
---|
[3530] | 642 | $organizations[0]['ou'] = $this->ldap_context; |
---|
| 643 | $organizations[0]['dn'] = $this->ldap_context; |
---|
[2] | 644 | } |
---|
[3530] | 645 | else{ |
---|
| 646 | for ($i=0; $i<$info["count"]; $i++) |
---|
| 647 | { |
---|
| 648 | $organizations[$i]['ou'] = $info[$i]["ou"][0]; |
---|
| 649 | $organizations[$i]['dn'] = $info[$i]["dn"]; |
---|
| 650 | } |
---|
| 651 | } |
---|
[2] | 652 | ldap_close($this->ds); |
---|
[387] | 653 | sort($organizations); |
---|
[2] | 654 | } |
---|
| 655 | return $organizations; |
---|
| 656 | } |
---|
[925] | 657 | //Busca usuarios de um contexto e ja retorna as options do select - usado por template serpro; |
---|
| 658 | function search_users($params) |
---|
[4929] | 659 | { |
---|
| 660 | $owner = $_SESSION['phpgw_info']['expressomail']['user']['owner']; |
---|
[4457] | 661 | $ldapService = ServiceLocator::getService('ldap'); |
---|
| 662 | $ldapService->connect($_SESSION['phpgw_info']['expressomail']['server']['ldap_host'], |
---|
| 663 | $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_dn'], |
---|
| 664 | $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_pw']); |
---|
[4929] | 665 | |
---|
[5134] | 666 | $groups = $ldapService->accountSearch($params['filter'], array("gidNumber","cn", 'uid'), $params['context'] , 'g', 'cn'); |
---|
| 667 | $users = $ldapService->accountSearch($params['filter'], array("uidNumber","cn", 'uid'), $params['context'] , 'u', 'cn'); |
---|
| 668 | $compartilhadas = $ldapService->accountSearch($params['filter'], array("uidNumber","cn",'uid'), $params['context'] , 's', 'cn'); |
---|
| 669 | |
---|
| 670 | |
---|
[4457] | 671 | $group_options = array(); |
---|
| 672 | $user_options = array(); |
---|
[5134] | 673 | $shared_options = array(); |
---|
| 674 | |
---|
[4457] | 675 | foreach($groups as $group) |
---|
[4929] | 676 | { |
---|
[5134] | 677 | $group_options[] = '"'.$group['gidnumber'].'U'.'":"'.$group['cn'].' ('.$group['uid'].')"'; |
---|
[925] | 678 | } |
---|
[4457] | 679 | foreach($users as $user) |
---|
[4929] | 680 | { |
---|
[5134] | 681 | if($owner != $user['uidnumber']) |
---|
| 682 | $user_options[] = '"'.$user['uidnumber'].'U'.'":"'.$user['cn'].' ('.$user['uid'].')"'; |
---|
| 683 | } |
---|
| 684 | foreach($compartilhadas as $shared) |
---|
| 685 | { |
---|
| 686 | if($owner != $shared['uidnumber']) |
---|
| 687 | $shared_options[] = '"'.$shared['uidnumber'].'U'.'":"'.$shared['cn'].' ('.$shared['uid'].')"'; |
---|
[4929] | 688 | } |
---|
| 689 | |
---|
[4457] | 690 | $user_options = '{'.implode( ',', $user_options ).'}'; |
---|
| 691 | $group_options = '{'.implode( ',', $group_options ).'}'; |
---|
[5134] | 692 | $shared_options = '{'.implode( ',', $shared_options ).'}'; |
---|
[4929] | 693 | |
---|
[5134] | 694 | return '{"users":'.$user_options.',"groups":'.$group_options.',"shared":'. $shared_options .'}'; |
---|
[4929] | 695 | } |
---|
[925] | 696 | |
---|
[2] | 697 | function catalogsearch($params) |
---|
[387] | 698 | { |
---|
[4457] | 699 | $ldapService = ServiceLocator::getService('ldap'); |
---|
| 700 | $filter = $ldapService->getSearchFilter($params['search_for'],array('u','l','s')); |
---|
| 701 | |
---|
[325] | 702 | $catalog = $params['catalog']; |
---|
[2] | 703 | $error = False; |
---|
[4929] | 704 | |
---|
[4457] | 705 | //if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['extended_info']) |
---|
| 706 | //$extendedinfo=true; |
---|
| 707 | //else |
---|
| 708 | //$extendedinfo=false; |
---|
[387] | 709 | |
---|
[3388] | 710 | |
---|
[381] | 711 | $this->ldapConnect(true,$catalog); |
---|
[387] | 712 | |
---|
| 713 | $params['organization'] == 'all' ? $user_context = $this->ldap_context :$user_context = $this->branch."=".$params['organization'].",".$this->ldap_context; |
---|
| 714 | |
---|
| 715 | if ($this->ds) { |
---|
[4929] | 716 | $justthese = array("cn", "mail", "phpgwaccounttype", "phpgwAccountVisible", "employeeNumber", "ou"); |
---|
[4457] | 717 | $sr=@ldap_search($this->ds, $user_context, $filter, $justthese, 0, $ldapService->limit+1); |
---|
[4929] | 718 | |
---|
[342] | 719 | if(!$sr) |
---|
| 720 | return null; |
---|
[2] | 721 | $count_entries = ldap_count_entries($this->ds,$sr); |
---|
[4457] | 722 | if ($count_entries > $ldapService->limit){ |
---|
[2] | 723 | $info = null; |
---|
[387] | 724 | $error = True; |
---|
[2] | 725 | } |
---|
| 726 | else |
---|
[387] | 727 | $info = ldap_get_entries($this->ds, $sr); |
---|
| 728 | |
---|
| 729 | ldap_close($this->ds); |
---|
| 730 | |
---|
[2] | 731 | $u_tmp = array(); |
---|
| 732 | $g_tmp = array(); |
---|
[387] | 733 | |
---|
[2] | 734 | for ($i=0; $i<$info["count"]; $i++){ |
---|
[325] | 735 | if((!$catalog==0)||(strtoupper($info[$i]["phpgwaccounttype"][0]) == 'U') && ($info[$i]["phpgwaccountvisible"][0] != '-1')) |
---|
| 736 | //aqui eh feita a concatenacao do departamento ao cn; |
---|
| 737 | $u_tmp[$info[$i]["mail"][0]] = utf8_decode($info[$i]["cn"][0]). '%' . $info[$i]["ou"][0]; |
---|
[387] | 738 | if((!$catalog==0)||(strtoupper($info[$i]["phpgwaccounttype"][0]) == 'L') && ($info[$i]["phpgwaccountvisible"][0] != '-1')) |
---|
[325] | 739 | $g_tmp[$info[$i]["mail"][0]] = utf8_decode($info[$i]["cn"][0]); |
---|
[387] | 740 | } |
---|
| 741 | |
---|
[2] | 742 | natcasesort($u_tmp); |
---|
| 743 | natcasesort($g_tmp); |
---|
[387] | 744 | |
---|
[2] | 745 | $i = 0; |
---|
[387] | 746 | $users = array(); |
---|
[325] | 747 | |
---|
[387] | 748 | foreach ($u_tmp as $mail => $cn){ |
---|
| 749 | |
---|
[325] | 750 | $tmp = explode("%", $cn); //explode o cn pelo caracter "%" e joga em $tmp; |
---|
| 751 | $name = $tmp[0]; //pega o primeiro item (cn) do vetor resultante do explode acima; |
---|
| 752 | $department = $tmp[1]; //pega o segundo item (ou) do vetor resultanto do explode acima; |
---|
| 753 | $users[$i++] = array("name" => $name, "email" => $mail, "department" => $department); |
---|
| 754 | |
---|
[2] | 755 | } |
---|
| 756 | unset($u_tmp); |
---|
[387] | 757 | |
---|
| 758 | $i = 0; |
---|
[2] | 759 | $groups = array(); |
---|
[387] | 760 | |
---|
| 761 | foreach ($g_tmp as $mail => $cn){ |
---|
[2] | 762 | $groups[$i++] = array("name" => $cn, "email" => $mail); |
---|
| 763 | } |
---|
| 764 | unset($g_tmp); |
---|
[387] | 765 | |
---|
[4457] | 766 | return array('users' => $users, 'groups' => $groups, 'error' => $error,'maxResult' => $ldapService->limit); |
---|
[387] | 767 | }else |
---|
[2] | 768 | return null; |
---|
| 769 | } |
---|
[387] | 770 | |
---|
[2] | 771 | function get_emails_ldap(){ |
---|
| 772 | |
---|
| 773 | $result['mail']= array(); |
---|
[387] | 774 | $result['mailalter']= array(); |
---|
[2] | 775 | $user = $_SESSION['phpgw_info']['expressomail']['user']['account_lid']; |
---|
| 776 | $this->ldapRootConnect(false); |
---|
| 777 | if ($this->ds) { |
---|
[387] | 778 | $filter="uid=".$user; |
---|
[2] | 779 | $justthese = array("mail","mailAlternateAddress"); |
---|
| 780 | $sr = ldap_search($this->ds,$this->ldap_context, $filter, $justthese); |
---|
| 781 | $ent = ldap_get_entries($this->ds, $sr); |
---|
| 782 | ldap_close($this->ds); |
---|
[387] | 783 | |
---|
[2] | 784 | for ($i=0; $i<$ent["count"]; $i++){ |
---|
| 785 | $result['mail'][] = $ent[$i]["mail"][0]; |
---|
[387] | 786 | $result['mailalter'][] = $ent[$i]["mailalternateaddress"][0]; |
---|
[2] | 787 | } |
---|
| 788 | } |
---|
| 789 | return $result; |
---|
| 790 | } |
---|
[387] | 791 | |
---|
[342] | 792 | //Busca usuarios de um contexto e ja retorna as options do select; |
---|
[2] | 793 | function get_available_users($params) |
---|
[37] | 794 | { |
---|
| 795 | $this->ldapRootConnect(); |
---|
[342] | 796 | //Monta lista de Grupos e Usuarios |
---|
[37] | 797 | $users = Array(); |
---|
| 798 | $groups = Array(); |
---|
| 799 | $user_context= $params['context']; |
---|
| 800 | $owner = $_SESSION['phpgw_info']['expressomail']['user']['owner']; |
---|
[2] | 801 | |
---|
[37] | 802 | if ($this->ds) |
---|
| 803 | { |
---|
| 804 | $justthese = array("gidNumber","cn"); |
---|
| 805 | if ($params['type'] == 'search') |
---|
| 806 | $sr=ldap_search($this->ds, $user_context, ("(&(cn=*)(phpgwaccounttype=g)(!(phpgwaccountvisible=-1)))"),$justthese); |
---|
| 807 | else |
---|
| 808 | $sr=ldap_list($this->ds, $user_context, ("(&(cn=*)(phpgwaccounttype=g)(!(phpgwaccountvisible=-1)))"),$justthese); |
---|
| 809 | $info = ldap_get_entries($this->ds, $sr); |
---|
| 810 | for ($i=0; $i<$info["count"]; $i++) |
---|
[387] | 811 | $groups[$uids=$info[$i]["gidnumber"][0]] = Array('name' => $uids=$info[$i]["cn"][0], 'type' => g); |
---|
[37] | 812 | $justthese = array("phpgwaccountvisible","uidNumber","cn"); |
---|
| 813 | if ($params['type'] == 'search') |
---|
| 814 | $sr=ldap_search($this->ds, $user_context, ("(&(cn=*)(phpgwaccounttype=u)(!(phpgwaccountvisible=-1)))"),$justthese); |
---|
| 815 | else |
---|
| 816 | $sr=ldap_list($this->ds, $user_context, ("(&(cn=*)(phpgwaccounttype=u)(!(phpgwaccountvisible=-1)))"),$justthese); |
---|
[2] | 817 | |
---|
[37] | 818 | $info = ldap_get_entries($this->ds, $sr); |
---|
| 819 | for ($i=0; $i<$info["count"]; $i++) |
---|
| 820 | { |
---|
| 821 | if ($info[$i]["phpgwaccountvisible"][0] == '-1') |
---|
| 822 | continue; |
---|
| 823 | $users[$uids=$info[$i]["uidnumber"][0]] = Array('name' => $uids=$info[$i]["cn"][0], 'type' => u); |
---|
| 824 | } |
---|
| 825 | } |
---|
| 826 | ldap_close($this->ds); |
---|
[387] | 827 | |
---|
[37] | 828 | @asort($users); |
---|
[387] | 829 | @reset($users); |
---|
[37] | 830 | @asort($groups); |
---|
| 831 | @reset($groups); |
---|
| 832 | $user_options =''; |
---|
| 833 | $group_options =''; |
---|
[2] | 834 | |
---|
[37] | 835 | foreach($groups as $id => $user_array) { |
---|
| 836 | $newId = $id.'U'; |
---|
| 837 | $group_options .= '<option value="'.$newId.'">'.utf8_decode($user_array['name']).'</option>'."\n"; |
---|
| 838 | } |
---|
| 839 | foreach($users as $id => $user_array) { |
---|
| 840 | if($owner != $id){ |
---|
| 841 | $newId = $id.'U'; |
---|
| 842 | $user_options .= '<option value="'.$newId.'">'.utf8_decode($user_array['name']).'</option>'."\n"; |
---|
| 843 | } |
---|
| 844 | } |
---|
| 845 | return array("users" => $user_options, "groups" => $group_options); |
---|
| 846 | } |
---|
| 847 | |
---|
[342] | 848 | //Busca usuarios de um contexto e ja retorna as options do select; |
---|
[2] | 849 | function get_available_users2($params) |
---|
| 850 | { |
---|
[4457] | 851 | $ldapService = ServiceLocator::getService('ldap'); |
---|
| 852 | $ldapService->connect($_SESSION['phpgw_info']['expressomail']['server']['ldap_host'], |
---|
| 853 | $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_dn'], |
---|
| 854 | $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_pw']); |
---|
[4929] | 855 | |
---|
[4457] | 856 | $entries = $ldapService->accountSearch($params['sentence'], array('cn', 'uid'), $params['context'], 'u', 'cn'); |
---|
[4929] | 857 | |
---|
[4457] | 858 | $options = array(); |
---|
[4929] | 859 | |
---|
[4457] | 860 | foreach ($entries as $value) |
---|
| 861 | $options[] = '"'.$value['uid'].'"'.':'.'"'.$value['cn'].'"'; |
---|
[4929] | 862 | |
---|
[4457] | 863 | return "{".implode(',',$options)."}"; |
---|
[4929] | 864 | } |
---|
[387] | 865 | |
---|
[2] | 866 | function uid2cn($uid) |
---|
[387] | 867 | { |
---|
[2] | 868 | // do not follow the referral |
---|
| 869 | $this->ldapRootConnect(false); |
---|
| 870 | if ($this->ds) |
---|
| 871 | { |
---|
[387] | 872 | $filter="(&(phpgwAccountType=u)(uid=$uid))"; |
---|
[2] | 873 | $justthese = array("cn"); |
---|
[344] | 874 | $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese); |
---|
| 875 | if(!$sr) |
---|
| 876 | return false; |
---|
[2] | 877 | $info = ldap_get_entries($this->ds, $sr); |
---|
[325] | 878 | return utf8_decode($info[0]["cn"][0]); |
---|
[2] | 879 | } |
---|
| 880 | return false; |
---|
| 881 | } |
---|
[757] | 882 | function uidnumber2uid($uidnumber) |
---|
| 883 | { |
---|
| 884 | // do not follow the referral |
---|
| 885 | $this->ldapRootConnect(false); |
---|
| 886 | if ($this->ds) |
---|
| 887 | { |
---|
| 888 | $filter="(&(phpgwAccountType=u)(uidnumber=$uidnumber))"; |
---|
| 889 | $justthese = array("uid"); |
---|
| 890 | $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese); |
---|
| 891 | if(!$sr) |
---|
| 892 | return false; |
---|
| 893 | $info = ldap_get_entries($this->ds, $sr); |
---|
| 894 | return $info[0]["uid"][0]; |
---|
| 895 | } |
---|
| 896 | return false; |
---|
| 897 | } |
---|
[387] | 898 | function getSharedUsersFrom($params){ |
---|
[2] | 899 | $filter = ''; |
---|
[7228] | 900 | $i = 0; |
---|
| 901 | //Added to save if must save sent messages in shared folder |
---|
| 902 | $acl_save_sent_in_shared = array(); |
---|
| 903 | |
---|
| 904 | if($params['uids']) { |
---|
| 905 | $uids = explode(";",$params['uids']); |
---|
| 906 | $this->imap = new imap_functions(); |
---|
| 907 | foreach($uids as $index => $uid){ |
---|
| 908 | $params = array(); |
---|
| 909 | //Added to save if user has create permission |
---|
| 910 | $acl_create_message = array(); |
---|
| 911 | $acl = $this->imap->getacltouser($uid ,true); |
---|
| 912 | |
---|
| 913 | if ( preg_match("/p/",$acl )){ |
---|
| 914 | $filter .= "(uid=$uid)"; |
---|
| 915 | $acl_save_sent_in_shared[ $i ] =$uid; |
---|
| 916 | $i++; |
---|
| 917 | |
---|
| 918 | } |
---|
| 919 | } |
---|
[6884] | 920 | } |
---|
[1912] | 921 | |
---|
[387] | 922 | $this->ldapRootConnect(false); |
---|
[371] | 923 | if ($this->ds) { |
---|
[1912] | 924 | $justthese = array("cn","mail","uid"); |
---|
[371] | 925 | if($filter) { |
---|
[1912] | 926 | $filter="(&(|(phpgwAccountType=u)(phpgwAccountType=s))(|$filter))"; |
---|
[371] | 927 | $sr = ldap_search($this->ds, $this->ldap_context, $filter, $justthese); |
---|
[387] | 928 | ldap_sort($this->ds,$sr,"cn"); |
---|
| 929 | $info = ldap_get_entries($this->ds, $sr); |
---|
[1912] | 930 | $var = print_r($acl_save_sent_in_shared, true); |
---|
| 931 | for ($i = 0;$i < $info["count"]; $i++){ |
---|
[371] | 932 | $info[$i]['cn'][0] = utf8_decode($info[$i]['cn'][0]); |
---|
[1912] | 933 | //verify if user has permission to save sent messages in a shared folder |
---|
| 934 | if ( in_array( $info[$i]['uid'][0],$acl_save_sent_in_shared) ){ |
---|
| 935 | $info[$i]['save_shared'][0] = 'y'; |
---|
| 936 | } else $info[$i]['save_shared'][0] = 'n'; |
---|
| 937 | } |
---|
[371] | 938 | } |
---|
[7228] | 939 | |
---|
[371] | 940 | $info['myname'] = $_SESSION['phpgw_info']['expressomail']['user']['fullname']; |
---|
[387] | 941 | |
---|
[371] | 942 | //Find institucional_account. |
---|
| 943 | $filter="(&(phpgwAccountType=i)(mailForwardingAddress=".$_SESSION['phpgw_info']['expressomail']['user']['email']."))"; |
---|
[387] | 944 | $sr = ldap_search($this->ds, $this->ldap_context, $filter, $justthese); |
---|
[448] | 945 | ## |
---|
| 946 | # @AUTHOR Rodrigo Souza dos Santos |
---|
| 947 | # @DATE 2008/09/17 |
---|
| 948 | # @BRIEF Changing to ensure that the variable session is always with due value. |
---|
| 949 | ## |
---|
| 950 | if(ldap_count_entries($this->ds,$sr)) |
---|
| 951 | { |
---|
| 952 | ldap_sort($this->ds,$sr,"cn"); |
---|
| 953 | $result = ldap_get_entries($this->ds, $sr); |
---|
| 954 | for ($j = 0;$j < $result["count"]; $j++){ |
---|
[7228] | 955 | $result[$j]['cn'][0] = utf8_decode($result[$j]['cn'][0]); |
---|
| 956 | $result[$j]['mail'][0] = $result[$j]['mail'][0]; |
---|
| 957 | $result[$j]['save_shared'][0] = 'n'; |
---|
| 958 | $info[$info['count']] = $result[$j]; |
---|
| 959 | $info['count'] = (int)$info['count'] + 1; |
---|
[448] | 960 | } |
---|
[371] | 961 | } |
---|
[448] | 962 | |
---|
| 963 | $_SESSION['phpgw_info']['expressomail']['user']['shared_mailboxes'] = $info; |
---|
[7228] | 964 | |
---|
[2] | 965 | return $info; |
---|
| 966 | } |
---|
| 967 | } |
---|
[27] | 968 | |
---|
[205] | 969 | function getUserByEmail($params) |
---|
| 970 | { |
---|
[3163] | 971 | $expires = 60*60*24*30; /* 30 days */ |
---|
| 972 | header("Cache-Control: maxage=".$expires); |
---|
| 973 | header("Pragma: public"); |
---|
| 974 | header("Expires: ".gmdate('D, d M Y H:i:s', time()+$expires)); |
---|
[205] | 975 | $filter="(&(phpgwAccountType=u)(mail=" . $params['email'] . "))"; |
---|
| 976 | $ldap_context = $_SESSION['phpgw_info']['expressomail']['ldap_server']['dn']; |
---|
[3388] | 977 | if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['extended_info']) |
---|
| 978 | $extendedinfo=true; |
---|
| 979 | else |
---|
| 980 | $extendedinfo=false; |
---|
[205] | 981 | |
---|
[3388] | 982 | if($extendedinfo) |
---|
| 983 | $justthese = array("cn","uid","telephoneNumber","jpegPhoto","mobile","ou","employeeNumber"); |
---|
| 984 | else |
---|
[6139] | 985 | $justthese = array("cn","uid","telephoneNumber","jpegPhoto"); |
---|
[3388] | 986 | |
---|
[27] | 987 | // Follow the referral |
---|
[205] | 988 | $ds = $this->ldapConnect2(true); |
---|
| 989 | if ($ds) |
---|
[387] | 990 | { |
---|
[342] | 991 | $sr=@ldap_search($ds, $ldap_context, $filter, $justthese); |
---|
[387] | 992 | |
---|
[205] | 993 | if (!$sr) |
---|
| 994 | return null; |
---|
[387] | 995 | |
---|
[205] | 996 | $entry = ldap_first_entry($ds, $sr); |
---|
[387] | 997 | |
---|
| 998 | if($entry) { |
---|
[381] | 999 | $obj = array("cn" => utf8_decode(current(ldap_get_values($ds, $entry, "cn"))), |
---|
[205] | 1000 | "email" => $params['email'], |
---|
| 1001 | "uid" => ldap_get_values($ds, $entry, "uid"), |
---|
[27] | 1002 | "type" => "global", |
---|
[205] | 1003 | "mobile" => @ldap_get_values($ds, $entry, "mobile"), |
---|
[3388] | 1004 | "telefone" => @ldap_get_values($ds, $entry, "telephonenumber"), |
---|
| 1005 | "ou" => @ldap_get_values($ds, $entry, "ou"), |
---|
| 1006 | "employeeNumber" => @ldap_get_values($ds, $entry, "employeeNumber") |
---|
[205] | 1007 | ); |
---|
[27] | 1008 | |
---|
[320] | 1009 | $_SESSION['phpgw_info']['expressomail']['contact_photo'] = @ldap_get_values_len($ds, $entry, "jpegphoto"); |
---|
[205] | 1010 | ldap_close($ds); |
---|
[27] | 1011 | return $obj; |
---|
[205] | 1012 | } |
---|
[27] | 1013 | } |
---|
| 1014 | return null; |
---|
| 1015 | } |
---|
[1500] | 1016 | |
---|
| 1017 | function uid2uidnumber($uid) |
---|
| 1018 | { |
---|
| 1019 | // do not follow the referral |
---|
| 1020 | $this->ldapRootConnect(false); |
---|
| 1021 | if ($this->ds) |
---|
| 1022 | { |
---|
| 1023 | $filter="(&(phpgwAccountType=u)(uid=$uid))"; |
---|
| 1024 | $justthese = array("uidnumber"); |
---|
| 1025 | $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese); |
---|
| 1026 | if(!$sr) |
---|
| 1027 | return false; |
---|
| 1028 | $info = ldap_get_entries($this->ds, $sr); |
---|
| 1029 | return $info[0]["uidnumber"][0]; |
---|
| 1030 | } |
---|
| 1031 | return false; |
---|
| 1032 | } |
---|
[5134] | 1033 | |
---|
| 1034 | function get_user_groups($uid) |
---|
| 1035 | { |
---|
| 1036 | |
---|
| 1037 | $organizations = array(); |
---|
| 1038 | |
---|
| 1039 | $this->ldapRootConnect(); |
---|
| 1040 | |
---|
| 1041 | $justthese = array("gidnumber","cn"); |
---|
| 1042 | $filter="(&(phpgwAccountType=g)(memberuid=".$uid."))"; |
---|
| 1043 | |
---|
| 1044 | $search = ldap_search($this->ds, $this->ldap_context, $filter, $justthese); |
---|
| 1045 | |
---|
| 1046 | $result = array(); |
---|
| 1047 | $entries = ldap_get_entries($this->ds, $search); |
---|
| 1048 | |
---|
| 1049 | |
---|
| 1050 | for ($i=0; $i<$entries['count']; $i++) |
---|
| 1051 | { |
---|
| 1052 | $result[ $entries[$i]['gidnumber'][0] ] = $entries[$i]['cn'][0]; |
---|
| 1053 | } |
---|
| 1054 | |
---|
| 1055 | return $result; |
---|
| 1056 | } |
---|
| 1057 | |
---|
| 1058 | function getMailByUid($pUid) |
---|
| 1059 | { |
---|
| 1060 | // do not follow the referral |
---|
| 1061 | $this->ldapRootConnect(false); |
---|
| 1062 | if ($this->ds) |
---|
| 1063 | { |
---|
| 1064 | $filter="(&(|(phpgwAccountType=u)(phpgwAccountType=s)(phpgwAccountType=l))(uid=$pUid))"; |
---|
| 1065 | $justthese = array("mail"); |
---|
| 1066 | $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese); |
---|
| 1067 | if(!$sr) |
---|
| 1068 | return false; |
---|
| 1069 | $info = ldap_get_entries($this->ds, $sr); |
---|
| 1070 | |
---|
| 1071 | |
---|
| 1072 | return utf8_decode($info[0]["mail"][0]); |
---|
| 1073 | } |
---|
| 1074 | return false; |
---|
| 1075 | } |
---|
| 1076 | |
---|
| 1077 | function mail2uid($mail) |
---|
| 1078 | { |
---|
| 1079 | if(!$this-ds) |
---|
| 1080 | $this->ldapRootConnect(false); |
---|
| 1081 | |
---|
| 1082 | $filter="(&(|(phpgwAccountType=u)(phpgwAccountType=s)(phpgwAccountType=i)(phpgwAccountType=g))(mail=$mail))"; |
---|
| 1083 | $justthese = array("uid"); |
---|
| 1084 | $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese); |
---|
| 1085 | if(!$sr) |
---|
| 1086 | return false; |
---|
| 1087 | $info = ldap_get_entries($this->ds, $sr); |
---|
| 1088 | return $info[0]["uid"][0]; |
---|
| 1089 | } |
---|
| 1090 | |
---|
| 1091 | |
---|
| 1092 | /** |
---|
| 1093 | * Retorna as contas compartilhas |
---|
| 1094 | * @param string $toaddress emails |
---|
| 1095 | * @param string $ccaddress emails |
---|
| 1096 | * @param string $ccoaddress emails |
---|
| 1097 | * @param array $groups array com os grupos que o usuario pertence |
---|
| 1098 | * @return array |
---|
| 1099 | */ |
---|
| 1100 | function returnSharedsAccounts($toaddress,$ccaddress,$ccoaddress) |
---|
| 1101 | { |
---|
| 1102 | |
---|
| 1103 | $arrayAllAddres = array(); |
---|
| 1104 | $arrayAllAddres = array_merge($arrayAllAddres , explode(',',$toaddress)); |
---|
| 1105 | $arrayAllAddres = array_merge($arrayAllAddres, explode(',',$ccaddress)); |
---|
| 1106 | $arrayAllAddres = array_merge($arrayAllAddres, explode(',',$ccoaddress)); |
---|
| 1107 | |
---|
| 1108 | $mailsArray = array(); |
---|
| 1109 | |
---|
| 1110 | foreach ($arrayAllAddres as $toAddres) |
---|
| 1111 | { |
---|
| 1112 | |
---|
| 1113 | if(strchr($toAddres,'@') && strchr($toAddres,'<') && strchr($toAddres,'>')) |
---|
| 1114 | { |
---|
| 1115 | $alias = substr($toAddres, strpos($toAddres,'<'), strpos($toAddres,'>')); |
---|
| 1116 | $alias = str_replace('<','', str_replace('>','',$alias)); |
---|
| 1117 | array_push($mailsArray, $alias); |
---|
| 1118 | } |
---|
| 1119 | else if(strchr($toAddres,'@')) |
---|
| 1120 | { |
---|
| 1121 | array_push($mailsArray, $toAddres); |
---|
| 1122 | } |
---|
| 1123 | } |
---|
| 1124 | $arraySharedAccounts = array(); |
---|
| 1125 | |
---|
| 1126 | $conexao = $this->ldapConnect2(true); |
---|
| 1127 | |
---|
| 1128 | |
---|
| 1129 | $mailFilter = ''; |
---|
| 1130 | |
---|
| 1131 | foreach ($mailsArray as $mail) |
---|
| 1132 | $mailFilter .= '(|(mail='.$mail.')(mailAlternateAddress='.$mail.'))'; |
---|
| 1133 | |
---|
| 1134 | |
---|
| 1135 | $filter = '(&(phpgwAccountType=s)(|'.$mailFilter.') )'; |
---|
| 1136 | $ldap_context = $_SESSION['phpgw_info']['expressomail']['server']['ldap_context']; |
---|
| 1137 | $justthese = array('cn','uid','mail'); |
---|
| 1138 | |
---|
| 1139 | if ($conexao) |
---|
| 1140 | { |
---|
| 1141 | $search = @ldap_search($conexao, $ldap_context, $filter, $justthese); |
---|
| 1142 | if($search) |
---|
| 1143 | { |
---|
| 1144 | $results = ldap_get_entries($conexao, $search); |
---|
| 1145 | |
---|
| 1146 | foreach ($results as $result) |
---|
| 1147 | { |
---|
| 1148 | if($result['mail'][0]) |
---|
| 1149 | array_push($arraySharedAccounts, $result['mail'][0]); |
---|
| 1150 | } |
---|
| 1151 | } |
---|
| 1152 | |
---|
| 1153 | } |
---|
| 1154 | |
---|
| 1155 | return $arraySharedAccounts; |
---|
| 1156 | } |
---|
| 1157 | /** |
---|
| 1158 | * Verifica se um email é uma conta compartilhada |
---|
| 1159 | * |
---|
| 1160 | * @license http://www.gnu.org/copyleft/gpl.html GPL |
---|
| 1161 | * @author Cons?rcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) |
---|
| 1162 | * @author Cristiano Corrêa Schmidt |
---|
| 1163 | * @param String $mail Email a ser verificado |
---|
| 1164 | * @return bolean |
---|
| 1165 | * @access public |
---|
| 1166 | */ |
---|
| 1167 | function isSharedAccountByMail($mail) |
---|
| 1168 | { |
---|
| 1169 | $return = false; |
---|
| 1170 | $conexao = $this->ldapConnect2(true); |
---|
| 1171 | $filter = '(&(phpgwAccountType=s)(mail='.$mail.'))'; |
---|
| 1172 | $ldap_context = $_SESSION['phpgw_info']['expressomail']['server']['ldap_context']; |
---|
| 1173 | $justthese = array('cn','uid','mail'); |
---|
| 1174 | if ($conexao) |
---|
| 1175 | { |
---|
| 1176 | $search = @ldap_search($conexao, $ldap_context, $filter, $justthese); |
---|
| 1177 | if(ldap_count_entries ($conexao , $search)) |
---|
| 1178 | $return = true; |
---|
| 1179 | } |
---|
| 1180 | |
---|
| 1181 | return $return; |
---|
| 1182 | } |
---|
[5821] | 1183 | |
---|
| 1184 | function save_telephoneNumber($params){ |
---|
| 1185 | $return = array(); |
---|
| 1186 | if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['blockpersonaldata']){ |
---|
| 1187 | $return['error'] = $this->functions->getLang("You can't modify your Commercial Telephone."); |
---|
| 1188 | return $return; |
---|
| 1189 | } |
---|
| 1190 | $old_telephone = 0; |
---|
| 1191 | $pattern = '/\([0-9]{2,3}\)[0-9]{4}-[0-9]{4}$/'; |
---|
| 1192 | if ((strlen($params['number']) != 0) && (!preg_match($pattern, $params['number']))) |
---|
| 1193 | { |
---|
| 1194 | $return['error'] = $this->functions->getLang('The format of telephone number is invalid'); |
---|
| 1195 | return $return; |
---|
| 1196 | } |
---|
| 1197 | if($params['number'] != $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['telephone_number']) { |
---|
| 1198 | $old_telephone = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['telephone_number']; |
---|
| 1199 | $this->ldapRootConnect(false); |
---|
| 1200 | if(strlen($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['telephone_number']) == 0) { |
---|
| 1201 | $info['telephonenumber'] = $params['number']; |
---|
| 1202 | $result = @ldap_mod_add($this->ds, $_SESSION['phpgw_info']['expressomail']['user']['account_dn'], $info); |
---|
| 1203 | } |
---|
| 1204 | else { |
---|
| 1205 | $info['telephonenumber'] = $params['number']; |
---|
| 1206 | $result = @ldap_mod_replace($this->ds, $_SESSION['phpgw_info']['expressomail']['user']['account_dn'], $info); |
---|
| 1207 | } |
---|
| 1208 | $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['telephone_number'] = $info['telephonenumber']; |
---|
| 1209 | // Log updated telephone number by user action |
---|
| 1210 | include_once('class.db_functions.inc.php'); |
---|
| 1211 | $db_functions = new db_functions(); |
---|
| 1212 | $db_functions->write_log('modified user telephone',"User changed its own telephone number in preferences $old_telephone => ".$info['telephonenumber']); |
---|
| 1213 | unset($info['telephonenumber']); |
---|
| 1214 | } |
---|
| 1215 | return $return['ok'] = true; |
---|
| 1216 | } |
---|
[2] | 1217 | } |
---|
[108] | 1218 | ?> |
---|