Skip to content
Snippets Groups Projects
Commit 029b9e07 authored by srosse's avatar srosse
Browse files

OO-3101: authorized feature appears in Excel archive and export (tool in the lectures list)

parent a287f505
No related branches found
No related tags found
No related merge requests found
...@@ -21,6 +21,7 @@ package org.olat.modules.lecture.ui; ...@@ -21,6 +21,7 @@ package org.olat.modules.lecture.ui;
import java.util.List; import java.util.List;
import org.olat.basesecurity.BaseSecurityModule;
import org.olat.core.gui.UserRequest; import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.Component; import org.olat.core.gui.components.Component;
import org.olat.core.gui.components.link.Link; import org.olat.core.gui.components.link.Link;
...@@ -38,6 +39,7 @@ import org.olat.core.gui.control.WindowControl; ...@@ -38,6 +39,7 @@ import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.controller.BasicController; import org.olat.core.gui.control.controller.BasicController;
import org.olat.core.gui.control.generic.dtabs.Activateable2; import org.olat.core.gui.control.generic.dtabs.Activateable2;
import org.olat.core.id.OLATResourceable; import org.olat.core.id.OLATResourceable;
import org.olat.core.id.Roles;
import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.ContextEntry;
import org.olat.core.id.context.StateEntry; import org.olat.core.id.context.StateEntry;
import org.olat.core.util.resource.OresHelper; import org.olat.core.util.resource.OresHelper;
...@@ -69,11 +71,15 @@ public class LectureRepositoryAdminController extends BasicController implements ...@@ -69,11 +71,15 @@ public class LectureRepositoryAdminController extends BasicController implements
private RepositoryEntry entry; private RepositoryEntry entry;
private boolean configurationChanges = false; private boolean configurationChanges = false;
private final boolean isAdministrativeUser;
private final boolean authorizedAbsenceEnabled;
@Autowired @Autowired
private LectureModule lectureModule; private LectureModule lectureModule;
@Autowired @Autowired
private LectureService lectureService; private LectureService lectureService;
@Autowired
private BaseSecurityModule securityModule;
public LectureRepositoryAdminController(UserRequest ureq, WindowControl wControl, TooledStackedPanel stackPanel, public LectureRepositoryAdminController(UserRequest ureq, WindowControl wControl, TooledStackedPanel stackPanel,
RepositoryEntry entry) { RepositoryEntry entry) {
...@@ -81,6 +87,10 @@ public class LectureRepositoryAdminController extends BasicController implements ...@@ -81,6 +87,10 @@ public class LectureRepositoryAdminController extends BasicController implements
this.entry = entry; this.entry = entry;
this.stackPanel = stackPanel; this.stackPanel = stackPanel;
Roles roles = ureq.getUserSession().getRoles();
isAdministrativeUser = securityModule.isUserAllowedAdminProps(roles);
authorizedAbsenceEnabled = lectureModule.isAuthorizedAbsenceEnabled();
mainVC = createVelocityContainer("admin_repository"); mainVC = createVelocityContainer("admin_repository");
segmentView = SegmentViewFactory.createSegmentView("segments", mainVC, this); segmentView = SegmentViewFactory.createSegmentView("segments", mainVC, this);
...@@ -227,7 +237,8 @@ public class LectureRepositoryAdminController extends BasicController implements ...@@ -227,7 +237,8 @@ public class LectureRepositoryAdminController extends BasicController implements
} }
private void doExportArchive(UserRequest ureq) { private void doExportArchive(UserRequest ureq) {
LecturesBlocksEntryExport archive = new LecturesBlocksEntryExport(entry, getTranslator());
LecturesBlocksEntryExport archive = new LecturesBlocksEntryExport(entry, isAdministrativeUser, authorizedAbsenceEnabled, getTranslator());
ureq.getDispatchResult().setResultingMediaResource(archive); ureq.getDispatchResult().setResultingMediaResource(archive);
} }
......
...@@ -26,6 +26,7 @@ import javax.xml.transform.TransformerException; ...@@ -26,6 +26,7 @@ import javax.xml.transform.TransformerException;
import org.apache.pdfbox.exceptions.COSVisitorException; import org.apache.pdfbox.exceptions.COSVisitorException;
import org.olat.NewControllerFactory; import org.olat.NewControllerFactory;
import org.olat.basesecurity.BaseSecurityModule;
import org.olat.core.commons.persistence.SortKey; import org.olat.core.commons.persistence.SortKey;
import org.olat.core.gui.UserRequest; import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.Component; import org.olat.core.gui.components.Component;
...@@ -57,6 +58,7 @@ import org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowC ...@@ -57,6 +58,7 @@ import org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowC
import org.olat.core.gui.control.generic.dtabs.Activateable2; import org.olat.core.gui.control.generic.dtabs.Activateable2;
import org.olat.core.id.Identity; import org.olat.core.id.Identity;
import org.olat.core.id.OLATResourceable; import org.olat.core.id.OLATResourceable;
import org.olat.core.id.Roles;
import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.ContextEntry;
import org.olat.core.id.context.StateEntry; import org.olat.core.id.context.StateEntry;
import org.olat.core.util.resource.OresHelper; import org.olat.core.util.resource.OresHelper;
...@@ -99,12 +101,17 @@ public class TeacherLecturesTableController extends FormBasicController implemen ...@@ -99,12 +101,17 @@ public class TeacherLecturesTableController extends FormBasicController implemen
private final String emptyI18nKey; private final String emptyI18nKey;
private final boolean withRepositoryEntry, withTeachers; private final boolean withRepositoryEntry, withTeachers;
private final boolean isAdministrativeUser;
private final boolean authorizedAbsenceEnabled;
@Autowired @Autowired
private UserManager userManager; private UserManager userManager;
@Autowired @Autowired
private LectureModule lectureModule; private LectureModule lectureModule;
@Autowired @Autowired
private LectureService lectureService; private LectureService lectureService;
@Autowired
private BaseSecurityModule securityModule;
public TeacherLecturesTableController(UserRequest ureq, WindowControl wControl, public TeacherLecturesTableController(UserRequest ureq, WindowControl wControl,
boolean admin, String emptyI18nKey, boolean sortAsc, String id, boolean admin, String emptyI18nKey, boolean sortAsc, String id,
...@@ -116,6 +123,10 @@ public class TeacherLecturesTableController extends FormBasicController implemen ...@@ -116,6 +123,10 @@ public class TeacherLecturesTableController extends FormBasicController implemen
this.emptyI18nKey = emptyI18nKey; this.emptyI18nKey = emptyI18nKey;
this.withTeachers = withTeachers; this.withTeachers = withTeachers;
this.withRepositoryEntry = withRepositoryEntry; this.withRepositoryEntry = withRepositoryEntry;
Roles roles = ureq.getUserSession().getRoles();
isAdministrativeUser = securityModule.isUserAllowedAdminProps(roles);
authorizedAbsenceEnabled = lectureModule.isAuthorizedAbsenceEnabled();
initForm(ureq); initForm(ureq);
} }
...@@ -278,7 +289,7 @@ public class TeacherLecturesTableController extends FormBasicController implemen ...@@ -278,7 +289,7 @@ public class TeacherLecturesTableController extends FormBasicController implemen
private void doExportLectureBlock(UserRequest ureq, LectureBlock row) { private void doExportLectureBlock(UserRequest ureq, LectureBlock row) {
LectureBlock lectureBlock = lectureService.getLectureBlock(row); LectureBlock lectureBlock = lectureService.getLectureBlock(row);
List<Identity> teachers = lectureService.getTeachers(lectureBlock); List<Identity> teachers = lectureService.getTeachers(lectureBlock);
LectureBlockExport export = new LectureBlockExport(lectureBlock, teachers, true, getTranslator()); LectureBlockExport export = new LectureBlockExport(lectureBlock, teachers, isAdministrativeUser, authorizedAbsenceEnabled, getTranslator());
ureq.getDispatchResult().setResultingMediaResource(export); ureq.getDispatchResult().setResultingMediaResource(export);
} }
......
...@@ -59,19 +59,19 @@ public class LectureBlockExport extends OpenXMLWorkbookResource { ...@@ -59,19 +59,19 @@ public class LectureBlockExport extends OpenXMLWorkbookResource {
private final LectureService lectureService; private final LectureService lectureService;
private final List<Identity> teachers; private final List<Identity> teachers;
private final boolean authorizedAbsence; private final boolean authorizedAbsenceEnabled;
private final boolean isAdministrativeUser; private final boolean isAdministrativeUser;
private List<UserPropertyHandler> userPropertyHandlers; private List<UserPropertyHandler> userPropertyHandlers;
private final UserManager userManager; private final UserManager userManager;
public LectureBlockExport(LectureBlock lectureBlock, List<Identity> teachers, boolean isAdministrativeUser, Translator translator) { public LectureBlockExport(LectureBlock lectureBlock, List<Identity> teachers, boolean isAdministrativeUser, boolean authorizedAbsenceEnabled, Translator translator) {
super(label(lectureBlock)); super(label(lectureBlock));
this.teachers = teachers; this.teachers = teachers;
this.lectureBlock = lectureBlock; this.lectureBlock = lectureBlock;
lectureService = CoreSpringFactory.getImpl(LectureService.class); lectureService = CoreSpringFactory.getImpl(LectureService.class);
this.isAdministrativeUser = isAdministrativeUser; this.isAdministrativeUser = isAdministrativeUser;
this.authorizedAbsence = true; this.authorizedAbsenceEnabled = authorizedAbsenceEnabled;
userManager = CoreSpringFactory.getImpl(UserManager.class); userManager = CoreSpringFactory.getImpl(UserManager.class);
userPropertyHandlers = userManager.getUserPropertyHandlersFor(ParticipantListRepositoryController.USER_PROPS_ID, isAdministrativeUser); userPropertyHandlers = userManager.getUserPropertyHandlersFor(ParticipantListRepositoryController.USER_PROPS_ID, isAdministrativeUser);
this.translator = userManager.getPropertyHandlerTranslator(translator); this.translator = userManager.getPropertyHandlerTranslator(translator);
...@@ -188,7 +188,7 @@ public class LectureBlockExport extends OpenXMLWorkbookResource { ...@@ -188,7 +188,7 @@ public class LectureBlockExport extends OpenXMLWorkbookResource {
headerRow.addCell(pos++, Integer.toString(i + 1)); headerRow.addCell(pos++, Integer.toString(i + 1));
} }
if(authorizedAbsence) { if(authorizedAbsenceEnabled) {
//authorized absence //authorized absence
headerRow.addCell(pos++, translator.translate("table.header.authorized.absence")); headerRow.addCell(pos++, translator.translate("table.header.authorized.absence"));
//authorized absence reason //authorized absence reason
...@@ -227,7 +227,7 @@ public class LectureBlockExport extends OpenXMLWorkbookResource { ...@@ -227,7 +227,7 @@ public class LectureBlockExport extends OpenXMLWorkbookResource {
row.addCell(pos++, val); row.addCell(pos++, val);
} }
if(authorizedAbsence && rollCall.getAbsenceAuthorized() != null if(authorizedAbsenceEnabled && rollCall.getAbsenceAuthorized() != null
&& rollCall.getAbsenceAuthorized().booleanValue()) { && rollCall.getAbsenceAuthorized().booleanValue()) {
row.addCell(pos++, "x"); row.addCell(pos++, "x");
row.addCell(pos++, rollCall.getAbsenceReason()); row.addCell(pos++, rollCall.getAbsenceReason());
......
...@@ -59,14 +59,19 @@ public class LecturesBlocksEntryExport extends OpenXMLWorkbookResource { ...@@ -59,14 +59,19 @@ public class LecturesBlocksEntryExport extends OpenXMLWorkbookResource {
private final RepositoryEntry entry; private final RepositoryEntry entry;
private final Translator translator; private final Translator translator;
private List<LectureBlockWithTeachers> blocks; private List<LectureBlockWithTeachers> blocks;
private final boolean authorizedAbsenceEnabled;
private final boolean isAdministrativeUser;
private final UserManager userManager; private final UserManager userManager;
private final LectureService lectureService; private final LectureService lectureService;
public LecturesBlocksEntryExport(RepositoryEntry entry, Translator translator) { public LecturesBlocksEntryExport(RepositoryEntry entry, boolean isAdministrativeUser, boolean authorizedAbsenceEnabled, Translator translator) {
super(label(entry)); super(label(entry));
this.entry = entry; this.entry = entry;
this.translator = translator; this.translator = translator;
this.isAdministrativeUser = isAdministrativeUser;
this.authorizedAbsenceEnabled = authorizedAbsenceEnabled;
userManager = CoreSpringFactory.getImpl(UserManager.class); userManager = CoreSpringFactory.getImpl(UserManager.class);
lectureService = CoreSpringFactory.getImpl(LectureService.class); lectureService = CoreSpringFactory.getImpl(LectureService.class);
formatter = Formatter.getInstance(translator.getLocale()); formatter = Formatter.getInstance(translator.getLocale());
...@@ -92,7 +97,8 @@ public class LecturesBlocksEntryExport extends OpenXMLWorkbookResource { ...@@ -92,7 +97,8 @@ public class LecturesBlocksEntryExport extends OpenXMLWorkbookResource {
for(LectureBlockWithTeachers block:blocks) { for(LectureBlockWithTeachers block:blocks) {
OpenXMLWorksheet exportBlockSheet = workbook.nextWorksheet(); OpenXMLWorksheet exportBlockSheet = workbook.nextWorksheet();
LectureBlockExport lectureBlockExport = new LectureBlockExport(block.getLectureBlock(), block.getTeachers(), true, translator); LectureBlockExport lectureBlockExport = new LectureBlockExport(block.getLectureBlock(), block.getTeachers(),
isAdministrativeUser, authorizedAbsenceEnabled, translator);
lectureBlockExport.generate(exportBlockSheet); lectureBlockExport.generate(exportBlockSheet);
} }
} catch (IOException e) { } catch (IOException e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment