solr global search capability question

solr global search capability question

by Yuval Jacobi -
Number of replies: 0

Hi,

We are currently deploying moodle global search using SOLR.

We have allocated the  moodle/search:query  capability to system roles  (e.g. admin, manager) and the search works well. Users with those roles can search and see the results.


Now we want teacher and student roles to will be able to search as well, so we've made the same capability allocation, giving those roles the moodle/search:query capability.

however they get an error saying something like "You have no permissions to perform Perform site-wide searches".

looking at /search/index.php code, I see that require_capability is called with the system context.

$context = context_system::instance();
require_capability('moodle/search:query', $context);

To overcome this, we made a small hack in  /search/index.php to calculate the relevant course context they came from and require the capability by the  course context. This works just fine, so now users with  the Teacher/Student role can search and get their relevant results.

The question is 
Is there another way  (other to the described code hack) to enable non-system roles to perform global search?
Or in other words:  How does Moodle expects that the Teacher and Student roles will perform search if they are not defined as system-roles?

We are probably missing something about allocating moodle/search:query for non-system roles,  so if anyone have had such an experience and  can clarify the best practice for working this out. 

Average of ratings: -