Skip to content
Snippets Groups Projects
Commit 39e2a1fa authored by srosse's avatar srosse
Browse files

OO-2499: show a message if the user has not enough privileges to edit the...

OO-2499: show a message if the user has not enough privileges to edit the quota and not a red screen
parent 4745bd38
No related branches found
No related tags found
No related merge requests found
......@@ -121,8 +121,9 @@ public class GenericQuotaEditController extends BasicController {
private void initMyContent(UserRequest ureq) {
QuotaManager qm = QuotaManager.getInstance();
if (!qm.hasQuotaEditRights(ureq.getIdentity()))
if (!qm.hasQuotaEditRights(ureq.getIdentity())) {
throw new OLATSecurityException("Insufficient permissions to access QuotaController");
}
myContent = createVelocityContainer("edit");
myContent.contextPut("modalMode", Boolean.valueOf(modalMode));
......@@ -130,7 +131,6 @@ public class GenericQuotaEditController extends BasicController {
delQuotaButton = LinkFactory.createButtonSmall("qf.del", myContent, this);
cancelButton = LinkFactory.createButtonSmall("cancel", myContent, this);
//TODO loop over QuotaManager.getDefaultQuotaIdentifyers instead
myContent.contextPut("users",qm.getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_USERS));
myContent.contextPut("powerusers",qm.getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_POWER));
myContent.contextPut("groups",qm.getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_GROUPS));
......
......@@ -31,7 +31,6 @@ import org.olat.core.gui.components.velocity.VelocityContainer;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.controller.BasicController;
import org.olat.core.logging.OLATSecurityException;
import org.olat.core.util.vfs.Quota;
import org.olat.core.util.vfs.QuotaManager;
......@@ -69,7 +68,7 @@ public class GenericQuotaViewController extends BasicController {
QuotaManager qm = QuotaManager.getInstance();
currentQuota = qm.getCustomQuota(relPath);
// init velocity context
initMyContent(ureq);
initMyContent();
if (currentQuota == null) {
currentQuota = qm.createQuota(relPath, null, null);
} else {
......@@ -78,16 +77,16 @@ public class GenericQuotaViewController extends BasicController {
myContent.contextPut("editQuota", Boolean.FALSE);
putInitialPanel(myContent);
}
public void setNotEnoughPrivilegeMessage() {
myContent.contextPut("notEnoughPrivilege", Boolean.TRUE);
}
private void initMyContent(UserRequest ureq) {
private void initMyContent() {
QuotaManager qm = QuotaManager.getInstance();
if (!qm.hasQuotaEditRights(ureq.getIdentity()))
throw new OLATSecurityException("Insufficient permissions to access QuotaController");
myContent = createVelocityContainer("edit");
myContent.contextPut("notEnoughPrivilege", Boolean.FALSE);
myContent.contextPut("modalMode", Boolean.valueOf(modalMode));
//TODO loop over QuotaManager.getDefaultQuotaIdentifyers instead
myContent.contextPut("users",qm.getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_USERS));
myContent.contextPut("powerusers",qm.getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_POWER));
myContent.contextPut("groups",qm.getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_GROUPS));
......@@ -95,7 +94,6 @@ public class GenericQuotaViewController extends BasicController {
myContent.contextPut("coursefolder",qm.getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_COURSE));
myContent.contextPut("nodefolder",qm.getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_NODES));
myContent.contextPut("feeds",qm.getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_FEEDS));
}
private void initQuotaForm(UserRequest ureq, Quota quota) {
......
......@@ -43,6 +43,7 @@ import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.id.Identity;
import org.olat.core.logging.OLATRuntimeException;
import org.olat.core.logging.OLATSecurityException;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.core.util.resource.OresHelper;
......@@ -400,13 +401,19 @@ public class QuotaManagerImpl extends QuotaManager {
return true;
}
/**
* @see org.olat.core.util.vfs.QuotaManager#getQuotaEditorInstance(org.olat.core.gui.UserRequest, org.olat.core.gui.control.WindowControl, java.lang.String, boolean)
*/
@Override
public Controller getQuotaEditorInstance(UserRequest ureq, WindowControl wControl, String relPath, boolean modalMode) {
return new GenericQuotaEditController(ureq, wControl, relPath, modalMode);
try {
return new GenericQuotaEditController(ureq, wControl, relPath, modalMode);
} catch (OLATSecurityException e) {
log.warn("Try to access the quota editor without enough privilege", e);
GenericQuotaViewController viewCtrl = new GenericQuotaViewController(ureq, wControl, relPath, modalMode);
viewCtrl.setNotEnoughPrivilegeMessage();
return viewCtrl;
}
}
......
#if($editQuota)
<fieldset class="clearfix">
<legend>$r.translate("qf.edit")</legend>
#if($r.isNotNull($notEnoughPrivilege) && $notEnoughPrivilege)
<div class="o_warning">$r.translate("warning.qd.not.enough.privilege")</div>
#end
#if(!$isEmptyQuota)
<div class="o_button_group o_button_group_right">$r.render("qf.del")</div>
#end
......@@ -9,6 +12,9 @@
#else
<fieldset class="clearfix">
<legend>$r.translate("qf.new")</legend>
#if($r.isNotNull($notEnoughPrivilege) && $notEnoughPrivilege)
<div class="o_warning">$r.translate("warning.qd.not.enough.privilege")</div>
#end
#if($r.available("qf.new"))
<div class="o_button_group o_button_group_right">$r.render("qf.new")</div>
#end
......
......@@ -25,3 +25,4 @@ qf.title=Quotaverwaltung
table.header.limit=Upload Limite KB
table.header.path=Pfad
table.header.quota=Quota KB
warning.qd.not.enough.privilege=Sie haben nicht die Berechtigungen Quota zu editieren.
......@@ -25,3 +25,4 @@ qf.title=Quota management
table.header.limit=Upload limit KB
table.header.path=Path
table.header.quota=Quota KB
warning.qd.not.enough.privilege=You don't have the privileges to edit quotas.
......@@ -33,7 +33,6 @@ import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.id.Identity;
import org.olat.core.manager.BasicManager;
/**
* Initial Date: Feb 17, 2004
......@@ -45,7 +44,7 @@ import org.olat.core.manager.BasicManager;
* <br>
* Comment: Refactoring to core package make default quotas generic
*/
public abstract class QuotaManager extends BasicManager{
public abstract class QuotaManager {
protected static QuotaManager INSTANCE;
......@@ -153,7 +152,8 @@ public abstract class QuotaManager extends BasicManager{
/**
* Factory method to create a controller that is capable of editing the
* quota for the given path.
* quota for the given path. If the user has not enough privileges to edit
* the quota, it will only see the quota's view.
* <p>
* The controller must fire the following events:
* <ul>
......
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