ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 31 of file class.ilGroupAddToGroupActionGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilGroupAddToGroupActionGUI::__construct ( )

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

47 {
48 global $DIC;
49
50 $this->ctrl = $DIC->ctrl();
51 $this->tpl = $DIC->ui()->mainTemplate();
52 $this->ui = $DIC->ui();
53 $this->lng = $DIC->language();
54 $this->tree = $DIC->repositoryTree();
55 $this->user = $DIC->user();
56 $this->http = $DIC->http();
57 $this->refinery = $DIC->refinery();
58
59
60 $this->lng->loadLanguageModule("grp");
61 $this->ctrl->saveParameter($this, array("user_id", "modal_exists"));
62 }
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26

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 252 of file class.ilGroupAddToGroupActionGUI.php.

252 : void
253 {
255
257 $user_id = $this->initUserIdFromQuery();
258
259 // @todo: check permission
260
261 $group = new ilObjGroup($ref_id);
262 $participants = ilParticipants::getInstanceByObjId($group->getId());
263
264 $participants->add($user_id, ilParticipants::IL_GRP_MEMBER);
265
266 $participants->sendNotification(
269 );
270
271 echo ilUtil::getSystemMessageHTML($lng->txt("grp_user_been_added"), "success");
272 echo "<script>setTimeout(function (){ il.Group.UserActions.closeModal();}, 1000);</script>";
273 exit;
274 }
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
$ref_id
Definition: ltiauth.php:66

References $lng, $ref_id, $user_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 212 of file class.ilGroupAddToGroupActionGUI.php.

212 : void
213 {
216
218 $user_id = $this->initUserIdFromQuery();
220 if ($participants->isMember($user_id)) {
221 $url = $ctrl->getLinkTarget($this, "selectGroup", "", true);
222 $button = $this->ui->factory()->button()->standard($lng->txt("back"), "#")
223 ->withOnLoadCode(function ($id) use ($url) {
224 return "$('#$id').on('click', function() {il.repository.core.fetchReplaceInner( document.getElementById('il_grp_action_modal_content'),'$url'); return false;})";
225 });
226
227 echo
228 ilUtil::getSystemMessageHTML($lng->txt("grp_user_already_in_group") . "<br>" .
229 $lng->txt("obj_user") . ": " . ilUserUtil::getNamePresentation($user_id) . "<br>" .
230 $lng->txt("obj_grp") . ": " . ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id)), "failure") .
231 $this->ui->renderer()->renderAsync($button);
232 exit;
233 }
234
235
236 // button create new group
237 $ctrl->setParameter($this, "grp_act_ref_id", $ref_id);
238 $url = $ctrl->getLinkTarget($this, "addUser", "", true);
239 $button = $this->ui->factory()->button()->standard($lng->txt("grp_add_user"), "#")
240 ->withOnLoadCode(function ($id) use ($url) {
241 return "$('#$id').on('click', function() {il.repository.core.fetchReplaceInner( document.getElementById('il_grp_action_modal_content'),'$url'); return false;})";
242 });
243
244 echo
245 ilUtil::getSystemMessageHTML($lng->txt("grp_sure_add_user_to_group") . "<br>" .
246 $lng->txt("obj_user") . ": " . ilUserUtil::getNamePresentation($user_id) . "<br>" .
247 $lng->txt("obj_grp") . ": " . ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id)), "question") .
248 $this->ui->renderer()->renderAsync($button);
249 exit;
250 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getLinkTarget(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
@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=null)
Default behaviour is:
$url
Definition: shib_logout.php:68

References $ctrl, $id, $lng, $ref_id, $url, $user_id, 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 327 of file class.ilGroupAddToGroupActionGUI.php.

327 : void
328 {
330
331 $user_id = $this->initUserIdFromQuery();
332 $title = '';
333 if ($this->http->wrapper()->post()->has('title')) {
334 $title = $this->http->wrapper()->post()->retrieve(
335 'title',
336 $this->refinery->kindlyTo()->string()
337 );
338 }
339 $form = $this->getGroupCreationForm();
340
341
342
343 if (!$form->checkInput()) {
344 $this->createGroup($form);
345 return;
346 }
347
348 $this->ctrl->saveParameter($this, "grp_act_par_ref_id");
349 $form->setFormAction($this->ctrl->getLinkTarget($this, "createGroupAndAddUser", "", true));
350 $form->setValuesByPost();
351
352 $button = $this->ui->factory()->button()->standard($lng->txt("grp_create_and_add_user"), "#")
353 ->withOnLoadCode(function ($id) {
354 return "$('#$id').on('click', function(e) {il.Group.UserActions.createGroup(e);})";
355 });
356
357 echo
358 ilUtil::getSystemMessageHTML($lng->txt("grp_sure_create_group_add_user") . "<br>" .
359 $lng->txt("obj_user") . ": " . ilUserUtil::getNamePresentation($user_id) . "<br>" .
360 $lng->txt("obj_grp") . ": " . $title, "question") .
361 "<div class='ilNoDisplay'>" . $form->getHTML() . "</div>" .
362 "<div class='ilRight'>" . $this->ui->renderer()->renderAsync($button) . "</div>";
363
364 exit;
365 }

References $id, $lng, $user_id, 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 294 of file class.ilGroupAddToGroupActionGUI.php.

294 : void
295 {
297
299
300 if ($form == null) {
301 $form = $this->getGroupCreationForm();
302 }
303 $this->ctrl->saveParameter($this, "grp_act_par_ref_id");
304 $form->setFormAction($this->ctrl->getLinkTarget($this, "confirmCreateGroupAndAddUser", "", true));
305
306 echo ilUtil::getSystemMessageHTML(str_replace("%1", ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id)), $lng->txt("grp_create_new_grp_in")), "info") .
307 $form->getHTML();
308 exit;
309 }

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 367 of file class.ilGroupAddToGroupActionGUI.php.

367 : void
368 {
370
371 $user_id = $this->initUserIdFromQuery();
373 $form = $this->getGroupCreationForm();
374
375 $form->checkInput();
376
377 $group_gui = new ilObjGroupGUI("", 0, true);
378
379 // create instance
380 $newObj = new ilObjGroup();
381 $newObj->setType("grp");
382 $newObj->setTitle($form->getInput("title"));
383 $newObj->setDescription($form->getInput("desc"));
384 $newObj->create();
385
386 $group_gui->putObjectInTree($newObj, $ref_id);
387 $group_gui = new ilObjGroupGUI("", $group_gui->getRefId(), true);
388
389
390 // apply didactic template?
391 $type = 'didactic_type';
392 $dtpl = 0;
393 if ($this->http->wrapper()->post()->has('didactic_type')) {
394 $var = $this->http->wrapper()->post()->retrieve(
395 'didactic_type',
396 $this->refinery->kindlyTo()->string()
397 );
398
399 if (substr($var, 0, strlen($type) + 1) != $type . "_") {
400 $dtpl = 0;
401 } else {
402 $dtpl = (int) substr($var, strlen($type) + 1);
403 }
404 }
405 if ($dtpl) {
406 $newObj->applyDidacticTemplate($dtpl);
407 }
408
409 $group_gui->afterSave($newObj, false);
410
411
412 $participants = ilParticipants::getInstanceByObjId($newObj->getId());
413
414 $participants->add($user_id, ilParticipants::IL_GRP_MEMBER);
415
416 $participants->sendNotification(
419 );
420
421
422 $url = ilLink::_getLink($newObj->getRefId());
423 echo ilUtil::getSystemMessageHTML($lng->txt("grp_created_and_user_been_added"), "success");
424 echo "<script>setTimeout(function (){ window.location.replace('$url');}, 1500);</script>";
425 exit;
426 }
Class ilObjGroupGUI.

References $lng, $ref_id, $url, $user_id, exit, getGroupCreationForm(), ilParticipants\getInstanceByObjId(), ilUtil\getSystemMessageHTML(), ILIAS\FileDelivery\http(), ilParticipants\IL_GRP_MEMBER, initGroupParentRefIdFromQuery(), initUserIdFromQuery(), ILIAS\Repository\int(), ILIAS\Repository\refinery(), ilLanguage\txt(), and ilGroupMembershipMailNotification\TYPE_ADMISSION_MEMBER.

+ Here is the call graph for this function:

◆ executeCommand()

ilGroupAddToGroupActionGUI::executeCommand ( )

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

100 : void
101 {
104
105 $next_class = $ctrl->getNextClass($this);
106 $cmd = $ctrl->getCmd("show");
107
108 if ($cmd == "show") {
110 if (count($ca) == 0) {
111 return;
112 }
113 if (count($ca) == 1) {
114 switch (current($ca)) {
115 case "create_grp":
116 $cmd = "selectParent";
117 break;
118
119 case "manage_members":
120 $cmd = "selectGroup";
121 break;
122
123 default:
124 return;
125 }
126 }
127 }
128
129 switch ($next_class) {
130 default:
131 if (in_array($cmd, array("show", "selectGroup", "confirmAddUser", "addUser",
132 "selectParent", "createGroup", "confirmCreateGroupAndAddUser", "createGroupAndAddUser"))) {
133 $ctrl->setParameter($this, "modal_exists", 1);
134 $this->$cmd();
135 }
136 }
137 }
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 312 of file class.ilGroupAddToGroupActionGUI.php.

313 {
315
317
318 $group_gui = new ilObjGroupGUI("", 0, true);
319 $group_gui->setCreationMode();
320 $form = $group_gui->initForm("create", true);
321 $form->clearCommandButtons();
322 $form->addCommandButton("save", $lng->txt("grp_next"));
323 $form->setShowTopButtons(false);
324 return $form;
325 }
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 76 of file class.ilGroupAddToGroupActionGUI.php.

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

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 64 of file class.ilGroupAddToGroupActionGUI.php.

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

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 88 of file class.ilGroupAddToGroupActionGUI.php.

88 : int
89 {
90 $user_id = 0;
91 if ($this->http->wrapper()->query()->has('user_id')) {
92 $user_id = $this->http->wrapper()->query()->retrieve(
93 'user_id',
94 $this->refinery->kindlyTo()->int()
95 );
96 }
97 return $user_id;
98 }

References $user_id, 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 196 of file class.ilGroupAddToGroupActionGUI.php.

196 : void
197 {
199
200 $exp = new ilGroupActionTargetExplorerGUI($this, "selectGroup");
201
202 $exp->setClickableType("grp");
203 $exp->setTypeWhiteList(array("root", "cat", "crs", "fold", "grp"));
204 $exp->setPathOpen($tree->readRootId());
205
206 if (!$exp->handleCommand()) {
207 $this->sendResponse($exp->getHTML());
208 }
209 exit;
210 }

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

+ Here is the call graph for this function:

◆ selectParent()

ilGroupAddToGroupActionGUI::selectParent ( )

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

276 : void
277 {
280
281 $exp = new ilGroupActionTargetExplorerGUI($this, "selectParent", true);
282
283 $exp->setTypeWhiteList(array("root", "cat", "crs"));
284 $exp->setPathOpen($tree->readRootId());
285
286 if (!$exp->handleCommand()) {
287 $this->sendResponse(ilUtil::getSystemMessageHTML($lng->txt("grp_no_perm_to_add_create_first")) .
288 $exp->getHTML());
289 }
290
291 exit;
292 }

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 167 of file class.ilGroupAddToGroupActionGUI.php.

167 : void
168 {
170
171 $modal_exists = false;
172 if ($this->http->wrapper()->query()->has('modal_exists')) {
173 $modal_exists = (bool) $this->http->wrapper()->query()->retrieve(
174 'modal_exists',
175 $this->refinery->kindlyTo()->int()
176 );
177 }
178 if ($modal_exists) {
179 echo $this->ui->renderer()->renderAsync($this->ui->factory()->legacy()->content($a_content));
180 } else {
181 $mtpl = new ilTemplate("tpl.grp_add_to_grp_modal_content.html", true, true, "./components/ILIAS/Group/UserActions");
182 $mtpl->setVariable("CONTENT", $a_content);
183 $content = $this->ui->factory()->legacy()->content($mtpl->get());
184 $modal = $this->ui->factory()->modal()->roundtrip(
185 $lng->txt("grp_add_user_to_group"),
186 $content
187 )->withOnLoadCode(function ($id) {
188 return "il.UI.modal.showModal(document.getElementById('$id'), {'ajaxRenderUrl':'','keyboard':true}, {id: '$id'});";
189 });
190 echo $this->ui->renderer()->renderAsync($modal);
191 }
192 exit;
193 }
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 138 of file class.ilGroupAddToGroupActionGUI.php.

138 : void
139 {
142
143 $toolbar = new ilToolbarGUI();
144
145 // button use existing group
146 $url1 = $ctrl->getLinkTarget($this, "selectGroup", "", true);
147 $button1 = $this->ui->factory()->button()->standard($lng->txt("grp_use_existing"), "#")
148 ->withOnLoadCode(function ($id) use ($url1) {
149 return "$('#$id').on('click', function() {il.repository.core.fetchReplaceInner( document.getElementById('il_grp_action_modal_content'),'$url1'); return false;})";
150 });
151 $toolbar->addComponent($button1);
152
153 // button create new group
154 $url2 = $ctrl->getLinkTarget($this, "selectParent", "", true);
155 $button2 = $this->ui->factory()->button()->standard($lng->txt("grp_create_new"), "#")
156 ->withOnLoadCode(function ($id) use ($url2) {
157 return "$('#$id').on('click', function() {il.repository.core.fetchReplaceInner( document.getElementById('il_grp_action_modal_content'),'$url2'); return false;})";
158 });
159 $toolbar->addComponent($button2);
160
161 $this->sendResponse(
162 ilUtil::getSystemMessageHTML($lng->txt("grp_create_or_use_existing"), "question") .
163 $toolbar->getHTML()
164 );
165 }
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 33 of file class.ilGroupAddToGroupActionGUI.php.

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

◆ $http

GlobalHttpState ilGroupAddToGroupActionGUI::$http
protected

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

◆ $lng

◆ $refinery

Factory ilGroupAddToGroupActionGUI::$refinery
protected

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

◆ $tpl

ilGlobalTemplateInterface ilGroupAddToGroupActionGUI::$tpl
protected

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

◆ $tree

ilTree ilGroupAddToGroupActionGUI::$tree
protected

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

Referenced by selectGroup(), and selectParent().

◆ $ui

UIServices ilGroupAddToGroupActionGUI::$ui
protected

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

◆ $user

ilObjUser ilGroupAddToGroupActionGUI::$user
protected

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

Referenced by executeCommand().


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