19 declare(strict_types=1);
    31     private readonly \ILIAS\HTTP\GlobalHttpState 
$http;
    51         $this->tpl = $DIC->ui()->mainTemplate();
    52         $this->
ctrl = $DIC[
'ilCtrl'];
    53         $this->
lng = $DIC[
'lng'];
    54         $this->rbacsystem = $DIC[
'rbacsystem'];
    55         $this->
user = $DIC[
'ilUser'];
    56         $this->error = $DIC[
'ilErr'];
    57         $this->
toolbar = $DIC[
'ilToolbar'];
    58         $this->
http = $DIC->http();
    60         $this->ui_factory = $DIC->ui()->factory();
    61         $this->ui_renderer = $DIC->ui()->renderer();
    62         $this->
tabs = $DIC->tabs();
    68         $this->
ctrl->saveParameter($this, 
'mobj_id');
    69         $this->
ctrl->saveParameter($this, 
'ref');
    71         $this->
lng->loadLanguageModule(
'mail');
    76         return $this->
http->wrapper()->query()->retrieve(
    79                 $this->refinery->kindlyTo()->int(),
    82                         $this->
http->wrapper()->query()->retrieve(
    83                             'contact_mailinglist_list_ml_ids',
    85                                 $this->refinery->kindlyTo()->listOf($this->
refinery->kindlyTo()->int()),
   101                 !$this->mlists->hasAny()
   104             $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
   107         if (!($cmd = $this->
ctrl->getCmd())) {
   108             $cmd = 
'showMailingLists';
   118         $action = $this->
http->wrapper()->query()->retrieve(
   119             'contact_mailinglist_members_action',
   121                 $this->refinery->kindlyTo()->string(),
   127             default => $this->
ctrl->redirect($this, 
'showMailingLists'),
   133         $action = $this->
http->wrapper()->query()->retrieve(
   134             'contact_mailinglist_list_action',
   136                 $this->refinery->kindlyTo()->string(),
   145             default => $this->
ctrl->redirect($this, 
'showMailingLists'),
   154         if ($this->
http->wrapper()->query()->has(
'ml_id')) {
   156                 $this->
http->wrapper()->query()->retrieve(
'ml_id', $this->
refinery->kindlyTo()->int())
   158         } elseif ($this->
http->wrapper()->post()->has(
'ml_id')) {
   159             $ml_ids = $this->
http->wrapper()->post()->retrieve(
   161                 $this->
refinery->kindlyTo()->listOf(
   166             $ml_ids = $this->
http->wrapper()->query()->retrieve(
   167                 'contact_mailinglist_list_ml_ids',
   169                     $this->refinery->kindlyTo()->listOf($this->
refinery->kindlyTo()->string()),
   175         return array_filter($ml_ids);
   181         if ($ml_ids === []) {
   182             $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_one_entry'));
   187         if ((
string) current($ml_ids) === 
'ALL_OBJECTS') {
   188             $entries = $this->mlists->getAll();
   190             $entries = $this->mlists->getSelected(
   197         $c_gui->setFormAction($this->
ctrl->getFormAction($this, 
'performDelete'));
   198         $c_gui->setHeaderText($this->
lng->txt(
'mail_sure_delete_entry'));
   199         $c_gui->setCancel($this->
lng->txt(
'cancel'), 
'showMailingLists');
   200         $c_gui->setConfirm($this->
lng->txt(
'confirm'), 
'performDelete');
   202         foreach ($entries as $entry) {
   203             $c_gui->addItem(
'ml_id[]', (
string) $entry->getId(), $entry->getTitle());
   206         $this->tpl->setTitle($this->
lng->txt(
'mail_addressbook'));
   207         $this->tpl->addBlockFile(
   210             'tpl.mail_mailing_lists_list.html',
   211             'components/ILIAS/Contact'   213         $this->tpl->setVariable(
'DELETE_CONFIRMATION', $c_gui->getHTML());
   215         $this->tpl->printToStdout();
   222         if ($this->
http->wrapper()->post()->has(
'ml_id')) {
   223             $ml_ids = array_filter(
   224                 $this->
http->wrapper()->post()->retrieve(
   226                     $this->
refinery->kindlyTo()->listOf(
   233             foreach ($ml_ids as 
$id) {
   234                 if ($this->mlists->isOwner($id, $this->user->getId())) {
   235                     $this->mlists->get($id)->delete();
   240             if ($counter !== 0) {
   241                 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'mail_deleted_entry'));
   244             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'mail_delete_error'));
   256         $mailing_allowed = $this->rbacsystem->checkAccess(
'internal_mail', $mail->getMailObjectReferenceId());
   258         if (!$mailing_allowed) {
   259             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_permission'));
   264         if ($ml_ids === []) {
   265             $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_one_entry'));
   270         if ((
string) current($ml_ids) === 
'ALL_OBJECTS') {
   271             $entries = $this->mlists->getAll();
   273             foreach ($entries as $entry) {
   274                 $ml_ids[] = $entry->getId();
   277             $ml_ids = 
array_map(intval(...), $ml_ids);
   280         $mail_data = $this->umail->retrieveFromStage();
   282         foreach ($ml_ids as 
$id) {
   283             if ($this->mlists->isOwner($id, $this->user->getId()) &&
   284                 !$this->umail->existsRecipient(
'#il_ml_' . $id, (
string) $mail_data[
'rcp_to'])) {
   285                 $lists[
'#il_ml_' . 
$id] = 
'#il_ml_' . 
$id;
   290             $mail_data = $this->umail->appendSearchResult(array_values($lists), 
'to');
   291             $this->umail->persistToStage(
   292                 (
int) $mail_data[
'user_id'],
   293                 $mail_data[
'attachments'],
   294                 $mail_data[
'rcp_to'],
   295                 $mail_data[
'rcp_cc'],
   296                 $mail_data[
'rcp_bcc'],
   297                 $mail_data[
'm_subject'],
   298                 $mail_data[
'm_message'],
   299                 $mail_data[
'use_placeholders'],
   300                 $mail_data[
'tpl_ctx_id'],
   301                 $mail_data[
'tpl_ctx_params']
   312         $this->tpl->setTitle($this->
lng->txt(
'mail_addressbook'));
   313         $this->tpl->addBlockFile(
   316             'tpl.mail_mailing_lists_list.html',
   317             'components/ILIAS/Contact'   324             $this->ui_factory->button()->standard(
   325                 $this->
lng->txt(
'create'),
   326                 $this->
ctrl->getLinkTarget($this, 
'showForm')
   337         $tbl->setMailingAllowed($this->rbacsystem->checkAccess(
'internal_mail', $mail->getMailObjectReferenceId()));
   338         $this->tpl->setVariable(
'MAILING_LISTS', $this->ui_renderer->render($tbl->getComponent()));
   339         $this->tpl->printToStdout();
   347             $this->
http->wrapper()->query()->has(
'ref') &&
   348             $this->
http->wrapper()->query()->retrieve(
'ref', $this->
refinery->kindlyTo()->string()) === 
'mail') {
   349             $this->
ctrl->returnToParent($this);
   357         if ($this->mlists->getCurrentMailingList() && $this->mlists->getCurrentMailingList()->getId()) {
   358             if (!$this->mlists->isOwner($this->mlists->getCurrentMailingList()->getId(), $this->
user->getId())) {
   359                 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
   362             $this->
ctrl->setParameter($this, 
'ml_id', $this->mlists->getCurrentMailingList()->getId());
   368         if ($this->form_gui->checkInput()) {
   369             $this->mlists->getCurrentMailingList()->setTitle(
   370                 $this->form_gui->getInput(
'title')
   372             $this->mlists->getCurrentMailingList()->setDescription(
   373                 $this->form_gui->getInput(
'description')
   376             $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'), 
true);
   377             if ($this->mlists->getCurrentMailingList()->getId() > 0) {
   378                 $this->mlists->getCurrentMailingList()->setChangedate(date(
'Y-m-d H:i:s'));
   379                 $this->mlists->getCurrentMailingList()->update();
   380                 $this->
ctrl->redirect($this, 
'showMailingLists');
   382                 $this->mlists->getCurrentMailingList()->setCreatedate(date(
'Y-m-d H:i:s'));
   383                 $this->mlists->getCurrentMailingList()->insert();
   385                 $this->
ctrl->setParameter($this, 
'ml_id', $this->mlists->getCurrentMailingList()->getId());
   386                 $this->
ctrl->redirect($this, 
'showMembersList');
   390         $this->tpl->setTitle($this->
lng->txt(
'mail_addressbook'));
   391         $this->tpl->addBlockFile(
   394             'tpl.mail_mailing_lists_form.html',
   395             'components/ILIAS/Contact'   398         $this->form_gui->setValuesByPost();
   400         $this->tpl->setVariable(
'FORM', $this->form_gui->getHTML());
   401         $this->tpl->printToStdout();
   407         $this->form_gui->setFormAction($this->
ctrl->getFormAction($this, 
'saveForm'));
   408         $this->form_gui->setTitle($this->
lng->txt(
'mail_mailing_list'));
   410         $titleGui->setRequired(
true);
   411         $this->form_gui->addItem($titleGui);
   414         $descriptionGui->setRows(8);
   415         $this->form_gui->addItem($descriptionGui);
   416         $this->form_gui->addCommandButton(
'saveForm', $this->
lng->txt(
'save'));
   417         $this->form_gui->addCommandButton(
'showMailingLists', $this->
lng->txt(
'cancel'));
   422         $this->form_gui->setValuesByArray([
   423             'title' => $this->mlists->getCurrentMailingList()->getTitle(),
   424             'description' => $this->mlists->getCurrentMailingList()->getDescription() ?? 
''   430         $this->form_gui->setValuesByArray([
   438         $this->tpl->setTitle($this->
lng->txt(
'mail_addressbook'));
   439         $this->tpl->addBlockFile(
   442             'tpl.mail_mailing_lists_form.html',
   443             'components/ILIAS/Contact'   446         if ($this->mlists->getCurrentMailingList() && $this->mlists->getCurrentMailingList()->getId()) {
   447             if (!$this->mlists->isOwner($this->mlists->getCurrentMailingList()->getId(), $this->
user->getId())) {
   448                 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
   451             $this->
ctrl->setParameter($this, 
'ml_id', $this->mlists->getCurrentMailingList()->getId());
   459         $this->tpl->setVariable(
'FORM', $this->form_gui->getHTML());
   460         $this->tpl->printToStdout();
   465         if ($this->mlists->getCurrentMailingList()->getId() === 0) {
   471         $this->
tabs->clearTargets();
   472         $this->
tabs->setBackTarget(
   473             $this->
lng->txt(
'back'),
   474             $this->
ctrl->getLinkTarget($this, 
'showMailingLists')
   477         $this->
ctrl->setParameter($this, 
'ml_id', $this->mlists->getCurrentMailingList()->getId());
   479         $this->tpl->setTitle($this->
lng->txt(
'mail_addressbook'));
   480         $this->tpl->addBlockFile(
   483             'tpl.mail_mailing_lists_members.html',
   484             'components/ILIAS/Contact'   487         $availale_usr_ids = array_diff(
   495                 static function (array $entry): 
int {
   496                     return $entry[
'usr_id'];
   498                 $this->mlists->getCurrentMailingList()->getAssignedEntries()
   502         if ($availale_usr_ids !== []) {
   504                 $this->ui_factory->button()->standard(
   505                     $this->
lng->txt(
'add'),
   506                     $this->
ctrl->getLinkTarget($this, 
'showAssignmentForm')
   512             $this->mlists->getCurrentMailingList(),
   518         $this->tpl->setVariable(
'MEMBERS_LIST', $this->ui_renderer->render($tbl->getComponent()));
   519         $this->tpl->printToStdout();
   526         $requested_record_ids = $this->
http->wrapper()->query()->retrieve(
   527             'contact_mailinglist_members_entry_ids',
   529                 $this->refinery->kindlyTo()->listOf($this->
refinery->kindlyTo()->string()),
   534         if ($requested_record_ids === []) {
   535             $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_one_entry'));
   541         if ((
string) current($requested_record_ids) === 
'ALL_OBJECTS') {
   542             $assigned_entries = $this->mlists->getCurrentMailingList()->getAssignedEntries();
   543             $requested_record_ids = [];
   544             foreach ($assigned_entries as $entry) {
   545                 $requested_record_ids[] = $entry[
'a_id'];
   548             $requested_record_ids = 
array_map(intval(...), $requested_record_ids);
   552         $this->
ctrl->setParameter($this, 
'ml_id', $this->mlists->getCurrentMailingList()->getId());
   553         $c_gui->setFormAction($this->
ctrl->getFormAction($this, 
'performDeleteMembers'));
   554         $c_gui->setHeaderText($this->
lng->txt(
'mail_sure_remove_user'));
   555         $c_gui->setCancel($this->
lng->txt(
'cancel'), 
'showMembersList');
   556         $c_gui->setConfirm($this->
lng->txt(
'confirm'), 
'performDeleteMembers');
   558         $assigned_entries = $this->mlists->getCurrentMailingList()->getAssignedEntries();
   559         $usr_ids = 
array_map(
static fn(array $entry): 
int => $entry[
'usr_id'], $assigned_entries);
   562         foreach ($assigned_entries as $entry) {
   563             if (in_array($entry[
'a_id'], $requested_record_ids, 
true)) {
   564                 $c_gui->addItem(
'a_id[]', (
string) $entry[
'a_id'], $names[$entry[
'usr_id']]);
   568         $this->tpl->setTitle($this->
lng->txt(
'mail_addressbook'));
   569         $this->tpl->addBlockFile(
   572             'tpl.mail_mailing_lists_members.html',
   573             'components/ILIAS/Contact'   575         $this->tpl->setVariable(
'DELETE_CONFIRMATION', $c_gui->getHTML());
   577         $this->tpl->printToStdout();
   584         if (!$this->mlists->isOwner($this->mlists->getCurrentMailingList()->getId(), $this->
user->getId())) {
   585             $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
   589             $this->
http->wrapper()->post()->has(
'a_id') &&
   590             ($requested_entry_ids = $this->
http->wrapper()->post()->retrieve(
   595             $assigned_entries = $this->mlists->getCurrentMailingList()->getAssignedEntries();
   596             foreach ($requested_entry_ids as 
$id) {
   597                 if (isset($assigned_entries[$id])) {
   598                     $this->mlists->getCurrentMailingList()->deleteEntry($id);
   601             $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'mail_success_removed_user'));
   603             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'mail_delete_error'));
   614         $this->
ctrl->setParameter($this, 
'ml_id', $this->mlists->getCurrentMailingList()->getId());
   615         $form->setFormAction($this->
ctrl->getFormAction($this, 
'saveAssignmentForm'));
   618                 $this->
lng->txt(
'mail_assign_entry_to_mailing_list'),
   619                 $this->mlists->getCurrentMailingList()->getTitle()
   624         $options[
''] = $this->
lng->txt(
'please_select');
   628             array_keys($relations->toArray()),
   638             $options[$relation->getBuddyUsrId()] = $names[$relation->getBuddyUsrId()];
   641         $assigned_entries = $this->mlists->getCurrentMailingList()->getAssignedEntries();
   642         foreach ($assigned_entries as $assigned_entry) {
   643             if (array_key_exists($assigned_entry[
'usr_id'], $options)) {
   644                 unset($options[$assigned_entry[
'usr_id']]);
   648         if (count($options) > 1) {
   651             $formItem->setOptions($options);
   652             $form->addItem($formItem);
   654             $form->addCommandButton(
'saveAssignmentForm', $this->
lng->txt(
'mail_assign_to_mailing_list'));
   655         } elseif (count($options) === 1 && count($relations) > 0) {
   656             $this->tpl->setOnScreenMessage(
   658                 $this->
lng->txt(
'mail_mailing_lists_all_contact_entries_assigned'),
   661             $this->
ctrl->redirect($this, 
'showMembersList');
   662         } elseif (count($relations) === 0) {
   663             $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_mailing_lists_no_contact_entries'), 
true);
   664             $this->
ctrl->redirect($this, 
'showMembersList');
   666         $form->addCommandButton(
'showMembersList', $this->
lng->txt(
'cancel'));
   673         if (!$this->mlists->isOwner($this->mlists->getCurrentMailingList()->getId(), $this->
user->getId())) {
   674             $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
   677         $form = $this->getAssignmentForm();
   678         if (!$form->checkInput()) {
   679             $form->setValuesByPost();
   687                 $this->
http->wrapper()->post()->retrieve(
'usr_id', $this->
refinery->kindlyTo()->int())
   690             $this->mlists->getCurrentMailingList()->assignUser(
   691                 $this->
http->wrapper()->post()->retrieve(
'usr_id', $this->
refinery->kindlyTo()->int())
   693             $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'));
   706         if ($this->mlists->getCurrentMailingList()->getId() === 0) {
   712         if (!$this->mlists->isOwner($this->mlists->getCurrentMailingList()->getId(), $this->
user->getId())) {
   713             $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
   716         $this->tpl->setTitle($this->
lng->txt(
'mail_addressbook'));
   717         $this->tpl->addBlockFile(
   720             'tpl.mail_mailing_lists_members_form.html',
   721             'components/ILIAS/Contact'   725             $form = $this->getAssignmentForm();
   728         $this->tpl->setVariable(
'FORM', $form->getHTML());
   729         $this->tpl->printToStdout();
 readonly Refinery $refinery
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
readonly ilFormatMail $umail
 
getMailingListIdsFromRequest()
 
handleMailingListMemberActions()
 
readonly ILIAS UI Factory $ui_factory
 
readonly ilRbacSystem $rbacsystem
 
readonly ilMailingLists $mlists
 
static http()
Fetches the global http state from ILIAS. 
 
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path='ilpublicuserprofilegui')
Default behaviour is: 
 
readonly ilToolbarGUI $toolbar
 
ilPropertyFormGUI $form_gui
 
readonly ilGlobalTemplateInterface $tpl
 
showAssignmentForm(?ilPropertyFormGUI $form=null)
 
static redirect(string $a_script)
 
static getInstanceByGlobalUser(ilObjUser $user=null)
 
handleMailingListActions()
 
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins 
 
This class represents a text area property in a property form. 
 
readonly ILIAS HTTP GlobalHttpState $http
 
readonly ilCtrlInterface $ctrl
 
readonly ilErrorHandling $error
 
readonly ILIAS UI Renderer $ui_renderer