Skip to content
Snippets Groups Projects
Commit 2df04c34 authored by srosse's avatar srosse
Browse files

OO-4121: check access right to user in full text search

parent 45446f43
No related branches found
No related tags found
No related merge requests found
...@@ -20,12 +20,18 @@ ...@@ -20,12 +20,18 @@
package org.olat.search.service.indexer.identity; package org.olat.search.service.indexer.identity;
import java.io.IOException; import java.io.IOException;
import java.util.Collections;
import java.util.List; import java.util.List;
import org.olat.basesecurity.BaseSecurity; import org.olat.basesecurity.BaseSecurity;
import org.olat.basesecurity.BaseSecurityManager; import org.olat.basesecurity.BaseSecurityManager;
import org.olat.basesecurity.IdentityPowerSearchQueries;
import org.olat.basesecurity.OrganisationRoles;
import org.olat.basesecurity.SearchIdentityParams;
import org.olat.core.CoreSpringFactory;
import org.olat.core.commons.persistence.DBFactory; import org.olat.core.commons.persistence.DBFactory;
import org.olat.core.id.Identity; import org.olat.core.id.Identity;
import org.olat.core.id.OrganisationRef;
import org.olat.core.id.Roles; import org.olat.core.id.Roles;
import org.olat.core.id.context.BusinessControl; import org.olat.core.id.context.BusinessControl;
import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.ContextEntry;
...@@ -46,11 +52,9 @@ import org.olat.search.service.indexer.OlatFullIndexer; ...@@ -46,11 +52,9 @@ import org.olat.search.service.indexer.OlatFullIndexer;
* @author gnaegi, gnaegi@frentix.com, www.frentix.com * @author gnaegi, gnaegi@frentix.com, www.frentix.com
*/ */
public class IdentityIndexer extends AbstractHierarchicalIndexer { public class IdentityIndexer extends AbstractHierarchicalIndexer {
public final static String TYPE = "type.identity"; public static final String TYPE = "type.identity";
/** @Override
* @see org.olat.search.service.indexer.Indexer#getSupportedTypeName()
*/
public String getSupportedTypeName() { public String getSupportedTypeName() {
return Identity.class.getSimpleName(); return Identity.class.getSimpleName();
} }
...@@ -100,6 +104,14 @@ public class IdentityIndexer extends AbstractHierarchicalIndexer { ...@@ -100,6 +104,14 @@ public class IdentityIndexer extends AbstractHierarchicalIndexer {
if(roles.isGuestOnly()) { if(roles.isGuestOnly()) {
return false; return false;
} }
return true;
Long identityKey = contextEntry.getOLATResourceable().getResourceableId();
List<OrganisationRef> organisations = roles.getOrganisationsWithRoles(OrganisationRoles.valuesWithoutGuestAndInvitee());
SearchIdentityParams params = new SearchIdentityParams(null, null, false, null,
null, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT);
params.setOrganisations(organisations);
params.setIdentityKeys(Collections.singletonList(identityKey));
List<Identity> ids = CoreSpringFactory.getImpl(IdentityPowerSearchQueries.class).getIdentitiesByPowerSearch(params, 0, 1);
return !ids.isEmpty();
} }
} }
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