Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-64323

GDPR: New request form user search - not using configured fields

XMLWordPrintable

    • MOODLE_35_STABLE
    • MOODLE_37_STABLE
    • Hide

      Precondition:
      1. Define a new role "DPO" with "tool/dataprivacy:managedatarequests" capability and set up for this role as DPO for data privacy tool.
      2. Create four users with following informations: 

      username  firstname lastname email idnumber roles
      student1 Student One email_student1@domain.com first_student Authenticated
      student2 Student Two email_student2@domain.com first_student Authenticated
      student3 Student Three email_student3@domain.com first_student Authenticated

      3. Check to ensure user "dpo" has capability "moodle/site:viewuseridentity".
      4. Navigate to "Site administration / Users / Permissions / User policies" and check only "ID number" in "Show user identity" field.
       
      TC1: Check DPO can search for student by first name, last name
      1. Login as DPO1.
      2. Navigate to "Create a new data request" page (admin/tool/dataprivacy/createdatarequest.php?manage=1)
      (Begin search for first name)
      3. Search for word "Student".
      4. Check the drop down shows 3 students as follow (ID number is show but the email isn't).
      Student One first_student
      Student Two second_student
      Student Three third_student
      (Begin search for last name)
      5. Search for word (Second).
      6. Check the drop down show second student as follow:
      Student Two second_student
      (Begin search for id number)
      7. Search for word "third".
      8. Check the drop down show third student as follow:
      Student Three third_student
      (Check we cannot search by email)
      9. Search for word "email".
      10. Check no result is shown.

       

      TC2: Check DPO can only search by identity when having "moodle/site:viewuseridentity" capabity.
      1. Login as admin and remove capability "moodle/site:viewuseridentity" from "dpo" role.
      2. Check DPO can still search by first name and last name (Step 1 to 6 of TC1).
      (Check we cannot search by using user identity)
      3. Search for word "third".
      4. Check no result is shown.
      5. Search for word "email".
      6. Check no result is shown.

      Show
      Precondition: 1. Define a new role " DPO " with " tool/dataprivacy:managedatarequests " capability and set up for this role as DPO for data privacy tool. 2. Create four users with following informations:  username  firstname lastname email idnumber roles student1 Student One email_student1@domain.com first_student Authenticated student2 Student Two email_student2@domain.com first_student Authenticated student3 Student Three email_student3@domain.com first_student Authenticated 3. Check to ensure user " dpo " has capability " moodle/site:viewuseridentity ". 4. Navigate to "Site administration / Users / Permissions / User policies" and check only " ID number " in " Show user identity " field.   TC1 : Check DPO can search for student by first name, last name 1 . Login as DPO1. 2. Navigate to "Create a new data request" page (admin/tool/dataprivacy/createdatarequest.php?manage=1) (Begin search for first name) 3. Search for word "Student". 4. Check the drop down shows 3 students as follow (ID number is show but the email isn't). Student One first_student Student Two second_student Student Three third_student (Begin search for last name) 5. Search for word (Second). 6. Check the drop down show second student as follow: Student Two second_student (Begin search for id number) 7. Search for word "third". 8. Check the drop down show third student as follow: Student Three third_student (Check we cannot search by email) 9. Search for word "email". 10. Check no result is shown.   TC2: Check DPO can only search by identity when having "moodle/site:viewuseridentity" capabity. 1. Login as admin and remove capability " moodle/site:viewuseridentity " from " dpo " role. 2. Check DPO can still search by first name and last name (Step 1 to 6 of TC1). (Check we cannot search by using user identity) 3. Search for word "third". 4. Check no result is shown. 5. Search for word "email". 6. Check no result is shown.

      When creating a GDPR request on behalf of a user, you need to search for them in the user field.

      The AJAX selector that searches for a user does not use the appropriate logic. It always searches the names (first/last), email, and username.

      It never searches the extra fields that are specified in admin settings (showuseridentity).

      This code is in admin/tool/dataprivacy/classes/external.php, function get_users.

      Currently it uses the datalib get_users function, which behaves incorrectly (as above) - it should probably be deprecated really. For example, in sites that don't support email address or username for searching, it probably shouldn't be searched.

      I searched the code for examples of how to do this correctly, I believe it is roughly:

      $extrafields = get_extra_user_fields($context);
      list($sql, $params) = users_search_sql($query, 'u', false, $extrafields, $excludedusers);

      (And then do the SQL query.)

      In addition to this, the display of the user name popup (after you search and it finds somebody) which can be found in templates/form-user-selector-suggestion.mustache is not really appropriate either - this should:

      (a) display the user's name
      and
      (b) also show - probably as a comma separated list - any fields that are returned by the get_extra_user_fields($context) function.

      Currently it shows like 'Full Name (email)'. So it should show:

      • If there's nothing from get_extra_user_fields, just 'Full name'
      • If there is a response, then those fields, in that order, comma-separated, e.g. 'Full Name (email, idnumber, department)'

      A particular use case for this is to search for somebody by their student number (idnumber). This is not possible in the current system. Not very helpful for our admin staff. But anyway, it ought to support the standard admin settings in this area.

      So to summarise all this into what needs doing (my opinion):

      1. The search should use all the fields selected in the showuseridentify admin setting, in addition to names, if the current user has moodle/site:viewuseridentity permission. If they do not have that permission then it should only search names.

      2. When displaying the popup of the selected user, this should also show all the fields selected in showuseridentity, in addition to names, if the current user has moodle/site:viewuseridentity permission. If they do not have that permission then it should only show names.

      3. There should be a PHPunit test of the web service to test the search behaviour. This should cover (may be one or several tests):

      • searching by name, as present (finds the user)
      • searching by a field configured in admin settings when user has viewuseridentity permission (finds the user)
      • searching by a field when user doesn't have viewuseridentity permission (doesn't find the user)
      • searching for a different field that is not configured in admin settings, when user does have permission (doesn't find the user)

      4. There should be a Behat test of the overall interface to test the popup appearance. This should cover:

      • display when user does not have the viewuseridentity, name only
      • display when they do have it, include all fields selected in admin settings (and not other fields)

            kietlyc Kiet Ly
            quen Sam Marshall
            Sam Marshall Sam Marshall
            Jake Dallimore Jake Dallimore
            Anna Carissa Sadia Anna Carissa Sadia
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 30 minutes
                2h 30m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.