902 Commits

Author SHA1 Message Date
sam marshall
7ba2a20166 MDL-66326 Global search: Delete from index when courses are deleted
Adds new API support within search engines for optional methods to
delete data for courses and contexts, and implements this for the
two core search plugins (simpledb and solr).

The new API is automatically called when courses or contexts are
deleted. When a whole course is deleted, it only sends the course
delete rather than sending 1,000 separate context deletions as
each activity/block is deleted.
2019-08-23 11:51:50 +01:00
Neill Magill
e3ec42093a MDL-65443 core: Log when a context is locked or unlocked 2019-08-20 08:52:35 +01:00
Simey Lameze
a98bafa163 MDL-66034 core_role: implement capability unassigned event 2019-08-05 13:09:18 +08:00
Simey Lameze
7b0afca816 MDL-66034 core_role: implement capability assigned event 2019-08-05 13:09:18 +08:00
Andrew Nicols
29c442c558 MDL-65646 core: Move component storage to json 2019-06-13 12:26:00 +08:00
Marina Glancy
beff3806d6 MDL-10965 courses: capability to browse course list 2019-04-10 12:35:28 +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
fe41810304 MDL-64410 access: Check for context locking in cap functions 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
Tim Hunt
a44065edaa MDL-61441 accesslib: get_users_by_capability groups perf improvement 2019-01-11 11:26:41 +00:00
Andrew Nicols
889b585b29 MDL-63686 core: recordset => records when fetching contexts 2019-01-09 19:08:08 +08:00
Andrew Nicols
ccbdced987 MDL-63686 core: Preload parent contexts 2019-01-08 14:11:00 +08:00
Andrew Nicols
bb41db9ce0 MDL-53566 core: Allow admins more control over locking
This change allows sites to configure locking such that it does not
apply to administrators at all.
2018-11-13 21:17:40 +08:00
Andrew Nicols
56db1a2d7c MDL-53566 core: Remove unused ancestorlocked field
This was originalyl intended as a performance improvement, but the
parent is already stored, and once calculated the value of locked is
already returned.
2018-11-13 21:17:40 +08:00
Andrew Nicols
0616f045c3 MDL-53566 core: Add support for context locking
This chagne adds support for a new feature known as Context Locking.
This allows a context to be locked, thereby removing all write
capabilities for all users (including admin) for that context, and all
child contexts.
2018-11-13 21:17:40 +08:00
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