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

groups_members table should have 'component' field

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.4
    • Component/s: Groups
    • Testing Instructions:
      Hide

      Test level DIFFICULT (requires use of manual database queries and edits to code)

      1. After upgrade to new version, look at the groups_members table using a database viewer.
      + The table should have fields 'component' and 'itemid'.
      + These fields should be, respectively, '' and zero for all entries.

      2. Go to any course that has at least 2 users in (or set up a new one).
      3. Create a new group 'Group A' for testing. Go to 'Add/remove users' for the group.
      4. Select both users and add them to the group.
      + The add should work OK
      + Check in the database - the new groups_members entries should have '' (blank field) and 0.

      5. In the database, manually edit one of the two entries to set the component name to 'mod_page' (the Page module cannot really add group members; this is just an example for testing).

      6. Return to the group page.
      + Under the entry you set up, there should be grey (disabled), indented text 'Added by Page'. (If using Firefox, this text will also be smaller than usual. On other browsers, CSS doesn't work on list items.)

      7. Under the search box, type in the name the user who was not set to mod_page.
      + Verify that only that user displays; the 'Added by Page' text which belongs to the other user has disappared.

      8. Change the search to type in the user who was set to mod_page.
      + Only that user should appear; this should include the 'Added by Page' text below.

      9. Clear the search and select both entries (note that you cannot select the 'Added automatically' lines because these are disabled).
      10. Click 'Remove'.
      + The remove should work OK with both entries removed.

      11. Add both users again and manually edit one of them to have component 'mod_page' again.
      12. Return to the group page and verify that the entry shows up as added by Page again.
      13. Modify the following function in mod/page/lib.php:

      function mod_page_allow_group_member_remove($itemid, $groupid, $userid) {
          return false;  // change this line from true to false.
      }

      14. Attempt to remove both users.
      + You should now receive an error 'You do not have permission to remove automatically-added group member Anne Other' (with the name of the group member that was owned by Page).
      + Depending on the order, the other user may or may not have been removed.

      15. Return to the group members page. If the other user got removed, add them back so that you again have two users, one of whom is owned by Page.
      16. Edit the code above to change the 'false' return to true.
      17. Attempt to remove both users.
      + Removing both users should now be OK.

      18. Add both users back and set one in database to have mod_page as component, itemid as 13.
      19. Reload group page and check the 'Added by Page' appears again.
      20. Back up course using default settings.
      21. Restore to new course using default settings.
      22. View groups page and show members for the group.
      + The 'Added by Page' should still be there.
      23. Alter the new course to have a component of 'mod_foo'
      24. Back up the new course using default settings.
      25. Restore to a new course using default settings
      22. View groups page and show members for the group.
      + The 'Added by xxx' should no longer be shown.

      Show
      Test level DIFFICULT (requires use of manual database queries and edits to code) 1. After upgrade to new version, look at the groups_members table using a database viewer. + The table should have fields 'component' and 'itemid'. + These fields should be, respectively, '' and zero for all entries. 2. Go to any course that has at least 2 users in (or set up a new one). 3. Create a new group 'Group A' for testing. Go to 'Add/remove users' for the group. 4. Select both users and add them to the group. + The add should work OK + Check in the database - the new groups_members entries should have '' (blank field) and 0. 5. In the database, manually edit one of the two entries to set the component name to 'mod_page' (the Page module cannot really add group members; this is just an example for testing). 6. Return to the group page. + Under the entry you set up, there should be grey (disabled), indented text 'Added by Page'. (If using Firefox, this text will also be smaller than usual. On other browsers, CSS doesn't work on list items.) 7. Under the search box, type in the name the user who was not set to mod_page. + Verify that only that user displays; the 'Added by Page' text which belongs to the other user has disappared. 8. Change the search to type in the user who was set to mod_page. + Only that user should appear; this should include the 'Added by Page' text below. 9. Clear the search and select both entries (note that you cannot select the 'Added automatically' lines because these are disabled). 10. Click 'Remove'. + The remove should work OK with both entries removed. 11. Add both users again and manually edit one of them to have component 'mod_page' again. 12. Return to the group page and verify that the entry shows up as added by Page again. 13. Modify the following function in mod/page/lib.php: function mod_page_allow_group_member_remove($itemid, $groupid, $userid) { return false; // change this line from true to false. } 14. Attempt to remove both users. + You should now receive an error 'You do not have permission to remove automatically-added group member Anne Other' (with the name of the group member that was owned by Page). + Depending on the order, the other user may or may not have been removed. 15. Return to the group members page. If the other user got removed, add them back so that you again have two users, one of whom is owned by Page. 16. Edit the code above to change the 'false' return to true. 17. Attempt to remove both users. + Removing both users should now be OK. 18. Add both users back and set one in database to have mod_page as component, itemid as 13. 19. Reload group page and check the 'Added by Page' appears again. 20. Back up course using default settings. 21. Restore to new course using default settings. 22. View groups page and show members for the group. + The 'Added by Page' should still be there. 23. Alter the new course to have a component of 'mod_foo' 24. Back up the new course using default settings. 25. Restore to a new course using default settings 22. View groups page and show members for the group. + The 'Added by xxx' should no longer be shown.
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-31973-master-6

      Description

      The role_assignments table has a 'component' field which is used to record which internal component created the assignment (it is blank if the assignment was added manually using the UI).

      Unfortunately there is no 'component' field in the groups_members table.

      We have a dataload system which automatically sets up tutor groups (and several other types of group) and it would make life significantly easier for this system if we could set a 'component' field in groups_members so that it can tell which rows it created. (I.e. there are cases where it needs to delete entries, but only if the system created them, otherwise it wipes manual changes.)

      My proposal is to add the 'component' field to groups_members (with same semantics as in role_assignments, blank = manually added/normal).

      I am not sure there is anywhere in Moodle that automatically creates group_members entries, but I'll search; if there is, I can make this fill in the component field. Otherwise, this feature would be solely for the use of plugins, so apart from the database change and maybe some changes to one or two groups_* functions (to add the new field, where there are lists of fields) it shouldn't change much.

      Note: I am proposing to implement this myself.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  1 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    3/Dec/12