From d84aec3110a8b3ba77f19457cf3c6e9b3a51929a Mon Sep 17 00:00:00 2001
From: fkiefer <none@none>
Date: Wed, 5 Apr 2017 14:54:24 +0200
Subject: [PATCH] OO-2621 edit rights

---
 .../info/ui/InfoDisplayController.java        | 22 +++++++++----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/main/java/org/olat/commons/info/ui/InfoDisplayController.java b/src/main/java/org/olat/commons/info/ui/InfoDisplayController.java
index 244835969f4..96d2ca32e80 100644
--- a/src/main/java/org/olat/commons/info/ui/InfoDisplayController.java
+++ b/src/main/java/org/olat/commons/info/ui/InfoDisplayController.java
@@ -124,7 +124,7 @@ public class InfoDisplayController extends FormBasicController {
 		initForm(ureq);	
 		
 		// now load with configuration
-		loadMessages();		
+		loadMessages(ureq);		
 	}
 	
 	public InfoDisplayController(UserRequest ureq, WindowControl wControl, ModuleConfiguration config,
@@ -166,7 +166,7 @@ public class InfoDisplayController extends FormBasicController {
 		}
 		
 		// now load with configuration
-		loadMessages();
+		loadMessages(ureq);
 	}
 	
 	private int getConfigValue(ModuleConfiguration config, String key, int def) {
@@ -201,7 +201,7 @@ public class InfoDisplayController extends FormBasicController {
 	 * This is the main method which push the messages in the layout container,
 	 * and clean-up old links.
 	 */
-	protected void loadMessages() {
+	protected void loadMessages(UserRequest ureq) {
 		//first clear the current message if any
 		for(Long key:previousDisplayKeys) {
 			flc.contextRemove("info.date." + key);
@@ -225,7 +225,7 @@ public class InfoDisplayController extends FormBasicController {
 			DateElement dateEl = DateComponentFactory.createDateElementWithYear(dateCmpName, info.getCreationDate());
 			flc.add(dateCmpName, dateEl);
 			
-			if(secCallback.canEdit()) {
+			if(secCallback.canEdit() && (ureq.getIdentity().equals(info.getAuthor()) || secCallback.canDelete())) {
 				String editName = "info.edit." + info.getKey();
 				FormLink link = uifactory.addFormLink(editName, "edit", "edit", flc, Link.BUTTON_SMALL);
 				link.setElementCssClass("o_sel_info_edit_msg");
@@ -313,7 +313,7 @@ public class InfoDisplayController extends FormBasicController {
 				getWindowControl().pop();
 			} else if (event == Event.CHANGED_EVENT) {
 				getWindowControl().pop();
-				loadMessages();
+				loadMessages(ureq);
 				flc.setDirty(true);//update the view
 			}	else if (event == Event.DONE_EVENT){
 				showError("failed");
@@ -326,7 +326,7 @@ public class InfoDisplayController extends FormBasicController {
 						LoggingResourceable.wrap(msgToDelete.getOLATResourceable(), OlatResourceableType.infoMessage));
 				
 				infoMessageManager.deleteInfoMessage(msgToDelete);
-				loadMessages();
+				loadMessages(ureq);
 			}
 			confirmDelete.setUserObject(null);
 			
@@ -335,7 +335,7 @@ public class InfoDisplayController extends FormBasicController {
 			lockEntry = null;
 		} else if (source == editController) {
 			if(event == Event.DONE_EVENT) {
-				loadMessages();
+				loadMessages(ureq);
 			}
 			editDialogBox.deactivate();
 			removeAsListenerAndDispose(editController);
@@ -371,11 +371,11 @@ public class InfoDisplayController extends FormBasicController {
 		} else if(source == oldMsgsLink) {
 			maxResults = -1;
 			after = null;
-			loadMessages();
+			loadMessages(ureq);
 		}  else if(source == newMsgsLink) {
 			maxResults = maxResultsConfig;
 			after = afterConfig;
-			loadMessages();
+			loadMessages(ureq);
 		} else {
 			super.formInnerEvent(ureq, source, event);
 		}
@@ -391,7 +391,7 @@ public class InfoDisplayController extends FormBasicController {
 				showWarning("already.deleted");
 				CoordinatorManager.getInstance().getCoordinator().getLocker().releaseLock(lockEntry);
 				lockEntry = null;
-				loadMessages();
+				loadMessages(ureq);
 			} else {
 				String title = StringHelper.escapeHtml(msg.getTitle());
 				String confirmDeleteText = translate("edit.confirm_delete", new String[]{ title });
@@ -414,7 +414,7 @@ public class InfoDisplayController extends FormBasicController {
 				showWarning("already.deleted");
 				CoordinatorManager.getInstance().getCoordinator().getLocker().releaseLock(lockEntry);
 				lockEntry = null;
-				loadMessages();
+				loadMessages(ureq);
 			} else {
 				removeAsListenerAndDispose(editController);
 				removeAsListenerAndDispose(editDialogBox);
-- 
GitLab