Commit Graph

937 Commits

Author SHA1 Message Date
Andrew Nicols
74a938c353 MDL-63818 core: Add all relevant module context caps
This change ensures that all capabilities at module context level are
shown within a module, only filtering out those which belong to another
module or the subplugins of another module.

This has the effect that module-level capabilities are included
providing they relate to
- the module being queried
- any subplugin of that module
- any capability at module level which does not belong to another module
  or its subplugin
- any other explicitly included capability

This allows permissions to be defined on a capability at a context
level.
2018-11-01 20:51:18 +08:00
David Monllao
e8ce6ca306 MDL-54035 accesslib: Check if the user can switch role before switching 2018-09-26 13:03:08 +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
1d049e08e5 MDL-54035 accesslib: add mark_user_dirty helper
Instead of marking an entire context dirty and affecting all users
of those contexts, mark the user as dirty when the change only
affects that user.
2018-09-21 09:17:43 -04:00
Jonathan Champ
34dd57053d MDL-54035 accesslib: only modify role_capabilities in accesslib
Whenever the role_capabilities table is changed, we need to remember
to clear the cache for the role(s) being modified. This is far simpler
when all of those changes happen in a single file, i.e. accesslib.php,
allowing other parts of the application to use the public functions
without requiring knowledge of the cache internals.
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
Marina Glancy
442f12f81a MDL-62742 core: rename coursecat->core_course_category
Also rename course_in_list -> core_course_list_element
Deprecate class coursecat_sortable_records
2018-08-28 11:36:23 +02:00
cescobedo
df536ab17d MDL-62065 core_access: First deprecation of get roles on exact context 2018-07-29 22:43:06 +02: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
Jun Pataleta
8403325c9e MDL-50666 core: Add sortorder to fields to be queried 2017-12-20 15:43:19 +13: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
Tomek Muras
aceb84ad76 MDL-60043 accesslib: improve query performance by removing ORDER BY
then add back the minimal necessary sorting in PHP. That part was
added by Tim Hunt.
2017-12-08 12:08:44 +00:00
Andrew Nicols
5be48c4514 MDL-59897 accesslib: Remove unused reset 2017-10-09 10:37:19 +08: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
da655d9ee4 MDL-37810 roles: get_user_roles_in_course returns all relevant roles
Fixed to return both those roles in the profileroles site policy and
any roles which the current user can assign in the respective context,
meaning a user can see a link to any role they can assign.
2017-09-18 08:59:29 +08:00
Jake Dallimore
7b30582669 MDL-37810 roles: fix get_profile_roles() so it returns assignable roles 2017-09-18 08:59:29 +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
Skylar Kelty
4bdd769309 MDL-49398 accesslib: Update for 3.4 and cleanups 2017-06-05 15:13:07 +01: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
Adrian Greeve
7c8afa8ff8 MDL-51833 tool_monitor: Improve access check for monitor. 2017-02-27 08:59:45 +08:00
Ankit Agarwal
5e80c61df4 MDL-57027 accesslib: Improve perf of sql 2017-02-01 13:01:29 +08:00
Petr Skoda
a6210651a9 MDL-57027 fix get_users_by_capability()
Change-Id: I98dc88784dfa0293f88a19c3d36e7a46a3f52672
2017-02-01 13:01:28 +08:00
Damyon Wiese
2fedc0da7c MDL-57001 roles: Do access check for switchroles
Put it in the API so it can't be skipped.
2016-11-24 15:11:19 +08:00
Marina Glancy
e938ea398c MDL-57007 behat: assume all capabilities during installation 2016-11-17 13:07:09 +08:00
John Beedell
10c4fce520 MDL-27072 Quiz: Remove get_users_by_capability from quiz reports 2016-10-10 11:05:15 +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
John Beedell
9f5170e955 MDL-31243 access/enrol libs: move enrol functions 2016-09-30 09:27:53 +01:00
Alexandru Elisei
03856ac5e8 MDL-55423 accesslib: Prevent get_role_users() false debugging messages 2016-08-17 20:43:39 +03:00
Tim Hunt
795efd9c1b MDL-54582 accesslib: improve performance of load_course_context
The new query is logically equivalen, but much, much faster, at
least on Postgred. (15ms, instead of 700ms, in one example I tried
on the database for the OU's main Moodle site.)
2016-05-13 20:36:33 +01:00
Andrew Nicols
83fc2cbd0d MDL-52574 core: Remove ASC/DESC when adding params from sort 2016-03-16 10:58:04 +08: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
Oleg Sychev
87b2ed6c1f MDL-51746 accesslib: Describe instanceid in context_something::instance
With no PHPDocs and $instanceid as name some module developers confuse
context_module::instance argument to be instanceid of the module while
it actually should be cmid.
2015-12-03 11:11:05 +01:00
Marina Glancy
5667e60249 MDL-41042 coursecat: reset course contacts cache more often 2015-10-07 10:23:03 +08:00
Eloy Lafuente (stronk7)
188458a604 MDL-50049 deprecation: Extra minor fixes.
- complete and cleanup upgrade.txt
- replace remaining uses in comments.
- fix some incorrect bulk-replacement in previous commit.
2015-07-10 01:59:31 +02:00
Dan Poltawski
a0dffaa946 MDL-42192 accesslib: tweak get_all_capabilities
Tony thinks its bike shed painting, I think its a bit more readable
and memory efficient. I am using integrator dictatorship for sure.
2015-06-18 07:13:37 +02:00
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
9d72ae249c MDL-49613 access: count_role_users gives unexpected results
The count_role_users function in lib/accesslib.php gives the wrong results if a user has the
same role at multiple levels in a context path.

For example a user is a coursecreator on a course and the category that the course is in,
in this case they would be counted twice, rather than being recognised as the same user.

This change will make the function only count unique users.
2015-04-22 09:34:45 +01:00
Tony Levi
a7e4cff20a MDL-49395 accesslib: Make get_suspended_userids more efficient 2015-04-02 13:53:49 +10:30
Andrew Nicols
558354df81 MDL-48807 accesslib: Change create_level_instance to recordset 2015-02-23 16:01:58 +08:00
Simey Lameze
5a39b24b9a MDL-48807 accesslib: table locking fix on all create_level_instance 2015-02-23 14:25:21 +08:00
Michael Aherne
c3acc77965 MDL-48830 accesslib: Add sort field to query 2015-01-15 10:12:23 +00:00
David Monllao
a8e60d97d9 MDL-22309 accesslib: Preventing incorrect get_role_users() uses 2014-11-24 10:46:04 +08:00
Mark Nelson
6c271ab5e6 MDL-47780 core: corrected docs for get_user_capability_course() 2014-10-21 00:52:54 -07:00
Kordan
f656df787f MDL-47594 core_accesslib: removed three useless lines of code 2014-10-09 11:04:36 +02:00
Marina Glancy
a3f234edfb Revert "Merge branch 'MDL-47012-m' of git://github.com/micaherne/moodle"
This reverts commit 0e88fe0227, reversing
changes made to de62e57a9b.
2014-09-10 11:18:52 +08:00
Michael Aherne
38b8d3e7f1 MDL-47012 core_enrol: remove desc and fix alias from ordering 2014-09-01 10:10:27 +01:00
Marina Glancy
274dc06881 MDL-34189 cohorts: Allow admin/manager to see all cohorts on one page 2014-07-28 15:02:27 +08:00