Commit graph

6707 commits

Author SHA1 Message Date
martinlanghoff
635bfbad21 accesslib: Introducing sort_by_roleassignment_authority()
This will help us bridge the gap from olden-style order-by
user_teachers.id. From the phpdoc...

 Will re-sort a $users results array (from get_users_by_capability(), usually)
 based on a sorting policy. This is to support the odd practice of
 sorting teachers by 'authority', where authority was "lowest id of the role
 assignment".

 Will execute 1 database query. Only suitable for small numbers of users, as it
 uses an u.id IN() clause.

 Notes about the sorting criteria.

 As a default, we cannot rely on role.sortorder because then
 admins/coursecreators will always win. That is why the sane
 rule "is locality matters most", with sortorder as 2nd
 consideration.

 If you want role.sortorder, use the 'sortorder' policy, and
 name explicitly what roles you want to cover. It's probably
 a good idea to see what roles have the capabilities you want
 (array_diff() them against roiles that have 'can-do-anything'
 to weed out admin-ish roles. Or fetch a list of roles from
 variables like $CFG->coursemanagers .

MDL-12452
2008-01-06 23:25:37 +00:00
martinlanghoff
1113f8002a lib/deprecatedlib: enrol/manual: Fix calls to get_users_by_capability() to avoid ra
get_users_by_capability() can no longer refer to properties of role
assignments or roles, as the capability aggregate is indirect.

Fixes:
 get_teacher() - though the results will be poor, as we cannot provide
                 role.sortorder reliably
		 (used mainly by mod/workshop)
 get_course_teachers() - which seems broken for a lot of situations as
                 its default parameters still refer to old tables.

MDL-12452
2008-01-06 23:25:26 +00:00
martinlanghoff
f17a660a05 accesslib: get_user_by_capability() - Fix pagination
Ooops! Off-by-one error

MDL-12452
2008-01-06 23:25:03 +00:00
martinlanghoff
c26ecb1a29 datalib: get_admins() - Rewrite to avoid get_users_by_capability()
get_admins() and get_admin() were counting on
get_users_by_capability() returning a role-assignment id to pick the
"primary" admin account. With the get_users_by_capability() rewrite,
we no longer have an RA id to clearly blame for the capability.

So, rewrite get_admins() based on the known-good SQL used in
is_siteadmin().

MDL-12452
2008-01-06 23:24:50 +00:00
martinlanghoff
c92bce4614 accesslib: get_user_by_capability() - Fix last_access handling
We were missing $courseid, which is actually $context->instanceid.

MDL-12452
2008-01-06 23:24:37 +00:00
martinlanghoff
6c9d86b7a6 accesslib: get_user_by_capability() - Move capcheck to has_capability_from_rarc()
This fixes the handling of default roles as "tie breakers" for lower
RAs in conflict, and simplifies the code a lot.

The main loop in get_user_by_capability() runs a simpler state machine
that just collects role assignments (roleid and depth), and handles
pagination.

The complex part of the state machine has moved to
has_capability_from_rarc() which will walk the data structures
collected by get_user_by_capability() for each user.

Having all the complex state handling of $hascap there makes things a
lot easier for pagination and general sanity of
get_user_by_capability().

MDL-12452
2008-01-06 23:24:25 +00:00
martinlanghoff
d2c5b7a9fa accesslib: get_user_by_capability() - Move hidden RA checks to subselect
we don't deal with RAs in the main SELECT -- we deal with _capabilities_
which is an entirely different matter ;-) -- so push the ra.hidden check
into the subselect.

Also, remove ra.hidden from the default list of fields. Hopefully no
callers are using ra.hidden -- if they are, they should be calling
something else, as this function deals with capabilities. So we might
need an audit of callers, to check that noone is expecting ra.hidden
to be there.

MDL-12452
2008-01-06 23:24:14 +00:00
martinlanghoff
a4436c6db8 accesslib: get_user_by_capability() - Handle the complex case
With this commit, we can handle the complex cases with

 - correct pagination, but not very efficient over large datasets

 - mostly-correct application of the override rules

The structure of the code is fairly complex in that we want to do
it without holding all the recs in memory, so we use a small state
machine. We have to handle the complex override rules over 1 or 2
permissions (when $doanything is set) so it all ends up quite complex.

There is one known issue with this code, in cases where the default
role ends up as the decider between 2 conflicting RAs, we fail to
apply it. This will need a bit of reorg of how the loop works.

MDL-12452
2008-01-06 23:23:58 +00:00
martinlanghoff
2d1669b0d5 accesslib: get_user_by_capability() - Simple cases now handle multiple RAs
The "simple" case SQL did not handle multiple enrolments for the same
user correctly -- it would generate multiple rows for those users,
incorrectly.

With this patch we move the join to RA to a subselect where DISTINCT
takes care of things.

MDL-12452
2008-01-06 23:23:46 +00:00
martinlanghoff
8b8bf40cc7 accesslib: get_user_by_capability() - Handle complex rolecap resolution
With this patch, get_user_by_capability() can handle the cases where
users have multiple role assignments to the same course, and PREVENTs
and PROHIBITs affect the rolecaps of this course.

Without stored procedures we cannot resolve this entirely on the
server side - so in the complex cases we do as much as we can on SQL,
and post-process the data on the PHP side, including SQL-style
pagination.

MDL-12452
2008-01-06 23:23:24 +00:00
martinlanghoff
26843e106b accesslib: get_user_by_capability() - First, handle simple cases
This patch reorganises the conditions and field handling so
we can spot if this is a call we can resolve in a single SQL
query that we just pass back the results.

If there are any PREVENTs or PROHIBITs, we need to delve into
more involved stuff...

MDL-12452
2008-01-06 23:22:26 +00:00
martinlanghoff
987e745442 accesslib: revert changes to get_users_by_capability() - MDL-12452 MDL-12451
The changes made by Yu and Tim are superceded by the patches that
follow -- and would not apply cleanly without this revert.
2008-01-06 23:22:08 +00:00
martinlanghoff
b1df0eb2ce lib/setup: restore sanity to rcache handling
$CFG->rcache is safe to keep, even as we are reading the config table.

This is because whenever we update the config table, all the rcache
plugins either mark the cache as dirty or they update the cache.

The reason we want to be able to preserve this is that rcache settings
in CFG should usually be set in config.php rather than in the config
table.

With this fix, we support both control points.
2008-01-06 22:56:07 +00:00
martinlanghoff
944a2c938f dmllib:rcache_get()/rcache_set() clone cached records - we do not want magic references here - MDL-12827\n And calling fullclone() with the huge cost in serialize()/unserialize() is not needed. 2008-01-06 22:46:20 +00:00
nicolasconnault
7dd512670b MDL-12827 Saving a clone of the $record in the cache instead of the record itself, to avoid referencing 2008-01-04 09:23:42 +00:00
nicolasconnault
bbc275c142 MDL-12429 Applied and tested Franois' patches to 1.8, 1.9 and head. 2008-01-04 06:46:52 +00:00
nicolasconnault
7734465963 MDL-12429 Applied and tested Franois' patches to 1.8, 1.9 and head. 2008-01-04 06:45:55 +00:00
poltawski
017b524a05 MDL-12825 - add some extra height to popups in IE7, otherwise they cant
be used merged from MOODLE_19_STABLE
2008-01-03 22:41:54 +00:00
skodak
8293c75198 MDL-6786 Improved dropping of block and module tables during uninstall; merged from MOODLE_19_STABLE 2008-01-03 15:03:32 +00:00
skodak
bc37088926 MDL-11471 adodb 4.96a import; merged from MOODLE_19_STABLE 2008-01-02 18:49:00 +00:00
stronk7
35107f8636 Respect case of enumvalues. MDL-12803 ; Merged from MOODLE_19_STABLE 2008-01-02 16:49:11 +00:00
skodak
7c09710cbf MDL-12796 iplookup rewrite 2008-01-02 16:47:57 +00:00
skodak
e9c0fa35f4 MDL-12794 admin setting for file location; merged from MOODLE_19_STABLE 2008-01-01 22:25:11 +00:00
skodak
3e475991f9 MDL-12793 PARAM_HOST incorrect cleaning; merged from MOODLE_19_STABLE 2008-01-01 17:23:05 +00:00
skodak
587c7040f5 MDL-12790 highlighting in admin search results breaks html
MDL-12791 add defaults parameter to format_admin_setting()
MDL-12792 search in admin settings and defaults
+ minor speedup of fast highlighting and fixed empty span tags

merged from MOODLE_19_STABLE
2008-01-01 15:51:54 +00:00
poltawski
3caca2b282 just tweaking comment for easy greppage 2008-01-01 15:30:57 +00:00
stronk7
0f62a5b5bb Better behaviour for "-" course searches under MSSQL and Oracle. MDL-7312 ; merged from 19_STABLE 2008-01-01 12:03:00 +00:00
skodak
599f06cff1 MDL-11845 fixed security issues in curl related code in new download_file_content() + minor fixes in Snoopy; merged from MOODLE_19_STABLE 2007-12-31 23:18:06 +00:00
skodak
407d81349c MDL-12786 admin search in configselect choices; merged from MOODLE_19_STABLE 2007-12-31 15:55:36 +00:00
skodak
6bf55889dd MDL-12782 magpie now uses download_file_content() - that should solve several remote RSS issues including proxy user/password + several download_file_content() improvements + other minor fixes; merged from MOODLE_19_STABLE 2007-12-31 15:37:12 +00:00
stronk7
a599aeebe5 Prevent some debugging notices, cast to object before inserting. Merged from 19_STABLE 2007-12-31 15:20:02 +00:00
stronk7
a2717fd721 1976 rules from 2007j Olson files. MDL-12024 ; merged from 19_STABLE 2007-12-31 13:23:23 +00:00
stronk7
f85236dc76 Change some constants to avoid name collisions. MDL-12698 ; Merged from MOODLE_19_STABLE 2007-12-31 01:07:49 +00:00
poltawski
ee3501f124 MDL-11845 - use the http 1.0 'Moved Temporarily' rather than unhelpful 'Found'
merged from MOODLE_19_STABLE
2007-12-30 23:10:42 +00:00
skodak
8cad6cca87 MDL-12775 PARAM_INT value '' automatically converted to 0 in configtext settings; merged from MOODLE_19_STABLE 2007-12-30 22:30:46 +00:00
skodak
a7d43f0d15 MDL-12698, MDL-12569 - componentlib & langimport improvements and fixes; merged from MOODLE_19_STABLE 2007-12-30 22:19:36 +00:00
skodak
5f8bdc17a8 MDL-11845 removing curl emulation library, snoopy has better support for proxies and seems to be more reliable on different platforms; spelling correction cURL instead of Curl; adding all proxy admin settings; better debug messages for file downloading; SOCKS5 proxy support; merged from MOODLE_19_STABLE 2007-12-30 19:42:51 +00:00
skodak
e33fbf87ed MDL-12774 allow returning of errors from admin configtext settings; merged from MOODLE_19_STABLE 2007-12-30 17:59:17 +00:00
skodak
8bbfc1e321 MDL-12756 print save button in admin search only when there are settings to save; merged from MOODLE_19_STABLE 2007-12-29 16:49:26 +00:00
skodak
64874c5aac MDL-12752 making unsupported pages truly hidden; merged from MOODLE_19_STABLE 2007-12-29 16:38:25 +00:00
poltawski
357f787bbc MDL-7242 eliminate last use of location to refer to city in profile where
it causes problems for translators
merged from MOODLE_19_STABLE
2007-12-29 15:38:14 +00:00
poltawski
1a4de3618b MDL-4692 - initalise var, merged from MOODLE_19_STABLE 2007-12-28 22:56:42 +00:00
mchurch
19c8cf7917 MDL-12703 - Use the 'welcometocourse' language string if there is no 'welcomemessage' property set in the course object. Currently, there does not seem to be any code or data items that would set this property. 2007-12-28 17:14:01 +00:00
mchurch
ca29e37d24 MDL-12744 - Add ability to pass an extra button for use in print header for modules that use the course page to display themselves with blocks. 2007-12-28 16:13:09 +00:00
urs_hunkler
d0f5b9f4ee merged from 1.9 :: MDL-12745 :: added class clearfix to "form-item" to stop div collapsing. 2007-12-27 21:00:00 +00:00
skodak
e69499c8df MDL-12729 show recoverable fatal errors in DEBUG_ALL and DEBUG_DEVELOPER; merged from MOODLE_19_STABLE 2007-12-26 13:33:25 +00:00
skodak
89f3974190 MDL-12351 verify active group before use because allowed groups may change; merged from MOODLE_19_STABLE 2007-12-26 12:42:33 +00:00
skodak
e7dee37f9b MDL-11758 removing one htmlpurifier file to prevent problems on some systems; merged from MOODLE_19_STABLE 2007-12-25 21:06:32 +00:00
skodak
696c7f753f MDL-12338 prevent KSES from breaking í chars in alt/title tags - credit goes to Eloy; merged from MOODLE_19_STABLE 2007-12-25 20:56:36 +00:00
skodak
109e3cb281 MDL-11561 improved text filter cache resetting when settings change; fixed bug causing fatal errors if html purifier enabled during upgrade; merged from MOODLE_19_STABLE 2007-12-25 10:03:59 +00:00