ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilIndividualAssessmentMembersGUI.php
Go to the documentation of this file.
1 <?php
2 require_once 'Modules/IndividualAssessment/classes/class.ilIndividualAssessmentMembersTableGUI.php';
3 require_once 'Modules/IndividualAssessment/classes/LearningProgress/class.ilIndividualAssessmentLPInterface.php';
15 {
16  protected $ctrl;
17  protected $parent_gui;
18  protected $ref_id;
19  protected $tpl;
20  protected $lng;
21 
22  public function __construct($a_parent_gui, $a_ref_id)
23  {
24  global $DIC;
25  $this->ctrl = $DIC['ilCtrl'];
26  $this->parent_gui = $a_parent_gui;
27  $this->object = $a_parent_gui->object;
28  $this->ref_id = $a_ref_id;
29  $this->tpl = $DIC['tpl'];
30  $this->lng = $DIC['lng'];
31  $this->toolbar = $DIC['ilToolbar'];
32  $this->iass_access = $this->object->accessHandler();
33  }
34 
35  public function executeCommand()
36  {
37  if (!$this->iass_access->mayEditMembers()
38  && !$this->iass_access->mayGradeUser()
39  && !$this->iass_access->mayViewUser()
40  && !$this->iass_access->mayAmendGradeUser()
41  ) {
42  $this->parent_gui->handleAccessViolation();
43  }
44  $cmd = $this->ctrl->getCmd();
45  $next_class = $this->ctrl->getNextClass();
46  switch ($next_class) {
47  case "ilrepositorysearchgui":
48  require_once 'Services/Search/classes/class.ilRepositorySearchGUI.php';
49  $rep_search = new ilRepositorySearchGUI();
50  $rep_search->setCallback($this, "addUsersFromSearch");
51  $this->ctrl->forwardCommand($rep_search);
52  break;
53  case "ilindividualassessmentmembergui":
54  require_once 'Modules/IndividualAssessment/classes/class.ilIndividualAssessmentMemberGUI.php';
55  $member = new ilIndividualAssessmentMemberGUI($this, $this->parent_gui, $this->ref_id);
56  $this->ctrl->forwardCommand($member);
57  break;
58  default:
59  if (!$cmd) {
60  $cmd = 'view';
61  }
62  $this->$cmd();
63  break;
64  }
65  }
66 
67  protected function addedUsers()
68  {
69  if (!$_GET['failure']) {
70  ilUtil::sendSuccess($this->lng->txt('iass_add_user_success'));
71  } else {
72  ilUtil::sendFailure($this->lng->txt('iass_add_user_failure'));
73  }
74  $this->view();
75  }
76 
77  protected function view()
78  {
79  if ($this->iass_access->mayEditMembers()) {
80  require_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
81 
82  $search_params = ['crs', 'grp'];
83  $container_id = $this->object->getParentContainerIdByType($this->ref_id, $search_params);
84  if ($container_id !== 0) {
86  $this,
87  $this->toolbar,
88  array(
89  'auto_complete_name' => $this->lng->txt('user'),
90  'submit_name' => $this->lng->txt('add'),
91  'add_search' => true,
92  'add_from_container' => $container_id
93  )
94  );
95  } else {
97  $this,
98  $this->toolbar,
99  array(
100  'auto_complete_name' => $this->lng->txt('user'),
101  'submit_name' => $this->lng->txt('add'),
102  'add_search' => true
103  )
104  );
105  }
106  }
108  $this->tpl->setContent($table->getHTML());
109  }
110 
111  public function addUsersFromSearch($user_ids)
112  {
113  if ($user_ids && is_array($user_ids) && !empty($user_ids)) {
114  $this->addUsers($user_ids);
115  }
116 
117  ilUtil::sendInfo($this->lng->txt("search_no_selection"), true);
118  $this->ctrl->redirectByClass(array(get_class($this->parent_gui),get_class($this)), 'view');
119  }
120 
126  public function addUsers(array $user_ids)
127  {
128  if (!$this->iass_access->mayEditMembers()) {
129  $this->parent_gui->handleAccessViolation();
130  }
131  $iass = $this->object;
132  $members = $iass->loadMembers();
133  $failure = null;
134  if (count($user_ids) === 0) {
135  $failure = 1;
136  }
137  foreach ($user_ids as $user_id) {
138  $user = new ilObjUser($user_id);
139  if (!$members->userAllreadyMember($user)) {
140  $members = $members->withAdditionalUser($user);
141  } else {
142  $failure = 1;
143  }
144  }
145  $members->updateStorageAndRBAC($iass->membersStorage(), $iass->accessHandler());
147  $this->ctrl->setParameter($this, 'failure', $failure);
148  $this->ctrl->redirectByClass(array(get_class($this->parent_gui),get_class($this)), 'addedUsers');
149  }
150 
151  protected function removeUserConfirmation()
152  {
153  if (!$this->iass_access->mayEditMembers()) {
154  $this->parent_gui->handleAccessViolation();
155  }
156  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
157  $confirm = new ilConfirmationGUI();
158  $confirm->addItem('usr_id', $_GET['usr_id'], ilObjUser::_lookupFullname($_GET['usr_id']));
159  $confirm->setHeaderText($this->lng->txt('iass_remove_user_qst'));
160  $confirm->setFormAction($this->ctrl->getFormAction($this));
161  $confirm->setConfirm($this->lng->txt('remove'), 'removeUser');
162  $confirm->setCancel($this->lng->txt('cancel'), 'view');
163  $this->tpl->setContent($confirm->getHTML());
164  }
165 
171  public function removeUser()
172  {
173  if (!$this->iass_access->mayEditMembers()) {
174  $this->parent_gui->handleAccessViolation();
175  }
176  $usr_id = $_POST['usr_id'];
177  $iass = $this->object;
178  $iass->loadMembers()
179  ->withoutPresentUser(new ilObjUser($usr_id))
180  ->updateStorageAndRBAC($iass->membersStorage(), $iass->accessHandler());
182  $this->ctrl->redirectByClass(array(get_class($this->parent_gui),get_class($this)), 'view');
183  }
184 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$failure
addUsers(array $user_ids)
Add users to corresponding iass-object.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
static _lookupFullname($a_user_id)
Lookup Full Name.
removeUser()
Remove users from corresponding iass-object.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
For the purpose of streamlining the grading and learning-process status definition outside of tests...
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static fillAutoCompleteToolbar($parent_object, ilToolbarGUI $toolbar=null, $a_options=array(), $a_sticky=false)
fill toolbar with
if(empty($password)) $table
Definition: pwgen.php:24
For the purpose of streamlining the grading and learning-process status definition outside of tests...
$_POST["username"]
Confirmation screen class.