628 Commits

Author SHA1 Message Date
tjhunt
c468795ce9 switch roles: MDL-18132 New Role allow switches page finished.
I also set up a reasonable set of default allows, including setting up some sensible allow_overrides, whatever the rant in MDL-15841 says.
2009-03-25 04:20:57 +00:00
tjhunt
82701e2443 switch roles: MDL-18132 separate database table role_allow_switch instead of re-using role_allow_assign.
This is part 1 that does the back-end:

1. New table role_allow_switch.
2. Upgrade that copies all the allows from role_allow_assign, and then drops the old CFG->allowuserswitchrolestheycantassign.
3. Old function get_assignable_roles_for_switchrole renamed to get_switchable_roles and changed to use the new table. Fixes MDL-18604 in HEAD.
4. Switch callers to use the new function name.
5. Unit tests for this new function.
6. To make those unit tests work, new switch_global_user_id and revert_global_user_id methods in UnitTestCaseUsingDatabase for toggling $USER->id.

I still need to do the editing interface under Administration ► Users ► Permissions ► Define roles. That will be done as a second commit.
2009-03-23 08:15:21 +00:00
tjhunt
ffdd703a99 MDL-18637 fix Moodle 1.9-style {$CFG->prefix}tablename in HEAD, and a few missing $DB->s.
I did not fix all the DB problems in search, there are too many there for me to be prepared to clean up other people's mess.

(For once, it was not me making this mistake ;-))
2009-03-23 05:19:53 +00:00
tjhunt
d867e696aa accesslib: MDL-18620 do not used static to cache things, it makes unit testing impossible.
Instead we have a new $ACCESSLIB_PRIVATE for all caching. Regrettably, the only way to make this work in PHP (other than rewriting everything to be methods of a class rather than functions) is to make this a global variable. However $ACCESSLIB_PRIVATE should not be thought of a global, it is a private implementation detail of accesslib.php. (And there is a comment saying that.)

There is a new function accesslib_clear_all_caches_for_unit_testing(). In a unit test, you need to call this at the start of your test method, before you set up any test data, and again at the end, after you have discarded all your test data.

This new $ACCESSLIB_PRIVATE subsumes the old $ACCESS, $RDEFS and $DITRYCONTEXTS globals.

Also, I took the opportunity to refactor the (inconsistently) duplicated code for adding a context to the caches code into a cache_context function.
2009-03-23 03:54:50 +00:00
stronk7
004865e20d MDL-15748 get_user_access_sitewide() - reduce looking for perms in any context below category level.
Dramatic speed-up in sites with zillions of contexts and overrides. Credit goes to Samuli Karevaara.
Merged from 19_STABLE
2009-03-20 12:10:47 +00:00
tjhunt
ea26b22262 accesslib. Improve comment. 2009-03-20 07:41:49 +00:00
skodak
795a08adb7 MDL-17458 upgrade logging implemented + a lot more refactoring + exceptions implemented in install/upgrade code + lang pack cleanup + some more improvements 2009-01-31 20:07:32 +00:00
skodak
88582df496 MDL-17458 refactored guest and admin user creation + refactored roles install + added protection for installation hijacking + added reliable session test right before editting of admin account 2009-01-29 22:54:41 +00:00
skodak
19a4a32e53 MDL-17942 fixed some incorrect uses of exceptions and typos 2009-01-17 23:24:31 +00:00
skodak
ac173d3ebe MDL-17267 simplified create_role - not adding assign and override perm to admin accounts, they have it now always 2009-01-17 23:16:20 +00:00
skodak
18818abf4c MDL-17458 $CFG->rolesactive cleanup + other cleanup in upgrade code 2009-01-15 22:09:57 +00:00
tjhunt
fb35c0cf72 accesslib: Nice debug developer warning if you call get_users_with_capability without including u.id in the list of fields. 2009-01-14 04:44:20 +00:00
skodak
1045a0074c MDL-17849 sql queries not printed by default during upgrade anymore, there is a new config.php only setting $CFG->upgradeshowsql instead 2009-01-12 16:52:53 +00:00
skodak
5c144d605e MDL-17845 now only one page per installs/upgrade :-D 2009-01-12 15:13:44 +00:00
tjhunt
4e7fabe6d6 accesslib: MDL-17626 role_names not cleaned up when a context is deleted. 2009-01-09 05:25:50 +00:00
skodak
a91b910e4f MDL-17776 added new define CLI_SCRIPT that identifies all CLI scripts + cron (cli scripts do not have session and do not like HTML in output and are executed from command line, cron is an exception) 2009-01-03 14:28:02 +00:00
skodak
b7b64ff2e0 MDL-17754 next round of session related refactoring 2009-01-02 20:32:05 +00:00
skodak
d993468db0 MDL-17556 fixed whitespace 2008-12-30 16:29:38 +00:00
mjollnir_
0e4e1a43f1 MDL-17693: get_role_users - add lastaccess & mnethostid to the list of default fields to return. These are used by messaging/emailing. (Merged from MOODLE_19_STABLE) 2008-12-19 08:56:25 +00:00
mjollnir_
a65cfba54d MDL-17692: count_role_users now accepts an int or an array of ints for roleid - this is now consistent with get_role_users. (Merged from MOODLE_19_STABLE) 2008-12-19 08:45:44 +00:00
sam_marshall
00653161b5 MDL-17556: Improve performance of get_fast_modinfo when courses have many activities 2008-12-18 17:52:29 +00:00
stronk7
294c03a996 MDL-17647 accesslib - cleaning some candoanything in comments. Merged from 19_STABLE 2008-12-17 00:33:32 +00:00
tjhunt
212235d3e2 accesslib: MDL-17647, MDL-17648 and MDL-17649 Bug fix, improvement and unit test.
MDL-17647 was referring to moodle/site:candoanything insstead of moodle/site:doanything

MDL-17648 Let get_users_by_capability take an array of capabilities, like has_any_capability

MDL-17649 get_users_by_capability must have unit tests (HEAD only).

The unit tests were briefly working (apart from the system context, which I had to set up by hand in the test contexts table). Then I made the mistake of trying to upgrade the test tables, and it all went horribly wrong (MDL-17644).
2008-12-15 06:22:18 +00:00
skodak
1a5b427e44 MDL-17589 fixed handling of missing caps in admin tree; merged from MOODLE_19_STABLE 2008-12-12 10:50:25 +00:00
dongsheng
771dc7b298 "MDL-14129, fix error() in moodle2" 2008-12-12 05:45:43 +00:00
skodak
3ce50127b9 MDL-17502 accesslib: added warning if incorrect parameters supplied to has_all_capabilities() and fixed parameters in course lib code 2008-12-09 16:25:38 +00:00
tjhunt
8a1b1c328d course categories: MDL-17502 when deleting a category and its contents, check moodle/course:delete capability.
* Note: this would never lead to problems with default role definions.
* Also ended up mostly rewriting delete_category_form to simplify the messages that are displayed.
* New helper function require_all_capabilities, a bit like require_any_capability.
2008-12-08 07:28:19 +00:00
tjhunt
8ed5dd63ee course categories: Fix many bugs with category editing and permissions. Clean up code.
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557.

* Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories.
* Enforce those correctly. (Note MDL 17502 is still outstanding.)
* Don't screw up category sort order when you just edit name or description.
* Niceties like where redirects go when you cancel or submit forms.
* Make sure a global course creator can see the site admin block.
* Don't allow a category to be made the child of one of its children!
* General code cleanup to bring key files more in line with best pracitice.

Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten.

Merged from MOODLE_19_STABLE.
2008-12-04 08:53:10 +00:00
skodak
9b1ad47be8 MDL-17372 new course reports string - role definition improvement; merged from MOODLE_19_STABLE 2008-11-29 16:33:58 +00:00
skodak
95f0446147 MDL-17372 course reports: Added full plugin support for course reports 2008-11-27 20:30:14 +00:00
skodak
a0005f678f MDL-17372 admin reports: Added full plugin support for admin reports; added specail capability for unittest execution, minor refactoring 2008-11-26 19:27:40 +00:00
skodak
d994ced22b MDL-17372 admin reports: Added full plugin support for admin reports; added specail capability for unittest execution, minor refactoring 2008-11-26 19:27:39 +00:00
jamiesensei
bbf4f440ee MDL-15326 "allow for per report capabilities to replace mod/quiz:viewreports" 2008-11-25 12:11:27 +00:00
tjhunt
759adfffa9 user's role / capabiltiy report: sort the context tree. 2008-11-25 07:29:14 +00:00
tjhunt
e86ecf1f04 Fix typo. 2008-11-24 07:27:11 +00:00
tjhunt
490740d6cb role assign: MDL-17323 Show users from parent contexts ... Refine group labels. 2008-11-21 06:19:52 +00:00
tjhunt
698ae7eb24 role assign: MDL-17323 Show users with the role in a parent context as disabled opitons in the existing users box 2008-11-21 05:46:45 +00:00
tjhunt
bed9cec80b define roles: MDL-16966 etc. polishing the new roles UI following a meeting with Martin.
* Move the show/hide advanced button a bit down the page.
* Improve save button caption when creating a role.
* Don't show defaults on the basic define roles screen.
* Explain the background shading on the advanced roels screen.
* Fix the problem with the risks link to Moodle docs.
* Help icon by the permissions column heading.
* Tables with rotated <th>s, make them vertical-align: bottom.
* Rename explain.php and explainhascapability.php to check.php and explain.php
* Tool tips on the number headers in the explain table.
* Explain table - role names were missing.
* Allow link_to_popup_window to work with full URLs.
2008-11-20 09:57:20 +00:00
skodak
0ecff22d84 MDL-17267 fixed regression caused by my last commit 2008-11-19 14:43:38 +00:00
skodak
26c46d0ed6 MDL-17267 roles, install: fixed allow role assign table duplicates problem during install - see tracker for more details 2008-11-18 09:56:59 +00:00
tjhunt
716dd16327 install / accesslib: Fix install problem 2008-11-18 09:28:05 +00:00
tjhunt
4659454ac6 manage roles: MDL-8313 fix bugs with safe overrides. 2008-11-18 08:08:18 +00:00
tjhunt
bbdb7070ca manage roles: MDL-8313 Provide a basic mode for the manage roles page.
* New basic define roles mode, with just an Allow checkbox for each capability.
* Button to toggle this form to/from advanced mode.
* Also, a separate mode for viewing a role definition, rather than just showing disabled checkboxes.
* Now duplicating a role just takes to you a pre-populated add role form, so you can double-check things before saving the new role.
* Deleting a role is now logged.
* Role reordering code cleaned up.
* You can now no longer delete the last role that has admin permissions.
* This includes a general refactor of manage.php, which eliminates manage.html, and splits of define.php.
2008-11-18 07:10:00 +00:00
tjhunt
a4df1cbbe5 role manage ui: MDL-8313 Refactoring and clean-up prior to basic/adv manage page. 2008-11-14 10:38:06 +00:00
tjhunt
bef12c997a course settings: MDL-16327 when creating a course, the role renames were not saved. 2008-11-13 08:11:10 +00:00
tjhunt
1e8e46879c roles interface: Code reorganisation and adding boilerplate comments.
I have collected code that used to be in lib/adminlib.php, lib/accesslib.php and user/selector/lib.php into a new admin/roles/lib.php file.

And I added standard GPL and Moodle comments to all the files in admin/roles.
2008-11-13 04:07:01 +00:00
tjhunt
e8155bc338 Fix typo. 2008-11-12 10:12:33 +00:00
tjhunt
7906379c9a role assign: MDL-13325 when assigning roles inside front page activites, list all users as potential users. 2008-11-11 07:23:25 +00:00
tjhunt
8f52ac3708 accesslib: MDL-17159 Fix regression I caused with MDL-8312. 2008-11-07 02:51:47 +00:00
tjhunt
01a80f51e5 role assign: MDL-8312 Restrict which roles can be assigned at which contextlevels.
* New table role_context_levels
* Populate table with defaults on install
* Populate table on upgrade with the same defaults, plus any additional ones needed to ensure all the role assignments already in the database are allowed.
* Change get_assignable_roles to respect these settings.
* UI for these settings on the add/edit role form.
* Save these settings when a role definition is saved.
* If in a context, there are no roles you can assign, display a polite message.
* Back up these settings.
* Restore these settings. When resotring a <=1.9.x backup file, any newly imported roles are set to be assignable at all contextlevels.

Restore not tested because it is broken in HEAD.
2008-11-06 07:34:01 +00:00