3 require_once(
"./Services/Search/classes/class.ilRepositorySearchGUI.php");
4 require_once(
"class.ilOrgUnitStaffTableGUI.php");
5 require_once(
"class.ilOrgUnitOtherRolesTableGUI.php");
66 $this->parent_object = $parent_gui->object;
67 $this->tabs_gui = $this->parent_gui->tabs_gui;
68 $this->toolbar = $ilToolbar;
71 $this->toolbar = $ilToolbar;
74 $this->tabs_gui->setTabActive(
"orgu_staff");
83 $next_class = $this->ctrl->getNextClass($this);
84 $cmd = $this->ctrl->getCmd();
86 switch ($next_class) {
87 case 'ilrepositorysearchgui':
89 case 'addUserFromAutoComplete':
90 if (
$_GET[
'addusertype'] ==
"staff") {
92 } elseif (
$_GET[
'addusertype'] ==
"other") {
98 $this->ctrl->forwardCommand($repo);
105 $this->tabs_gui->activateSubTab(
"show_staff");
108 case 'showOtherRoles':
109 $this->tabs_gui->activateSubTab(
"show_other_roles");
113 $this->tabs_gui->activateSubTab(
"show_staff_rec");
116 case 'confirmRemoveFromRole':
117 case 'confirmRemoveFromEmployees':
118 case 'confirmRemoveFromSuperiors':
136 $this->ctrl->redirect($this->parent_gui,
"");
138 if ($this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
141 $this->ctrl->setParameter($this,
"recursive",
false);
147 if (!$this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
149 $this->ctrl->redirect($this->parent_gui,
"");
151 if ($this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
162 $this->ctrl->redirect($this->parent_gui,
"");
164 $this->ctrl->setParameter($this,
"recursive",
true);
171 "employee" => $this->lng->txt(
"employee"),
172 "superior" => $this->lng->txt(
"superior")
174 $this->ctrl->setParameterByClass(
'ilRepositorySearchGUI',
'addusertype',
'staff');
176 'auto_complete_name' => $this->lng->txt(
'user'),
177 'user_type' => $types,
178 'submit_name' => $this->lng->txt(
'add')
184 $arrLocalRoles = $this->rbacreview->getLocalRoles($this->parent_object->getRefId());
186 foreach ($arrLocalRoles as $role_id) {
188 if (! preg_match(
"/il_orgu_/", $ilObjRole->getUntranslatedTitle())) {
189 $types[$role_id] = $ilObjRole->getPresentationTitle();
192 $this->ctrl->setParameterByClass(
'ilRepositorySearchGUI',
'addusertype',
'other');
194 'auto_complete_name' => $this->lng->txt(
'user'),
195 'user_type' => $types,
196 'submit_name' => $this->lng->txt(
'add')
202 if (!$this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
204 $this->ctrl->redirect($this->parent_gui,
"");
207 $users = explode(
',',
$_POST[
'user_login']);
209 foreach ($users as $user) {
212 $user_ids[] = $user_id;
216 if(!count($user_ids)) {
218 $this->ctrl->redirect($this,
"showStaff");
221 $user_type = isset(
$_POST[
'user_type']) ?
$_POST[
'user_type'] : 0;
222 if ($user_type ==
"employee") {
223 $this->parent_object->assignUsersToEmployeeRole($user_ids);
224 } elseif ($user_type ==
"superior") {
225 $this->parent_object->assignUsersToSuperiorRole($user_ids);
227 throw new Exception(
"The post request didn't specify wether the user_ids should be assigned to the employee or the superior role.");
230 $this->ctrl->redirect($this,
"showStaff");
236 if (!$this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
238 $this->ctrl->redirect($this->parent_gui,
"");
241 $users = explode(
',',
$_POST[
'user_login']);
243 foreach ($users as $user) {
246 $user_ids[] = $user_id;
249 $user_type = isset(
$_POST[
'user_type']) ?
$_POST[
'user_type'] : 0;
250 $arrLocalRoles = $rbacreview->getLocalRoles($this->parent_object->getRefId());
251 if (in_array($user_type, $arrLocalRoles)) {
252 foreach ($user_ids as $user_id) {
253 $rbacadmin->assignUser($user_type, $user_id);
259 $this->ctrl->redirect($this,
"showOtherRoles");
272 $superior_table->parseData();
273 $superior_table->setTitle($lng->txt(
"il_orgu_superior"));
275 $employee_table->parseData();
276 $employee_table->setTitle($lng->txt(
"il_orgu_employee"));
278 return $superior_table->getHTML() . $employee_table->getHTML();
284 $arrLocalRoles = $rbacreview->getLocalRoles($this->parent_object->getRefId());
286 foreach ($arrLocalRoles as $role_id) {
288 if (! preg_match(
"/il_orgu_/", $ilObjRole->getUntranslatedTitle())) {
290 $other_roles_table->readData();
291 $html .= $other_roles_table->getHTML() .
"<br/>";
295 $html = $lng->txt(
"no_roles");
302 if (!$this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
304 $this->ctrl->redirect($this->parent_gui,
"");
306 $this->parent_object->deassignUserFromSuperiorRole(
$_GET[
"obj_id"]);
307 $this->parent_object->assignUsersToEmployeeRole(array(
$_GET[
"obj_id"] ));
309 $this->ctrl->redirect($this,
"showStaff");
314 if (!$this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
316 $this->ctrl->redirect($this->parent_gui,
"");
318 $this->parent_object->deassignUserFromEmployeeRole(
$_GET[
"obj_id"]);
319 $this->parent_object->assignUsersToSuperiorRole(array(
$_GET[
"obj_id"] ));
321 $this->ctrl->redirect($this,
"showStaff");
325 if (!$this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
327 $this->ctrl->redirect($this->parent_gui,
"");
330 case "confirmRemoveFromRole":
331 $this->tabs_gui->activateSubTab(
"show_other_roles");
332 $nextcmd =
"removeFromRole";
333 $paramname =
"obj_id-role_id";
334 $param =
$_GET[
"obj_id"] .
'-' .
$_GET[
"role_id"];
336 case "confirmRemoveFromSuperiors":
337 $this->tabs_gui->activateSubTab(
"show_staff");
338 $nextcmd =
"removeFromSuperiors";
339 $paramname =
"obj_id";
340 $param =
$_GET[
"obj_id"];
342 case "confirmRemoveFromEmployees":
343 $this->tabs_gui->activateSubTab(
"show_staff");
344 $nextcmd =
"removeFromEmployees";
345 $paramname =
"obj_id";
346 $param =
$_GET[
"obj_id"];
349 include_once(
'./Services/Utilities/classes/class.ilConfirmationGUI.php');
351 $confirm->setFormAction($this->ctrl->getFormAction($this, $nextcmd));
352 $confirm->setHeaderText($this->lng->txt(
'orgu_staff_deassign'));
353 $confirm->setConfirm($this->lng->txt(
'confirm'), $nextcmd);
354 $confirm->setCancel($this->lng->txt(
'cancel'),
'showStaff');
356 $confirm->addItem($paramname, $param,
357 $arrUser[
'lastname'] .
', ' . $arrUser[
'firstname'] .
' [' . $arrUser[
'login']
359 $this->tpl->setContent($confirm->getHTML());
363 if (!$this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
365 $this->ctrl->redirect($this->parent_gui,
"");
367 $this->parent_object->deassignUserFromSuperiorRole(
$_POST[
"obj_id"]);
369 $this->ctrl->redirect($this,
"showStaff");
374 if (!$this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
376 $this->ctrl->redirect($this->parent_gui,
"");
378 $this->parent_object->deassignUserFromEmployeeRole(
$_POST[
"obj_id"]);
380 $this->ctrl->redirect($this,
"showStaff");
385 if (!$this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
387 $this->ctrl->redirect($this->parent_gui,
"");
390 $arrObjIdRolId = explode(
"-",
$_POST[
"obj_id-role_id"]);
391 $rbacadmin->deassignUser($arrObjIdRolId[1], $arrObjIdRolId[0]);
393 $this->ctrl->redirect($this,
"showOtherRoles");
398 $this->tabs_gui->addSubTab(
"show_staff", sprintf($this->lng->txt(
"local_staff"), $this->parent_object->getTitle()), $this->ctrl->getLinkTarget($this,
"showStaff"));
399 if ($this->ilAccess->checkAccess(
"view_learning_progress_rec",
"", $this->parent_object->getRefId())) {
400 $this->tabs_gui->addSubTab(
"show_staff_rec", sprintf($this->lng->txt(
"rec_staff"), $this->parent_object->getTitle()), $this->ctrl->getLinkTarget($this,
"showStaffRec"));
402 if ($this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
403 $this->tabs_gui->addSubTab(
"show_other_roles", sprintf($this->lng->txt(
"local_other_roles"), $this->parent_object->getTitle()), $this->ctrl->getLinkTarget($this,
"showOtherRoles"));