258 : void
259 {
261
262 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail_search.html', 'components/ILIAS/Contact');
263 $this->tpl->setVariable(
'ACTION', $this->
ctrl->getFormAction($this));
264 $this->tpl->setTitle($this->
lng->txt(
'mail'));
265 $this->tpl->setVariable('SEARCHFORM', $form->getHtml());
266
267
268 if (
272 ) {
274 $this->tpl->printToStdout();
275 }
276 return;
277 }
278
280 if (count($relations) > 0) {
282
285 $query_parser->setMinWordLength(3);
286 $query_parser->parse();
287
289 $user_search->enableActiveCheck(true);
290 $user_search->setFields(['login']);
291 $result_obj = $user_search->performSearch();
292 $contacts_search_result->mergeEntries($result_obj);
293
294 $user_search->setFields(['firstname']);
295 $result_obj = $user_search->performSearch();
296 $contacts_search_result->mergeEntries($result_obj);
297
298 $user_search->setFields(['lastname']);
299 $result_obj = $user_search->performSearch();
300 $contacts_search_result->mergeEntries($result_obj);
301
302 $contacts_search_result->setMaxHits(100000);
303 $contacts_search_result->preventOverwritingMaxhits(true);
305
306
308 $users = array_intersect($users, $relations->getKeys());
309
311 $tbl_contacts->setTitle($this->
lng->txt(
'mail_addressbook'));
312 $tbl_contacts->setRowTemplate('tpl.mail_search_addr_row.html', 'components/ILIAS/Contact');
313
314 $has_mail_addr = false;
315 $result = [];
317 foreach ($users as $user) {
319
321 foreach (['to', 'cc', 'bcc'] as $recipient_type) {
323 }
324 } else {
326 }
327
328 $result[
$counter][
'login'] = $login;
330 $has_mail_addr = true;
332 }
333
336 $result[
$counter][
'firstname'] = $name[
'firstname'];
337 $result[
$counter][
'lastname'] = $name[
'lastname'];
338 } else {
339 $result[
$counter][
'firstname'] =
'';
341 }
342
344 }
345
347 $tbl_contacts->addColumn(
348 $this->
lng->txt(
'mail_to') .
'/' . $this->lng->txt(
'mail_cc') .
'/' . $this->lng->txt(
'mail_bcc'),
349 'check',
350 '10%'
351 );
352 } else {
353 $tbl_contacts->addColumn('', '', '1%', true);
354 }
355 $tbl_contacts->addColumn($this->
lng->txt(
'login'),
'login',
'15%');
356 $tbl_contacts->addColumn($this->
lng->txt(
'firstname'),
'firstname',
'15%');
357 $tbl_contacts->addColumn($this->
lng->txt(
'lastname'),
'lastname',
'15%');
358 if ($has_mail_addr) {
359 foreach ($result as $key => $val) {
360 if (!isset($val['email']) || $val['email'] === '') {
361 $result[$key]['email'] = ' ';
362 }
363 }
364
365 $tbl_contacts->addColumn($this->
lng->txt(
'email'),
'email',
"15%");
366 }
367 $tbl_contacts->setData($result);
368
369 $tbl_contacts->setDefaultOrderField('login');
370 $tbl_contacts->enable('select_all');
371 $tbl_contacts->setSelectAllCheckbox('search_name_to_addr');
372 $tbl_contacts->setFormName('recipients');
373
374 $this->tpl->setVariable('TABLE_ADDR', $tbl_contacts->getHTML());
375 }
376
378
381 $query_parser->setMinWordLength(3);
382 $query_parser->parse();
383
385 $user_search->enableActiveCheck(true);
386 $user_search->setFields(['login']);
387 $result_obj = $user_search->performSearch();
388 $all_results->mergeEntries($result_obj);
389
390 $user_search->setFields(['firstname']);
391 $result_obj = $user_search->performSearch();
392 $all_results->mergeEntries($result_obj);
393
394 $user_search->setFields(['lastname']);
395 $result_obj = $user_search->performSearch();
396 $all_results->mergeEntries($result_obj);
397
398 $all_results->setMaxHits(100000);
399 $all_results->preventOverwritingMaxhits(true);
401
402
403 $has_mail_usr = false;
405 if ($users !== []) {
407 $tbl_users->setTitle($this->
lng->txt(
'system') .
': ' . $this->lng->txt(
'persons'));
408 $tbl_users->setRowTemplate('tpl.mail_search_users_row.html', 'components/ILIAS/Contact');
409
410 $result = [];
412 foreach ($users as $user) {
414
416 foreach (['to', 'cc', 'bcc'] as $recipient_type) {
418 }
419 } else {
421 }
422 $result[
$counter][
'login'] = $login;
423
426 $result[
$counter][
'firstname'] = $name[
'firstname'];
427 $result[
$counter][
'lastname'] = $name[
'lastname'];
428 } else {
429 $result[
$counter][
'firstname'] =
'';
431 }
432
434 $has_mail_usr = true;
436 }
437
439 }
440
442 $tbl_users->addColumn(
443 $this->
lng->txt(
'mail_to') .
'/' . $this->lng->txt(
'mail_cc') .
'/' . $this->lng->txt(
'mail_bcc'),
444 'check',
445 '10%'
446 );
447 } else {
448 $tbl_users->addColumn('', '', '1%');
449 }
450 $tbl_users->addColumn($this->
lng->txt(
'login'),
'login',
'15%');
451 $tbl_users->addColumn($this->
lng->txt(
'firstname'),
'firstname',
'15%');
452 $tbl_users->addColumn($this->
lng->txt(
'lastname'),
'lastname',
'15%');
453 if ($has_mail_usr) {
454 foreach ($result as $key => $val) {
455 if (!isset($val['email']) || $val['email'] === '') {
456 $result[$key]['email'] = ' ';
457 }
458 }
459
460 $tbl_users->addColumn($this->
lng->txt(
'email'),
'email',
'15%');
461 }
462 $tbl_users->setData($result);
463
464 $tbl_users->setDefaultOrderField('login');
465 $tbl_users->enable('select_all');
466 $tbl_users->setSelectAllCheckbox('search_name_to_usr');
467 $tbl_users->setFormName('recipients');
468
469 $this->tpl->setVariable('TABLE_USERS', $tbl_users->getHTML());
470 }
471
473
476 $query_parser->setMinWordLength(3);
477 $query_parser->parse();
478
480 $search->setFilter(['grp']);
481 $result = $search->performSearch();
482 $group_results->mergeEntries($result);
483 $group_results->setMaxHits(PHP_INT_MAX);
484 $group_results->preventOverwritingMaxhits(true);
485 $group_results->setRequiredPermission('read');
487
488 $visible_groups = [];
489 if ($group_results->getResults()) {
491 $tbl_grp->setTitle($this->
lng->txt(
'system') .
': ' . $this->lng->txt(
'groups'));
492 $tbl_grp->setRowTemplate('tpl.mail_search_groups_row.html', 'components/ILIAS/Contact');
493
494 $result = [];
496
497 $this->object_data_cache->preloadReferenceCache(array_keys($group_results->getResults()));
498
499 $groups = $group_results->getResults();
500 foreach ($groups as $grp) {
502 continue;
503 }
504
506 $members = [];
507 $roles = $this->rbacreview->getAssignableChildRoles($grp['ref_id']);
508 foreach ($roles as $role) {
509 if (
510 str_starts_with($role['title'], 'il_grp_member_') ||
511 str_starts_with($role['title'], 'il_grp_admin_')
512 ) {
513
514 $members[] = '#' . $role['title'];
515 }
516 }
517 $str_members = implode(',', $members);
518
519 foreach (['to', 'cc', 'bcc'] as $recipient_type) {
521 }
522 } else {
524 }
525 $result[
$counter][
'title'] = $this->object_data_cache->lookupTitle((
int) $grp[
'obj_id']);
526 $result[
$counter][
'description'] = $this->object_data_cache->lookupDescription((
int) $grp[
'obj_id']);
527
529 $visible_groups[] = $grp;
530 }
531
532 if ($visible_groups !== []) {
533 $tbl_grp->setData($result);
534
536 $tbl_grp->addColumn(
537 $this->
lng->txt(
'mail_to') .
'/' . $this->lng->txt(
'mail_cc') .
'/' . $this->lng->txt(
'mail_bcc'),
538 'check',
539 '10%'
540 );
541 } else {
542 $tbl_grp->addColumn('', '', '1%');
543 }
544 $tbl_grp->addColumn($this->
lng->txt(
'title'),
'title',
'15%');
545 $tbl_grp->addColumn($this->
lng->txt(
'description'),
'description',
'15%');
546
547 $tbl_grp->setDefaultOrderField('title');
548 $tbl_grp->enable('select_all');
549 $tbl_grp->setSelectAllCheckbox('search_name_to_grp');
550 $tbl_grp->setFormName('recipients');
551
552 $this->tpl->setVariable('TABLE_GRP', $tbl_grp->getHTML());
553 }
554 }
555
556 if (count($users) || count($visible_groups) || count($relations)) {
558 $this->tpl->setVariable("ALT_ARROW", '');
560 $this->tpl->setVariable("ALT_ARROW_UP", '');
561
563 $this->tpl->setVariable(
'BUTTON_ADOPT', $this->
lng->txt(
'adopt'));
564 } else {
565 $this->tpl->setVariable(
'BUTTON_ADOPT', $this->
lng->txt(
'wsp_share_with_users'));
566 }
567 } else {
568 $this->
lng->loadLanguageModule(
'search');
569 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'search_no_match'));
570 }
571
573 $this->tpl->printToStdout();
574 }
575 }
static getInstanceByGlobalUser(?ilObjUser $user=null)
appendRecipientSelection(array &$result, int $index, string $search_type, string $recipient_type, string $value)
static _lookupName(int $a_user_id)
static _lookupPref(int $a_usr_id, string $a_keyword)
static _lookupLogin(int $a_user_id)
static _lookupEmail(int $a_user_id)
static _getObjectSearchInstance(ilQueryParser $query_parser)
static _getUserSearchInstance(ilQueryParser $query_parser)
static hasParticipantListAccess(int $a_obj_id, ?int $a_usr_id=null)
Check if (current) user has access to the participant list.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)