Details

    • Testing Instructions:
      Hide

      Run the unit tests.
      OR follow the steps :
      0. Setup :
      Create 3 users : u1, u2 and u3
      Create 2 courses : c1 and c2

      Enrol u1 to c1 as teacher.
      Enrol u2 to c1 as student.
      Enrol u2 to c2 as student.
      Enrol u3 to c2 as student.

      1. Login as u1.
      In the globalsearch input box on the header, search for u2 (not username).
      Expectation : record for u2's profile should be displayed in results.

      In the globalsearch input box on the header, search for u3 (not username).
      Expectation : record for u3's profile should NOT be displayed in results.

      Search for 'admin' and 'guest'
      Expectation : records for admin and guest user profiles should not be displayed.

      2. Login as u2

      search for u1 .
      Expectation : record for u1's profile should be displayed in results.

      search for u3 .
      Expectation : record for u3's profile should be displayed in results.

      3. Login as u3

      search for u1 .
      Expectation : record for u1's profile should NOT be displayed in results.

      search for u2 .
      Expectation : record for u2's profile should be displayed in results.

      4. Login as 'Admin'
      Search for any user.
      Expectation : record for the user's profile should be displayed in the search results.

      5. Login as any user, for eg. u1.
      Search for yourself (the logged in user)
      Expectation : record for the user's profile should be displayed in the search results.

      Show
      Run the unit tests. OR follow the steps : 0. Setup : Create 3 users : u1, u2 and u3 Create 2 courses : c1 and c2 Enrol u1 to c1 as teacher. Enrol u2 to c1 as student. Enrol u2 to c2 as student. Enrol u3 to c2 as student. 1. Login as u1. In the globalsearch input box on the header, search for u2 (not username). Expectation : record for u2's profile should be displayed in results. In the globalsearch input box on the header, search for u3 (not username). Expectation : record for u3's profile should NOT be displayed in results. Search for 'admin' and 'guest' Expectation : records for admin and guest user profiles should not be displayed. 2. Login as u2 search for u1 . Expectation : record for u1's profile should be displayed in results. search for u3 . Expectation : record for u3's profile should be displayed in results. 3. Login as u3 search for u1 . Expectation : record for u1's profile should NOT be displayed in results. search for u2 . Expectation : record for u2's profile should be displayed in results. 4. Login as 'Admin' Search for any user. Expectation : record for the user's profile should be displayed in the search results. 5. Login as any user, for eg. u1. Search for yourself (the logged in user) Expectation : record for the user's profile should be displayed in the search results.
    • Affected Branches:
      MOODLE_32_STABLE
    • Fixed Branches:
      MOODLE_32_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-54794_master

      Description

      This issue is about adding users to global search, pinging Devang Gaur as this is part of his GSOC proposal. Feel free to assign the issue to you or let me know if you don't have permissions to do it, I can do it for you.

      Moodle managers can brower and filter users using admin/user.php, any moodle user can search for other users as well using the messaging system or just pointing to its profile URL (user/profile.php?id=XXX) although it may depend on some factors, which I explain below. We want moodle users to search for users through the global search box, once on their profile page (the search result could point to the user's profile) users have links to whatever action they want to perform and we don't need to worry about it.

      Some tips about this implementation.

      Indexed data (https://docs.moodle.org/dev/Search_API#Index_data)

      • Only data visible in the user's profile page should be indexed, we should not index user data that can only be visible for some users (idnumber field may be an example, should be checked) because search queries will be applied to all user indexed data and we can not filter out these results later.
      • To know which users should be indexed we can look at what users are available through user/profile.php. Consider unconfirmed users (confirmed field) suspended users, users without email... as a general rule, whatever is available through user/profile.php should be available through global search.

      Access control (https://docs.moodle.org/dev/Search_API#Access_control)

      • Although it depends on some settings, by default, non-guest users will be able to use this search area so it should work at CONTEXT_SYSTEM (https://docs.moodle.org/dev/Search_API#Automatic_context-based_filtering)
      • user/profile.php can be again the base to look at, we should not only look at the required capabilities but also at site-wide settings ($CFG) like forceloginforprofiles. Take into account that, by default, global search is available for all the site users (depending on $CFG->forcelogin - see search/index.php) Part of this issue's tasks is to investigate this.
      • We are not interested in duplicating logic, if we notice that there is a significant amount of code duplicated between user/profile.php and check_access function or even user/externallib.php web services function (get_users) we should discuss it and see if it is worth adding a new function to user/lib.php

      Unit tests to check that the data is indexed are pretty trivial, you can pick one of the existing tests as a base, but access control unit tests change significantly between search areas, as what we are interested in testing depends on the search area check_access contents. Unit tests should be included as part of this issue.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              devang2511 Devang Gaur
              Reporter:
              dmonllao David Monllaó
              Peer reviewer:
              David Monllaó
              Integrator:
              Dan Poltawski
              Tester:
              Rajesh Taneja
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                5/Dec/16