19 declare(strict_types=1);
54 $this->tpl = $DIC[
'tpl'];
55 $this->
ctrl = $DIC[
'ilCtrl'];
56 $this->
lng = $DIC[
'lng'];
57 $this->rbacreview = $DIC[
'rbacreview'];
58 $this->object_data_cache = $DIC[
'ilObjDataCache'];
59 $this->
http = $DIC->http();
65 $this->
ctrl->saveParameter($this,
'mobj_id');
66 $this->
ctrl->saveParameter($this,
'ref');
73 $forward_class = $this->
ctrl->getNextClass($this);
74 switch ($forward_class) {
76 if (!($cmd = $this->
ctrl->getCmd())) {
90 !$this->
http->wrapper()->query()->has(
'ref') ||
91 $this->
http->wrapper()->query()->retrieve(
'ref', $this->
refinery->kindlyTo()->string()) !==
'wsp' 97 $trafo = $this->
refinery->kindlyTo()->int();
99 $trafo = $this->
refinery->kindlyTo()->string();
103 foreach ([
'to',
'cc',
'bcc'] as $recipient_type) {
105 foreach ([
'addr',
'usr',
'grp'] as $search_type) {
106 if ($this->
http->wrapper()->post()->has(
'search_name_' . $recipient_type .
'_' . $search_type)) {
107 $recipients[] = $this->
http->wrapper()->post()->retrieve(
108 'search_name_' . $recipient_type .
'_' . $search_type,
109 $this->
refinery->kindlyTo()->listOf($trafo)
114 $recipients = array_unique(array_merge(...$recipients));
115 ilSession::set(
'mail_search_results_' . $recipient_type, $recipients);
117 if (
'to' === $recipient_type) {
118 $recipients_to = $recipients;
128 $this->
ctrl->returnToParent($this);
133 $mail_data = $this->umail->retrieveFromStage();
134 $this->umail->persistToStage(
135 (
int) $mail_data[
'user_id'],
136 $mail_data[
'attachments'],
137 $mail_data[
'rcp_to'],
138 $mail_data[
'rcp_cc'],
139 $mail_data[
'rcp_bcc'],
140 $mail_data[
'm_subject'],
141 $mail_data[
'm_message'],
142 $mail_data[
'use_placeholders'],
143 $mail_data[
'tpl_ctx_id'],
144 $mail_data[
'tpl_ctx_params']
150 $this->
ctrl->returnToParent($this);
156 if ($this->
http->wrapper()->post()->has(
'search')) {
157 $search = $this->
http->wrapper()->post()->retrieve(
'search', $this->
refinery->kindlyTo()->string());
163 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_insert_query'));
165 $this->
lng->loadLanguageModule(
'search');
166 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'search_minimum_three'));
178 $title = $this->
lng->txt(
'search_recipients');
180 $this->
lng->loadLanguageModule(
'wsp');
181 $title = $this->
lng->txt(
'wsp_share_search_users');
185 $form->setTitle($title);
186 $form->setId(
'search_rcp');
187 $form->setFormAction($this->
ctrl->getFormAction($this,
'search'));
191 $dsDataLink = $this->
ctrl->getLinkTarget($this,
'lookupRecipientAsync',
'',
true,
false);
192 $inp->setDataSource($dsDataLink);
203 $form->addItem($inp);
205 $form->addCommandButton(
'search', $this->
lng->txt(
'search'));
206 $form->addCommandButton(
'cancel', $this->
lng->txt(
'cancel'));
214 if ($this->
http->wrapper()->query()->has(
'term')) {
215 $search = $this->
http->wrapper()->query()->retrieve(
217 $this->
refinery->kindlyTo()->string()
220 if ($this->
http->wrapper()->post()->has(
'term')) {
221 $search = $this->
http->wrapper()->post()->retrieve(
223 $this->
refinery->kindlyTo()->string()
227 $search = trim($search);
233 $quoted = str_replace([
'%',
'_'], [
'\%',
'\_'], $quoted);
236 $result = $mailFormObj->getRecipientAsync(
243 $this->
http->saveResponse(
244 $this->
http->response()
245 ->withHeader(ResponseHeader::CONTENT_TYPE,
'application/json')
246 ->withBody(\
ILIAS\
Filesystem\Stream\Streams::ofString(json_encode($result, JSON_THROW_ON_ERROR)))
248 $this->
http->sendResponse();
249 $this->
http->close();
259 string $recipient_type,
264 'search_name_' . $recipient_type .
'_' . $search_type .
'[' . $index .
']',
268 $result[
$index][
'id_' . $recipient_type] =
'search_name_' . $search_type .
'_' .
$index;
269 $result[
$index][
'txt_' . $recipient_type] = $this->
lng->txt(
'mail_' . $recipient_type);
276 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.mail_search.html',
'Services/Contact');
277 $this->tpl->setVariable(
'ACTION', $this->
ctrl->getFormAction($this));
278 $this->tpl->setTitle($this->
lng->txt(
'mail'));
279 $this->tpl->setVariable(
'SEARCHFORM', $form->getHtml());
288 $this->tpl->printToStdout();
294 if (count($relations)) {
299 $query_parser->setMinWordLength(3);
300 $query_parser->parse();
303 $user_search->enableActiveCheck(
true);
304 $user_search->setFields([
'login']);
305 $result_obj = $user_search->performSearch();
306 $contacts_search_result->mergeEntries($result_obj);
308 $user_search->setFields([
'firstname']);
309 $result_obj = $user_search->performSearch();
310 $contacts_search_result->mergeEntries($result_obj);
312 $user_search->setFields([
'lastname']);
313 $result_obj = $user_search->performSearch();
314 $contacts_search_result->mergeEntries($result_obj);
316 $contacts_search_result->setMaxHits(100000);
317 $contacts_search_result->preventOverwritingMaxhits(
true);
322 $users = array_intersect($users, $relations->getKeys());
325 $tbl_contacts->setTitle($this->
lng->txt(
'mail_addressbook'));
326 $tbl_contacts->setRowTemplate(
'tpl.mail_search_addr_row.html',
'Services/Contact');
328 $has_mail_addr =
false;
331 foreach ($users as $user) {
335 foreach ([
'to',
'cc',
'bcc'] as $recipient_type) {
342 $result[$counter][
'login'] = $login;
344 $has_mail_addr =
true;
350 $result[$counter][
'firstname'] =
$name[
'firstname'];
351 $result[$counter][
'lastname'] =
$name[
'lastname'];
353 $result[$counter][
'firstname'] =
'';
354 $result[$counter][
'lastname'] =
'';
361 $tbl_contacts->addColumn(
362 $this->
lng->txt(
'mail_to') .
'/' . $this->
lng->txt(
'mail_cc') .
'/' . $this->
lng->txt(
'mail_bcc'),
367 $tbl_contacts->addColumn(
'',
'',
'1%',
true);
369 $tbl_contacts->addColumn($this->
lng->txt(
'login'),
'login',
'15%');
370 $tbl_contacts->addColumn($this->
lng->txt(
'firstname'),
'firstname',
'15%');
371 $tbl_contacts->addColumn($this->
lng->txt(
'lastname'),
'lastname',
'15%');
372 if ($has_mail_addr) {
373 foreach ($result as
$key => $val) {
374 if (!isset($val[
'email']) || (string) $val[
'email'] ===
'') {
375 $result[
$key][
'email'] =
' ';
379 $tbl_contacts->addColumn($this->
lng->txt(
'email'),
'email',
"15%");
381 $tbl_contacts->setData($result);
383 $tbl_contacts->setDefaultOrderField(
'login');
384 $tbl_contacts->enable(
'select_all');
385 $tbl_contacts->setSelectAllCheckbox(
'search_name_to_addr');
386 $tbl_contacts->setFormName(
'recipients');
388 $this->tpl->setVariable(
'TABLE_ADDR', $tbl_contacts->getHTML());
395 $query_parser->setMinWordLength(3);
396 $query_parser->parse();
399 $user_search->enableActiveCheck(
true);
400 $user_search->setFields([
'login']);
401 $result_obj = $user_search->performSearch();
402 $all_results->mergeEntries($result_obj);
404 $user_search->setFields([
'firstname']);
405 $result_obj = $user_search->performSearch();
406 $all_results->mergeEntries($result_obj);
408 $user_search->setFields([
'lastname']);
409 $result_obj = $user_search->performSearch();
410 $all_results->mergeEntries($result_obj);
412 $all_results->setMaxHits(100000);
413 $all_results->preventOverwritingMaxhits(
true);
417 $has_mail_usr =
false;
421 $tbl_users->setTitle($this->
lng->txt(
'system') .
': ' . $this->
lng->txt(
'persons'));
422 $tbl_users->setRowTemplate(
'tpl.mail_search_users_row.html',
'Services/Contact');
426 foreach ($users as $user) {
430 foreach ([
'to',
'cc',
'bcc'] as $recipient_type) {
436 $result[$counter][
'login'] = $login;
440 $result[$counter][
'firstname'] =
$name[
'firstname'];
441 $result[$counter][
'lastname'] =
$name[
'lastname'];
443 $result[$counter][
'firstname'] =
'';
444 $result[$counter][
'lastname'] =
'';
448 $has_mail_usr =
true;
456 $tbl_users->addColumn(
457 $this->
lng->txt(
'mail_to') .
'/' . $this->
lng->txt(
'mail_cc') .
'/' . $this->
lng->txt(
'mail_bcc'),
462 $tbl_users->addColumn(
'',
'',
'1%');
464 $tbl_users->addColumn($this->
lng->txt(
'login'),
'login',
'15%');
465 $tbl_users->addColumn($this->
lng->txt(
'firstname'),
'firstname',
'15%');
466 $tbl_users->addColumn($this->
lng->txt(
'lastname'),
'lastname',
'15%');
467 if ($has_mail_usr ===
true) {
468 foreach ($result as
$key => $val) {
469 if (!isset($val[
'email']) || (string) $val[
'email'] ===
'') {
470 $result[
$key][
'email'] =
' ';
474 $tbl_users->addColumn($this->
lng->txt(
'email'),
'email',
'15%');
476 $tbl_users->setData($result);
478 $tbl_users->setDefaultOrderField(
'login');
479 $tbl_users->enable(
'select_all');
480 $tbl_users->setSelectAllCheckbox(
'search_name_to_usr');
481 $tbl_users->setFormName(
'recipients');
483 $this->tpl->setVariable(
'TABLE_USERS', $tbl_users->getHTML());
490 $query_parser->setMinWordLength(3);
491 $query_parser->parse();
494 $search->setFilter([
'grp']);
495 $result = $search->performSearch();
496 $group_results->mergeEntries($result);
497 $group_results->setMaxHits(PHP_INT_MAX);
498 $group_results->preventOverwritingMaxhits(
true);
499 $group_results->setRequiredPermission(
'read');
502 $visible_groups = [];
503 if ($group_results->getResults()) {
505 $tbl_grp->setTitle($this->
lng->txt(
'system') .
': ' . $this->
lng->txt(
'groups'));
506 $tbl_grp->setRowTemplate(
'tpl.mail_search_groups_row.html',
'Services/Contact');
511 $this->object_data_cache->preloadReferenceCache(array_keys($group_results->getResults()));
513 $groups = $group_results->getResults();
514 foreach ($groups as $grp) {
521 $roles = $this->rbacreview->getAssignableChildRoles($grp[
'ref_id']);
522 foreach ($roles as $role) {
524 strpos($role[
'title'],
'il_grp_member_') === 0 ||
525 strpos($role[
'title'],
'il_grp_admin_') === 0
528 $members[] =
'#' . $role[
'title'];
531 $str_members = implode(
',', $members);
533 foreach ([
'to',
'cc',
'bcc'] as $recipient_type) {
539 $result[$counter][
'title'] = $this->object_data_cache->lookupTitle((
int) $grp[
'obj_id']);
540 $result[$counter][
'description'] = $this->object_data_cache->lookupDescription((
int) $grp[
'obj_id']);
543 $visible_groups[] = $grp;
546 if ($visible_groups) {
547 $tbl_grp->setData($result);
551 $this->
lng->txt(
'mail_to') .
'/' . $this->
lng->txt(
'mail_cc') .
'/' . $this->
lng->txt(
'mail_bcc'),
556 $tbl_grp->addColumn(
'',
'',
'1%');
558 $tbl_grp->addColumn($this->
lng->txt(
'title'),
'title',
'15%');
559 $tbl_grp->addColumn($this->
lng->txt(
'description'),
'description',
'15%');
561 $tbl_grp->setDefaultOrderField(
'title');
562 $tbl_grp->enable(
'select_all');
563 $tbl_grp->setSelectAllCheckbox(
'search_name_to_grp');
564 $tbl_grp->setFormName(
'recipients');
566 $this->tpl->setVariable(
'TABLE_GRP', $tbl_grp->getHTML());
570 if (count($users) || count($visible_groups) || count($relations)) {
572 $this->tpl->setVariable(
"ALT_ARROW",
'');
574 $this->tpl->setVariable(
"ALT_ARROW_UP",
'');
577 $this->tpl->setVariable(
'BUTTON_ADOPT', $this->
lng->txt(
'adopt'));
579 $this->tpl->setVariable(
'BUTTON_ADOPT', $this->
lng->txt(
'wsp_share_with_users'));
582 $this->
lng->loadLanguageModule(
'search');
583 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'search_no_match'));
587 $this->tpl->printToStdout();
596 if (!is_array($a_obj_ids)) {
597 $a_obj_ids = [$a_obj_ids];
600 $existing = $this->wsp_access_handler->getPermissions($this->wsp_node_id);
602 foreach ($a_obj_ids as $object_id) {
603 if (!in_array($object_id, $existing,
true)) {
604 $added = $this->wsp_access_handler->addPermission($this->wsp_node_id, $object_id);
609 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'wsp_share_success'),
true);
Interface GlobalHttpState.
static get(string $a_var)
static getInstanceByGlobalUser()
Class ChatMainBarProvider .
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static _lookupName(int $a_user_id)
lookup user name
static _lookupPref(int $a_usr_id, string $a_keyword)
static _getUserSearchInstance(ilQueryParser $query_parser)
ilObjectDataCache $object_data_cache
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static strLen(string $a_string)
static http()
Fetches the global http state from ILIAS.
static _getObjectSearchInstance(ilQueryParser $query_parser)
static hasParticipantListAccess(int $a_obj_id, int $a_usr_id=null)
Check if (current) user has access to the participant list.
ilGlobalTemplateInterface $tpl
addPermission(array $a_obj_ids)
isDefaultRequestContext()
__construct(Container $dic, ilPlugin $plugin)
appendRecipientSelection(array &$result, int $index, string $search_type, string $recipient_type, string $value)
static _lookupEmail(int $a_user_id)
static set(string $a_var, $a_val)
Set a value.
Class FlySystemFileAccessTest disabled disabled disabled.
static _lookupLogin(int $a_user_id)