ILIAS  release_8 Revision v8.24
ilGroupAddToGroupActionGUI Class Reference

Add user to group from awareness tool. More...

+ Collaboration diagram for ilGroupAddToGroupActionGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 show ()
 
 sendResponse (string $a_content)
 
 selectGroup ()
 
 confirmAddUser ()
 
 addUser ()
 
 selectParent ()
 
 createGroup ($form=null)
 
 confirmCreateGroupAndAddUser ()
 
 createGroupAndAddUser ()
 

Protected Member Functions

 initGroupRefIdFromQuery ()
 
 initGroupParentRefIdFromQuery ()
 
 initUserIdFromQuery ()
 
 getGroupCreationForm ()
 

Protected Attributes

ilCtrl $ctrl
 
ilGlobalTemplateInterface $tpl
 
UIServices $ui
 
ilLanguage $lng
 
ilTree $tree
 
ilObjUser $user
 
GlobalHttpState $http
 
Factory $refinery
 

Detailed Description

Add user to group from awareness tool.

Author
Alex Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 17 of file class.ilGroupAddToGroupActionGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilGroupAddToGroupActionGUI::__construct ( )

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

33 {
34 global $DIC;
35
36 $this->ctrl = $DIC->ctrl();
37 $this->tpl = $DIC->ui()->mainTemplate();
38 $this->ui = $DIC->ui();
39 $this->lng = $DIC->language();
40 $this->tree = $DIC->repositoryTree();
41 $this->user = $DIC->user();
42 $this->http = $DIC->http();
43 $this->refinery = $DIC->refinery();
44
45
46 $this->lng->loadLanguageModule("grp");
47 $this->ctrl->saveParameter($this, array("user_id", "modal_exists"));
48 }
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.

References $DIC, ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ILIAS\Repository\ui(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ addUser()

ilGroupAddToGroupActionGUI::addUser ( )

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

238 : void
239 {
241
243 $user_id = $this->initUserIdFromQuery();
244
245 // @todo: check permission
246
247 $group = new ilObjGroup($ref_id);
248 $participants = ilParticipants::getInstanceByObjId($group->getId());
249
250 $participants->add($user_id, ilParticipants::IL_GRP_MEMBER);
251
252 $participants->sendNotification(
254 $user_id
255 );
256
257 echo ilUtil::getSystemMessageHTML($lng->txt("grp_user_been_added"), "success");
258 echo "<script>setTimeout(function (){ il.Group.UserActions.closeModal();}, 1000);</script>";
259 exit;
260 }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
Class ilObjGroup.
static getInstanceByObjId(int $a_obj_id)
Get instance by obj type.
static getSystemMessageHTML(string $a_txt, string $a_type="info")
Get HTML for a system message.
exit
Definition: login.php:28
$ref_id
Definition: ltiauth.php:67

References $lng, $ref_id, exit, ilParticipants\getInstanceByObjId(), ilUtil\getSystemMessageHTML(), ilParticipants\IL_GRP_MEMBER, initGroupRefIdFromQuery(), initUserIdFromQuery(), ilLanguage\txt(), and ilGroupMembershipMailNotification\TYPE_ADMISSION_MEMBER.

+ Here is the call graph for this function:

◆ confirmAddUser()

ilGroupAddToGroupActionGUI::confirmAddUser ( )

Definition at line 198 of file class.ilGroupAddToGroupActionGUI.php.

198 : void
199 {
202
204 $user_id = $this->initUserIdFromQuery();
206 if ($participants->isMember($user_id)) {
207 $url = $ctrl->getLinkTarget($this, "selectGroup", "", true);
208 $button = $this->ui->factory()->button()->standard($lng->txt("back"), "#")
209 ->withOnLoadCode(function ($id) use ($url) {
210 return "$('#$id').on('click', function() {il.Util.ajaxReplaceInner('$url', 'il_grp_action_modal_content'); return false;})";
211 });
212
213 echo
214 ilUtil::getSystemMessageHTML($lng->txt("grp_user_already_in_group") . "<br>" .
215 $lng->txt("obj_user") . ": " . ilUserUtil::getNamePresentation($user_id) . "<br>" .
216 $lng->txt("obj_grp") . ": " . ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id)), "failure") .
217 $this->ui->renderer()->renderAsync($button);
218 exit;
219 }
220
221
222 // button create new group
223 $ctrl->setParameter($this, "grp_act_ref_id", $ref_id);
224 $url = $ctrl->getLinkTarget($this, "addUser", "", true);
225 $button = $this->ui->factory()->button()->standard($lng->txt("grp_add_user"), "#")
226 ->withOnLoadCode(function ($id) use ($url) {
227 return "$('#$id').on('click', function() {il.Util.ajaxReplaceInner('$url', 'il_grp_action_modal_content'); return false;})";
228 });
229
230 echo
231 ilUtil::getSystemMessageHTML($lng->txt("grp_sure_add_user_to_group") . "<br>" .
232 $lng->txt("obj_user") . ": " . ilUserUtil::getNamePresentation($user_id) . "<br>" .
233 $lng->txt("obj_grp") . ": " . ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id)), "question") .
234 $this->ui->renderer()->renderAsync($button);
235 exit;
236 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
@inheritDoc
getLinkTarget(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
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:
$url

References $ctrl, $id, $lng, $ref_id, $url, ilObject\_lookupObjId(), ilObject\_lookupTitle(), exit, ilParticipants\getInstanceByObjId(), ilCtrl\getLinkTarget(), ilUserUtil\getNamePresentation(), ilUtil\getSystemMessageHTML(), initGroupRefIdFromQuery(), initUserIdFromQuery(), ilCtrl\setParameter(), ilLanguage\txt(), and ILIAS\Repository\ui().

+ Here is the call graph for this function:

◆ confirmCreateGroupAndAddUser()

ilGroupAddToGroupActionGUI::confirmCreateGroupAndAddUser ( )

Definition at line 313 of file class.ilGroupAddToGroupActionGUI.php.

313 : void
314 {
316
317 $user_id = $this->initUserIdFromQuery();
318 $title = '';
319 if ($this->http->wrapper()->post()->has('title')) {
320 $title = $this->http->wrapper()->post()->retrieve(
321 'title',
322 $this->refinery->kindlyTo()->string()
323 );
324 }
325 $form = $this->getGroupCreationForm();
326
327
328
329 if (!$form->checkInput()) {
330 $this->createGroup($form);
331 return;
332 }
333
334 $this->ctrl->saveParameter($this, "grp_act_par_ref_id");
335 $form->setFormAction($this->ctrl->getLinkTarget($this, "createGroupAndAddUser", "", true));
336 $form->setValuesByPost();
337
338 $button = $this->ui->factory()->button()->standard($lng->txt("grp_create_and_add_user"), "#")
339 ->withOnLoadCode(function ($id) {
340 return "$('#$id').on('click', function(e) {il.Group.UserActions.createGroup(e);})";
341 });
342
343 echo
344 ilUtil::getSystemMessageHTML($lng->txt("grp_sure_create_group_add_user") . "<br>" .
345 $lng->txt("obj_user") . ": " . ilUserUtil::getNamePresentation($user_id) . "<br>" .
346 $lng->txt("obj_grp") . ": " . $title, "question") .
347 "<div class='ilNoDisplay'>" . $form->getHTML() . "</div>" .
348 "<div class='ilRight'>" . $this->ui->renderer()->renderAsync($button) . "</div>";
349
350 exit;
351 }

References $id, $lng, createGroup(), ILIAS\Repository\ctrl(), exit, getGroupCreationForm(), ilUserUtil\getNamePresentation(), ilUtil\getSystemMessageHTML(), ILIAS\FileDelivery\http(), initUserIdFromQuery(), ILIAS\Repository\refinery(), ilLanguage\txt(), and ILIAS\Repository\ui().

+ Here is the call graph for this function:

◆ createGroup()

ilGroupAddToGroupActionGUI::createGroup (   $form = null)

Definition at line 280 of file class.ilGroupAddToGroupActionGUI.php.

280 : void
281 {
283
285
286 if ($form == null) {
287 $form = $this->getGroupCreationForm();
288 }
289 $this->ctrl->saveParameter($this, "grp_act_par_ref_id");
290 $form->setFormAction($this->ctrl->getLinkTarget($this, "confirmCreateGroupAndAddUser", "", true));
291
292 echo ilUtil::getSystemMessageHTML(str_replace("%1", ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id)), $lng->txt("grp_create_new_grp_in")), "info") .
293 $form->getHTML();
294 exit;
295 }

References $lng, $ref_id, ilObject\_lookupObjId(), ilObject\_lookupTitle(), ILIAS\Repository\ctrl(), exit, getGroupCreationForm(), ilUtil\getSystemMessageHTML(), initGroupParentRefIdFromQuery(), and ilLanguage\txt().

Referenced by confirmCreateGroupAndAddUser().

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

◆ createGroupAndAddUser()

ilGroupAddToGroupActionGUI::createGroupAndAddUser ( )

Definition at line 353 of file class.ilGroupAddToGroupActionGUI.php.

353 : void
354 {
356
357 $user_id = $this->initUserIdFromQuery();
359 $form = $this->getGroupCreationForm();
360
361 $form->checkInput();
362
363 $group_gui = new ilObjGroupGUI("", 0, true);
364
365 // create instance
366 $newObj = new ilObjGroup();
367 $newObj->setType("grp");
368 $newObj->setTitle($form->getInput("title"));
369 $newObj->setDescription($form->getInput("desc"));
370 $newObj->create();
371
372 $group_gui->putObjectInTree($newObj, $ref_id);
373
374 // apply didactic template?
375 $dtpl = $group_gui->getDidacticTemplateVar("dtpl");
376 if ($dtpl) {
377 $newObj->applyDidacticTemplate($dtpl);
378 }
379
380 $group_gui->afterSave($newObj, false);
381
382
383 $participants = ilParticipants::getInstanceByObjId($newObj->getId());
384
385 $participants->add($user_id, ilParticipants::IL_GRP_MEMBER);
386
387 $participants->sendNotification(
389 $user_id
390 );
391
392
393 $url = ilLink::_getLink($newObj->getRefId());
394 echo ilUtil::getSystemMessageHTML($lng->txt("grp_created_and_user_been_added"), "success");
395 echo "<script>setTimeout(function (){ window.location.replace('$url');}, 1500);</script>";
396 exit;
397 }
Class ilObjGroupGUI.

References $lng, $ref_id, $url, ilLink\_getLink(), exit, getGroupCreationForm(), ilParticipants\getInstanceByObjId(), ilUtil\getSystemMessageHTML(), ilParticipants\IL_GRP_MEMBER, initGroupParentRefIdFromQuery(), initUserIdFromQuery(), ilLanguage\txt(), and ilGroupMembershipMailNotification\TYPE_ADMISSION_MEMBER.

+ Here is the call graph for this function:

◆ executeCommand()

ilGroupAddToGroupActionGUI::executeCommand ( )

Definition at line 86 of file class.ilGroupAddToGroupActionGUI.php.

86 : void
87 {
90
91 $next_class = $ctrl->getNextClass($this);
92 $cmd = $ctrl->getCmd("show");
93
94 if ($cmd == "show") {
96 if (count($ca) == 0) {
97 return;
98 }
99 if (count($ca) == 1) {
100 switch (current($ca)) {
101 case "create_grp":
102 $cmd = "selectParent";
103 break;
104
105 case "manage_members":
106 $cmd = "selectGroup";
107 break;
108
109 default:
110 return;
111 }
112 }
113 }
114
115 switch ($next_class) {
116 default:
117 if (in_array($cmd, array("show", "selectGroup", "confirmAddUser", "addUser",
118 "selectParent", "createGroup", "confirmCreateGroupAndAddUser", "createGroupAndAddUser"))) {
119 $ctrl->setParameter($this, "modal_exists", 1);
120 $this->$cmd();
121 }
122 }
123 }
getNextClass($a_gui_class=null)
@inheritDoc
getCmd(string $fallback_command=null)
@inheritDoc

References $ctrl, $user, ilCtrl\getCmd(), ilGroupUserActionProvider\getCommandAccess(), ilObject\getId(), ilCtrl\getNextClass(), and ilCtrl\setParameter().

+ Here is the call graph for this function:

◆ getGroupCreationForm()

ilGroupAddToGroupActionGUI::getGroupCreationForm ( )
protected

Definition at line 298 of file class.ilGroupAddToGroupActionGUI.php.

299 {
301
303
304 $group_gui = new ilObjGroupGUI("", 0, true);
305 $group_gui->setCreationMode();
306 $form = $group_gui->initForm("create", true);
307 $form->clearCommandButtons();
308 $form->addCommandButton("save", $lng->txt("grp_next"));
309 $form->setShowTopButtons(false);
310 return $form;
311 }
This class represents a property form user interface.

References $lng, $ref_id, initGroupRefIdFromQuery(), and ilLanguage\txt().

Referenced by confirmCreateGroupAndAddUser(), createGroup(), and createGroupAndAddUser().

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

◆ initGroupParentRefIdFromQuery()

ilGroupAddToGroupActionGUI::initGroupParentRefIdFromQuery ( )
protected

Definition at line 62 of file class.ilGroupAddToGroupActionGUI.php.

62 : int
63 {
64 $ref_id = 0;
65 if ($this->http->wrapper()->query()->has('grp_act_par_ref_id')) {
66 $ref_id = $this->http->wrapper()->query()->retrieve(
67 'grp_act_par_ref_id',
68 $this->refinery->kindlyTo()->int()
69 );
70 }
71 return $ref_id;
72 }

References $ref_id, ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by createGroup(), and createGroupAndAddUser().

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

◆ initGroupRefIdFromQuery()

ilGroupAddToGroupActionGUI::initGroupRefIdFromQuery ( )
protected

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

50 : int
51 {
52 $ref_id = 0;
53 if ($this->http->wrapper()->query()->has('grp_act_ref_id')) {
54 $ref_id = $this->http->wrapper()->query()->retrieve(
55 'grp_act_ref_id',
56 $this->refinery->kindlyTo()->int()
57 );
58 }
59 return $ref_id;
60 }

References $ref_id, ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by addUser(), confirmAddUser(), and getGroupCreationForm().

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

◆ initUserIdFromQuery()

ilGroupAddToGroupActionGUI::initUserIdFromQuery ( )
protected

Definition at line 74 of file class.ilGroupAddToGroupActionGUI.php.

74 : int
75 {
76 $user_id = 0;
77 if ($this->http->wrapper()->query()->has('user_id')) {
78 $user_id = $this->http->wrapper()->query()->retrieve(
79 'user_id',
80 $this->refinery->kindlyTo()->int()
81 );
82 }
83 return $user_id;
84 }

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by addUser(), confirmAddUser(), confirmCreateGroupAndAddUser(), and createGroupAndAddUser().

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

◆ selectGroup()

ilGroupAddToGroupActionGUI::selectGroup ( )

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

182 : void
183 {
185
186 $exp = new ilGroupActionTargetExplorerGUI($this, "selectGroup");
187
188 $exp->setClickableType("grp");
189 $exp->setTypeWhiteList(array("root", "cat", "crs", "fold", "grp"));
190 $exp->setPathOpen($tree->readRootId());
191
192 if (!$exp->handleCommand()) {
193 $this->sendResponse($exp->getHTML());
194 }
195 exit;
196 }

References $tree, exit, ilTree\readRootId(), and sendResponse().

+ Here is the call graph for this function:

◆ selectParent()

ilGroupAddToGroupActionGUI::selectParent ( )

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

262 : void
263 {
266
267 $exp = new ilGroupActionTargetExplorerGUI($this, "selectParent", true);
268
269 $exp->setTypeWhiteList(array("root", "cat", "crs"));
270 $exp->setPathOpen($tree->readRootId());
271
272 if (!$exp->handleCommand()) {
273 $this->sendResponse(ilUtil::getSystemMessageHTML($lng->txt("grp_no_perm_to_add_create_first")) .
274 $exp->getHTML());
275 }
276
277 exit;
278 }

References $lng, $tree, exit, ilUtil\getSystemMessageHTML(), ilTree\readRootId(), sendResponse(), and ilLanguage\txt().

+ Here is the call graph for this function:

◆ sendResponse()

ilGroupAddToGroupActionGUI::sendResponse ( string  $a_content)

Definition at line 153 of file class.ilGroupAddToGroupActionGUI.php.

153 : void
154 {
156
157 $modal_exists = false;
158 if ($this->http->wrapper()->query()->has('modal_exists')) {
159 $modal_exists = (bool) $this->http->wrapper()->query()->retrieve(
160 'modal_exists',
161 $this->refinery->kindlyTo()->int()
162 );
163 }
164 if ($modal_exists) {
165 echo $this->ui->renderer()->renderAsync($this->ui->factory()->legacy($a_content));
166 } else {
167 $mtpl = new ilTemplate("tpl.grp_add_to_grp_modal_content.html", true, true, "./Modules/Group/UserActions");
168 $mtpl->setVariable("CONTENT", $a_content);
169 $content = $this->ui->factory()->legacy($mtpl->get());
170 $modal = $this->ui->factory()->modal()->roundtrip(
171 $lng->txt("grp_add_user_to_group"),
172 $content
173 )->withOnLoadCode(function ($id) {
174 return "il.UI.modal.showModal('$id', {'ajaxRenderUrl':'','keyboard':true}, {id: '$id'});";
175 });
176 echo $this->ui->renderer()->renderAsync($modal);
177 }
178 exit;
179 }
special template class to simplify handling of ITX/PEAR

References $id, $lng, exit, ILIAS\FileDelivery\http(), ILIAS\Repository\refinery(), ilLanguage\txt(), and ILIAS\Repository\ui().

Referenced by selectGroup(), selectParent(), and show().

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

◆ show()

ilGroupAddToGroupActionGUI::show ( )

Definition at line 124 of file class.ilGroupAddToGroupActionGUI.php.

124 : void
125 {
128
129 $toolbar = new ilToolbarGUI();
130
131 // button use existing group
132 $url1 = $ctrl->getLinkTarget($this, "selectGroup", "", true);
133 $button1 = $this->ui->factory()->button()->standard($lng->txt("grp_use_existing"), "#")
134 ->withOnLoadCode(function ($id) use ($url1) {
135 return "$('#$id').on('click', function() {il.Util.ajaxReplaceInner('$url1', 'il_grp_action_modal_content'); return false;})";
136 });
137 $toolbar->addComponent($button1);
138
139 // button create new group
140 $url2 = $ctrl->getLinkTarget($this, "selectParent", "", true);
141 $button2 = $this->ui->factory()->button()->standard($lng->txt("grp_create_new"), "#")
142 ->withOnLoadCode(function ($id) use ($url2) {
143 return "$('#$id').on('click', function() {il.Util.ajaxReplaceInner('$url2', 'il_grp_action_modal_content'); return false;})";
144 });
145 $toolbar->addComponent($button2);
146
147 $this->sendResponse(
148 ilUtil::getSystemMessageHTML($lng->txt("grp_create_or_use_existing"), "question") .
149 $toolbar->getHTML()
150 );
151 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $ctrl, $id, $lng, ilCtrl\getLinkTarget(), ilUtil\getSystemMessageHTML(), sendResponse(), ilLanguage\txt(), and ILIAS\Repository\ui().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilGroupAddToGroupActionGUI::$ctrl
protected

Definition at line 19 of file class.ilGroupAddToGroupActionGUI.php.

Referenced by confirmAddUser(), executeCommand(), and show().

◆ $http

GlobalHttpState ilGroupAddToGroupActionGUI::$http
protected

Definition at line 27 of file class.ilGroupAddToGroupActionGUI.php.

◆ $lng

◆ $refinery

Factory ilGroupAddToGroupActionGUI::$refinery
protected

Definition at line 28 of file class.ilGroupAddToGroupActionGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilGroupAddToGroupActionGUI::$tpl
protected

Definition at line 20 of file class.ilGroupAddToGroupActionGUI.php.

◆ $tree

ilTree ilGroupAddToGroupActionGUI::$tree
protected

Definition at line 23 of file class.ilGroupAddToGroupActionGUI.php.

Referenced by selectGroup(), and selectParent().

◆ $ui

UIServices ilGroupAddToGroupActionGUI::$ui
protected

Definition at line 21 of file class.ilGroupAddToGroupActionGUI.php.

◆ $user

ilObjUser ilGroupAddToGroupActionGUI::$user
protected

Definition at line 24 of file class.ilGroupAddToGroupActionGUI.php.

Referenced by executeCommand().


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