19 declare(strict_types=1);
41 protected const string TABLE_ID =
'crsprtcpntsgrpstbl';
42 protected const string FILTER_ID =
'crsprtcpntsgrpstbl_filter';
43 protected const string ROW_ID =
'row_ids';
73 $this->
lng->loadLanguageModule(
'grp');
78 return self::TABLE_ACTION_ADD_TO_GROUP .
'_' . $group_ref_id;
84 self::TABLE_COL_NAME => $this->ui_services->factory()->table()->column()->text(
85 $this->
lng->txt(self::LNG_TABLE_COL_NAME)
87 self::TABLE_COL_LOGIN => $this->ui_services->factory()->table()->column()->text(
88 $this->
lng->txt(self::LNG_TABLE_COL_LOGIN)
90 self::TABLE_COL_GROUP_NUMBER => $this->ui_services->factory()->table()->column()->number(
91 $this->
lng->txt(self::LNG_TABLE_COL_GROUP_NUMBER)
93 self::TABLE_COL_GROUPS => $this->ui_services->factory()->table()->column()->text(
94 $this->
lng->txt(self::LNG_TABLE_COL_GROUPS)
95 )->withIsSortable(
false)
101 $this->url_builder =
new URLBuilder($this->data_factory->uri($this->http_services->request()->getUri()->__toString()));
102 list($this->url_builder, $this->action_parameter_token, $this->row_id_token) =
103 $this->url_builder->acquireParameters(
104 [
'datatable', self::TABLE_ID],
105 self::TABLE_ACTION_ID,
109 foreach ($this->data_retrieval->getSelectableGroups() as
$ref_id => $group_name) {
111 $actions[$action_id] = $this->ui_services->factory()->table()->action()->multi(
112 $this->
lng->txt(self::LNG_ADD_TO_GROUP) .
': ' . $group_name,
113 $this->url_builder->withParameter($this->action_parameter_token, $action_id),
116 $action_id = $this->data_retrieval->buildConfirmUnsubscribeActionId((
int) $ref_id);
117 $actions[$action_id] = $this->ui_services->factory()->table()->action()->single(
118 $group_name .
' ' . $this->
lng->txt(self::LNG_TABLE_ACTION_CONFIRM_UNSUBSCRIBE),
119 $this->url_builder->withParameter($this->action_parameter_token, $action_id),
128 if (isset($this->
filter)) {
132 $this->
filter = $this->ui_service->filter()->standard(
134 $this->
ctrl->getLinkTargetByClass(ilCourseParticipantsGroupsGUI::class,
'show'),
136 array_fill(0, count($filter_fields),
true),
148 self::TABLE_FILTER_NAME => $this->ui_services->factory()->input()->field()->text(
149 $this->
lng->txt(self::LNG_TABLE_COL_NAME)
151 self::TABLE_FILTER_GROUPS => $this->ui_services->factory()->input()->field()->select(
152 $this->
lng->txt(self::TABLE_COL_GROUPS),
153 $this->data_retrieval->getSelectableGroups()
160 if (isset($this->table)) {
163 $this->table = $this->ui_services->factory()->table()->data(
164 $this->data_retrieval,
165 $this->
lng->txt(self::LNG_TABLE_TITLE),
168 ->withId(self::TABLE_ID)
170 ->withRequest($this->http_services->request());
175 $tokens = $this->http_services->wrapper()->query()->retrieve(
176 $this->row_id_token->getName(),
177 $this->
refinery->custom()->transformation(fn($v) => $v)
179 return is_null($tokens) ? [] : (is_array($tokens) ? $tokens : [$tokens]);
182 protected function addToGroup(array $user_ids,
int $group_ref_id): void
184 if (!$this->
access->checkRbacOrPositionPermissionAccess(
'manage_members',
'manage_members', $group_ref_id)) {
185 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"permission_denied"),
true);
186 $this->
ctrl->redirectByClass(ilCourseParticipantsGroupsGUI::class,
'show');
191 foreach ($user_ids as $new_member) {
196 $members_obj->sendNotification(
201 if ($rejected_count === 0) {
202 $message = $this->
lng->txt(
'grp_msg_member_assigned');
204 $accepted_count = count($user_ids) - $rejected_count;
206 $this->
lng->txt(
'grp_not_all_users_assigned_msg'),
211 $this->tpl->setOnScreenMessage(
'success',
$message,
true);
212 $this->
ctrl->redirectByClass(ilCourseParticipantsGroupsGUI::class,
'show');
215 protected function unsubscribe(array $user_ids,
int $group_id): void
218 if (!$this->
access->checkRbacOrPositionPermissionAccess(
'manage_members',
'manage_members', $group_id)) {
219 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"permission_denied"),
true);
220 $this->
ctrl->redirectByClass(ilCourseParticipantsGroupsGUI::class,
'show');
224 $members_obj->delete((
int) $user_id);
226 $members_obj->sendNotification(
231 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"grp_msg_membership_annulled"),
true);
232 $this->
ctrl->redirectByClass(ilCourseParticipantsGroupsGUI::class,
"show");
235 #[NoReturn] protected function showConfirmUnsubscribeModal(array $user_ids, int $group_ref_id): void 239 $items[] = $this->ui_services->factory()->modal()->interruptiveItem()->standard(
242 $this->ui_services->factory()->image()->standard(
ilUtil::getImagePath(
'standard/icon_usr.svg'),
'')
245 echo($this->ui_services->renderer()->renderAsync([
246 $this->ui_services->factory()->modal()->interruptive(
247 $this->
lng->txt(
'confirm'),
248 $this->
lng->txt(
'grp_dismiss_member'),
249 (string) $this->url_builder
251 $this->action_parameter_token,
252 $this->data_retrieval->buildUnsubscribeActionId($group_ref_id)
257 )->withAffectedItems($items)
266 return $this->ui_services->renderer()->render([
268 $this->table->withFilter($this->filter->getInputs())
275 if (!$this->http_services->wrapper()->query()->has($this->action_parameter_token->getName())) {
278 $action = $this->http_services->wrapper()->query()->retrieve(
279 $this->action_parameter_token->getName(),
282 $tokens = $this->http_services->wrapper()->query()->retrieve(
283 $this->row_id_token->getName(),
284 $this->
refinery->custom()->transformation(fn($v) => $v)
286 $all_entries = ($tokens[0] ??
"") === self::ALL_OBJECTS;
289 $user_ids = $this->data_retrieval->getAllUserIds();
294 foreach ($this->data_retrieval->getSelectableGroups() as
$ref_id => $group_name) {
299 if ($action === $this->data_retrieval->buildUnsubscribeActionId($ref_id)) {
303 if ($action === $this->data_retrieval->buildConfirmUnsubscribeActionId($ref_id)) {
304 $this->showConfirmUnsubscribeModal($user_ids, $ref_id);
const string TABLE_COL_GROUPS
addToGroup(array $user_ids, int $group_ref_id)
const string LNG_TABLE_COL_GROUPS
const TYPE_DISMISS_MEMBER
__construct(protected ilCourseParticipantsGroupsTableDataRetrieval $data_retrieval, protected ilUIServices $ui_services, protected ilUIService $ui_service, protected ilHTTPServices $http_services, protected ilRefineryFactory $refinery, protected ilLanguage $lng, protected ilCtrl $ctrl, protected ilDataFactory $data_factory, protected ilGlobalTemplateInterface $tpl, protected ilAccess $access, protected ilObjectDataCache $object_data_cache)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilURLBuilderToken $row_id_token
const string TABLE_ACTION_ADD_TO_GROUP
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:
const string TABLE_COL_GROUP_NUMBER
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const string LNG_TABLE_ACTION_CONFIRM_UNSUBSCRIBE
const string TABLE_COL_NAME
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
const string LNG_TABLE_COL_LOGIN
const string LNG_TABLE_COL_GROUP_NUMBER
const string LNG_ADD_TO_GROUP
const string TABLE_COL_LOGIN
unsubscribe(array $user_ids, int $group_id)
ilURLBuilderToken $action_parameter_token
const string TABLE_FILTER_NAME
static _getInstanceByObjId(int $a_obj_id)
Get singleton instance.
const string LNG_TABLE_COL_NAME
const string TABLE_FILTER_GROUPS
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
const TYPE_ADMISSION_MEMBER
const string LNG_TABLE_TITLE
const string TABLE_ACTION_ID
buildAddToGroupString(int $group_ref_id)