267 {
269
270 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mail_search.html", "Services/Contact");
271 $this->tpl->setVariable("ACTION", $this->ctrl->getFormAction($this));
272 $this->tpl->setTitle($this->lng->txt("mail"));
273 $this->tpl->setVariable('SEARCHFORM', $form->getHtml());
274
275
276 if (
277 !isset(
$_SESSION[
"mail_search_search"]) ||
278 !is_string(
$_SESSION[
"mail_search_search"]) ||
279 strlen(trim(
$_SESSION[
"mail_search_search"])) < 3
280 ) {
282 $this->tpl->printToStdout();
283 }
284 return;
285 }
286
287 require_once 'Services/Contact/BuddySystem/classes/class.ilBuddyList.php';
289 if (count($relations)) {
291
294 $query_parser->setMinWordLength(3);
295 $query_parser->parse();
296
298 $user_search->enableActiveCheck(true);
299 $user_search->setFields(array('login'));
300 $result_obj = $user_search->performSearch();
301 $contacts_search_result->mergeEntries($result_obj);
302
303 $user_search->setFields(array('firstname'));
304 $result_obj = $user_search->performSearch();
305 $contacts_search_result->mergeEntries($result_obj);
306
307 $user_search->setFields(array('lastname'));
308 $result_obj = $user_search->performSearch();
309 $contacts_search_result->mergeEntries($result_obj);
310
311 $contacts_search_result->setMaxHits(100000);
312 $contacts_search_result->preventOverwritingMaxhits(true);
314
315
316 include_once 'Services/User/classes/class.ilUserFilter.php';
318 $users = array_intersect($users, $relations->getKeys());
319
321 $tbl_contacts->setTitle($this->lng->txt('mail_addressbook'));
322 $tbl_contacts->setRowTemplate('tpl.mail_search_addr_row.html', 'Services/Contact');
323
324 $has_mail_addr = false;
326 $counter = 0;
327 foreach ($users as $user) {
329
331 foreach (['to', 'cc', 'bcc'] as $recipient_type) {
333 }
334 } else {
336 }
337
340 $has_mail_addr = true;
342 }
343
348 } else {
349 $result[$counter][
'firstname'] =
'';
350 $result[$counter][
'lastname'] =
'';
351 }
352
353 ++$counter;
354 }
355
357 $tbl_contacts->addColumn(
358 $this->lng->txt('mail_to') . '/' . $this->lng->txt('mail_cc') . '/' . $this->lng->txt('mail_bcc'),
359 '',
360 '10%'
361 );
362 } else {
363 $tbl_contacts->addColumn("", "", "1%", true);
364 }
365 $tbl_contacts->addColumn($this->lng->txt('login'), 'login', '15%');
366 $tbl_contacts->addColumn($this->lng->txt('firstname'), 'firstname', '15%');
367 $tbl_contacts->addColumn($this->lng->txt('lastname'), 'lastname', '15%');
368 if ($has_mail_addr) {
369 foreach (
$result as $key => $val) {
370 if ($val['email'] == '') {
371 $result[$key][
'email'] =
' ';
372 }
373 }
374
375 $tbl_contacts->addColumn($this->lng->txt('email'), 'email', "15%");
376 }
377 $tbl_contacts->setData(
$result);
378
379 $tbl_contacts->setDefaultOrderField('login');
380 $tbl_contacts->enable('select_all');
381 $tbl_contacts->setSelectAllCheckbox('search_name_to_addr');
382 $tbl_contacts->setFormName('recipients');
383
384 $this->tpl->setVariable('TABLE_ADDR', $tbl_contacts->getHTML());
385 }
386
388
391 $query_parser->setMinWordLength(3);
392 $query_parser->parse();
393
395 $user_search->enableActiveCheck(true);
396 $user_search->setFields(array('login'));
397 $result_obj = $user_search->performSearch();
398 $all_results->mergeEntries($result_obj);
399
400 $user_search->setFields(array('firstname'));
401 $result_obj = $user_search->performSearch();
402 $all_results->mergeEntries($result_obj);
403
404 $user_search->setFields(array('lastname'));
405 $result_obj = $user_search->performSearch();
406 $all_results->mergeEntries($result_obj);
407
408 $all_results->setMaxHits(100000);
409 $all_results->preventOverwritingMaxhits(true);
411
412
413 $has_mail_usr = false;
414 include_once 'Services/User/classes/class.ilUserFilter.php';
416 if (count($users)) {
418 $tbl_users->setTitle($this->lng->txt('system') . ': ' . $this->lng->txt('persons'));
419 $tbl_users->setRowTemplate('tpl.mail_search_users_row.html', 'Services/Contact');
420
422 $counter = 0;
423 foreach ($users as $user) {
425
427 foreach (['to', 'cc', 'bcc'] as $recipient_type) {
429 }
430 } else {
432 }
434
439 } else {
440 $result[$counter][
'firstname'] =
'';
441 $result[$counter][
'lastname'] =
'';
442 }
443
445 $has_mail_usr = true;
447 }
448
449 ++$counter;
450 }
451
453 $tbl_users->addColumn(
454 $this->lng->txt('mail_to') . '/' . $this->lng->txt('mail_cc') . '/' . $this->lng->txt('mail_bcc'),
455 '',
456 '10%'
457 );
458 } else {
459 $tbl_users->addColumn("", "", "1%");
460 }
461 $tbl_users->addColumn($this->lng->txt('login'), 'login', '15%');
462 $tbl_users->addColumn($this->lng->txt('firstname'), 'firstname', '15%');
463 $tbl_users->addColumn($this->lng->txt('lastname'), 'lastname', '15%');
464 if ($has_mail_usr == true) {
465 foreach (
$result as $key => $val) {
466 if ($val['email'] == '') {
467 $result[$key][
'email'] =
' ';
468 }
469 }
470
471 $tbl_users->addColumn($this->lng->txt('email'), 'email', '15%');
472 }
474
475 $tbl_users->setDefaultOrderField('login');
476 $tbl_users->enable('select_all');
477 $tbl_users->setSelectAllCheckbox('search_name_to_usr');
478 $tbl_users->setFormName('recipients');
479
480 $this->tpl->setVariable('TABLE_USERS', $tbl_users->getHTML());
481 }
482
483 include_once 'Services/Search/classes/class.ilQueryParser.php';
484 include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
485 include_once 'Services/Search/classes/class.ilSearchResult.php';
486 include_once 'Services/Membership/classes/class.ilParticipants.php';
487
489
492 $query_parser->setMinWordLength(3);
493 $query_parser->parse();
494
496 $search->setFilter(array('grp'));
497 $result = $search->performSearch();
498 $group_results->mergeEntries(
$result);
499 $group_results->setMaxHits(PHP_INT_MAX);
500 $group_results->preventOverwritingMaxhits(true);
501 $group_results->setRequiredPermission('read');
503
504 $visible_groups = array();
505 if ($group_results->getResults()) {
507 $tbl_grp->setTitle($this->lng->txt('system') . ': ' . $this->lng->txt('groups'));
508 $tbl_grp->setRowTemplate('tpl.mail_search_groups_row.html', 'Services/Contact');
509
511 $counter = 0;
512
513 $this->object_data_cache->preloadReferenceCache(array_keys($group_results->getResults()));
514
515 $groups = $group_results->getResults();
516 foreach ($groups as $grp) {
518 continue;
519 }
520
522 $members = array();
523 $roles = $this->rbacreview->getAssignableChildRoles($grp['ref_id']);
524 foreach ($roles as $role) {
525 if (substr($role['title'], 0, 14) == 'il_grp_member_' ||
526 substr($role['title'], 0, 13) == 'il_grp_admin_'
527 ) {
528
529 array_push($members, '#' . $role['title']);
530 }
531 }
532 $str_members = implode(',', $members);
533
534 foreach (['to', 'cc', 'bcc'] as $recipient_type) {
536 }
537 } else {
539 }
540 $result[$counter][
'title'] = $this->object_data_cache->lookupTitle($grp[
'obj_id']);
541 $result[$counter][
'description'] = $this->object_data_cache->lookupDescription($grp[
'obj_id']);
542
543 ++$counter;
544 $visible_groups[] = $grp;
545 }
546
547 if ($visible_groups) {
549
551 $tbl_grp->addColumn(
552 $this->lng->txt('mail_to') . '/' . $this->lng->txt('mail_cc') . '/' . $this->lng->txt('mail_bcc'),
553 '',
554 '10%'
555 );
556 } else {
557 $tbl_grp->addColumn("", "", "1%");
558 }
559 $tbl_grp->addColumn($this->lng->txt('title'), 'title', '15%');
560 $tbl_grp->addColumn($this->lng->txt('description'), 'description', '15%');
561
562 $tbl_grp->setDefaultOrderField('title');
563 $tbl_grp->enable('select_all');
564 $tbl_grp->setSelectAllCheckbox('search_name_to_grp');
565 $tbl_grp->setFormName('recipients');
566
567 $this->tpl->setVariable('TABLE_GRP', $tbl_grp->getHTML());
568 }
569 }
570
571 if (count($users) || count($visible_groups) || count($relations)) {
573 $this->tpl->setVariable("ALT_ARROW", '');
575 $this->tpl->setVariable("ALT_ARROW_UP", '');
576
578 $this->tpl->setVariable('BUTTON_ADOPT', $this->lng->txt('adopt'));
579 } else {
580 $this->tpl->setVariable('BUTTON_ADOPT', $this->lng->txt('wsp_share_with_users'));
581 }
582 } else {
583 $this->lng->loadLanguageModule('search');
585 }
586
588 $this->tpl->printToStdout();
589 }
590 }
const QP_COMBINATION_AND
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByGlobalUser()
appendRecipientSelection(array &$result, int $index, string $search_type, string $recipient_type, string $value)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupPref($a_usr_id, $a_keyword)
static _lookupEmail($a_user_id)
Lookup email.
static _lookupLogin($a_user_id)
lookup login
static _lookupName($a_user_id)
lookup user name
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 getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)