ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilGroupAddToGroupActionGUI Class Reference

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

+ Collaboration diagram for ilGroupAddToGroupActionGUI:

Public Member Functions

 __construct ()
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 show ()
 Show. More...
 
 sendResponse ($a_content)
 Send response. More...
 
 selectGroup ()
 Select group. More...
 
 confirmAddUser ()
 Confirm add user to group. More...
 
 addUser ()
 Add user. More...
 
 selectParent ()
 Select group. More...
 
 createGroup ($form=null)
 Create group. More...
 
 confirmCreateGroupAndAddUser ()
 Save group. More...
 
 createGroupAndAddUser ()
 Create group and add user. More...
 

Protected Member Functions

 getGroupCreationForm ()
 

Protected Attributes

 $ctrl
 
 $tpl
 
 $ui
 
 $lng
 
 $tree
 

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

Constructor & Destructor Documentation

◆ __construct()

ilGroupAddToGroupActionGUI::__construct ( )

Constructor.

Parameters

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

References $DIC, and user().

44  {
45  global $DIC;
46 
47  $this->ctrl = $DIC->ctrl();
48  $this->tpl = $DIC["tpl"];
49  $this->ui = $DIC->ui();
50  $this->lng = $DIC->language();
51  $this->tree = $DIC->repositoryTree();
52  $this->user = $DIC->user();
53 
54  $this->lng->loadLanguageModule("grp");
55  $this->ctrl->saveParameter($this, array("user_id", "modal_exists"));
56  }
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
+ Here is the call graph for this function:

Member Function Documentation

◆ addUser()

ilGroupAddToGroupActionGUI::addUser ( )

Add user.

Parameters

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

References $_GET, $lng, $tpl, exit, ilParticipants\getInstanceByObjId(), IL_GRP_MEMBER, and ilGroupMembershipMailNotification\TYPE_ADMISSION_MEMBER.

238  {
239  $tpl = $this->tpl;
240  $lng = $this->lng;
241 
242  $user_id = (int) $_GET["user_id"];
243 
244  // @todo: check permission
245 
246  include_once("./Modules/Group/classes/class.ilObjGroup.php");
247  $group = new ilObjGroup((int) $_GET["grp_act_ref_id"]);
248 
249  include_once './Services/Membership/classes/class.ilParticipants.php';
250  $participants = ilParticipants::getInstanceByObjId($group->getId());
251 
252  $participants->add($user_id, IL_GRP_MEMBER);
253 
254  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
255  $participants->sendNotification(
257  $user_id
258  );
259 
260  echo $tpl->getMessageHTML($lng->txt("grp_user_been_added"), "success");
261  echo "<script>setTimeout(function (){ il.Group.UserActions.closeModal();}, 1000);</script>";
262  exit;
263  }
$_GET["client_id"]
const IL_GRP_MEMBER
exit
Definition: backend.php:16
Class ilObjGroup.
static getInstanceByObjId($a_obj_id)
Get instance by obj type.
+ Here is the call graph for this function:

◆ confirmAddUser()

ilGroupAddToGroupActionGUI::confirmAddUser ( )

Confirm add user to group.

Parameters

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

References $_GET, $ctrl, $id, $lng, $tpl, $url, ilObject\_lookupObjId(), ilObject\_lookupTitle(), exit, ilParticipants\getInstanceByObjId(), ilUserUtil\getNamePresentation(), and ILIAS\UI\Implementation\Component\withOnLoadCode().

192  {
193  $ctrl = $this->ctrl;
194  $tpl = $this->tpl;
195  $lng = $this->lng;
196 
197  include_once("./Services/Membership/classes/class.ilParticipants.php");
198  include_once './Services/Membership/classes/class.ilParticipants.php';
199  $participants = ilParticipants::getInstanceByObjId(ilObject::_lookupObjId((int) $_GET["grp_act_ref_id"]));
200  if ($participants->isMember((int) $_GET["user_id"])) {
201  $url = $ctrl->getLinkTarget($this, "selectGroup", "", true, false);
202  $button = $this->ui->factory()->button()->standard($lng->txt("back"), "#")
203  ->withOnLoadCode(function ($id) use ($url) {
204  return "$('#$id').on('click', function() {il.Util.ajaxReplaceInner('$url', 'il_grp_action_modal_content'); return false;})";
205  });
206 
207  echo
208  $tpl->getMessageHTML($lng->txt("grp_user_already_in_group") . "<br>" .
209  $lng->txt("obj_user") . ": " . ilUserUtil::getNamePresentation((int) $_GET["user_id"]) . "<br>" .
210  $lng->txt("obj_grp") . ": " . ilObject::_lookupTitle(ilObject::_lookupObjId($_GET["grp_act_ref_id"])), "failure") .
211  $this->ui->renderer()->renderAsync($button);
212  exit;
213  }
214 
215 
216  // button create new group
217  $ctrl->setParameter($this, "grp_act_ref_id", $_GET["grp_act_ref_id"]);
218  $url = $ctrl->getLinkTarget($this, "addUser", "", true, false);
219  $button = $this->ui->factory()->button()->standard($lng->txt("grp_add_user"), "#")
220  ->withOnLoadCode(function ($id) use ($url) {
221  return "$('#$id').on('click', function() {il.Util.ajaxReplaceInner('$url', 'il_grp_action_modal_content'); return false;})";
222  });
223 
224  echo
225  $tpl->getMessageHTML($lng->txt("grp_sure_add_user_to_group") . "<br>" .
226  $lng->txt("obj_user") . ": " . ilUserUtil::getNamePresentation((int) $_GET["user_id"]) . "<br>" .
227  $lng->txt("obj_grp") . ": " . ilObject::_lookupTitle(ilObject::_lookupObjId($_GET["grp_act_ref_id"])), "question") .
228  $this->ui->renderer()->renderAsync($button);
229  exit;
230  }
$_GET["client_id"]
if(!array_key_exists('StateId', $_REQUEST)) $id
static _lookupTitle($a_id)
lookup object title
static _lookupObjId($a_id)
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
exit
Definition: backend.php:16
$url
static getInstanceByObjId($a_obj_id)
Get instance by obj type.
+ Here is the call graph for this function:

◆ confirmCreateGroupAndAddUser()

ilGroupAddToGroupActionGUI::confirmCreateGroupAndAddUser ( )

Save group.

Parameters

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

References $_GET, $_POST, $ctrl, $form, $id, $lng, $tpl, createGroup(), exit, getGroupCreationForm(), ilUserUtil\getNamePresentation(), and ILIAS\UI\Implementation\Component\withOnLoadCode().

337  {
338  $ctrl = $this->ctrl;
339  $tpl = $this->tpl;
340  $lng = $this->lng;
341 
342  $form = $this->getGroupCreationForm();
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, false));
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  $tpl->getMessageHTML($lng->txt("grp_sure_create_group_add_user") . "<br>" .
359  $lng->txt("obj_user") . ": " . ilUserUtil::getNamePresentation($_GET["user_id"]) . "<br>" .
360  $lng->txt("obj_grp") . ": " . $_POST["title"], "question") .
361  "<div class='ilNoDisplay'>" . $form->getHTML() . "</div>" .
362  "<div class='ilRight'>" . $this->ui->renderer()->renderAsync($button) . "</div>";
363 
364  exit;
365  }
$_GET["client_id"]
if(!array_key_exists('StateId', $_REQUEST)) $id
if(isset($_POST['submit'])) $form
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
exit
Definition: backend.php:16
$_POST["username"]
+ Here is the call graph for this function:

◆ createGroup()

ilGroupAddToGroupActionGUI::createGroup (   $form = null)

Create group.

Parameters

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

References $_GET, $form, $lng, $tpl, ilObject\_lookupObjId(), ilObject\_lookupTitle(), exit, and getGroupCreationForm().

Referenced by confirmCreateGroupAndAddUser().

298  {
299  $tpl = $this->tpl;
300  $lng = $this->lng;
301 
302  if ($form == null) {
303  $form = $this->getGroupCreationForm();
304  }
305  $this->ctrl->saveParameter($this, "grp_act_par_ref_id");
306  $form->setFormAction($this->ctrl->getLinkTarget($this, "confirmCreateGroupAndAddUser", "", true, false));
307 
308  echo $tpl->getMessageHTML(str_replace("%1", ilObject::_lookupTitle(ilObject::_lookupObjId($_GET["grp_act_par_ref_id"])), $lng->txt("grp_create_new_grp_in")), "info") .
309  $form->getHTML();
310  exit;
311  }
$_GET["client_id"]
static _lookupTitle($a_id)
lookup object title
if(isset($_POST['submit'])) $form
static _lookupObjId($a_id)
exit
Definition: backend.php:16
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createGroupAndAddUser()

ilGroupAddToGroupActionGUI::createGroupAndAddUser ( )

Create group and add user.

Parameters

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

References $_GET, $form, $lng, $tpl, $url, ilLink\_getLink(), exit, getGroupCreationForm(), ilParticipants\getInstanceByObjId(), IL_GRP_MEMBER, and ilGroupMembershipMailNotification\TYPE_ADMISSION_MEMBER.

374  {
375  $lng = $this->lng;
376  $tpl = $this->tpl;
377 
378  $user_id = (int) $_GET["user_id"];
379  $form = $this->getGroupCreationForm();
380 
381  $form->checkInput();
382 
383  $group_gui = new ilObjGroupGUI("", 0, true);
384 
385  // create instance
386  include_once("./Modules/Group/classes/class.ilObjGroup.php");
387  $newObj = new ilObjGroup();
388  $newObj->setType("grp");
389  $newObj->setTitle($form->getInput("title"));
390  $newObj->setDescription($form->getInput("desc"));
391  $newObj->create();
392 
393  $group_gui->putObjectInTree($newObj, (int) $_GET["grp_act_par_ref_id"]);
394 
395  // apply didactic template?
396  $dtpl = $group_gui->getDidacticTemplateVar("dtpl");
397  if ($dtpl) {
398  $newObj->applyDidacticTemplate($dtpl);
399  }
400 
401  $group_gui->afterSave($newObj, false);
402 
403 
404  include_once './Services/Membership/classes/class.ilParticipants.php';
405  $participants = ilParticipants::getInstanceByObjId($newObj->getId());
406 
407  $participants->add($user_id, IL_GRP_MEMBER);
408 
409  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
410  $participants->sendNotification(
412  $user_id
413  );
414 
415 
416  include_once("./Services/Link/classes/class.ilLink.php");
417  $url = ilLink::_getLink($newObj->getRefId());
418  echo $tpl->getMessageHTML($lng->txt("grp_created_and_user_been_added"), "success");
419  echo "<script>setTimeout(function (){ window.location.replace('$url');}, 1500);</script>";
420  exit;
421  }
Class ilObjGroupGUI.
$_GET["client_id"]
const IL_GRP_MEMBER
if(isset($_POST['submit'])) $form
exit
Definition: backend.php:16
Class ilObjGroup.
$url
static getInstanceByObjId($a_obj_id)
Get instance by obj type.
+ Here is the call graph for this function:

◆ executeCommand()

ilGroupAddToGroupActionGUI::executeCommand ( )

Execute command.

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

References $ctrl, $user, and ilGroupUserActionProvider\getCommandAccess().

62  {
65 
66  $next_class = $ctrl->getNextClass($this);
67  $cmd = $ctrl->getCmd("show");
68 
69  if ($cmd == "show") {
70  include_once("./Modules/Group/UserActions/classes/class.ilGroupUserActionProvider.php");
72  if (count($ca) == 0) {
73  return;
74  }
75  if (count($ca) == 1) {
76  switch (current($ca)) {
77  case "create_grp":
78  $cmd = "selectParent";
79  break;
80 
81  case "manage_members":
82  $cmd = "selectGroup";
83  break;
84 
85  default:
86  return;
87  }
88  }
89  }
90 
91  switch ($next_class) {
92  default:
93  if (in_array($cmd, array("show", "selectGroup", "confirmAddUser", "addUser",
94  "selectParent", "createGroup", "confirmCreateGroupAndAddUser", "createGroupAndAddUser"))) {
95  $ctrl->setParameter($this, "modal_exists", 1);
96  $this->$cmd();
97  }
98  }
99  }
$user
Definition: migrateto20.php:57
static getCommandAccess($a_user_id)
Get command access for user.
+ Here is the call graph for this function:

◆ getGroupCreationForm()

ilGroupAddToGroupActionGUI::getGroupCreationForm ( )
protected

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

References $_GET, $form, and $lng.

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

314  {
315  $lng = $this->lng;
316 
317  $group_gui = new ilObjGroupGUI("", 0, true);
318  $group_gui->setCreationMode(true);
319  // workaround for bug #22748 (which is triggered, if a didactic template for groups exist which is limited to a rep node)
320  $ref_id = $_GET["ref_id"];
321  $_GET["ref_id"] = $_GET["grp_act_par_ref_id"];
322  $form = $group_gui->initForm("create", true);
323  $_GET["ref_id"] = $ref_id;
324  $form->clearCommandButtons();
325  $form->addCommandButton("save", $lng->txt("grp_next"));
326  $form->setShowTopButtons(false);
327  return $form;
328  }
Class ilObjGroupGUI.
$_GET["client_id"]
if(isset($_POST['submit'])) $form
+ Here is the caller graph for this function:

◆ selectGroup()

ilGroupAddToGroupActionGUI::selectGroup ( )

Select group.

Parameters

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

References $tree, exit, and sendResponse().

168  {
169  $tree = $this->tree;
170 
171  include_once("./Modules/Group/UserActions/classes/class.ilGroupActionTargetExplorerGUI.php");
172  $exp = new ilGroupActionTargetExplorerGUI($this, "selectGroup");
173 
174  $exp->setClickableType("grp");
175  $exp->setTypeWhiteList(array("root", "cat", "crs", "fold", "grp"));
176  $exp->setPathOpen((int) $tree->readRootId());
177 
178  if (!$exp->handleCommand()) {
179  $this->sendResponse($exp->getHTML());
180  }
181 
182  exit;
183  }
exit
Definition: backend.php:16
+ Here is the call graph for this function:

◆ selectParent()

ilGroupAddToGroupActionGUI::selectParent ( )

Select group.

Parameters

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

References $lng, $tpl, $tree, exit, and sendResponse().

272  {
273  $tree = $this->tree;
274  $lng = $this->lng;
275  $tpl = $this->tpl;
276 
277  include_once("./Modules/Group/UserActions/classes/class.ilGroupActionTargetExplorerGUI.php");
278  $exp = new ilGroupActionTargetExplorerGUI($this, "selectParent", true);
279 
280  $exp->setTypeWhiteList(array("root", "cat", "crs"));
281  $exp->setPathOpen((int) $tree->readRootId());
282 
283  if (!$exp->handleCommand()) {
284  $this->sendResponse($tpl->getMessageHTML($lng->txt("grp_no_perm_to_add_create_first"), "info") .
285  $exp->getHTML());
286  }
287 
288  exit;
289  }
exit
Definition: backend.php:16
+ Here is the call graph for this function:

◆ sendResponse()

ilGroupAddToGroupActionGUI::sendResponse (   $a_content)

Send response.

Parameters
string$a_content

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

References $_GET, $a_content, $id, $lng, exit, and ILIAS\UI\Implementation\Component\withOnLoadCode().

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

140  {
141  $lng = $this->lng;
142 
143  if ($_GET["modal_exists"] == 1) {
144  echo $this->ui->renderer()->renderAsync($this->ui->factory()->legacy($a_content));
145  } else {
146  $mtpl = new ilTemplate("tpl.grp_add_to_grp_modal_content.html", true, true, "./Modules/Group/UserActions");
147  $mtpl->setVariable("CONTENT", $a_content);
148  $content = $this->ui->factory()->legacy($mtpl->get());
149  $modal = $this->ui->factory()->modal()->roundtrip(
150  $lng->txt("grp_add_user_to_group"),
151  $content
152  )->withOnLoadCode(function ($id) {
153  return "il.UI.modal.showModal('$id', {'ajaxRenderUrl':'','keyboard':true});";
154  });
155  echo $this->ui->renderer()->renderAsync($modal);
156  }
157  exit;
158  }
$_GET["client_id"]
if(!array_key_exists('StateId', $_REQUEST)) $id
$a_content
Definition: workflow.php:93
special template class to simplify handling of ITX/PEAR
exit
Definition: backend.php:16
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ show()

ilGroupAddToGroupActionGUI::show ( )

Show.

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

References $ctrl, $id, $lng, $tpl, sendResponse(), and ILIAS\UI\Implementation\Component\withOnLoadCode().

105  {
106  $tpl = $this->tpl;
107  $lng = $this->lng;
108  $ctrl = $this->ctrl;
109 
110  $toolbar = new ilToolbarGUI();
111 
112  // button use existing group
113  $url1 = $ctrl->getLinkTarget($this, "selectGroup", "", true, false);
114  $button1 = $this->ui->factory()->button()->standard($lng->txt("grp_use_existing"), "#")
115  ->withOnLoadCode(function ($id) use ($url1) {
116  return "$('#$id').on('click', function() {il.Util.ajaxReplaceInner('$url1', 'il_grp_action_modal_content'); return false;})";
117  });
118  $toolbar->addComponent($button1);
119 
120  // button create new group
121  $url2 = $ctrl->getLinkTarget($this, "selectParent", "", true, false);
122  $button2 = $this->ui->factory()->button()->standard($lng->txt("grp_create_new"), "#")
123  ->withOnLoadCode(function ($id) use ($url2) {
124  return "$('#$id').on('click', function() {il.Util.ajaxReplaceInner('$url2', 'il_grp_action_modal_content'); return false;})";
125  });
126  $toolbar->addComponent($button2);
127 
128  $this->sendResponse(
129  $tpl->getMessageHTML($lng->txt("grp_create_or_use_existing"), "question") .
130  $toolbar->getHTML()
131  );
132  }
if(!array_key_exists('StateId', $_REQUEST)) $id
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilGroupAddToGroupActionGUI::$ctrl
protected

◆ $lng

◆ $tpl

ilGroupAddToGroupActionGUI::$tpl
protected

◆ $tree

ilGroupAddToGroupActionGUI::$tree
protected

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

Referenced by selectGroup(), and selectParent().

◆ $ui

ilGroupAddToGroupActionGUI::$ui
protected

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


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