moodle-pu.git
16 years agoenrol/database: calls to role_assign() follow the new prototypemdl19-enroldb
Martin Langhoff [Wed, 8 Aug 2007 09:15:02 +0000 (8 21:15 +1200)]
enrol/database: calls to role_assign() follow the new prototype

16 years agoenrol/database: fix deletion of old enrolments
Matt Clarkson [Fri, 27 Jul 2007 05:07:32 +0000 (27 17:07 +1200)]
enrol/database: fix deletion of old enrolments

16 years agoenrol/database: add cron = FULLME to prevent error
Matt Clarkson [Wed, 18 Jul 2007 04:47:37 +0000 (18 16:47 +1200)]
enrol/database: add cron = FULLME to prevent error

16 years agoenrol/database: Add 'copy full course' and 'restore from backup' options for auto...
Matt Clarkson [Tue, 19 Jun 2007 02:17:54 +0000 (19 14:17 +1200)]
enrol/database: Add 'copy full course' and 'restore from backup' options for auto course creation

16 years agoenrol/database: bugfixes - fix notices generated by op_cleanup_pref() - courses were...
Matt Clarkson [Mon, 28 May 2007 22:13:42 +0000 (29 10:13 +1200)]
enrol/database: bugfixes - fix notices generated by op_cleanup_pref() - courses were being un-enrolled if there was a current and valid enrolment

16 years agoenrol/database: fix sync where the ext db doesn't have role info
Martin Langhoff [Wed, 23 May 2007 00:03:29 +0000 (23 12:03 +1200)]
enrol/database: fix sync where the ext db doesn't have role info

16 years agoenrol/db: fix typo
Matt Clarkson [Mon, 21 May 2007 22:38:19 +0000 (22 10:38 +1200)]
enrol/db: fix typo

- Patch supplied by Penny.

16 years agoenrol/database: silence a warning
Martin Langhoff [Thu, 17 May 2007 00:58:11 +0000 (17 12:58 +1200)]
enrol/database: silence a warning

16 years agoenrol/database: reuse db connection
Martin Langhoff [Thu, 3 May 2007 23:18:49 +0000 (4 11:18 +1200)]
enrol/database: reuse db connection

16 years agoenrol/database: setup_enrolments() fix handling of users with idnumber not set
Martin Langhoff [Thu, 3 May 2007 05:55:53 +0000 (3 17:55 +1200)]
enrol/database: setup_enrolments() fix handling of users with idnumber not set

Like admin users ;-)

16 years agoenrol/database: sync() - use xid notation, plus setup_enrolment() and create_course...
Martin Langhoff [Thu, 3 May 2007 02:43:46 +0000 (3 14:43 +1200)]
enrol/database: sync() - use xid notation, plus setup_enrolment() and create_course() fixes

 - sync() - consolidate on using the xid notation to make it
   clear when we are using an external bit of data that needs
   to be mapped or escaped

 - create_course() was getting the context creation wrong

 - setup_enrolment() had bad cals to addslashes

16 years agoenrol/database: sync() now enrol_db_defaulrole takes precedence over the course
Martin Langhoff [Thu, 3 May 2007 02:07:07 +0000 (3 14:07 +1200)]
enrol/database: sync() now enrol_db_defaulrole takes precedence over the course

16 years agoenrol/database: setup_enrolments() rewritten to take a constant number of queries
Martin Langhoff [Thu, 3 May 2007 02:05:01 +0000 (3 14:05 +1200)]
enrol/database: setup_enrolments() rewritten to take a constant number of queries

Note! this patch probably breaks sync_enrolments -

16 years agoenrol/database: several fixes to sync()
Martin Langhoff [Wed, 2 May 2007 05:11:54 +0000 (2 17:11 +1200)]
enrol/database: several fixes to sync()

 * Fixed typo that would try to reenrol users
   all the time

 * Fixed SQL thinko that crashed Pg client libraries

 * create_course() now triggers a context creation
   to save time later. a context-less course is pointless

 * Better messages while we are running

With this commit, on my test env the times are

 * 8m creating 2.5k courses

 * 14m creating 135k enrolments -- including calls to mod/forum
   in this case we do see some memory growth - probable the unbound
   context cache growing...

 * 2m an update over 135k enrolments with no changes

16 years agoenrol/database: sync() - implement role changes, and several fixes
Martin Langhoff [Mon, 30 Apr 2007 01:55:54 +0000 (30 13:55 +1200)]
enrol/database: sync() - implement role changes, and several fixes

16 years agoenrol/database: sync() rewrite
Martin Langhoff [Fri, 27 Apr 2007 02:51:57 +0000 (27 14:51 +1200)]
enrol/database: sync() rewrite

Significant rewrite of the sync() method. Work in progress...

Behaviour changes:

 - the semantics change - the sync call will take care of
   all the roles

 - if there is a conflicting role from a different plugin,
   enrol/db will respect it, and not add its enrolment record

 - create_course() now never calls fix_course_sortorder()

 - scales to hundreds of thousands of roles

Internally, the function is arranged around a strategy of
copying all the enrolment data from the external DB into
a local temporary table, and then extracting all the info
we need from a couple of SQL queries.

The complexity is all in the SQL - the data management is
trivial. We walk the records in the recordset, and avoid
SQL IN by using OUTER JOINs.

Pending/TODO:

 - Deal with role changes

 - Ensure the login-time behaviour matches the sync()
   behaviour.

 - Unenrolments should use role_unassign_f()

16 years agoaccesslib.php: role_assign now keeps enrol information - and uses $fast
Luke Hudson [Thu, 17 May 2007 00:41:12 +0000 (17 12:41 +1200)]
accesslib.php: role_assign now keeps enrol information - and uses $fast

Important fix for upgrading sites that use enrolment backends.

16 years agolib/accesslib: fixed role_assign's debugging() call, clear warning
Luke Hudson [Mon, 9 Jul 2007 06:35:12 +0000 (9 18:35 +1200)]
lib/accesslib: fixed role_assign's debugging() call, clear warning

16 years agoaccesslib: role_assign() can take a contextobj
Martin Langhoff [Fri, 21 Sep 2007 00:46:34 +0000 (21 12:46 +1200)]
accesslib: role_assign() can take a contextobj

Saves quite a few DB queries...

16 years agoaccesslib: role_assign() gets a "$fast" parameter
Martin Langhoff [Sun, 29 Apr 2007 21:24:51 +0000 (30 09:24 +1200)]
accesslib: role_assign() gets a "$fast" parameter

All the callers to role_assign() are pretty safe and we should
just be able to avoid those silly checks. However, to be safe...

16 years agoAutomatic installer.php lang files by installer_builder (20070920)
moodler [Thu, 20 Sep 2007 04:22:39 +0000 (20 04:22 +0000)]
installer.php lang files by installer_builder (20070920)

16 years agoaccesslib: load_all_capabilities() - remember to check_enrolment_plugins()!
martinlanghoff [Thu, 20 Sep 2007 03:23:12 +0000 (20 03:23 +0000)]
accesslib: load_all_capabilities() - remember to check_enrolment_plugins()!

When setting up accessdata for a newly-logged-in user, call the
enrolment plugins. Thanks to Matt Clarkson for the heads up.

Affects: MDL-11180

16 years agogroup should probably be passed into get_role_users()
toyomoyo [Thu, 20 Sep 2007 03:11:51 +0000 (20 03:11 +0000)]
group should probably be passed into get_role_users()

16 years agofixing a calendar warning
toyomoyo [Thu, 20 Sep 2007 03:04:53 +0000 (20 03:04 +0000)]
fixing a calendar warning

16 years agofixing a warning in calendar
toyomoyo [Thu, 20 Sep 2007 02:57:17 +0000 (20 02:57 +0000)]
fixing a warning in calendar

16 years agofixing a warning when variable is not an object
toyomoyo [Thu, 20 Sep 2007 02:45:59 +0000 (20 02:45 +0000)]
fixing a warning when variable is not an object

16 years agoaccesslib:build_context_path() refer to dbfamily instead of dbtype
martinlanghoff [Thu, 20 Sep 2007 02:45:57 +0000 (20 02:45 +0000)]
accesslib:build_context_path() refer to dbfamily instead of dbtype

so mysql's various drivers can be used.

16 years agoMDL-11356, set display of grade items to database default (-1)
toyomoyo [Thu, 20 Sep 2007 02:39:25 +0000 (20 02:39 +0000)]
MDL-11356, set display of grade items to database default (-1)

16 years agoaccesslib: build_context_path() - better UPDATE SQL
martinlanghoff [Thu, 20 Sep 2007 01:03:35 +0000 (20 01:03 +0000)]
accesslib: build_context_path() - better UPDATE SQL

A bit of cleanup on the SQL we use for updates. Unfortunately, MySQL
uses non-SQL-standard syntax for updates reading or updating multiple
tables. After much testing across Pg and MySQL, I boiled it down to
the minimal differences -- but we still have different SQL.

The timings for this on a large reference install, calling
build_context_path(true):

 - MySQL incompatible 1s
 - Petr's fixes 60s -- DB complains of too many writes
 - This commit 24s  -- DB complains of too many writes

Also - fixed a remaining problem with $emptyclause

Affects MDL-11347

16 years agoaccesslib:build_Context_path() fix $emptyclause
martinlanghoff [Thu, 20 Sep 2007 00:16:22 +0000 (20 00:16 +0000)]
accesslib:build_Context_path() fix $emptyclause

We need 2 different empty clauses, one for updates, anotherone for
selects.

16 years agoaccesslib:build_context_path() - fix $emptyclause to avoid Oracle's dirty hack
martinlanghoff [Wed, 19 Sep 2007 23:46:37 +0000 (19 23:46 +0000)]
accesslib:build_context_path() - fix $emptyclause to avoid Oracle's dirty hack

accesslib is now clean of Oracle's dirty hack. Thanks Eloy for the idea.

MDL-11347

16 years agoDelete one excess parenthesis... Applying Bryce's patch to MDL-11347
stronk7 [Wed, 19 Sep 2007 22:40:58 +0000 (19 22:40 +0000)]
Delete one excess parenthesis... Applying Bryce's patch to MDL-11347

16 years agoMDL-11347 yet more beautification proposed by Eloy
skodak [Wed, 19 Sep 2007 19:20:18 +0000 (19 19:20 +0000)]
MDL-11347 yet more beautification proposed by Eloy

16 years agoMDL-11347 yet more beautification proposed by Eloy
skodak [Wed, 19 Sep 2007 19:13:49 +0000 (19 19:13 +0000)]
MDL-11347 yet more beautification proposed by Eloy

16 years agoMDL-11347 improving sql syntax - thanks Eloy for comments
skodak [Wed, 19 Sep 2007 19:01:32 +0000 (19 19:01 +0000)]
MDL-11347 improving sql syntax - thanks Eloy for comments

16 years agoFixes MDL-11327. Error when trying to include a non existing file.
mudrd8mz [Wed, 19 Sep 2007 17:58:03 +0000 (19 17:58 +0000)]
Fixes MDL-11327. Error when trying to include a non existing file.

16 years agoMDL-10824 - spaces in javascript URLs are not strictly valid. Merged from MOODLE_18_S...
tjhunt [Wed, 19 Sep 2007 17:44:52 +0000 (19 17:44 +0000)]
MDL-10824 - spaces in javascript URLs are not strictly valid. Merged from MOODLE_18_STABLE.

16 years agoMDL-11347 fixed context c in update which Tim's pg did not like much
skodak [Wed, 19 Sep 2007 17:40:20 +0000 (19 17:40 +0000)]
MDL-11347 fixed context c in update which Tim's pg did not like much

16 years agoMDL-11048 fixing some notices and changing the list of correlated tags to comma separ...
skodak [Wed, 19 Sep 2007 17:34:19 +0000 (19 17:34 +0000)]
MDL-11048 fixing some notices and changing the list of correlated tags to comma separated format without apostrophes

16 years agoMDL-10903 - Wrong capability checked in get_all_instances_in_course should be moodle...
tjhunt [Wed, 19 Sep 2007 17:06:31 +0000 (19 17:06 +0000)]
MDL-10903 - Wrong capability checked in get_all_instances_in_course should be moodle/course:viewhiddenactivities, not moodle/course:viewhiddencourses. Merged from MOODLE_18_STABLE.

16 years agoMDL-10972 - The lang string 'fullname', which is normally used for course fullnames...
tjhunt [Wed, 19 Sep 2007 15:52:27 +0000 (19 15:52 +0000)]
MDL-10972 - The lang string 'fullname', which is normally used for course fullnames, was being used for a person's full name in some quiz reports. This dual usage is not translatable into all languages. Merged from MOODLE_18_STABLE.

16 years agoMDL-11347 temporary patch for mysql trouble in build_context_path()
skodak [Wed, 19 Sep 2007 15:51:04 +0000 (19 15:51 +0000)]
MDL-11347 temporary patch for mysql trouble in build_context_path()

16 years agoMDL-11354 ipaddress typo in mnet environment.php
skodak [Wed, 19 Sep 2007 15:44:31 +0000 (19 15:44 +0000)]
MDL-11354 ipaddress typo in mnet environment.php

16 years agoMDL-6043 - supplimental - make corse reset function update quiz open and close dates...
tjhunt [Wed, 19 Sep 2007 15:38:14 +0000 (19 15:38 +0000)]
MDL-6043 - supplimental - make corse reset function update quiz open and close dates. Thanks to Shamim Rezaei for the implementation, which I edited slightly.

16 years agoMDL-11353 Completed the implementation. This included a new method in grade_item...
nicolasconnault [Wed, 19 Sep 2007 15:37:46 +0000 (19 15:37 +0000)]
MDL-11353 Completed the implementation. This included a new method in grade_item: get_displaytype(), since that value could be set to default, and we must then look up to course, then site values. And the get_letter() method in grade_grade has been modified to first check the grade_letters table. All works like a dream!

16 years agoMDL-11339 Moved the gradedisplaytype element from user prefs to the display element...
nicolasconnault [Wed, 19 Sep 2007 14:28:26 +0000 (19 14:28 +0000)]
MDL-11339 Moved the gradedisplaytype element from user prefs to the display element of the grade_item settings

16 years agoMDL-11340 Finished!
nicolasconnault [Wed, 19 Sep 2007 14:12:34 +0000 (19 14:12 +0000)]
MDL-11340 Finished!

16 years agoMDL-11340 Almost complete: Just need the "Add grade letter" button
nicolasconnault [Wed, 19 Sep 2007 13:49:26 +0000 (19 13:49 +0000)]
MDL-11340 Almost complete: Just need the "Add grade letter" button

16 years agoMDL-11340 Almost complete: Just need the "Add grade letter" button
nicolasconnault [Wed, 19 Sep 2007 12:45:44 +0000 (19 12:45 +0000)]
MDL-11340 Almost complete: Just need the "Add grade letter" button

16 years agoMDL-6315 - When processing a manul grading action, if both the comment and the score...
tjhunt [Wed, 19 Sep 2007 10:56:24 +0000 (19 10:56 +0000)]
MDL-6315 - When processing a manul grading action, if both the comment and the score are blank - as might be the case on the 'Grade all' page of the manual grading when the teacher uses it to grade some, but not all of the students - then do not record the question as graded. Merged from MOODLE_18_STABLE.

16 years agoXHTML Strictness. Merged from MOODLE_18_STABLE.
tjhunt [Wed, 19 Sep 2007 10:32:09 +0000 (19 10:32 +0000)]
XHTML Strictness. Merged from MOODLE_18_STABLE.

16 years agoMDL-11095 - Use absolute path to include tabs.php, not a relative path, for greater...
tjhunt [Wed, 19 Sep 2007 10:26:39 +0000 (19 10:26 +0000)]
MDL-11095 - Use absolute path to include tabs.php, not a relative path, for greater robustness. Merged from MOODLE_18_STABLE.

16 years agoOnly show SQL feedback during full forced update (ie upgrade)
moodler [Wed, 19 Sep 2007 09:55:31 +0000 (19 09:55 +0000)]
Only show SQL feedback during full forced update (ie upgrade)

16 years agoJust enabling SQL feedback so that errors like we're seeing in MySQL right now are...
moodler [Wed, 19 Sep 2007 09:43:13 +0000 (19 09:43 +0000)]
Just enabling SQL feedback so that errors like we're seeing in MySQL right now are exposed

16 years agoNew tags file
moodler [Wed, 19 Sep 2007 08:57:31 +0000 (19 08:57 +0000)]
New tags file

16 years agoadding missing closing }
skodak [Wed, 19 Sep 2007 08:53:24 +0000 (19 08:53 +0000)]
adding missing closing }

16 years agoNow assignment submodules are handled by the XMLDB editor. Pending commit.
stronk7 [Wed, 19 Sep 2007 08:04:11 +0000 (19 08:04 +0000)]
Now assignment submodules are handled by the XMLDB editor. Pending commit.

16 years agoaccesslib: update PHPDoc with intro to code
martinlanghoff [Wed, 19 Sep 2007 07:57:10 +0000 (19 07:57 +0000)]
accesslib: update PHPDoc with intro to code

Explain what we mean by _fad(), $ad and $ctx. Might help resolve MDL-11173

16 years agoaccesslib: janitorial - use $ad for accessdata everywhere
martinlanghoff [Wed, 19 Sep 2007 07:56:56 +0000 (19 07:56 +0000)]
accesslib: janitorial - use $ad for accessdata everywhere

Make sure we always say $ad when we talk about accessdata. This patch
fixes a few leftover bits and pieces...

16 years agoaccesslib: cleanup_dirty_contexts() - also forget about CAST()s
martinlanghoff [Wed, 19 Sep 2007 07:56:43 +0000 (19 07:56 +0000)]
accesslib: cleanup_dirty_contexts() - also forget about CAST()s

16 years agoaccesslib: get_dirty_contexts() - fix race condition, forget about CAST()s
martinlanghoff [Wed, 19 Sep 2007 07:56:30 +0000 (19 07:56 +0000)]
accesslib: get_dirty_contexts() - fix race condition, forget about CAST()s

In one tiny patch we do two things.

First, we fix the race condition around dirty context and accessdata
timestamps -- it is saner to offset the check than to offset the
recording of the change (as an earlier patch did).

    On a cluster, you still need NTP.

Second, we do away with CAST(). Ideally, the values should be compared
as ints but it's hard to get a CAST() syntax that is portable enough
to work on all our supported DBs. And Eloy pointed out (and I
corroborated testing) that we'll never have problems with the string
length, as our timestamps are always 10 chars as a string... and the
day they go to 11 chars we'll hit the unix Year-2038 bug.

16 years agoaccesslib: build_context_path() now sets path/depth for other blocks
martinlanghoff [Wed, 19 Sep 2007 07:56:14 +0000 (19 07:56 +0000)]
accesslib: build_context_path() now sets path/depth for other blocks

Blocks not on the coursepage should have their context "hanging" from the
site context. get_context_instance() was doing this correctly, but not
build_context_path().

16 years agoRevert "accesslib: mark_context_dirty() - fix race condition"
martinlanghoff [Wed, 19 Sep 2007 07:55:59 +0000 (19 07:55 +0000)]
Revert "accesslib: mark_context_dirty() - fix race condition"

This reverts commit 2b65045c5e8259f5997b3bbf457ec9d05027a93c.

16 years agolib/setup: Cleanup warnings in apacheloguser handling
martinlanghoff [Wed, 19 Sep 2007 07:55:46 +0000 (19 07:55 +0000)]
lib/setup: Cleanup warnings in apacheloguser handling

16 years agoweblib: print_user_picture() fix typoed classname when faking user object
martinlanghoff [Wed, 19 Sep 2007 07:55:29 +0000 (19 07:55 +0000)]
weblib: print_user_picture() fix typoed classname when faking user object

16 years agouser/index: switch to recordsets to use less memory
martinlanghoff [Wed, 19 Sep 2007 07:55:15 +0000 (19 07:55 +0000)]
user/index: switch to recordsets to use less memory

Memory usage was still high for long userlists. Use recordsets
to manage memory growth.

Note that we are still collecting a long long HTML table in memory
before we print it, so the footprint of the html itself is bit of an
issue.

16 years agouser/index: Fetch participants' contexts with the search
martinlanghoff [Wed, 19 Sep 2007 07:55:00 +0000 (19 07:55 +0000)]
user/index: Fetch participants' contexts with the search

With this patch, we fetch participants contexts in the main search
query. This cuts 1DBq per participant for the display.

Might fix MDL-11222 'global teacher viewing participants issues' where
we are getting OOM'd with many users.

16 years agoaccesslib: make_context_subobj() now expects ctxlevel, and fix all callers
martinlanghoff [Wed, 19 Sep 2007 07:54:37 +0000 (19 07:54 +0000)]
accesslib: make_context_subobj() now expects ctxlevel, and fix all callers

make_context_subobj() was not providing a contextlevel property, and
no callers fetched the field. This comes from its humble origins where
it was only ever called for course objects. These days it's used in
many other situations, so this patch DTRT and

 - fixes make_context_subobj() expect a cxtlevel and turn it into
   contextlevel

 - fixes all callers (accesslib, datalib) to provide it

16 years agodatalib:get_courses_wmanagers() handle empty $CFG->coursemanager more gracefully
martinlanghoff [Wed, 19 Sep 2007 07:54:23 +0000 (19 07:54 +0000)]
datalib:get_courses_wmanagers() handle empty $CFG->coursemanager more gracefully

Having no roles set as coursemanager is a valid setting.
get_courses_wmanagers() should not produce invalid SQL on it...
actually, it should not even try to get the course managers.

16 years agoaccesslib: get_user_access_sitewide() was skipping rdefs
martinlanghoff [Wed, 19 Sep 2007 07:54:06 +0000 (19 07:54 +0000)]
accesslib: get_user_access_sitewide() was skipping rdefs

The SQL query that would fetch rdefs not associated with any ra was
not being executed. Duh! For example, a user with a teacher RA sitewide
would never be affected by a role override at the category
level, because it was not being loaded into accessdata.

16 years agoaccesslib: get_user_access_bycontext() fetches all relevant rdefs
martinlanghoff [Wed, 19 Sep 2007 07:53:49 +0000 (19 07:53 +0000)]
accesslib: get_user_access_bycontext() fetches all relevant rdefs

get_user_access_bycontext() was narrowing down too much the rdefs it
was fetching. With this patch, it now correctly retrieves the rdefs for
new roles assigned in lower contexts, and also correctly retrieves
rdefs present in the course context (fixing MDL-11220).

This also means that we now do the job in 2 DB queries (instead of 3),
and we move a bit more data, but those rows are actually needed ;-)

16 years agocalendar/lib: calendar_set_filters() use pre-fetched context and course recs
martinlanghoff [Wed, 19 Sep 2007 07:53:33 +0000 (19 07:53 +0000)]
calendar/lib: calendar_set_filters() use pre-fetched context and course recs

Showing the calendar block was causing 2 DB queries per course the
user is enrolled in. Instead, use the data available in the array that
is passed as a parameter, and spare the DB a ton of needless traffic.

Fixes MDL-11221 Calendar not using context stuff from get_my_courses

Author: Martin Dougiamas

16 years agocourse/index: remove call to rebuild_context_rel()
martinlanghoff [Wed, 19 Sep 2007 07:53:17 +0000 (19 07:53 +0000)]
course/index: remove call to rebuild_context_rel()

Very last caller to rebuild_context_rel() and any XX_context_rel()
function. move_category() already takes care of calling
context_moved(), which does the required context.path maintenance.

Addresses MDL-11219

16 years agoaccesslib upgrade: remove stray build_context_rel(), force path rebuild
martinlanghoff [Wed, 19 Sep 2007 07:53:00 +0000 (19 07:53 +0000)]
accesslib upgrade: remove stray build_context_rel(), force path rebuild

Fixes problems during upgrades from 1.7x/1.8.x to mdl19-perf.

16 years agoweblib: build_navigation() try to avoid pointless capchecks
martinlanghoff [Wed, 19 Sep 2007 07:52:42 +0000 (19 07:52 +0000)]
weblib: build_navigation() try to avoid pointless capchecks

Prevent calls to has_capability() in build_navigation() from messing
with upgrades.

Most calls to has_capability() in weblib should be moved to the callers.

16 years agocourse/lib: print_course() fix bug when $course->managers was not set
martinlanghoff [Wed, 19 Sep 2007 07:52:27 +0000 (19 07:52 +0000)]
course/lib: print_course() fix bug when $course->managers was not set

Fix a thinko in a variable assignment that prevented us from grabbing
the correct roles as managers. Addresses Yu's report at
MDL-11182 admin shows up as teacher.

16 years agoaccesslib: has_cap_fad() respect local-context-wins permissions rule
martinlanghoff [Wed, 19 Sep 2007 07:52:06 +0000 (19 07:52 +0000)]
accesslib: has_cap_fad() respect local-context-wins permissions rule

The initial implementation of has_cap_fad() just added the permission
values regardless of the locality of the context. This patch adds
support (read: fixes bug) for the "local context wins" rule.

Additionally, it removes a related bug where we were exiting early
if we found a CAP_PROHIBIT, ignoring the $doanything flag.

16 years agocourse/lib: print_my_moodle() - ask get_my_courses() for the summary
martinlanghoff [Wed, 19 Sep 2007 07:51:50 +0000 (19 07:51 +0000)]
course/lib: print_my_moodle() - ask get_my_courses() for the summary

get_my_courses() now defaults to a much leaner dataset, but accepts an
array of "additional" fields we want. So ask nicely for the summary,
so that we can print_course() later with it.

16 years agodatalib: get_my_courses() honour $fields array
martinlanghoff [Wed, 19 Sep 2007 07:51:36 +0000 (19 07:51 +0000)]
datalib: get_my_courses() honour $fields array

If the caller passes a fields array, then merge it as we say we will do.

16 years agoaccesslib: get_my_courses() fix when called when empty sort
martinlanghoff [Wed, 19 Sep 2007 07:51:19 +0000 (19 07:51 +0000)]
accesslib: get_my_courses() fix when called when empty sort

get_my_courses() was failing if called with an empty sortorder on a
cached courselist. Fix.

16 years agoindex.php: drop unused $hidesitecourse parameter when calling print_courses()
martinlanghoff [Wed, 19 Sep 2007 07:51:02 +0000 (19 07:51 +0000)]
index.php: drop unused $hidesitecourse parameter when calling print_courses()

And this is the only user of print_courses() that mentions it
explicitly. Other callers have been checked and don't need or use the
sitecourse.

16 years agocourse/lib: print_courses() drop $hidesitecourse parameter
martinlanghoff [Wed, 19 Sep 2007 07:50:41 +0000 (19 07:50 +0000)]
course/lib: print_courses() drop $hidesitecourse parameter

The $hidesitecourse and related code seem to be dead code. An audit of
the callers did not turn up any interesting/valid use of it.

16 years agoRevert "course/lib: print_courses() - no need to worry about sitecourse"
martinlanghoff [Wed, 19 Sep 2007 07:50:28 +0000 (19 07:50 +0000)]
Revert "course/lib: print_courses() - no need to worry about sitecourse"

This reverts commit d7816749a4ceda352a2fac6e82d7f02f435473ed.

16 years agoaccesslib - Ensure newly-created categories have a context
martinlanghoff [Wed, 19 Sep 2007 07:50:05 +0000 (19 07:50 +0000)]
accesslib - Ensure newly-created categories have a context

New categories need a context immediately, and for top-level
categories, they also need to taint the "root" context to trigger
a reload of $USER->access.

This fixes problems with creation of initial courses(MDL-11178),
duplicate misc categories, etc.

16 years agoRevert "textlib: Don't require_once() class.t3lib_div.php which we never use"
martinlanghoff [Wed, 19 Sep 2007 07:49:49 +0000 (19 07:49 +0000)]
Revert "textlib: Don't require_once() class.t3lib_div.php which we never use"

Turns out class.t3lib_cs.php depends on class.t3lib_div.php. Will drop
the two commits before we go into HEAD.

This reverts commit 5768bf6fb4dfa334dc81a80d26111904c4d13abd.

16 years agoaccesslib: get_user_access_bycontext() remove 2 unused var declarations (trivial)
martinlanghoff [Wed, 19 Sep 2007 07:49:35 +0000 (19 07:49 +0000)]
accesslib: get_user_access_bycontext() remove 2 unused var declarations (trivial)

16 years agocourse/lib: print_courses() - no need to worry about sitecourse
martinlanghoff [Wed, 19 Sep 2007 07:49:23 +0000 (19 07:49 +0000)]
course/lib: print_courses() - no need to worry about sitecourse

get_courses_wmanagers() excludes the sitecourse, so we no longer
check for it. And check explicitly for an empty course array.

16 years agodatalib: get_courses_wmanagers() exclude the sitecourse
martinlanghoff [Wed, 19 Sep 2007 07:49:10 +0000 (19 07:49 +0000)]
datalib: get_courses_wmanagers() exclude the sitecourse

Should never return the sitecourse - so we exclude it explicitly.

16 years agocourse/index: Bring back Petr's MDL-9647 simplify dealing with headers/footers in...
martinlanghoff [Wed, 19 Sep 2007 07:48:56 +0000 (19 07:48 +0000)]
course/index: Bring back Petr's MDL-9647 simplify dealing with headers/footers in admin sections

I had mistakenly reverted some of Petr's changes.

Fixes MDL-11179 19PERF: Notice on /course/index.php as admin

16 years agoaccesslib: is_siteadmin() bugfixes
martinlanghoff [Wed, 19 Sep 2007 07:48:43 +0000 (19 07:48 +0000)]
accesslib: is_siteadmin() bugfixes

Fixed two horrid bugs in is_siteadmin(). Both userid and the check for
matching cpabilities lines were wrong.

16 years agoaccesslib: fix SQL CAST()s to work on MySQL and PostgreSQL
martinlanghoff [Wed, 19 Sep 2007 07:48:31 +0000 (19 07:48 +0000)]
accesslib: fix SQL CAST()s to work on MySQL and PostgreSQL

CAST() target types aren't very portable. Use DECIMAL which works
for MySQL and Pg.

DECIMAL does seem to be supported in Oracle - but the syntax seems
different. We may still need a compat function.

16 years agoaccesslib: remove has_capability_including_child_contexts()
martinlanghoff [Wed, 19 Sep 2007 07:48:19 +0000 (19 07:48 +0000)]
accesslib: remove has_capability_including_child_contexts()

No code is calling it, and it never appeared in any release.

16 years agomoodlelib: isediting() uses $PAGE->user_allowed_editing(), drop editcourseallowed()
martinlanghoff [Wed, 19 Sep 2007 07:48:03 +0000 (19 07:48 +0000)]
moodlelib: isediting() uses $PAGE->user_allowed_editing(), drop editcourseallowed()

With this commit, isediting() checks with the page if the user is
allowed editing. And as the last caller of editcourseallowed() is gone,
remove it.

16 years agoindex: use $PAGE->edit_course_allowed() instead of editcourseallowed()
martinlanghoff [Wed, 19 Sep 2007 07:47:49 +0000 (19 07:47 +0000)]
index: use $PAGE->edit_course_allowed() instead of editcourseallowed()

$PAGE->edit_course_allowed() has been reworked and is faster/smarter
than editcourseallowed(). It can also be made more specific on a
per-page-type basis.

16 years agoblocks/admin_tree: applicable_formats() is called as a class method
martinlanghoff [Wed, 19 Sep 2007 07:47:38 +0000 (19 07:47 +0000)]
blocks/admin_tree: applicable_formats() is called as a class method

Can't find it documented anywhere, but applicable_formats() is only
ever called as a class method, so it cannot say $this. Instead, say
block_admin_tree::has_admin_caps().

16 years agoRevert "datalib: Introducing sql_intarray_to_in()"
martinlanghoff [Wed, 19 Sep 2007 07:47:26 +0000 (19 07:47 +0000)]
Revert "datalib: Introducing sql_intarray_to_in()"

We don't need sql_intarray_to_in(), use implode() instead.

This reverts commit 3ef7fc54d9df780c837c64a8ace1fc565d6d7744.

16 years agoaccesslib: replace join() and sql_intarray_to_in() with implode()
martinlanghoff [Wed, 19 Sep 2007 07:47:11 +0000 (19 07:47 +0000)]
accesslib: replace join() and sql_intarray_to_in() with implode()

implode() is the PHP-ish way of saying this. join() is too Perlish and
may get confused (or misgrepped) with a SQL JOIN.

16 years agotextlib: Don't require_once() class.t3lib_div.php which we never use
martinlanghoff [Wed, 19 Sep 2007 07:46:54 +0000 (19 07:46 +0000)]
textlib: Don't require_once() class.t3lib_div.php which we never use

The largest of the 2 typo3 libs we ship in Moodle is never used. So
don't even parse it.

This takes Moodle's "default homepage" from 1.8MB to 1.6MB of PHP.
Tiny, but every bit helps...

16 years agomoodlelib: moodle_request_shutdown() prints included files
martinlanghoff [Wed, 19 Sep 2007 07:46:39 +0000 (19 07:46 +0000)]
moodlelib: moodle_request_shutdown() prints included files

If MDL_PERFINC is defined, we now print to errorlog a listing
of the files included, their size, and then a total size.

The total size isn't the most important metric, though it does give us
a good idea of how much PHP the PHP engine is parsing for us. The main
cost is still in the seeks involved.

Even when using precompilers -- our best-case scenario -- each include
or require forces at least 2 stat()s to compare timestamps in the php
file vs the precompiled file. If the working set fits in buffers we are
fine, but our 60+ stat() calls per page is quite a bit.

16 years agoblocks/admin_tree: Show the block if some admin privs present...
martinlanghoff [Wed, 19 Sep 2007 07:46:24 +0000 (19 07:46 +0000)]
blocks/admin_tree: Show the block if some admin privs present...

Dan Poltawski said:
> Previously users with different permissions could have granular
> access to the admin menu for the items they have access to, so
> limiting to only users with moodle/site:config would break that.
> Although I agree that that menu is slowww to render and needs
> fixing. Perhaps permissions for the various elements could be
> gathered and checked first

This commit addresses the problem checking for all the caps that are
mentioned by code in /admin (according to grep, at least). Some light
testing with the "moodle/user:create" seems to work properly.

This burdens us with maintaining the list in has_admin_caps() -- less
than ideal, but easier than rewriting /admin.