/** * import users */ function importUsersObject() { global $rbacreview, $ilUser; // Blind out tabs for local user import if ($_GET["baseClass"] == 'ilRepositoryGUI') { $this->tabs_gui->clearTargets(); } include_once './Services/AccessControl/classes/class.ilObjRole.php'; include_once './Services/User/classes/class.ilUserImportParser.php'; global $rbacreview, $rbacsystem, $tree, $lng; switch ($_POST["conflict_handling_choice"]) { case "update_on_conflict": $rule = IL_UPDATE_ON_CONFLICT; break; case "ignore_on_conflict": default: $rule = IL_IGNORE_ON_CONFLICT; break; } $importParser = new ilUserImportParser($_POST["xml_file"], IL_USER_IMPORT, $rule); $importParser->setFolderId($this->getUserOwnerId()); $import_dir = $this->getImportDir(); // Catch hack attempts // We check here again, if the role folders are in the tree, and if the // user has permission on the roles. if ($_POST["role_assign"]) { $global_roles = $rbacreview->getGlobalRoles(); $roles_of_user = $rbacreview->assignedRoles($ilUser->getId()); foreach ($_POST["role_assign"] as $role_id) { if ($role_id != "") { if (in_array($role_id, $global_roles)) { if (!in_array(SYSTEM_ROLE_ID, $roles_of_user)) { if ($role_id == SYSTEM_ROLE_ID && !in_array(SYSTEM_ROLE_ID, $roles_of_user) || $this->object->getRefId() != USER_FOLDER_ID && !ilObjRole::_getAssignUsersStatus($role_id)) { ilUtil::delDir($import_dir); $this->ilias->raiseError($this->lng->txt("usrimport_with_specified_role_not_permitted"), $this->ilias->error_obj->MESSAGE); } } } else { $rolf = $rbacreview->getFoldersAssignedToRole($role_id, true); if ($rbacreview->isDeleted($rolf[0]) || !$rbacsystem->checkAccess('write', $tree->getParentId($rolf[0]))) { ilUtil::delDir($import_dir); $this->ilias->raiseError($this->lng->txt("usrimport_with_specified_role_not_permitted"), $this->ilias->error_obj->MESSAGE); return; } } } } } $importParser->setRoleAssignment($_POST["role_assign"]); $importParser->startParsing(); // purge user import directory ilUtil::delDir($import_dir); switch ($importParser->getErrorLevel()) { case IL_IMPORT_SUCCESS: ilUtil::sendSuccess($this->lng->txt("user_imported"), true); break; case IL_IMPORT_WARNING: ilUtil::sendInfo($this->lng->txt("user_imported_with_warnings") . $importParser->getProtocolAsHTML($lng->txt("import_warning_log")), true); break; case IL_IMPORT_FAILURE: $this->ilias->raiseError($this->lng->txt("user_import_failed") . $importParser->getProtocolAsHTML($lng->txt("import_failure_log")), $this->ilias->error_obj->MESSAGE); break; } if (strtolower($_GET["baseClass"]) == "iladministrationgui") { $this->ctrl->redirect($this, "view"); //ilUtil::redirect($this->ctrl->getLinkTarget($this)); } else { $this->ctrl->redirectByClass('ilobjcategorygui', 'listUsers'); } }