ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
class.ilMailSearchObjectMembershipsTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22use ILIAS\Refinery\Factory as Refinery;
23
29{
31 private Refinery $refinery;
32 protected ilObjUser $user;
34 protected array $mode;
35 protected bool $mailing_allowed;
36
43 public function __construct(
44 object $a_parent_obj,
45 string $type = 'crs',
46 string $context = 'mail',
47 array $contextObjects = []
48 ) {
49 global $DIC;
50
51 $this->ctrl = $DIC['ilCtrl'];
52 $this->lng = $DIC['lng'];
53 $this->user = $DIC['ilUser'];
54 $this->http = $DIC->http();
55 $this->refinery = $DIC->refinery();
56
57 $tableId = ilStr::subStr($type . '_cml_' . md5(implode('_', $contextObjects)), 0, 30);
58 $this->setId($tableId);
59 parent::__construct($a_parent_obj, 'showMembers');
60
61 $this->context = $context;
62 if ($this->context === 'mail') {
63 $mail = new ilMail($this->user->getId());
64 $this->mailing_allowed = $DIC->rbac()->system()->checkAccess('internal_mail', $mail->getMailObjectReferenceId());
65 }
66
67 $this->setDefaultOrderDirection('ASC');
68 $this->setDefaultOrderField('members_login');
69
70 $this->lng->loadLanguageModule('crs');
71 $this->lng->loadLanguageModule('buddysystem');
72
73 $mode = [];
74 if ($type === 'crs') {
75 $mode['checkbox'] = 'search_crs';
76 $mode['short'] = 'crs';
77 $mode['long'] = 'course';
78 $mode['lng_type'] = $this->lng->txt('course');
79 $mode['view'] = 'crs_members';
80 } elseif ($type === 'grp') {
81 $mode['checkbox'] = 'search_grp';
82 $mode['short'] = 'grp';
83 $mode['long'] = 'group';
84 $mode['lng_type'] = $this->lng->txt('group');
85 $mode['view'] = 'grp_members';
86 }
87
88 $this->setTitle($this->lng->txt('members'));
89 $this->mode = $mode;
90
91 $this->ctrl->setParameter($a_parent_obj, 'view', $mode['view']);
92
93 if (
94 $this->http->wrapper()->query()->has('ref') &&
95 $this->http->wrapper()->query()->retrieve('ref', $this->refinery->kindlyTo()->string()) !== ''
96 ) {
97 $this->ctrl->setParameter(
98 $a_parent_obj,
99 'ref',
100 $this->http->wrapper()->query()->retrieve('ref', $this->refinery->kindlyTo()->string())
101 );
102 }
103
104 if ($this->http->wrapper()->post()->has($mode['checkbox'])) {
105 $ids = $this->http->wrapper()->post()->retrieve(
106 $mode['checkbox'],
107 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
108 );
109
110 if ($ids !== []) {
111 $this->ctrl->setParameter(
112 $a_parent_obj,
113 $mode['checkbox'],
114 implode(', ', $ids)
115 );
116 }
117 }
118
119 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
120
121 $this->setRowTemplate('tpl.mail_search_objects_members_row.html', 'Services/Contact');
122
123 $this->addColumn('', '', '1%', true);
124 $this->addColumn($this->lng->txt('login'), 'members_login', '22%');
125 $this->addColumn($this->lng->txt('name'), 'members_name', '22%');
126 $this->addColumn($this->lng->txt($mode['long']), 'members_crs_grp', '22%');
127 if (ilBuddySystem::getInstance()->isEnabled()) {
128 $this->addColumn($this->lng->txt('buddy_tbl_filter_state'), 'status', '23%');
129 }
130 $this->addColumn($this->lng->txt('actions'), '', '10%');
131
132 if ($this->context === 'mail') {
133 if ($this->mailing_allowed) {
134 $this->setSelectAllCheckbox('search_members[]');
135 $this->addMultiCommand('mail', $this->lng->txt('mail_members'));
136 }
137 } else {
138 $this->setSelectAllCheckbox('search_members[]');
139 $this->lng->loadLanguageModule('wsp');
140 $this->addMultiCommand('share', $this->lng->txt('wsp_share_with_members'));
141 }
142 $this->lng->loadLanguageModule('buddysystem');
143 $this->addCommandButton('cancel', $this->lng->txt('cancel'));
144 }
145
146 protected function getRequestValue(string $key, \ILIAS\Refinery\Transformation $trafo, $default = null)
147 {
148 $value = $default;
149 if ($this->http->wrapper()->query()->has($key)) {
150 $value = $this->http->wrapper()->query()->retrieve($key, $trafo);
151 }
152
153 if ($this->http->wrapper()->post()->has($key)) {
154 $value = $this->http->wrapper()->post()->retrieve($key, $trafo);
155 }
156
157 return $value;
158 }
159
160 protected function fillRow(array $a_set): void
161 {
162 $trafo = $this->refinery->custom()->transformation(function ($value): string {
163 if (is_string($value)) {
164 return $this->refinery
165 ->custom()
166 ->transformation(fn (string $value): string => ilUtil::stripSlashes($value))
167 ->transform($value);
168 }
169
170 return implode(
171 ',',
172 $this->refinery->kindlyTo()->listOf(
173 $this->refinery->in()->series([
174 $this->refinery->kindlyTo()->int(),
175 $this->refinery->kindlyTo()->string()
176 ])
177 )->transform($value)
178 );
179 });
180
181 $current_selection_list = new ilAdvancedSelectionListGUI();
182 $current_selection_list->setListTitle($this->lng->txt('actions'));
183 $current_selection_list->setId('act_' . md5($a_set['members_id'] . '::' . $a_set['search_' . $this->mode['short']]));
184
185 $this->ctrl->setParameter($this->parent_obj, 'search_members', $a_set['members_id']);
186 $this->ctrl->setParameter(
187 $this->parent_obj,
188 'search_' . $this->mode['short'],
189 $this->getRequestValue('search_' . $this->mode['short'], $trafo)
190 );
191 $this->ctrl->setParameter($this->parent_obj, 'view', $this->mode['view']);
192
193 $action_html = '';
194 if ($this->context === 'mail') {
195 if ($this->mailing_allowed) {
196 $current_selection_list->addItem(
197 $this->lng->txt('mail_member'),
198 '',
199 $this->ctrl->getLinkTarget($this->parent_obj, 'mail')
200 );
201 }
202 } else {
203 $current_selection_list->addItem(
204 $this->lng->txt('wsp_share_with_members'),
205 '',
206 $this->ctrl->getLinkTarget($this->parent_obj, 'share')
207 );
208 }
209
210 if ($this->context === 'mail' && ilBuddySystem::getInstance()->isEnabled()) {
211 $relation = ilBuddyList::getInstanceByGlobalUser()->getRelationByUserId((int) $a_set['members_id']);
212 if (
213 $a_set['members_id'] !== $this->user->getId() &&
214 $relation->isUnlinked() &&
215 ilUtil::yn2tf((string) ilObjUser::_lookupPref($a_set['members_id'], 'bs_allow_to_contact_me'))
216 ) {
217 $this->ctrl->setParameterByClass(ilBuddySystemGUI::class, 'user_id', $a_set['members_id']);
218 $current_selection_list->addItem(
219 $this->lng->txt('buddy_bs_btn_txt_unlinked_a'),
220 '',
221 $this->ctrl->getLinkTargetByClass(ilBuddySystemGUI::class, 'request')
222 );
223 }
224 }
225
226 if ($current_selection_list->getItems()) {
227 $action_html = $current_selection_list->getHTML();
228 }
229 $this->tpl->setVariable('CURRENT_ACTION_LIST', $action_html);
230
231 foreach ($a_set as $key => $value) {
232 $this->tpl->setVariable(strtoupper($key), $value);
233 }
234 }
235}
Builds data types.
Definition: Factory.php:21
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByGlobalUser()
__construct(object $a_parent_obj, string $type='crs', string $context='mail', array $contextObjects=[])
getRequestValue(string $key, \ILIAS\Refinery\Transformation $trafo, $default=null)
User class.
static _lookupPref(int $a_usr_id, string $a_keyword)
static subStr(string $a_str, int $a_start, ?int $a_length=null)
Definition: class.ilStr.php:24
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setDefaultOrderField(string $a_defaultorderfield)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static yn2tf(string $a_yn)
global $DIC
Definition: feed.php:28
Interface GlobalHttpState.
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
string $key
Consumer key/client ID value.
Definition: System.php:193
Class ChatMainBarProvider \MainMenu\Provider.
$type