mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-05 07:03:24 +01:00
Minor permissions modification.
This commit is contained in:
parent
2e2e978c43
commit
a263a05520
@ -44,6 +44,8 @@ public class MindmapServiceImpl
|
|||||||
@Autowired
|
@Autowired
|
||||||
private NotificationService notificationService;
|
private NotificationService notificationService;
|
||||||
|
|
||||||
|
private String adminUser;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermissions(@Nullable User user, int mapId, @NotNull CollaborationRole grantedRole) {
|
public boolean hasPermissions(@Nullable User user, int mapId, @NotNull CollaborationRole grantedRole) {
|
||||||
final Mindmap map = mindmapManager.getMindmapById(mapId);
|
final Mindmap map = mindmapManager.getMindmapById(mapId);
|
||||||
@ -54,7 +56,7 @@ public class MindmapServiceImpl
|
|||||||
public boolean hasPermissions(@Nullable User user, @Nullable Mindmap map, @NotNull CollaborationRole role) {
|
public boolean hasPermissions(@Nullable User user, @Nullable Mindmap map, @NotNull CollaborationRole role) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
if (map.isPublic() && role == CollaborationRole.VIEWER) {
|
if ((map.isPublic() && role == CollaborationRole.VIEWER) || (isAdmin(user) && role == CollaborationRole.VIEWER)) {
|
||||||
result = true;
|
result = true;
|
||||||
} else if (user != null) {
|
} else if (user != null) {
|
||||||
final Collaboration collaboration = map.findCollaboration(user);
|
final Collaboration collaboration = map.findCollaboration(user);
|
||||||
@ -67,6 +69,10 @@ public class MindmapServiceImpl
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isAdmin(User user) {
|
||||||
|
return (user != null && user.getEmail().equals(adminUser));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mindmap getMindmapByTitle(String title, User user) {
|
public Mindmap getMindmapByTitle(String title, User user) {
|
||||||
return mindmapManager.getMindmapByTitle(title, user);
|
return mindmapManager.getMindmapByTitle(title, user);
|
||||||
@ -219,7 +225,6 @@ public class MindmapServiceImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MindMapHistory> findMindmapHistory(int mindmapId) {
|
public List<MindMapHistory> findMindmapHistory(int mindmapId) {
|
||||||
return mindmapManager.getHistoryFrom(mindmapId);
|
return mindmapManager.getHistoryFrom(mindmapId);
|
||||||
@ -282,4 +287,12 @@ public class MindmapServiceImpl
|
|||||||
public void setNotificationService(NotificationService notificationService) {
|
public void setNotificationService(NotificationService notificationService) {
|
||||||
this.notificationService = notificationService;
|
this.notificationService = notificationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAdminUser(String adminUser) {
|
||||||
|
this.adminUser = adminUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAdminUser() {
|
||||||
|
return adminUser;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
<property name="mindmapManager" ref="mindmapManager"/>
|
<property name="mindmapManager" ref="mindmapManager"/>
|
||||||
<property name="userService" ref="userService"/>
|
<property name="userService" ref="userService"/>
|
||||||
<property name="notificationService" ref="notificationService"/>
|
<property name="notificationService" ref="notificationService"/>
|
||||||
|
<property name="adminUser" ref="${admin.user}/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="mindmapService"
|
<bean id="mindmapService"
|
||||||
|
Loading…
Reference in New Issue
Block a user