Commit Graph

118 Commits

Author SHA1 Message Date
Simey Lameze
2d526dcb33 MDL-66034 core_role: improve role events php unit coverage 2019-08-05 13:09:19 +08:00
Simey Lameze
3a18032dbf MDL-66034 core: delete role_capabilities_updated event triggers 2019-08-05 13:09:19 +08:00
Simey Lameze
32306e8390 MDL-66034 core_role: add more detail to role allow event classes 2019-08-05 13:09:19 +08:00
Marina Glancy
ff51af495f MDL-65726 core_roles: allow to create roles in install.php 2019-05-29 10:48:51 +02:00
Marina Glancy
f2c00a6f22 MDL-65726 role: do not fail unittest if plugins create their roles 2019-05-28 19:06:35 +02:00
Paul Holden
9ded266b4e MDL-43130 access: fix user counting when retrieving assignable roles.
Previously users assigned the same role in a context via multiple
components would be counted multiple times.
2019-03-08 12:32:24 +00:00
Andrew Nicols
54c2b17604 MDL-64410 access: Unit tests for context locking SQL 2019-03-06 12:36:05 +01:00
Andrew Nicols
c40f6adbe0 MDL-64971 access: Ensure that the capability exists when fetching 2019-03-06 10:16:06 +08:00
Andrew Nicols
ccbdced987 MDL-63686 core: Preload parent contexts 2019-01-08 14:11:00 +08:00
Tim Hunt
ab1272a0da MDL-46783 accesslib: add tests for MDL-63772 and MDL-63818
MDL-46783, MDL-63772 and MDL-63818 were originally coded on the
assumption that MDL-46783 would get integrated first. However it wasn't.
Therefore, it was not easy to add unit tests for MDL-63772 and MDL-63818
at the time, but it is now, so here they are.
2018-12-05 16:44:57 +00:00
Tim Hunt
939218c2b6 MDL-46783 permissions: let some moodle/ caps be overriden in all mods
The capabilities changed ('contextlevel' => CONTEXT_COURSE changed to
'contextlevel' => CONTEXT_MODULE) are:

* moodle/site:accessallgroups
* moodle/site:viewfullnames
* moodle/site:trustcontent
* moodle/site:viewuseridentity

This list came from reviewing the _get_extra_capabilities functions in
all core activities. They were all somewhat inconsistent, but I think it
makes sense that these capabilities are consistently overridable in all
activities. E.g. moodle/site:accessallgroups affects conditional
availability even if there is no other user of groups, and
moodle/site:viewuseridentity and moodle/site:viewfullnames affect the
logs report, if nothing else.

As a result of this, several _get_extra_capabilities functions are no
longer needed, and all the rest have been simplified.
2018-12-05 16:44:25 +00:00
David Monllao
85d4b77cd3 Merge branch 'MDL-61967-master' of git://github.com/sarjona/moodle 2018-09-25 11:08:53 +02: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
Jonathan Champ
1113e34675 MDL-54035 accesslib: Add context->get_parent_context_paths()
Returns full context paths for parent contexts. Useful for exact
matches, such as when checking dirtycontexts.
2018-09-21 09:17:43 -04:00
Jonathan Champ
b2f349a433 MDL-54035 accesslib: separate role definition cache clear
Thanks to MDL-49398, we can separate the combined user session and role
definition cache clearing function into two separate functions. At the
same time, we want to identify and remove mark_dirty() calls that were
added for role definition changes but were incorrectly left behind.

Change highlights:
 - Remove unnecessary mark_dirty() calls performed after
   assign_capability(), unassign_capability(), delete_role(),
   deleted contexts, brand new contexts
 - Move role definition cache clear from the user-centric
   accesslib_clear_all_caches() to the newly created,
   role-dedicated accesslib_reset_role_cache()
2018-09-21 09:17:42 -04:00
Tim Hunt
a1bc8928cc MDL-62747 accesslib: rdef caching should handle roles with no caps 2018-06-19 16:26:00 +01:00
Tim Hunt
5359c517d0 MDL-62440 participants: out-of-memory is many site-wide role assigns 2018-05-17 10:42:31 +01:00
Andrew Hancox
64cd459648 MDL-50666 core: Rename allow_ACTION to core_role_set_ACTION_allowed 2017-12-19 13:53:23 +13:00
Andrew Hancox
a63cd3e2ca MDL-50666 core: Add function get_viewable_roles to set role visibility 2017-12-19 13:53:23 +13:00
Tim Hunt
91c8d8b130 MDL-60983 get_user_capability_course: fix buggy edge cases
There were basically two problems, which are demostrated by
the new test users u7 and u8 in the unit test.

1. There was a problem if a role was overridden in a context above the
one where it was assigned. E.g. User has teacher role in a course, and
there is a role override in the course-category context. That was being
ignored.

2. Problems with the handling of PROHIBITs. It should be the case that
if there is a PROHIBIT in force, then it cannot be overridden by another
role, or by a role override. However, this was not working in all cases.

Also, I had to add comments to the unit test so that I could understand
it. Hopefully these will be hepful to other developers too.
2017-12-07 18:28:18 +00:00
sam marshall
46f7b264a3 MDL-59897 Accesslib: get_user_capability_course is slow 2017-10-06 13:57:55 +01:00
Jake Dallimore
b7e9f1cc42 MDL-37810 roles: fix profile roles logic to include all roles
If the user has the role:assign capability then the list of profile roles
will include any role assigned in the context or above.
2017-09-21 22:23:41 +08:00
Jake Dallimore
434d138c2a MDL-37810 roles: added manager case to test_get_user_roles_in_course()
Managers can assign managers, and should be able to see that role on
the course profile page, as a link to the participants page.
2017-09-18 10:16:08 +08:00
Jake Dallimore
42a2c4794d MDL-37810 roles: unit tests for get_profile_roles() 2017-09-18 08:59:29 +08:00
Andrew Nicols
d59be47602 MDL-59367 participants: Whitespace fix 2017-07-26 13:30:44 +08:00
Damyon Wiese
0ae28fad3a MDL-59367 participants: Reduce db queries
Fetch all role assignments for the course in a single query, instead of for each of the listed users.

More data but less queries.
2017-07-26 11:21:59 +08:00
Tony Levi
e705e69e7f MDL-49398 accesslib: Simplify role definition loading and cache
This change removes the complex and partial loading of role definition data for users.
It is replaced by keeping one system-wide definition for each role in MUC.

This is cheaper to regenerate as it avoids complex database queries (repeated LEFT JOIN to context).
Memory usage is kept low thanks to array CoW for each user access data.
2017-06-02 07:53:23 +01:00
Petr Skoda
a6210651a9 MDL-57027 fix get_users_by_capability()
Change-Id: I98dc88784dfa0293f88a19c3d36e7a46a3f52672
2017-02-01 13:01:28 +08:00
Damyon Wiese
245d354c6c MDL-55074 theme_boost: Unit test fixes for all these changes 2016-10-21 12:40:06 +08: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
Dan Poltawski
13b3bf6cd5 MDL-55423 tests: remove non-cross-db testcase
This isn't used in moodle core and is problematic on oracle, don't test
it.
2016-08-23 12:36:28 +01:00
Alexandru Elisei
03856ac5e8 MDL-55423 accesslib: Prevent get_role_users() false debugging messages 2016-08-17 20:43:39 +03:00
Alexandru Elisei
b6d1286414 MDL-52574 accesslib: Prevent get_role_users() fail in certain cases
The function get_role_users() requires the caller to include the $sort fields in
the $fields argument. On PostgreSQL this will cause the function to fail when
the default $sort fields aren't part of the requested fields. The behavior of
the function is augmented to add the $sort fields to $fields if they are not
already present.
2016-03-11 13:10:01 +02:00
Ankit Agarwal
2149326b8c MDL-50049 deprecation: Remove usage of deprecated api and cleanup 2015-06-29 17:15:50 +05:30
Tony Levi
aa7017432a MDL-42192 accesslib: Cache capabilities list
With thanks to Andrew Nicols <andrew@nicols.co.uk> for some ammendments.
2015-05-14 11:23:47 +09:30
Neill Magill
3a92084c6b MDL-49613 access: Unit test for count_role_users 2015-04-22 09:34:44 +01:00
Andrew Nicols
78db0d13de MDL-49395 core: add more unit tests for get_enrolled_sql 2015-04-07 15:30:07 +08:00
Tony Levi
a7e4cff20a MDL-49395 accesslib: Make get_suspended_userids more efficient 2015-04-02 13:53:49 +10:30
Ankit Agarwal
f9b7be4f95 MDL-34550 libraries: Final deprecation - get_context_instance_by_id() 2014-12-10 13:50:08 +05:30
David Monllao
655f737187 MDL-22309 accesslib: Adding unit test to expose the issue 2014-11-24 09:45:50 +08: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
Russell Smith
d2c58b95bb MDL-43835 phpunit: Correct unit tests.
When different ID's are set for each sequence a number
of unit test failures appear.  They have been corrected
to allow unit tests to pass with the new generator in place.
2014-06-17 19:08:01 +10:00
Charles Fulton
2f9c7f45dc MDL-45148 unit testing: pass role id instead of user id 2014-04-16 20:46:00 -07:00
Ankit Agarwal
b63f773296 MDL-44717 events: Fix multiple issues in events
Fix various incorrect urls
Fix incorrect phpdocs and other minor code style issues
Fix missing/incorrect strings

AMOS BEGIN
 MOV [eventblogassociationcreated, core_blog],[eventblogassociationadded, core_blog]
AMOS END
2014-04-01 15:08:34 +08:00
Russell Smith
74b63eae76 MDL-43440 unit testing: Use cmid in unit tests when it should be used.
instance is has been used instead of cmid.  This works as all id's are 1
in most cases, but not always.

accesslib_clear_all_caches_for_unit_testing was updated to clear the
$USER->access cache which would fail test when the wrong user's data was used.
2014-01-25 08:57:32 +11:00
sam marshall
0f1882ed1f MDL-43619 Roles: reset_role_capabilities unit test, cache fix 2014-01-14 13:46:25 +00:00
Russell Smith
038f546777 MDL-41198 lib: Allow PHP to generate random seed on script start
Most srand instances are removed to allow PHP to do the work.

srand was left for group randomization due to the method used.
2013-12-18 16:45:34 +11:00
Petr Škoda
fc4365d0fe MDL-42555 fix moodle_url typo in namespaces 2013-10-29 17:03:58 +08:00
Rajesh Taneja
045d913d11 MDL-42560 Events: Removed use of role->name
role->name is usually empty or localized, so should not be used in events
2013-10-28 11:06:47 +08:00
Damyon Wiese
74df2951d1 Revert "MDL-39876 Change get_record('course') calls to get_course"
This reverts commit ab7632b74c.
2013-08-21 13:42:30 +08:00