19 declare(strict_types=1);
    47     public function __construct(
protected $wsp_access_handler = null, 
protected ?
int $wsp_node_id = null)
    51         $this->tpl = $DIC[
'tpl'];
    52         $this->
ctrl = $DIC[
'ilCtrl'];
    53         $this->
lng = $DIC[
'lng'];
    54         $this->
user = $DIC[
'ilUser'];
    55         $this->error = $DIC[
'ilErr'];
    56         $this->rbacsystem = $DIC[
'rbacsystem'];
    57         $this->rbacreview = $DIC[
'rbacreview'];
    58         $this->tree = $DIC[
'tree'];
    59         $this->cache = $DIC[
'ilObjDataCache'];
    60         $this->
http = $DIC->http();
    62         $this->ui_factory = $DIC->ui()->factory();
    63         $this->ui_renderer = $DIC->ui()->renderer();
    65         $this->
ctrl->saveParameter($this, 
'mobj_id');
    66         $this->
ctrl->saveParameter($this, 
'ref');
    69         $this->mailing_allowed = $this->rbacsystem->checkAccess(
'internal_mail', $mail->getMailObjectReferenceId());
    73         $this->
lng->loadLanguageModule(
'mail');
    79             !$this->
http->wrapper()->query()->has(
'ref') ||
    80             $this->
http->wrapper()->query()->retrieve(
'ref', $this->
refinery->kindlyTo()->string()) !== 
'wsp'    87         if ($this->
http->wrapper()->query()->has(
'ref')) {
    88             $context = $this->
http->wrapper()->query()->retrieve(
'ref', $this->
refinery->kindlyTo()->string());
    97             if (str_starts_with($title, $local_role_prefix)) {
   115         if ($this->
http->wrapper()->query()->has($key)) {
   116             $value = $this->
http->wrapper()->query()->retrieve($key, $trafo);
   119         if ($this->
http->wrapper()->post()->has($key)) {
   120             $value = $this->
http->wrapper()->post()->retrieve($key, $trafo);
   131         $added = $this->wsp_access_handler->addMissingPermissionForObjects($this->wsp_node_id, $a_obj_ids);
   134             $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'wsp_share_success'), 
true);
   136         $this->
ctrl->redirectByClass(ilWorkspaceAccessGUI::class, 
'share');
   142         if ($this->
http->wrapper()->query()->has(
'view')) {
   143             $view = $this->
http->wrapper()->query()->retrieve(
'view', $this->
refinery->kindlyTo()->string());
   146         if ($view === 
'myobjects') {
   150                     $this->
http->wrapper()->query()->retrieve(
   155             } elseif ($this->
http->wrapper()->post()->has(
'search_' . $this->
getObjectType())) {
   156                 $obj_ids = $this->
http->wrapper()->post()->retrieve(
   162             if ($obj_ids !== []) {
   165                 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_' . $this->getObjectType()));
   166                 $this->showMyObjects();
   170             if ($this->
http->wrapper()->query()->has(
'search_members')) {
   172                     $this->
http->wrapper()->query()->retrieve(
   177             } elseif ($this->
http->wrapper()->post()->has(
'search_members')) {
   178                 $usr_ids = $this->
http->wrapper()->post()->retrieve(
   184             if ($usr_ids !== []) {
   187                 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_one_entry'));
   188                 $this->showMembers();
   191             $this->showMyObjects();
   195     protected function mail(): void
   198         if ($this->
http->wrapper()->query()->has(
'view')) {
   199             $view = $this->
http->wrapper()->query()->retrieve(
'view', $this->
refinery->kindlyTo()->string());
   202         if ($view === 
'myobjects') {
   206                     $this->
http->wrapper()->query()->retrieve(
   211             } elseif ($this->
http->wrapper()->post()->has(
'search_' . $this->
getObjectType())) {
   212                 $obj_ids = $this->
http->wrapper()->post()->retrieve(
   218             if ($obj_ids !== []) {
   221                 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_' . $this->getObjectType()));
   222                 $this->showMyObjects();
   226             if ($this->
http->wrapper()->query()->has(
'search_members')) {
   228                     $this->
http->wrapper()->query()->retrieve(
   233             } elseif ($this->
http->wrapper()->post()->has(
'search_members')) {
   234                 $usr_ids = $this->
http->wrapper()->post()->retrieve(
   240             if ($usr_ids !== []) {
   243                 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_one_entry'));
   244                 $this->showMembers();
   247             $this->showMyObjects();
   254         $mail_data = $this->umail->retrieveFromStage();
   259                 $this->
http->wrapper()->query()->retrieve(
   264         } elseif ($this->
http->wrapper()->post()->has(
'search_' . $this->
getObjectType())) {
   265             $obj_ids = $this->
http->wrapper()->post()->retrieve(
   271         foreach ($obj_ids as $obj_id) {
   273             foreach ($ref_ids as 
$ref_id) {
   276                     $this->
user->getId(),
   279                 if (!$can_send_mails) {
   283                 $roles = $this->rbacreview->getAssignableChildRoles($ref_id);
   284                 foreach ($roles as $role) {
   287                         if (!$this->umail->existsRecipient($recipient, (
string) $mail_data[
'rcp_to'])) {
   288                             $members[] = $recipient;
   295         $mail_data = $members !== [] ? $this->umail->appendSearchResult(array_unique($members), 
'to') : $this->umail->retrieveFromStage();
   297         $this->umail->persistToStage(
   298             (
int) $mail_data[
'user_id'],
   299             $mail_data[
'attachments'],
   300             $mail_data[
'rcp_to'],
   301             $mail_data[
'rcp_cc'],
   302             $mail_data[
'rcp_bcc'],
   303             $mail_data[
'm_subject'],
   304             $mail_data[
'm_message'],
   305             $mail_data[
'use_placeholders'],
   306             $mail_data[
'tpl_ctx_id'],
   307             $mail_data[
'tpl_ctx_params']
   310         $this->
ctrl->redirectToURL(
'ilias.php?baseClass=ilMailGUI&type=search_res');
   317         if ($this->
http->wrapper()->query()->has(
'search_members')) {
   319                 $this->
http->wrapper()->query()->retrieve(
   324         } elseif ($this->
http->wrapper()->post()->has(
'search_members')) {
   325             $usr_ids = $this->
http->wrapper()->post()->retrieve(
   331         $mail_data = $this->umail->retrieveFromStage();
   332         foreach ($usr_ids as $usr_id) {
   334             if (!$this->umail->existsRecipient($login, (
string) $mail_data[
'rcp_to'])) {
   338         $mail_data = $this->umail->appendSearchResult(array_unique($members), 
'to');
   340         $this->umail->persistToStage(
   341             (
int) $mail_data[
'user_id'],
   342             $mail_data[
'attachments'],
   343             $mail_data[
'rcp_to'],
   344             $mail_data[
'rcp_cc'],
   345             $mail_data[
'rcp_bcc'],
   346             $mail_data[
'm_subject'],
   347             $mail_data[
'm_message'],
   348             $mail_data[
'use_placeholders'],
   349             $mail_data[
'tpl_ctx_id'],
   350             $mail_data[
'tpl_ctx_params']
   353         $this->
ctrl->redirectToURL(
'ilias.php?baseClass=ilMailGUI&type=search_res');
   359         if ($this->
http->wrapper()->query()->has(
'view')) {
   360             $view = $this->
http->wrapper()->query()->retrieve(
'view', $this->
refinery->kindlyTo()->string());
   364             $this->
ctrl->returnToParent($this);
   366             $this->showMyObjects();
   370     public function showMembers(): 
void   374             $obj_ids = $this->
refinery->kindlyTo()->listOf(
   376             )->transform(explode(
',', (
string) $this->
http->wrapper()->query()->retrieve(
   378                 $this->
refinery->kindlyTo()->string()
   380         } elseif ($this->
http->wrapper()->post()->has(
'search_' . $this->
getObjectType())) {
   381             $obj_ids = $this->
http->wrapper()->post()->retrieve(
   383                 $this->
refinery->kindlyTo()->listOf(
   388             $obj_ids = $this->
refinery->kindlyTo()->listOf(
   394         if ($obj_ids === []) {
   395             $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_select_' . $this->getObjectType()));
   396             $this->showMyObjects();
   400         foreach ($obj_ids as $obj_id) {
   409                 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'mail_crs_list_members_not_available_for_at_least_one_crs'));
   410                 $this->showMyObjects();
   415         $this->tpl->setTitle($this->
lng->txt(
'mail_addressbook'));
   418         if ($obj_ids !== []) {
   419             $this->
ctrl->setParameter($this, 
'search_' . $this->
getObjectType(), implode(
',', $obj_ids));
   421         $this->tpl->setVariable(
'ACTION', $this->
ctrl->getFormAction($this));
   422         $this->
ctrl->clearParameters($this);
   436         $searchTpl = 
new ilTemplate(
'tpl.mail_search_template.html', 
true, 
true, 
'Services/Contact');
   437         foreach ($obj_ids as $obj_id) {
   439             $usr_ids = array_map(
'intval', 
ilUtil::_sortIds($members_obj->getParticipants(), 
'usr_data', 
'lastname', 
'usr_id'));
   440             foreach ($usr_ids as $usr_id) {
   452                     'members_id' => $user->
getId(),
   453                     'members_login' => $user->
getLogin(),
   454                     'members_name' => $fullname,
   455                     'members_crs_grp' => $this->cache->lookupTitle((
int) $obj_id),
   462                     $rowData[
'status'] = 
'';
   463                     if ($user->
getId() !== $this->
user->getId()) {
   465                             $rowData[
'status'] = $this->
lng->txt(
'buddy_bs_state_' . $state_name . 
'_a');
   467                             $rowData[
'status'] = $this->
lng->txt(
'buddy_bs_state_' . $state_name . 
'_p');
   472                 $tableData[] = $rowData;
   475         $table->setData($tableData);
   477         if ($tableData !== []) {
   478             $searchTpl->setVariable(
'TXT_MARKED_ENTRIES', $this->
lng->txt(
'marked_entries'));
   481         $searchTpl->setVariable(
'TABLE', $table->getHTML());
   482         $this->tpl->setContent($searchTpl->get());
   485             $this->tpl->printToStdout();
   491     public function showMyObjects(): 
void   493         $this->tpl->setTitle($this->
lng->txt(
'mail_addressbook'));
   495         $searchTpl = 
new ilTemplate(
'tpl.mail_search_template.html', 
true, 
true, 
'Services/Contact');
   497         $this->
lng->loadLanguageModule(
'crs');
   509         if ($objs_ids !== []) {
   510             $num_courses_hidden_members = 0;
   511             foreach ($objs_ids as $obj_id) {
   522                     $this->
user->getId(),
   527                 if ($has_untrashed_references && ($can_send_mails || $exposes_members)) {
   529                     $usr_ids = $participants->getParticipants();
   531                     foreach ($usr_ids as 
$key => $usr_id) {
   534                             unset($usr_ids[
$key]);
   537                     $usr_ids = array_values($usr_ids);
   539                     if (!$exposes_members) {
   540                         ++$num_courses_hidden_members;
   543                     $path_arr = $this->tree->getPathFull($object->
getRefId(), $this->tree->getRootId());
   545                     foreach ($path_arr as 
$data) {
   549                         $path .= $data[
'title'];
   553                     $this->
ctrl->setParameter($this, 
'view', 
'myobjects');
   557                         if ($this->mailing_allowed && $can_send_mails) {
   558                             $buttons[] = $this->ui_factory
   561                                     $this->
lng->txt(
'mail_members'),
   562                                     $this->
ctrl->getLinkTarget($this, 
'mail')
   566                         $buttons[] = $this->ui_factory
   569                                 $this->
lng->txt(
'wsp_share_with_members'),
   570                                 $this->
ctrl->getLinkTarget($this, 
'share')
   574                     if ($exposes_members) {
   575                         $buttons[] = $this->ui_factory
   578                                 $this->
lng->txt(
'mail_list_members'),
   579                                 $this->
ctrl->getLinkTarget($this, 
'showMembers')
   583                     $this->
ctrl->clearParameters($this);
   586                     if ($buttons !== []) {
   587                         $drop_down = $this->ui_factory
   590                             ->withLabel($this->
lng->txt(
'actions'));
   594                         'OBJECT_ID' => $object->
getId(),
   595                         'OBJECT_NAME' => $object->
getTitle(),
   596                         'OBJECT_NO_MEMBERS' => count($usr_ids),
   597                         'OBJECT_PATH' => 
$path,
   598                         'COMMAND_SELECTION_LIST' => $drop_down ? $this->ui_renderer->render($drop_down) : 
'',
   599                         'hidden_members' => !$exposes_members,
   602                     $tableData[] = $rowData;
   606             if ($num_courses_hidden_members > 0) {
   607                 $searchTpl->setCurrentBlock(
'caption_block');
   608                 $searchTpl->setVariable(
'TXT_LIST_MEMBERS_NOT_AVAILABLE', $this->
lng->txt(
'mail_crs_list_members_not_available'));
   609                 $searchTpl->parseCurrentBlock();
   613         $searchTpl->setVariable(
'TXT_MARKED_ENTRIES', $this->
lng->txt(
'marked_entries'));
   615         $table->setData($tableData);
   616         $searchTpl->setVariable(
'TABLE', $table->getHTML());
   617         $this->tpl->setContent($searchTpl->get());
   620             $this->tpl->printToStdout();
   626         $forward_class = $this->
ctrl->getNextClass($this);
   627         switch (strtolower($forward_class)) {
   628             case strtolower(ilBuddySystemGUI::class):
   630                     $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
   635                 $this->
ctrl->setReturn($this, 
'showMembers');
   640                 if (!($cmd = $this->
ctrl->getCmd())) {
   641                     $cmd = 
'showMyObjects';
 
Interface GlobalHttpState. 
 
static get(string $a_var)
 
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)
 
__construct(protected $wsp_access_handler=null, protected ?int $wsp_node_id=null)
 
ilGlobalTemplateInterface $tpl
 
isLocalRoleTitle(string $title)
 
addPermission(array $a_obj_ids)
 
static http()
Fetches the global http state from ILIAS. 
 
ILIAS UI Factory $ui_factory
 
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 getInstanceByGlobalUser(ilObjUser $user=null)
 
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. 
 
getLocalDefaultRolePrefixes()
 
ILIAS UI Renderer $ui_renderer
 
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 canSendMailToMembers(int|ilObject $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. 
 
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)