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