Skip to content
Snippets Groups Projects
Commit a875c925 authored by aboeckle's avatar aboeckle
Browse files

OO-4402: Overlapping booking methods warning

parent 8eacd70d
No related branches found
No related tags found
No related merge requests found
...@@ -211,6 +211,7 @@ public class AccessConfigurationController extends FormBasicController { ...@@ -211,6 +211,7 @@ public class AccessConfigurationController extends FormBasicController {
OfferAccess newLink = editMethodCtrl.commitChanges(); OfferAccess newLink = editMethodCtrl.commitChanges();
newLink = acService.saveOfferAccess(newLink); newLink = acService.saveOfferAccess(newLink);
replace(newLink); replace(newLink);
checkOverlap();
fireEvent(ureq, Event.CHANGED_EVENT); fireEvent(ureq, Event.CHANGED_EVENT);
} }
cmc.deactivate(); cmc.deactivate();
...@@ -242,6 +243,7 @@ public class AccessConfigurationController extends FormBasicController { ...@@ -242,6 +243,7 @@ public class AccessConfigurationController extends FormBasicController {
if("delete".equals(cmd)) { if("delete".equals(cmd)) {
AccessInfo infos = (AccessInfo)source.getUserObject(); AccessInfo infos = (AccessInfo)source.getUserObject();
removeMethod(infos); removeMethod(infos);
checkOverlap();
fireEvent(ureq, Event.CHANGED_EVENT); fireEvent(ureq, Event.CHANGED_EVENT);
} else if("edit".equals(cmd)) { } else if("edit".equals(cmd)) {
AccessInfo infos = (AccessInfo)source.getUserObject(); AccessInfo infos = (AccessInfo)source.getUserObject();
...@@ -302,6 +304,7 @@ public class AccessConfigurationController extends FormBasicController { ...@@ -302,6 +304,7 @@ public class AccessConfigurationController extends FormBasicController {
} }
updateConfirmationEmail(); updateConfirmationEmail();
checkOverlap();
} }
private void updateConfirmationEmail() { private void updateConfirmationEmail() {
...@@ -397,6 +400,34 @@ public class AccessConfigurationController extends FormBasicController { ...@@ -397,6 +400,34 @@ public class AccessConfigurationController extends FormBasicController {
dbInstance.commit(); dbInstance.commit();
loadConfigurations(); loadConfigurations();
} }
private void checkOverlap() {
boolean overlap = false;
for (AccessInfo confControllerA : confControllers) {
for (AccessInfo confControllerB : confControllers) {
// Dont compare a confController with itself
if (!confControllerA.equals(confControllerB)) {
Date aFrom = confControllerA.getLink().getValidFrom();
Date aTo = confControllerA.getLink().getValidTo();
Date bFrom = confControllerB.getLink().getValidFrom();
Date bTo = confControllerB.getLink().getValidTo();
// Options: Dates cross each other or on date range is within another
if ((aFrom.compareTo(bFrom) <= 0 &&
aTo.compareTo(bTo) <= 0 &&
bFrom.compareTo(aTo) <= 0) ||
(aFrom.compareTo(bFrom) <= 0) &&
bTo.compareTo(aTo) <= 0 &&
bTo.compareTo(aFrom) >= 0) {
overlap = true;
}
}
}
}
confControllerContainer.contextPut("overlappingConfigs", overlap);
confControllerContainer.setDirty(true);
}
public class AccessInfo { public class AccessInfo {
private String name; private String name;
......
#if($overlappingConfigs)
<div class="o_important"><i class="o_icon o_icon_important"> </i> $r.translate("accesscontrol.overlap.found")</div>
#end
#if ($confControllers && $confControllers.size() > 0) #if ($confControllers && $confControllers.size() > 0)
#foreach($confController in $confControllers) #foreach($confController in $confControllers)
#set($css = $confController.getLink().getMethod().getMethodCssClass()) #set($css = $confController.getLink().getMethod().getMethodCssClass())
......
...@@ -23,6 +23,7 @@ accesscontrol.desc=Sie k\u00F6nnen die Buchungsmethoden f\u00FCr den Zugang zu d ...@@ -23,6 +23,7 @@ accesscontrol.desc=Sie k\u00F6nnen die Buchungsmethoden f\u00FCr den Zugang zu d
accesscontrol.desc.end=W\u00E4hlen Sie die Schaltfl\u00E4che "$\:add.accesscontrol" um aus der Liste der verf\u00FCgbaren Buchungsmethoden eine oder mehrere auszuw\u00E4hlen. Optional k\u00F6nnen Buchungsmethoden mit einem G\u00FCltigkeitsdatum versehen werden. accesscontrol.desc.end=W\u00E4hlen Sie die Schaltfl\u00E4che "$\:add.accesscontrol" um aus der Liste der verf\u00FCgbaren Buchungsmethoden eine oder mehrere auszuw\u00E4hlen. Optional k\u00F6nnen Buchungsmethoden mit einem G\u00FCltigkeitsdatum versehen werden.
accesscontrol.no.methods.full.access=Es ist noch keine Buchungsmethode konfiguriert.<br />Der Zugang zu dieser Ressource steht allen Systembenutzern ohne Buchung offen. W\u00E4hlen Sie die Schaltfl\u00E4che "$\:add.accesscontrol" um den Zugang einzuschr\u00E4nken und/oder eine Buchung zu erzwingen. accesscontrol.no.methods.full.access=Es ist noch keine Buchungsmethode konfiguriert.<br />Der Zugang zu dieser Ressource steht allen Systembenutzern ohne Buchung offen. W\u00E4hlen Sie die Schaltfl\u00E4che "$\:add.accesscontrol" um den Zugang einzuschr\u00E4nken und/oder eine Buchung zu erzwingen.
accesscontrol.no.methods.no.access=Es ist noch keine Buchungsmethode konfiguriert.<br />Diese Ressource kann nur von den Teilnehmer der Ressource verwendet werden. W\u00E4hlen Sie die Schaltfl\u00E4che "$\:add.accesscontrol" um eine Buchungsmethode zu w\u00E4hlen und die Ressource zu ver\u00F6ffentlichen. accesscontrol.no.methods.no.access=Es ist noch keine Buchungsmethode konfiguriert.<br />Diese Ressource kann nur von den Teilnehmer der Ressource verwendet werden. W\u00E4hlen Sie die Schaltfl\u00E4che "$\:add.accesscontrol" um eine Buchungsmethode zu w\u00E4hlen und die Ressource zu ver\u00F6ffentlichen.
accesscontrol.overlap.found=Es wurden \u00FCberlappende Buchungsmethoden gefunden. Bitte stellen Sie sicher, dass dies beabsichtig und korrekt ist.
accesscontrol.table.from=g\u00FCltig von accesscontrol.table.from=g\u00FCltig von
accesscontrol.table.method=Buchungsmethode accesscontrol.table.method=Buchungsmethode
accesscontrol.table.to=bis accesscontrol.table.to=bis
......
...@@ -23,6 +23,7 @@ accesscontrol.desc=You can configure booking methods for accessing this resource ...@@ -23,6 +23,7 @@ accesscontrol.desc=You can configure booking methods for accessing this resource
accesscontrol.desc.end=Select the button "$\:add.accesscontrol" to select one or more booking methods. As an option you can also define the period in which each booking method is valid. accesscontrol.desc.end=Select the button "$\:add.accesscontrol" to select one or more booking methods. As an option you can also define the period in which each booking method is valid.
accesscontrol.no.methods.full.access=There is no booking method configured to restrict access. This resource can be accessed by all known users without an explicit booking. Select the button "$\:add.accesscontrol" to restrict access and/or to require an explicit booking. accesscontrol.no.methods.full.access=There is no booking method configured to restrict access. This resource can be accessed by all known users without an explicit booking. Select the button "$\:add.accesscontrol" to restrict access and/or to require an explicit booking.
accesscontrol.no.methods.no.access=There is no booking method configured. This resource can only be accessed by explicit members of this resource. Select the button "$\:add.accesscontrol" to add a booking method and to publish the resource. accesscontrol.no.methods.no.access=There is no booking method configured. This resource can only be accessed by explicit members of this resource. Select the button "$\:add.accesscontrol" to add a booking method and to publish the resource.
accesscontrol.overlap.found=There are overlapping booking methods. Please make sure this is intended and correct.
accesscontrol.table.from=valid from accesscontrol.table.from=valid from
accesscontrol.table.method=Booking method accesscontrol.table.method=Booking method
accesscontrol.table.to=to accesscontrol.table.to=to
......
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