105 Commits

Author SHA1 Message Date
Sara Arjona
298d136e98
Merge branch 'MDL-79635' of https://github.com/paulholden/moodle 2023-10-18 19:55:42 +02:00
Paul Holden
be8f3f2788
MDL-79635 group: ensure unique params used to determine visibility.
Or we'll trigger DML "Incorrect number of query parameters" exception.
2023-10-10 10:06:06 +01:00
Paul Holden
dc01be8c54
MDL-79611 group: early exit getting members of non-existing group. 2023-10-09 15:00:14 +01:00
Mark Johnson
b0bb97ee3b MDL-79213 groups: Add visibility checks in groups_get_members_join()
Group visibility was not taken into account when
generating SQL for getting enrolled users restricted
to a list of groups. This may have allowed users to
infer membership of groups they were not allowed to
see members of.
2023-10-04 01:24:20 +00:00
Tomo Tsuyuki
d8a4cc9533 MDL-67186 group: add custom fields 2023-08-09 11:02:49 +10:00
Eloy Lafuente (stronk7)
e12c760a12 MDL-78156 groups: Make groups_get_user_groups() order deterministic
Right now the order of the groups returned by groups_get_user_groups()
is not fixed and, every DB, can return them in any order. While 99%
of times the order will be the creation one, depending of the RDBMS
decisions, they can be returned in any order.

This is specially noticeable with Oracle, but can affect to any DB.

And that makes some tests (expecting a given order) to fail.

This commit fixes the problem by making the order of the groups
deterministic, because that's the way we use to fix these problems.

Alternative is to relax the tests so only values are asserted by
using assertEqualsCanonicalizing().
2023-05-08 18:18:54 +02:00
Mark Johnson
958da5b67e MDL-68093 groups: Add visibility and participation settings
These new settings are designed to enchance user privacy surrounding
groups. They allow groups to be configured so that users outside the
group cannot see the group, so that users in the group cannot see each
other, or so that users cannot see the group at all, even if they are in
it. This avoids issues where a group may be assigned based on sensitive
personal information (such as a person requiring special arrangements
due to a disability).

By default, groups are visible to all and available for participation in
activities, which maintains the current behaviour.

For performance, a new cache has been added to track the number of
groups on a course that are not visible to non-members. This allows us
to revert to the existing behaviour if the new features are not being
used at all on a course, and only apply the new visibility conditions if
they are.

Users who have the moodle/course:viewhiddengroups capability should be
concious of exposing hidden groups when showing their screen to other
users. The "Switch role to..." feature can be used to show a course page
on screen without exposing private availability conditions, for example.

The changes cover several specific areas:
* grouplib functions, which most code should use to get lists of groups
  and members (this includes the participants page).
* Activities supporting group overrides will not allow overrides for
  groups that are hidden from all users.
* Activities supporting separate/visible groups modes will only allow
  groups with the new "participation" flag enabled to be selected.
* Group messaging will be disabled for groups where members cannot see
  each other, or cannot see the group at all.
2023-03-14 08:52:25 +00:00
Paul Holden
fdc9bd1a76 MDL-77057 group: format group names in module override pages. 2023-01-27 11:50:58 +00:00
Paul Holden
c260bad774 MDL-69908 user: include groups with exported course participants. 2021-06-14 09:31:30 +01:00
sam marshall
5e72715e4f MDL-71099 Lib: Move new user_fields class from core to core_user
This class would belong more appropriately within the 'user' API
(core_user) instead of within the 'core' API, since it is
directly related to user data.

Since the class has only just been added to Moodle, now is a good
time to move it.
2021-03-25 13:47:23 +00:00
sam marshall
558cc1b85e MDL-45242 Lib: Replace calls to deprecated functions
In all cases changes have been kept to a minimum while not making
the code completely horrible. For example, there are many instances
where it would probably be better to rewrite a query entirely, but
I have not done that (in order to reduce the risk of changes).
2021-03-10 10:57:10 +00:00
Michael Hawkins
03397c817b MDL-68348 lib: User filter match types support - groups
Updated groups_get_members_join to support different filter match types
2020-05-25 18:35:08 +08:00
Michael Hawkins
44e47eff9a MDL-68246 lib: Prepare for participants filter multiple groups support
These function updates are in preparation for the participants_search
class, which will be used to support multiple values per filter when
filtering the participants page.
2020-05-14 15:47:52 +08:00
Michael Hawkins
036b7cda10 MDL-68246 lib: Grouplib coding standards and consistency improvements 2020-05-14 15:47:34 +08:00
Tim Hunt
a73fa10678 MDL-64521 grouplib: reduce memory use in groups_get_all_groups
This avoids loading multiple copies of g.* when $withmembers is true
2019-01-22 16:42:18 +00:00
Sara Arjona
5290d0604b MDL-61967 core_user: Allow filtering by No groups on participants page
A new optional parameter $context has been added to the
core_group::groups_get_members_join() function.
Besides, some core_group methods now accept -1 (USERSWITHOUTHGROUP) for
the groupid field.
2018-09-24 18:33:45 +02:00
Simey Lameze
e2b7dca006 MDL-60826 groups: deprecate groups_get_all_groups_for_courses function 2018-07-24 07:58:35 +08:00
Shamim Rezaie
e4d3ed18ff MDL-61166 Groups: Fixed a typo in PHPDoc 2018-01-14 09:18:12 +11:00
Shamim Rezaie
0897d6588e MDL-60188 groups: cache user's groups and groupings
The function groups_get_user_groups is called too often both before rendering the page and after the page is rendered (using ajax).
The function was executing a query joining 3 tables in each call. The plementation of the function has now modified to store the
query result in a request cache.
2017-11-27 10:46:35 +08:00
Ryan Wyllie
d6942fb5ba MDL-59382 calendar: fix CiBoT warnings 2017-08-03 01:07:01 +00:00
Simey Lameze
705eea84d1 MDL-59382 core: make CiBoT happy. 2017-08-02 07:52:20 +00:00
Ryan Wyllie
aa0912258d MDL-59382 calendar: add modal to create and update events 2017-08-02 04:47:43 +00:00
Damyon Wiese
f746a078cb MDL-59368 groups: Postgres fix
Postgres is strict about mixing types.
2017-07-12 10:07:58 +08:00
Damyon Wiese
76c493b3f2 MDL-59368 groups: Add behat for new group edit 2017-07-12 10:07:58 +08:00
Damyon Wiese
2fa35b8d16 MDL-59368 groups: Inplace editing for users groups 2017-07-12 10:07:57 +08:00
Juan Leyva
8c60d198c2 MDL-57411 groups: Fix tests for MSSQL 2017-04-05 13:17:46 +02:00
Juan Leyva
a7d9c5373e MDL-57411 groups: New helper functions
- groups_get_groups_members
- groups_get_activity_shared_group_members
2017-03-31 09:04:58 +02:00
John Beedell
905953909f MDL-31243 access/enrol libs: rename new groups functions 2016-09-30 09:27:59 +01:00
John Beedell
9121bb2d23 MDL-31243 access/enrol libs: new fns returning useful SQL fragments
Refactor similar SQL generation code from get_users_by_capability
and get_enrolled_uses to make get_with_capability_sql.
Modified files: accesslib.php, enrollib.php, grouplib.php, new tests.
2016-09-30 09:27:56 +01:00
Juan Leyva
c616c5f145 MDL-49314 groups: New API function groups_user_groups_visible 2015-04-01 10:19:26 +02:00
Jason Platts
a75a381f04 MDL-48437 Make Visible/All groups selector show own groups first 2015-02-18 09:32:23 +00:00
sam marshall
061e6b2864 MDL-44725 Availability: Replace groupmembersonly - upgrade, core (1)
* Upgrades existing data so that the groupmembersonly option is
  replaced with equivalent data for the new availability API.
* Removes the database field and admin setting used for
  groupmembersonly.
* Changes core modinfo library to remove/deprecate groupmembersonly
  data and functions.
* Changes other core library files to remove groupmembersonly
  references.

Includes deprecation of several functions, listed in lib/upgrade.txt.
2014-09-02 13:03:07 +01:00
Ruslan Kabalin
dfaedf0854 MDL-46833 mod_assign: Fix assignment view when available for group members only.
When assignment is "Available for group members only" and no users with
mod/assign:submit role permision is enrolled (students),
groups_filter_users_by_course_module_visible is causing error (as $users
array is empty). The patch resolves the issue.
2014-08-14 16:06:08 +01:00
Marina Glancy
92e2e85523 MDL-44720 modinfo: make it easier to use cm_info instead of get_coursemodule_from_id
by adding function cm_info::get_course_module_record()
2014-03-27 11:24:00 +08:00
Damyon Wiese
c46db93c28 MDL-43721 Assign + groups: Improve performance of assign grading table
Add a function to the groups lib to filter a list of users down
to the ones who can see the module. Required because calling
groups_course_module_visible() for a list of users is too slow
and we shouldn't spread group logic outside of grouplib.php.

Using it in the assign grading table reduces DB queries from 6198/1 to 256/3.

This is 12secs down to 2.5secs.
2014-03-06 15:50:13 +08:00
sam marshall
4c31243fc7 MDL-43252 Group menu in wrong order when groupings used 2013-12-09 13:02:12 +00:00
Aaron Barnes
2eaa440c34 MDL-42913 lib/grouplib.php: Avoid cache sometimes for groups_get_all_groups
The new groups cache returns unexpected results when you pass
in a field parameter than would normally change the result array index
2013-11-20 11:56:42 +13:00
Ankit Agarwal
ef9ca10699 MDL-21415 reports: We should fetch active group from session not page params
Also donot allow active group to be set to something that user doesn't have access to
2013-09-12 11:18:25 +08:00
Ankit Agarwal
28c4399b6b MDL-21415 reports: Adding support of groups to course participation reports
Also introducing new api groups_allgroups_course_menu() that generates a selector for all groups in course"
2013-09-10 13:14:33 +08:00
Marina Glancy
6d04c4f2a2 MDL-41192 course: Added property-read cm_info::effectivegroupmode 2013-09-10 14:11:36 +10:00
Marina Glancy
1171ad564b MDL-40897 avoid extra DB queries in groups_get_activity_groupmode() 2013-07-28 18:47:57 +10:00
Ankit Agarwal
e481f05c0d MDL-40354 groups: Fix issues in groups_group_visible() 2013-07-10 10:50:22 +08:00
Ankit Agarwal
2d4d29da06 MDL-40354 groups:groups_get_activity_allowed_groups() should use passed userid to check capabilities 2013-07-10 10:50:22 +08:00
Ankit Agarwal
e7eb992d3a MDL-40354 groups: Add new api groups_group_visible() 2013-07-10 10:50:21 +08:00
Ankit Agarwal
475896bdbc MDL-37100 webservices: Implement core_calendar_get_calendar_events() 2013-01-21 11:05:50 +08:00
Sam Hemelryk
e17dbeeb1a MDL-34398 groups: implemented caching of group information. 2013-01-17 09:24:58 +13:00
Adrian Greeve
b0c6dc1cac MDL-34465 - lib - Replacing get_context_instance with context_XXXX::instance (group 8) 2012-07-27 10:10:46 +08:00
Eloy Lafuente (stronk7)
dd420abadf Merge branch 'MDL-24419-master' of git://github.com/sammarshallou/moodle
Conflicts:
	lib/db/upgrade.php
	lib/phpunit/lib.php
	version.php

Fixed:
    lib/db/upgrade.php - duplicate course->sectioncache add code
    lib/db/install.xml - cleanup needed because xmldb editor was not used
    lib/phpunit/classes/util.php - cleanup $GROUPLIB_CACHE on test reset
2012-05-16 23:53:47 +02:00
Andrew Robert Nicols
74b714df7e MDL-32005 Add idnumber field to groups and groupings 2012-05-15 09:38:51 +01:00
sam marshall
ae3fbf7b06 MDL-24419 (2): Moved groupings cache to get_all_groupings function
There was a static cache inside course/lib.php. I need to access this
information in other places, so to avoid making two queries, I am
moving the cache into the groups_get_all_groupings function instead.
2012-05-14 11:15:15 +01:00