19 declare(strict_types=1);
55 $this->tpl = $DIC[
'tpl'];
56 $this->
ctrl = $DIC[
'ilCtrl'];
57 $this->
lng = $DIC[
'lng'];
58 $this->
user = $DIC[
'ilUser'];
59 $this->error = $DIC[
'ilErr'];
60 $this->rbacsystem = $DIC[
'rbacsystem'];
61 $this->rbacreview = $DIC[
'rbacreview'];
62 $this->tree = $DIC[
'tree'];
63 $this->cache = $DIC[
'ilObjDataCache'];
64 $this->
http = $DIC->http();
70 $this->
ctrl->saveParameter($this,
'mobj_id');
71 $this->
ctrl->saveParameter($this,
'ref');
74 $this->mailing_allowed = $this->rbacsystem->checkAccess(
'internal_mail', $mail->getMailObjectReferenceId());
82 !$this->
http->wrapper()->query()->has(
'ref') ||
83 $this->
http->wrapper()->query()->retrieve(
'ref', $this->
refinery->kindlyTo()->string()) !==
'wsp' 90 if ($this->
http->wrapper()->query()->has(
'ref')) {
91 $context = $this->
http->wrapper()->query()->retrieve(
'ref', $this->
refinery->kindlyTo()->string());
100 if (strpos($title, $local_role_prefix) === 0) {
118 if ($this->
http->wrapper()->query()->has($key)) {
119 $value = $this->
http->wrapper()->query()->retrieve($key, $trafo);
122 if ($this->
http->wrapper()->post()->has($key)) {
123 $value = $this->
http->wrapper()->post()->retrieve($key, $trafo);
134 $existing = $this->wsp_access_handler->getPermissions($this->wsp_node_id);
136 foreach ($a_obj_ids as $object_id) {
137 if (!in_array($object_id, $existing,
true)) {
138 $added = $this->wsp_access_handler->addPermission($this->wsp_node_id, $object_id);
143 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'wsp_share_success'),
true);
145 $this->
ctrl->redirectByClass(ilWorkspaceAccessGUI::class,
'share');
151 if ($this->
http->wrapper()->query()->has(
'view')) {
152 $view = $this->
http->wrapper()->query()->retrieve(
'view', $this->
refinery->kindlyTo()->string());
155 if ($view ===
'myobjects') {
159 $this->
http->wrapper()->query()->retrieve(
164 } elseif ($this->
http->wrapper()->post()->has(
'search_' . $this->
getObjectType())) {
165 $obj_ids = $this->
http->wrapper()->post()->retrieve(
171 if ($obj_ids !== []) {
174 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_course'));
175 $this->showMyObjects();
179 if ($this->
http->wrapper()->query()->has(
'search_members')) {
181 $this->
http->wrapper()->query()->retrieve(
186 } elseif ($this->
http->wrapper()->post()->has(
'search_members')) {
187 $usr_ids = $this->
http->wrapper()->post()->retrieve(
193 if ($usr_ids !== []) {
196 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_one_entry'));
197 $this->showMembers();
200 $this->showMyObjects();
204 protected function mail(): void
207 if ($this->
http->wrapper()->query()->has(
'view')) {
208 $view = $this->
http->wrapper()->query()->retrieve(
'view', $this->
refinery->kindlyTo()->string());
211 if ($view ===
'myobjects') {
215 $this->
http->wrapper()->query()->retrieve(
220 } elseif ($this->
http->wrapper()->post()->has(
'search_' . $this->
getObjectType())) {
221 $obj_ids = $this->
http->wrapper()->post()->retrieve(
227 if ($obj_ids !== []) {
230 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_course'));
231 $this->showMyObjects();
235 if ($this->
http->wrapper()->query()->has(
'search_members')) {
237 $this->
http->wrapper()->query()->retrieve(
242 } elseif ($this->
http->wrapper()->post()->has(
'search_members')) {
243 $usr_ids = $this->
http->wrapper()->post()->retrieve(
249 if ($usr_ids !== []) {
252 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_one_entry'));
253 $this->showMembers();
256 $this->showMyObjects();
263 $mail_data = $this->umail->retrieveFromStage();
268 $this->
http->wrapper()->query()->retrieve(
273 } elseif ($this->
http->wrapper()->post()->has(
'search_' . $this->
getObjectType())) {
274 $obj_ids = $this->
http->wrapper()->post()->retrieve(
280 foreach ($obj_ids as $obj_id) {
282 foreach ($ref_ids as
$ref_id) {
285 $this->
user->getId(),
288 if (!$can_send_mails) {
292 $roles = $this->rbacreview->getAssignableChildRoles($ref_id);
293 foreach ($roles as $role) {
296 if (!$this->umail->existsRecipient($recipient, (
string) $mail_data[
'rcp_to'])) {
297 $members[] = $recipient;
304 $mail_data = $members !== [] ? $this->umail->appendSearchResult(array_unique($members),
'to') : $this->umail->retrieveFromStage();
306 $this->umail->persistToStage(
307 (
int) $mail_data[
'user_id'],
308 $mail_data[
'attachments'],
309 $mail_data[
'rcp_to'],
310 $mail_data[
'rcp_cc'],
311 $mail_data[
'rcp_bcc'],
312 $mail_data[
'm_subject'],
313 $mail_data[
'm_message'],
314 $mail_data[
'use_placeholders'],
315 $mail_data[
'tpl_ctx_id'],
316 $mail_data[
'tpl_ctx_params']
319 $this->
ctrl->redirectToURL(
'ilias.php?baseClass=ilMailGUI&type=search_res');
326 if ($this->
http->wrapper()->query()->has(
'search_members')) {
328 $this->
http->wrapper()->query()->retrieve(
333 } elseif ($this->
http->wrapper()->post()->has(
'search_members')) {
334 $usr_ids = $this->
http->wrapper()->post()->retrieve(
340 $mail_data = $this->umail->retrieveFromStage();
341 foreach ($usr_ids as $usr_id) {
343 if (!$this->umail->existsRecipient($login, (
string) $mail_data[
'rcp_to'])) {
347 $mail_data = $this->umail->appendSearchResult(array_unique($members),
'to');
349 $this->umail->persistToStage(
350 (
int) $mail_data[
'user_id'],
351 $mail_data[
'attachments'],
352 $mail_data[
'rcp_to'],
353 $mail_data[
'rcp_cc'],
354 $mail_data[
'rcp_bcc'],
355 $mail_data[
'm_subject'],
356 $mail_data[
'm_message'],
357 $mail_data[
'use_placeholders'],
358 $mail_data[
'tpl_ctx_id'],
359 $mail_data[
'tpl_ctx_params']
362 $this->
ctrl->redirectToURL(
'ilias.php?baseClass=ilMailGUI&type=search_res');
368 if ($this->
http->wrapper()->query()->has(
'view')) {
369 $view = $this->
http->wrapper()->query()->retrieve(
'view', $this->
refinery->kindlyTo()->string());
373 $this->
ctrl->returnToParent($this);
375 $this->showMyObjects();
379 public function showMembers():
void 383 $obj_ids = $this->
refinery->kindlyTo()->listOf(
385 )->transform(explode(
',', $this->
http->wrapper()->query()->retrieve(
387 $this->
refinery->kindlyTo()->string()
389 } elseif ($this->
http->wrapper()->post()->has(
'search_' . $this->
getObjectType())) {
390 $obj_ids = $this->
http->wrapper()->post()->retrieve(
392 $this->
refinery->kindlyTo()->listOf(
397 $obj_ids = $this->
refinery->kindlyTo()->listOf(
403 if ($obj_ids === []) {
404 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_course'));
405 $this->showMyObjects();
409 foreach ($obj_ids as $obj_id) {
412 if (!$object->getShowMembers()) {
413 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_crs_list_members_not_available_for_at_least_one_crs'));
414 $this->showMyObjects();
419 $this->tpl->setTitle($this->
lng->txt(
'mail_addressbook'));
422 if ($obj_ids !== []) {
423 $this->
ctrl->setParameter($this,
'search_' . $this->
getObjectType(), implode(
',', $obj_ids));
425 $this->tpl->setVariable(
'ACTION', $this->
ctrl->getFormAction($this));
426 $this->
ctrl->clearParameters($this);
440 $searchTpl =
new ilTemplate(
'tpl.mail_search_template.html',
true,
true,
'Services/Contact');
441 foreach ($obj_ids as $obj_id) {
443 $usr_ids = array_map(
'intval',
ilUtil::_sortIds($members_obj->getParticipants(),
'usr_data',
'lastname',
'usr_id'));
444 foreach ($usr_ids as $usr_id) {
456 'members_id' => $user->
getId(),
457 'members_login' => $user->
getLogin(),
458 'members_name' => $fullname,
459 'members_crs_grp' => $this->cache->lookupTitle((
int) $obj_id),
466 $rowData[
'status'] =
'';
467 if ($user->
getId() !== $this->
user->getId()) {
468 if ($relation->isOwnedByActor()) {
469 $rowData[
'status'] = $this->
lng->txt(
'buddy_bs_state_' . $state_name .
'_a');
471 $rowData[
'status'] = $this->
lng->txt(
'buddy_bs_state_' . $state_name .
'_p');
476 $tableData[] = $rowData;
479 $table->setData($tableData);
481 if (count($tableData)) {
482 $searchTpl->setVariable(
'TXT_MARKED_ENTRIES', $this->
lng->txt(
'marked_entries'));
485 $searchTpl->setVariable(
'TABLE', $table->getHTML());
486 $this->tpl->setContent($searchTpl->get());
489 $this->tpl->printToStdout();
495 public function showMyObjects():
void 497 $this->tpl->setTitle($this->
lng->txt(
'mail_addressbook'));
499 $searchTpl =
new ilTemplate(
'tpl.mail_search_template.html',
true,
true,
'Services/Contact');
501 $this->
lng->loadLanguageModule(
'crs');
513 if ($objs_ids !== []) {
514 $num_courses_hidden_members = 0;
515 foreach ($objs_ids as $obj_id) {
526 $this->
user->getId(),
530 if ($has_untrashed_references && ($can_send_mails || $this->
doesExposeMembers($object))) {
531 $member_list_enabled = $object->getShowMembers();
533 $usr_ids = $participants->getParticipants();
535 foreach ($usr_ids as
$key => $usr_id) {
538 unset($usr_ids[
$key]);
541 $usr_ids = array_values($usr_ids);
543 $hiddenMembers =
false;
544 if (!$member_list_enabled) {
545 ++$num_courses_hidden_members;
546 $hiddenMembers =
true;
549 $path_arr = $this->tree->getPathFull($object->
getRefId(), $this->tree->getRootId());
551 foreach ($path_arr as
$data) {
555 $path .= $data[
'title'];
559 $current_selection_list->setListTitle($this->
lng->txt(
'actions'));
560 $current_selection_list->setId(
'act_' . $counter);
563 $this->
ctrl->setParameter($this,
'view',
'myobjects');
566 if ($this->mailing_allowed && $can_send_mails) {
567 $current_selection_list->addItem(
568 $this->
lng->txt(
'mail_members'),
570 $this->
ctrl->getLinkTarget($this,
'mail')
574 $current_selection_list->addItem(
575 $this->
lng->txt(
'wsp_share_with_members'),
577 $this->
ctrl->getLinkTarget($this,
'share')
580 $current_selection_list->addItem(
581 $this->
lng->txt(
'mail_list_members'),
583 $this->
ctrl->getLinkTarget($this,
'showMembers')
586 $this->
ctrl->clearParameters($this);
589 'OBJECT_ID' => $object->
getId(),
590 'OBJECT_NAME' => $object->
getTitle(),
591 'OBJECT_NO_MEMBERS' => count($usr_ids),
592 'OBJECT_PATH' =>
$path,
593 'COMMAND_SELECTION_LIST' => $current_selection_list->getHTML(),
594 'hidden_members' => $hiddenMembers,
597 $tableData[] = $rowData;
601 if ($num_courses_hidden_members > 0) {
602 $searchTpl->setCurrentBlock(
'caption_block');
603 $searchTpl->setVariable(
'TXT_LIST_MEMBERS_NOT_AVAILABLE', $this->
lng->txt(
'mail_crs_list_members_not_available'));
604 $searchTpl->parseCurrentBlock();
608 $searchTpl->setVariable(
'TXT_MARKED_ENTRIES', $this->
lng->txt(
'marked_entries'));
610 $table->setData($tableData);
611 $searchTpl->setVariable(
'TABLE', $table->getHTML());
612 $this->tpl->setContent($searchTpl->get());
615 $this->tpl->printToStdout();
621 $forward_class = $this->
ctrl->getNextClass($this);
622 switch (strtolower($forward_class)) {
623 case strtolower(ilBuddySystemGUI::class):
625 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
630 $this->
ctrl->setReturn($this,
'showMembers');
635 if (!($cmd = $this->
ctrl->getCmd())) {
636 $cmd =
'showMyObjects';
static canSendMailToMembers( $ref_id_or_instance, ?int $usr_id=null, ?int $mail_obj_ref_id=null)
This method was introduced as a band-aid fix for #22764.
Interface GlobalHttpState.
static get(string $a_var)
__construct($wsp_access_handler=null, ?int $wsp_node_id=null)
static getInstanceByGlobalUser()
static convertUpperCamelCaseToUnderscoreCase(string $value)
Convert a value given in camel case conversion to underscore case conversion (e.g.
Class ChatMainBarProvider .
static _getAllReferences(int $id)
get all reference ids for object ID
static getInstanceByObjId(int $a_obj_id)
Get instance by obj type.
Class ilRoleMailboxAddress.
static _hasUntrashedReference(int $obj_id)
checks whether an object has at least one reference that is not in trash
static _lookupPref(int $a_usr_id, string $a_keyword)
doesExposeMembers(ilObject $object)
ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isLocalRoleTitle(string $title)
addPermission(array $a_obj_ids)
static http()
Fetches the global http state from ILIAS.
static _sortIds(array $a_ids, string $a_table, string $a_field, string $a_id_name)
Function that sorts ids by a given table field using WHERE IN E.g: __sort(array(6,7),'usr_data','lastname','usr_id') => sorts by lastname.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Error Handling & global info handling uses PEAR error class.
getLocalDefaultRolePrefixes()
static getMailObjectRefId()
isDefaultRequestContext()
static _getMembershipByType(int $a_usr_id, array $a_type, bool $a_only_member_role=false)
get membership by type Get course or group membership
static set(string $a_var, $a_val)
Set a value.
static _lookupActive(int $a_usr_id)
getRequestValue(string $key, \ILIAS\Refinery\Transformation $trafo, $default=null)
static _lookupLogin(int $a_user_id)