217 {
218 global
$lng,
$ilUser, $rbacreview, $ilObjDataCache;
219
221
222 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mail_search.html", "Services/Contact");
223 $this->tpl->setVariable("ACTION", $this->ctrl->getFormAction($this));
224 $this->tpl->setTitle($this->lng->txt("mail"));
225 $this->tpl->setVariable('SEARCHFORM', $form->getHtml());
226
227
228 if(strlen(
$_SESSION[
'mail_search_search']) < 3)
229 {
230 if(
$_GET[
"ref"] !=
"wsp")
231 {
232 $this->tpl->show();
233 }
234 return;
235 }
236
238 $entries = $abook->searchUsers(addslashes(urldecode(
$_SESSION[
'mail_search_search'])));
239
240
241 if(
$_GET[
"ref"] ==
"wsp")
242 {
243 foreach($entries as $idx => $entry)
244 {
245 if(!$entry["login"])
246 {
247 unset($entries[$idx]);
248 }
249 }
250 }
251
252 if(count($entries))
253 {
255 $tbl_addr->setTitle(
$lng->txt(
'mail_addressbook'));
256 $tbl_addr->setRowTemplate('tpl.mail_search_addr_row.html', 'Services/Contact');
257
259 $counter = 0;
260 foreach($entries as $entry)
261 {
262 if(
$_GET[
"ref"] !=
"wsp")
263 {
264 $result[$counter][
'check'] =
ilUtil::formCheckbox(0,
'search_name_to_addr[]', ($entry[
'login'] ? $entry[
'login'] : $entry[
'email'])) .
265 ilUtil::formCheckbox(0,
'search_name_cc[]', ($entry[
'login'] ? $entry[
'login'] : $entry[
'email'])) .
266 ilUtil::formCheckbox(0,
'search_name_bcc[]', ($entry[
'login'] ? $entry[
'login'] : $entry[
'email']));
267 }
268 else
269 {
272 }
273
274 $result[$counter][
'login'] = $entry[
'login'];
275 $result[$counter][
'firstname'] = $entry[
'firstname'];
276 $result[$counter][
'lastname'] = $entry[
'lastname'];
277
280 {
281 $has_mail_addr = true;
282 $result[$counter][
'email'] = $entry[
'email'];
283 }
284
285 ++$counter;
286 }
287
288 if(
$_GET[
"ref"] !=
"wsp")
289 {
290 $tbl_addr->addColumn($this->lng->txt('mail_to') . '/' . $this->lng->txt('cc') . '/' . $this->lng->txt('bc'), 'check', '10%');
291 }
292 else
293 {
294 $tbl_addr->addColumn("", "", "1%");
295 }
296 $tbl_addr->addColumn($this->lng->txt('login'), 'login', "15%");
297 $tbl_addr->addColumn($this->lng->txt('firstname'), 'firstname', "15%");
298 $tbl_addr->addColumn($this->lng->txt('lastname'), 'lastname', "15%");
299 if($has_mail_addr)
300 {
301 foreach(
$result as $key => $val)
302 {
303 if($val[
'email'] ==
'')
$result[$key][
'email'] =
' ';
304 }
305
306 $tbl_addr->addColumn($this->lng->txt('email'), 'email', "15%");
307 }
309
310 $tbl_addr->setDefaultOrderField('login');
311 $tbl_addr->setPrefix('addr_');
312 $tbl_addr->enable('select_all');
313 $tbl_addr->setSelectAllCheckbox('search_name_to_addr');
314 $tbl_addr->setFormName('recipients');
315
316 $this->tpl->setVariable('TABLE_ADDR', $tbl_addr->getHTML());
317 }
318
319 include_once 'Services/Search/classes/class.ilQueryParser.php';
320 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
321 include_once 'Services/Search/classes/class.ilSearchResult.php';
322
324
327 $query_parser->setMinWordLength(3);
328 $query_parser->parse();
329
331 $user_search->enableActiveCheck(true);
332 $user_search->setFields(array('login'));
333 $result_obj = $user_search->performSearch();
334 $all_results->mergeEntries($result_obj);
335
336 $user_search->setFields(array('firstname'));
337 $result_obj = $user_search->performSearch();
338 $all_results->mergeEntries($result_obj);
339
340 $user_search->setFields(array('lastname'));
341 $result_obj = $user_search->performSearch();
342 $all_results->mergeEntries($result_obj);
343
344 $all_results->setMaxHits(100000);
345 $all_results->preventOverwritingMaxhits(true);
346 $all_results->filter(ROOT_FOLDER_ID, true);
347
348
349 include_once 'Services/User/classes/class.ilUserFilter.php';
351 if(count($users))
352 {
354 $tbl_users->setTitle(
$lng->txt(
'system') .
': ' .
$lng->txt(
'persons'));
355 $tbl_users->setRowTemplate('tpl.mail_search_users_row.html', 'Services/Contact');
356
358 $counter = 0;
359 foreach($users as $user)
360 {
362
363 if(
$_GET[
"ref"] !=
"wsp")
364 {
368 }
369 else
370 {
372 }
373 $result[$counter][
'login'] = $login;
374
376 {
378 $result[$counter][
'firstname'] = $name[
'firstname'];
379 $result[$counter][
'lastname'] = $name[
'lastname'];
380 }
381 else
382 {
383 $result[$counter][
'firstname'] =
'';
384 $result[$counter][
'lastname'] =
'';
385 }
386
388 {
389 $has_mail_usr = true;
391 }
392
393 ++$counter;
394 }
395
396 if(
$_GET[
"ref"] !=
"wsp")
397 {
398 $tbl_users->addColumn($this->lng->txt('mail_to') . '/' . $this->lng->txt('cc') . '/' . $this->lng->txt('bc'), 'check', '10%');
399 }
400 else
401 {
402 $tbl_users->addColumn("", "", "1%");
403 }
404 $tbl_users->addColumn($this->lng->txt('login'), 'login', '15%');
405 $tbl_users->addColumn($this->lng->txt('firstname'), 'firstname', '15%');
406 $tbl_users->addColumn($this->lng->txt('lastname'), 'lastname', '15%');
407 if($has_mail_usr == true)
408 {
409 foreach(
$result as $key => $val)
410 {
411 if($val[
'email'] ==
'')
$result[$key][
'email'] =
' ';
412 }
413
414 $tbl_users->addColumn($this->lng->txt('email'), 'email', '15%');
415 }
417
418 $tbl_users->setDefaultOrderField('login');
419 $tbl_users->setPrefix('usr_');
420 $tbl_users->enable('select_all');
421 $tbl_users->setSelectAllCheckbox('search_name_to_usr');
422 $tbl_users->setFormName('recipients');
423
424 $this->tpl->setVariable('TABLE_USERS', $tbl_users->getHTML());
425 }
426
427 include_once 'Services/Search/classes/class.ilQueryParser.php';
428 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
429 include_once 'Services/Search/classes/class.ilSearchResult.php';
430 include_once 'Services/Membership/classes/class.ilParticipants.php';
431
433
436 $query_parser->setMinWordLength(3);
437 $query_parser->parse();
438
440 $search->setFilter(array('grp'));
441 $result = $search->performSearch();
442 $group_results->mergeEntries(
$result);
443 $group_results->setMaxHits(PHP_INT_MAX);
444 $group_results->preventOverwritingMaxhits(true);
445 $group_results->setRequiredPermission('read');
446 $group_results->filter(ROOT_FOLDER_ID, true);
447
448 $visible_groups = array();
449 if($group_results->getResults())
450 {
452 $tbl_grp->setTitle(
$lng->txt(
'system') .
': ' .
$lng->txt(
'groups'));
453 $tbl_grp->setRowTemplate('tpl.mail_search_groups_row.html', 'Services/Contact');
454
456 $counter = 0;
457
458 $ilObjDataCache->preloadReferenceCache(array_keys($group_results->getResults()));
459
460 $groups = $group_results->getResults();
461 foreach($groups as $grp)
462 {
464 {
465 continue;
466 }
467
468 if(
$_GET[
"ref"] !=
"wsp")
469 {
470 $members = array();
471 $roles = $rbacreview->getAssignableChildRoles($grp['ref_id']);
472 foreach($roles as $role)
473 {
474 if(substr($role['title'], 0, 14) == 'il_grp_member_' ||
475 substr($role['title'], 0, 13) == 'il_grp_admin_'
476 )
477 {
478
479
480
481 array_push($members, '#' . $role['title']);
482 }
483 }
484 $str_members = implode(',', $members);
485
490 }
491 else
492 {
494 }
495 $result[$counter][
'title'] = $ilObjDataCache->lookupTitle($grp[
'obj_id']);
496 $result[$counter][
'description'] = $ilObjDataCache->lookupDescription($grp[
'obj_id']);
497
498 ++$counter;
499 $visible_groups[] = $grp;
500 }
501
502 if($visible_groups)
503 {
505
506 if(
$_GET[
"ref"] !=
"wsp")
507 {
508 $tbl_grp->addColumn($this->lng->txt('mail_to') . '/' . $this->lng->txt('cc') . '/' . $this->lng->txt('bc'), 'check', '10%');
509 }
510 else
511 {
512 $tbl_grp->addColumn("", "", "1%");
513 }
514 $tbl_grp->addColumn($this->lng->txt('title'), 'title', '15%');
515 $tbl_grp->addColumn($this->lng->txt('description'), 'description', '15%');
516
517 $tbl_grp->setDefaultOrderField('title');
518 $tbl_grp->setPrefix('grp_');
519 $tbl_grp->enable('select_all');
520 $tbl_grp->setSelectAllCheckbox('search_name_to_grp');
521 $tbl_grp->setFormName('recipients');
522
523 $this->tpl->setVariable('TABLE_GRP', $tbl_grp->getHTML());
524 }
525 }
526
527 if(count($users) || count($visible_groups) || count($entries))
528 {
530 $this->tpl->setVariable("ALT_ARROW", '');
531
532 if(
$_GET[
"ref"] !=
"wsp")
533 {
534 $this->tpl->setVariable('BUTTON_ADOPT', $this->lng->txt('adopt'));
535 }
536 else
537 {
538 $this->tpl->setVariable('BUTTON_ADOPT', $this->lng->txt('wsp_share_with_users'));
539 }
540 }
541 else
542 {
543 $this->lng->loadLanguageModule('search');
545 }
546
547 if(
$_GET[
"ref"] !=
"wsp")
548 {
549 $this->tpl->show();
550 }
551 }
Mail Box class Base class for creating and handling mail boxes.
_lookupLogin($a_user_id)
lookup login
static _lookupId($a_user_str)
lookup id by login
static _lookupName($a_user_id)
lookup user name
_lookupEmail($a_user_id)
Lookup email.
static _loginExists($a_login, $a_user_id=0)
check if a login name already exists You may exclude a user from the check by giving his user id as 2...
_lookupPref($a_usr_id, $a_keyword)
static _getObjectSearchInstance($query_parser)
get reference of ilFulltext/LikeObjectSearch.
static _getUserSearchInstance($query_parser)
get reference of ilLikeUserSearch
static hasParticipantListAccess($a_obj_id, $a_usr_id=null)
Check if (current) user has access to the participant list.
static getInstance()
Singelton get instance.
static formCheckbox($checked, $varname, $value, $disabled=false)
??? @access public
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)