diff --git a/distro/changelog.xml b/distro/changelog.xml
index f554e1d..9dfa656 100644
--- a/distro/changelog.xml
+++ b/distro/changelog.xml
@@ -10,6 +10,7 @@
Several improvements in url checkings
resolved problem with AdBlock plugin
Fixed mention user dialog y-position when textbox is higher than usual due to new lines
+ Mention users list now returns only the list of the available users in the current organization
diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java b/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java
index ce310a4..6aac916 100644
--- a/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java
+++ b/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java
@@ -568,13 +568,37 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
@Override
public ArrayList getPortalUsers() {
+ ASLSession session = getASLSession();
+ return getOrganizationUsers(session.getScope(), session.getUsername(), withinPortal);
+ }
+
+ /**
+ *
+ * @param session the Asl Session
+ * @param withinPortal true when is on Liferay portal
+ * @return the users belonging to the current organization (scope)
+ */
+ public static ArrayList getOrganizationUsers(String scope, String currUser, boolean withinPortal) {
ArrayList portalUsers = new ArrayList();
- String currUser = getASLSession().getUsername();
try {
if (withinPortal) {
UserManager um = new LiferayUserManager();
GroupManager gm = new LiferayGroupManager();
- List users = um.listUsersByGroup(gm.getRootVO().getGroupId());
+ ScopeBean sb = new ScopeBean(scope);
+ List users = null;
+
+ if (sb.is(Type.INFRASTRUCTURE))
+ users = um.listUsersByGroup(gm.getRootVO().getGroupId());
+ else if (sb.is(Type.VRE)) { //must be in VRE
+ //get the name from the scope
+ String orgName = scope.substring(scope.lastIndexOf("/")+1, scope.length());
+ //ask the users
+ users = um.listUsersByGroup(gm.getGroupId(orgName));
+ }
+ else {
+ _log.error("Error, you must be in SCOPE VRE OR INFRASTURCTURE, you are in VO SCOPE returning no users");
+ return portalUsers;
+ }
for (UserModel user : users) {
if (user.getScreenName().compareTo("test.user") != 0 && user.getScreenName().compareTo(currUser) != 0) { //skip test.user & current user
String thumbnailURL = "";