ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilCourseParticipantsGroupsTableGUI Class Reference
+ Collaboration diagram for ilCourseParticipantsGroupsTableGUI:

Public Member Functions

 __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)
 
 getHTML ()
 
 handleCommands ()
 

Data Fields

const string TABLE_COL_NAME = 'name'
 
const string TABLE_COL_LOGIN = 'login'
 
const string TABLE_COL_GROUP_NUMBER = 'groups_number'
 
const string TABLE_COL_GROUPS = 'groups'
 
const string TABLE_FILTER_NAME = 'filter_name'
 
const string TABLE_FILTER_GROUPS = 'filter_groups'
 
 foreach ( $user_ids as $user_id)
 

Protected Member Functions

 buildAddToGroupString (int $group_ref_id)
 
 getColumns ()
 
 getActions ()
 
 getFilterFields ()
 
 initTable ()
 
 readIdsFromQuery ()
 
 addToGroup (array $user_ids, int $group_ref_id)
 
 unsubscribe (array $user_ids, int $group_id)
 

Protected Attributes

const string ALL_OBJECTS = 'ALL_OBJECTS'
 
const string TABLE_ID = 'crsprtcpntsgrpstbl'
 
const string FILTER_ID = 'crsprtcpntsgrpstbl_filter'
 
const string ROW_ID = 'row_ids'
 
const string TABLE_ACTION_ID = 'table_action'
 
const string TABLE_ACTION_ADD_TO_GROUP = 'add_to_group'
 
const string LNG_TABLE_COL_NAME = 'name'
 
const string LNG_TABLE_COL_LOGIN = 'login'
 
const string LNG_TABLE_COL_GROUP_NUMBER = 'crs_groups_nr'
 
const string LNG_TABLE_COL_GROUPS = 'groups'
 
const string LNG_TABLE_ACTION_CONFIRM_UNSUBSCRIBE = 'grp_unsubscribe'
 
const string LNG_TABLE_TITLE = 'crs_grp_assignments'
 
const string LNG_ADD_TO_GROUP = 'crs_add_to_group'
 
URLBuilder $url_builder
 
ilURLBuilderToken $action_parameter_token
 
ilURLBuilderToken $row_id_token
 
ilDataTable $table
 
ilFilter $filter
 

Private Member Functions

 initFilter ()
 

Detailed Description

Definition at line 32 of file class.ilCourseParticipantsGroupsTableGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilCourseParticipantsGroupsTableGUI::__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 
)

Definition at line 60 of file class.ilCourseParticipantsGroupsTableGUI.php.

72 {
73 $this->lng->loadLanguageModule('grp');
74 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ addToGroup()

ilCourseParticipantsGroupsTableGUI::addToGroup ( array  $user_ids,
int  $group_ref_id 
)
protected

Definition at line 182 of file class.ilCourseParticipantsGroupsTableGUI.php.

182 : void
183 {
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');
187 return;
188 }
189 $members_obj = ilGroupParticipants::_getInstanceByObjId($this->object_data_cache->lookupObjId($group_ref_id));
190 $rejected_count = 0;
191 foreach ($user_ids as $new_member) {
192 if (!$members_obj->add((int) $new_member, ilParticipants::IL_GRP_MEMBER)) {
193 $rejected_count++;
194 continue;
195 }
196 $members_obj->sendNotification(
198 (int) $new_member
199 );
200 }
201 if ($rejected_count === 0) {
202 $message = $this->lng->txt('grp_msg_member_assigned');
203 } else {
204 $accepted_count = count($user_ids) - $rejected_count;
205 $message = sprintf(
206 $this->lng->txt('grp_not_all_users_assigned_msg'),
207 $accepted_count,
208 $rejected_count
209 );
210 }
211 $this->tpl->setOnScreenMessage('success', $message, true);
212 $this->ctrl->redirectByClass(ilCourseParticipantsGroupsGUI::class, 'show');
213 }
static _getInstanceByObjId(int $a_obj_id)
Get singleton instance.
$message
Definition: xapiexit.php:31

References $message, ilGroupParticipants\_getInstanceByObjId(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilParticipants\IL_GRP_MEMBER, ILIAS\Repository\lng(), and ilGroupMembershipMailNotification\TYPE_ADMISSION_MEMBER.

Referenced by handleCommands().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildAddToGroupString()

ilCourseParticipantsGroupsTableGUI::buildAddToGroupString ( int  $group_ref_id)
protected

Definition at line 76 of file class.ilCourseParticipantsGroupsTableGUI.php.

76 : string
77 {
78 return self::TABLE_ACTION_ADD_TO_GROUP . '_' . $group_ref_id;
79 }

Referenced by getActions(), and handleCommands().

+ Here is the caller graph for this function:

◆ getActions()

ilCourseParticipantsGroupsTableGUI::getActions ( )
protected

Definition at line 99 of file class.ilCourseParticipantsGroupsTableGUI.php.

99 : array
100 {
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,
106 self::ROW_ID
107 );
108 $actions = [];
109 foreach ($this->data_retrieval->getSelectableGroups() as $ref_id => $group_name) {
110 $action_id = $this->buildAddToGroupString((int) $ref_id);
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),
114 $this->row_id_token
115 );
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),
120 $this->row_id_token
121 )->withAsync(true);
122 }
123 return $actions;
124 }
$ref_id
Definition: ltiauth.php:66

References $ref_id, buildAddToGroupString(), and ILIAS\Repository\lng().

Referenced by initTable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColumns()

ilCourseParticipantsGroupsTableGUI::getColumns ( )
protected

Definition at line 81 of file class.ilCourseParticipantsGroupsTableGUI.php.

81 : array
82 {
83 return [
84 self::TABLE_COL_NAME => $this->ui_services->factory()->table()->column()->text(
85 $this->lng->txt(self::LNG_TABLE_COL_NAME)
86 ),
87 self::TABLE_COL_LOGIN => $this->ui_services->factory()->table()->column()->text(
88 $this->lng->txt(self::LNG_TABLE_COL_LOGIN)
89 ),
90 self::TABLE_COL_GROUP_NUMBER => $this->ui_services->factory()->table()->column()->number(
91 $this->lng->txt(self::LNG_TABLE_COL_GROUP_NUMBER)
92 ),
93 self::TABLE_COL_GROUPS => $this->ui_services->factory()->table()->column()->text(
94 $this->lng->txt(self::LNG_TABLE_COL_GROUPS)
95 )->withIsSortable(false)
96 ];
97 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getFilterFields()

ilCourseParticipantsGroupsTableGUI::getFilterFields ( )
protected
Returns
\ILIAS\UI\Component\Input\Container\Filter\FilterInput[]

Definition at line 145 of file class.ilCourseParticipantsGroupsTableGUI.php.

145 : array
146 {
147 return [
148 self::TABLE_FILTER_NAME => $this->ui_services->factory()->input()->field()->text(
149 $this->lng->txt(self::LNG_TABLE_COL_NAME)
150 ),
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()
154 )
155 ];
156 }

References ILIAS\Repository\lng().

Referenced by initFilter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHTML()

ilCourseParticipantsGroupsTableGUI::getHTML ( )

Definition at line 262 of file class.ilCourseParticipantsGroupsTableGUI.php.

262 : string
263 {
264 $this->initTable();
265 $this->initFilter();
266 return $this->ui_services->renderer()->render([
267 $this->filter,
268 $this->table->withFilter($this->filter->getInputs())
269 ]);
270 }
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)

References ILIAS\Repository\filter(), initFilter(), and initTable().

+ Here is the call graph for this function:

◆ handleCommands()

ilCourseParticipantsGroupsTableGUI::handleCommands ( )

Definition at line 272 of file class.ilCourseParticipantsGroupsTableGUI.php.

272 : void
273 {
274 $this->initTable();
275 if (!$this->http_services->wrapper()->query()->has($this->action_parameter_token->getName())) {
276 return;
277 }
278 $action = $this->http_services->wrapper()->query()->retrieve(
279 $this->action_parameter_token->getName(),
280 $this->refinery->to()->string()
281 );
282 $tokens = $this->http_services->wrapper()->query()->retrieve(
283 $this->row_id_token->getName(),
284 $this->refinery->custom()->transformation(fn($v) => $v)
285 );
286 $all_entries = ($tokens[0] ?? "") === self::ALL_OBJECTS;
287 $user_ids = [];
288 if ($all_entries) {
289 $user_ids = $this->data_retrieval->getAllUserIds();
290 }
291 if (!$all_entries) {
292 $user_ids = $this->readIdsFromQuery();
293 }
294 foreach ($this->data_retrieval->getSelectableGroups() as $ref_id => $group_name) {
295 if ($action === $this->buildAddToGroupString((int) $ref_id)) {
296 $this->addToGroup($user_ids, $ref_id);
297 break;
298 }
299 if ($action === $this->data_retrieval->buildUnsubscribeActionId($ref_id)) {
300 $this->unsubscribe($user_ids, $ref_id);
301 break;
302 }
303 if ($action === $this->data_retrieval->buildConfirmUnsubscribeActionId($ref_id)) {
304 $this->showConfirmUnsubscribeModal($user_ids, $ref_id);
305 break;
306 }
307 }
308 }

References $ref_id, addToGroup(), buildAddToGroupString(), initTable(), readIdsFromQuery(), and unsubscribe().

+ Here is the call graph for this function:

◆ initFilter()

ilCourseParticipantsGroupsTableGUI::initFilter ( )
private

Definition at line 126 of file class.ilCourseParticipantsGroupsTableGUI.php.

126 : void
127 {
128 if (isset($this->filter)) {
129 return;
130 }
131 $filter_fields = $this->getFilterFields();
132 $this->filter = $this->ui_service->filter()->standard(
133 self::FILTER_ID,
134 $this->ctrl->getLinkTargetByClass(ilCourseParticipantsGroupsGUI::class, 'show'),
135 $filter_fields,
136 array_fill(0, count($filter_fields), true),
137 true,
138 true
139 );
140 }

References ILIAS\Repository\ctrl(), ILIAS\Repository\filter(), and getFilterFields().

Referenced by getHTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initTable()

ilCourseParticipantsGroupsTableGUI::initTable ( )
protected

Definition at line 158 of file class.ilCourseParticipantsGroupsTableGUI.php.

158 : void
159 {
160 if (isset($this->table)) {
161 return;
162 }
163 $this->table = $this->ui_services->factory()->table()->data(
164 $this->data_retrieval,
165 $this->lng->txt(self::LNG_TABLE_TITLE),
166 $this->getColumns()
167 )
168 ->withId(self::TABLE_ID)
169 ->withActions($this->getActions())
170 ->withRequest($this->http_services->request());
171 }

References getActions(), and ILIAS\Repository\lng().

Referenced by getHTML(), and handleCommands().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readIdsFromQuery()

ilCourseParticipantsGroupsTableGUI::readIdsFromQuery ( )
protected

Definition at line 173 of file class.ilCourseParticipantsGroupsTableGUI.php.

173 : array
174 {
175 $tokens = $this->http_services->wrapper()->query()->retrieve(
176 $this->row_id_token->getName(),
177 $this->refinery->custom()->transformation(fn($v) => $v)
178 );
179 return is_null($tokens) ? [] : (is_array($tokens) ? $tokens : [$tokens]);
180 }

Referenced by handleCommands().

+ Here is the caller graph for this function:

◆ unsubscribe()

ilCourseParticipantsGroupsTableGUI::unsubscribe ( array  $user_ids,
int  $group_id 
)
protected

Definition at line 215 of file class.ilCourseParticipantsGroupsTableGUI.php.

215 : void
216 {
217 foreach ($user_ids as $user_id) {
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');
221 return;
222 }
223 $members_obj = ilGroupParticipants::_getInstanceByObjId($this->object_data_cache->lookupObjId($group_id));
224 $members_obj->delete((int) $user_id);
225 // Send notification
226 $members_obj->sendNotification(
228 (int) $user_id
229 );
230 }
231 $this->tpl->setOnScreenMessage('success', $this->lng->txt("grp_msg_membership_annulled"), true);
232 $this->ctrl->redirectByClass(ilCourseParticipantsGroupsGUI::class, "show");
233 }
234
235 #[NoReturn] protected function showConfirmUnsubscribeModal(array $user_ids, int $group_ref_id): void
236 {
237 $items = [];
238 foreach ($user_ids as $user_id) {
239 $items[] = $this->ui_services->factory()->modal()->interruptiveItem()->standard(
240 $user_id . '',
241 ilUserUtil::getNamePresentation($user_id, false, false, "", true),
242 $this->ui_services->factory()->image()->standard(ilUtil::getImagePath('standard/icon_usr.svg'), '')
243 );
244 }
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=null)
Default behaviour is:
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)

References $user_id, ilGroupParticipants\_getInstanceByObjId(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ilGroupMembershipMailNotification\TYPE_DISMISS_MEMBER.

Referenced by handleCommands().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $action_parameter_token

ilURLBuilderToken ilCourseParticipantsGroupsTableGUI::$action_parameter_token
protected

Definition at line 55 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ $filter

ilFilter ilCourseParticipantsGroupsTableGUI::$filter
protected

Definition at line 58 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ $row_id_token

ilURLBuilderToken ilCourseParticipantsGroupsTableGUI::$row_id_token
protected

Definition at line 56 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ $table

ilDataTable ilCourseParticipantsGroupsTableGUI::$table
protected

Definition at line 57 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ $url_builder

URLBuilder ilCourseParticipantsGroupsTableGUI::$url_builder
protected

Definition at line 54 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ ALL_OBJECTS

const string ilCourseParticipantsGroupsTableGUI::ALL_OBJECTS = 'ALL_OBJECTS'
protected

Definition at line 40 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ FILTER_ID

const string ilCourseParticipantsGroupsTableGUI::FILTER_ID = 'crsprtcpntsgrpstbl_filter'
protected

Definition at line 42 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ foreach

ilCourseParticipantsGroupsTableGUI::foreach($user_ids as $user_id)
Initial value:
{
$items = []

Definition at line 238 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ LNG_ADD_TO_GROUP

const string ilCourseParticipantsGroupsTableGUI::LNG_ADD_TO_GROUP = 'crs_add_to_group'
protected

Definition at line 52 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ LNG_TABLE_ACTION_CONFIRM_UNSUBSCRIBE

const string ilCourseParticipantsGroupsTableGUI::LNG_TABLE_ACTION_CONFIRM_UNSUBSCRIBE = 'grp_unsubscribe'
protected

Definition at line 50 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ LNG_TABLE_COL_GROUP_NUMBER

const string ilCourseParticipantsGroupsTableGUI::LNG_TABLE_COL_GROUP_NUMBER = 'crs_groups_nr'
protected

Definition at line 48 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ LNG_TABLE_COL_GROUPS

const string ilCourseParticipantsGroupsTableGUI::LNG_TABLE_COL_GROUPS = 'groups'
protected

Definition at line 49 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ LNG_TABLE_COL_LOGIN

const string ilCourseParticipantsGroupsTableGUI::LNG_TABLE_COL_LOGIN = 'login'
protected

Definition at line 47 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ LNG_TABLE_COL_NAME

const string ilCourseParticipantsGroupsTableGUI::LNG_TABLE_COL_NAME = 'name'
protected

Definition at line 46 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ LNG_TABLE_TITLE

const string ilCourseParticipantsGroupsTableGUI::LNG_TABLE_TITLE = 'crs_grp_assignments'
protected

Definition at line 51 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ ROW_ID

const string ilCourseParticipantsGroupsTableGUI::ROW_ID = 'row_ids'
protected

Definition at line 43 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ TABLE_ACTION_ADD_TO_GROUP

const string ilCourseParticipantsGroupsTableGUI::TABLE_ACTION_ADD_TO_GROUP = 'add_to_group'
protected

Definition at line 45 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ TABLE_ACTION_ID

const string ilCourseParticipantsGroupsTableGUI::TABLE_ACTION_ID = 'table_action'
protected

Definition at line 44 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ TABLE_COL_GROUP_NUMBER

const string ilCourseParticipantsGroupsTableGUI::TABLE_COL_GROUP_NUMBER = 'groups_number'

Definition at line 36 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ TABLE_COL_GROUPS

const string ilCourseParticipantsGroupsTableGUI::TABLE_COL_GROUPS = 'groups'

Definition at line 37 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ TABLE_COL_LOGIN

const string ilCourseParticipantsGroupsTableGUI::TABLE_COL_LOGIN = 'login'

Definition at line 35 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ TABLE_COL_NAME

const string ilCourseParticipantsGroupsTableGUI::TABLE_COL_NAME = 'name'

Definition at line 34 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ TABLE_FILTER_GROUPS

const string ilCourseParticipantsGroupsTableGUI::TABLE_FILTER_GROUPS = 'filter_groups'

Definition at line 39 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ TABLE_FILTER_NAME

const string ilCourseParticipantsGroupsTableGUI::TABLE_FILTER_NAME = 'filter_name'

Definition at line 38 of file class.ilCourseParticipantsGroupsTableGUI.php.

◆ TABLE_ID

const string ilCourseParticipantsGroupsTableGUI::TABLE_ID = 'crsprtcpntsgrpstbl'
protected

Definition at line 41 of file class.ilCourseParticipantsGroupsTableGUI.php.


The documentation for this class was generated from the following file: