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");
86 $next_class = $this->ctrl->getNextClass($this);
87 $cmd = $this->ctrl->getCmd();
89 switch ($next_class) {
90 case 'ilrepositorysearchgui':
92 case 'addUserFromAutoComplete':
93 if (
$_GET[
'addusertype'] ==
"staff") {
95 } elseif (
$_GET[
'addusertype'] ==
"other") {
101 $this->ctrl->forwardCommand($repo);
108 $this->tabs_gui->activateSubTab(
"show_staff");
111 case 'showOtherRoles':
112 $this->tabs_gui->activateSubTab(
"show_other_roles");
116 $this->tabs_gui->activateSubTab(
"show_staff_rec");
119 case 'confirmRemoveFromRole':
120 case 'confirmRemoveFromEmployees':
121 case 'confirmRemoveFromSuperiors':
125 case 'addOtherRoles':
126 case 'fromSuperiorToEmployee':
127 case 'fromEmployeeToSuperior':
128 case 'removeFromSuperiors':
129 case 'removeFromEmployees':
130 case 'removeFromRole':
134 throw new ilException(
"Unknown command for command class ilOrgUnitStaffGUI: ".
$cmd);
148 $this->ctrl->redirect($this->parent_gui,
"");
150 if ($this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
153 $this->ctrl->setParameter($this,
"recursive",
false);
159 if (!$this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
161 $this->ctrl->redirect($this->parent_gui,
"");
163 if ($this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
174 $this->ctrl->redirect($this->parent_gui,
"");
176 $this->ctrl->setParameter($this,
"recursive",
true);
183 "employee" => $this->lng->txt(
"employee"),
184 "superior" => $this->lng->txt(
"superior")
186 $this->ctrl->setParameterByClass(
'ilRepositorySearchGUI',
'addusertype',
'staff');
188 'auto_complete_name' => $this->lng->txt(
'user'),
189 'user_type' => $types,
190 'submit_name' => $this->lng->txt(
'add')
196 $arrLocalRoles = $this->rbacreview->getLocalRoles($this->parent_object->getRefId());
198 foreach ($arrLocalRoles as $role_id) {
200 if (! preg_match(
"/il_orgu_/", $ilObjRole->getUntranslatedTitle())) {
201 $types[$role_id] = $ilObjRole->getPresentationTitle();
204 $this->ctrl->setParameterByClass(
'ilRepositorySearchGUI',
'addusertype',
'other');
206 'auto_complete_name' => $this->lng->txt(
'user'),
207 'user_type' => $types,
208 'submit_name' => $this->lng->txt(
'add')
214 if (!$this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
216 $this->ctrl->redirect($this->parent_gui,
"");
219 $users = explode(
',',
$_POST[
'user_login']);
221 foreach ($users as $user) {
224 $user_ids[] = $user_id;
228 if(!count($user_ids)) {
230 $this->ctrl->redirect($this,
"showStaff");
233 $user_type = isset(
$_POST[
'user_type']) ?
$_POST[
'user_type'] : 0;
234 if ($user_type ==
"employee") {
235 $this->parent_object->assignUsersToEmployeeRole($user_ids);
236 } elseif ($user_type ==
"superior") {
237 $this->parent_object->assignUsersToSuperiorRole($user_ids);
239 throw new Exception(
"The post request didn't specify wether the user_ids should be assigned to the employee or the superior role.");
242 $this->ctrl->redirect($this,
"showStaff");
247 if (!$this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
249 $this->ctrl->redirect($this->parent_gui,
"");
252 $users = explode(
',',
$_POST[
'user_login']);
254 foreach ($users as $user) {
257 $user_ids[] = $user_id;
260 $role_id = isset(
$_POST[
'user_type']) ?
$_POST[
'user_type'] : 0;
261 foreach ($user_ids as $user_id) {
262 $this->parent_object->assignUserToLocalRole($role_id, $user_id);
265 $this->ctrl->redirect($this,
"showOtherRoles");
278 $superior_table->parseData();
279 $superior_table->setTitle($lng->txt(
"il_orgu_superior"));
281 $employee_table->parseData();
282 $employee_table->setTitle($lng->txt(
"il_orgu_employee"));
284 return $superior_table->getHTML() . $employee_table->getHTML();
290 $arrLocalRoles = $rbacreview->getLocalRoles($this->parent_object->getRefId());
292 foreach ($arrLocalRoles as $role_id) {
294 if (! preg_match(
"/il_orgu_/", $ilObjRole->getUntranslatedTitle())) {
296 $other_roles_table->readData();
297 $html .= $other_roles_table->getHTML() .
"<br/>";
301 $html = $lng->txt(
"no_roles");
308 if (!$this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
310 $this->ctrl->redirect($this->parent_gui,
"");
312 $this->parent_object->deassignUserFromSuperiorRole(
$_GET[
"obj_id"]);
313 $this->parent_object->assignUsersToEmployeeRole(array(
$_GET[
"obj_id"] ));
315 $this->ctrl->redirect($this,
"showStaff");
320 if (!$this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
322 $this->ctrl->redirect($this->parent_gui,
"");
324 $this->parent_object->deassignUserFromEmployeeRole(
$_GET[
"obj_id"]);
325 $this->parent_object->assignUsersToSuperiorRole(array(
$_GET[
"obj_id"] ));
327 $this->ctrl->redirect($this,
"showStaff");
331 if (!$this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
333 $this->ctrl->redirect($this->parent_gui,
"");
336 case "confirmRemoveFromRole":
337 $this->tabs_gui->activateSubTab(
"show_other_roles");
338 $nextcmd =
"removeFromRole";
339 $paramname =
"obj_id-role_id";
340 $param =
$_GET[
"obj_id"] .
'-' .
$_GET[
"role_id"];
342 case "confirmRemoveFromSuperiors":
343 $this->tabs_gui->activateSubTab(
"show_staff");
344 $nextcmd =
"removeFromSuperiors";
345 $paramname =
"obj_id";
346 $param =
$_GET[
"obj_id"];
348 case "confirmRemoveFromEmployees":
349 $this->tabs_gui->activateSubTab(
"show_staff");
350 $nextcmd =
"removeFromEmployees";
351 $paramname =
"obj_id";
352 $param =
$_GET[
"obj_id"];
355 include_once(
'./Services/Utilities/classes/class.ilConfirmationGUI.php');
357 $confirm->setFormAction($this->ctrl->getFormAction($this, $nextcmd));
358 $confirm->setHeaderText($this->lng->txt(
'orgu_staff_deassign'));
359 $confirm->setConfirm($this->lng->txt(
'confirm'), $nextcmd);
360 $confirm->setCancel($this->lng->txt(
'cancel'),
'showStaff');
362 $confirm->addItem($paramname, $param,
363 $arrUser[
'lastname'] .
', ' . $arrUser[
'firstname'] .
' [' . $arrUser[
'login']
365 $this->tpl->setContent($confirm->getHTML());
369 if (!$this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
371 $this->ctrl->redirect($this->parent_gui,
"");
373 $this->parent_object->deassignUserFromSuperiorRole(
$_POST[
"obj_id"]);
375 $this->ctrl->redirect($this,
"showStaff");
380 if (!$this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
382 $this->ctrl->redirect($this->parent_gui,
"");
384 $this->parent_object->deassignUserFromEmployeeRole(
$_POST[
"obj_id"]);
386 $this->ctrl->redirect($this,
"showStaff");
391 if (!$this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
393 $this->ctrl->redirect($this->parent_gui,
"");
395 $arrObjIdRolId = explode(
"-",
$_POST[
"obj_id-role_id"]);
396 $this->parent_object->deassignUserFromLocalRole($arrObjIdRolId[1], $arrObjIdRolId[0]);
398 $this->ctrl->redirect($this,
"showOtherRoles");
403 $this->tabs_gui->addSubTab(
"show_staff", sprintf($this->lng->txt(
"local_staff"), $this->parent_object->getTitle()), $this->ctrl->getLinkTarget($this,
"showStaff"));
404 if ($this->ilAccess->checkAccess(
"view_learning_progress_rec",
"", $this->parent_object->getRefId())) {
405 $this->tabs_gui->addSubTab(
"show_staff_rec", sprintf($this->lng->txt(
"rec_staff"), $this->parent_object->getTitle()), $this->ctrl->getLinkTarget($this,
"showStaffRec"));
407 if ($this->ilAccess->checkAccess(
"write",
"", $this->parent_object->getRefId())) {
408 $this->tabs_gui->addSubTab(
"show_other_roles", sprintf($this->lng->txt(
"local_other_roles"), $this->parent_object->getTitle()), $this->ctrl->getLinkTarget($this,
"showOtherRoles"));