More cleanups to come from Ed.
This isn't actually working for me right now but he'll fix it now.
This is completely optional and won't affect any other code right now.
=======================================
WARNING: DEV IS CURRENTLY VERY UNSTABLE.
This is a mega-checkin of the new Roles system. A lot of changes have
been made in core and modules.
Currently there are a lot of rough edges and known problems. We are
working hard on these .. .the reason for getting this into HEAD at this
stage is enable us to move faster (our branch was diverging from HEAD
too much).
Please keep an eye on http://docs.moodle.org/en/Roles for current status
and information for developers on how to use the new Roles system.
Now blocks_have_content() caches instantiated block objects inside $pageblocks
and blocks_print_blocks() uses them if available. This behaviour now matches
the documentation: blocks instances are created only once, get_content()
may be invoked several times.
A better fix would be to cache the _output_ of the block (the ->content
property) but it may bite us if any block is counting on being called twice.
Discussion at: http://moodle.org/mod/forum/discuss.php?d=45867
and from blocks admin page and their instances haven't been deleted.
We should build some sort of check to do all the house-cleaning of "orphaned"
blocks, perhaps each time we arrive to the blocks admin page.
Per-block access controls for creating and editing block instances. Defaults
behave the same as before, and the framework has final say as before.
See relevant discussion at http://moodle.org/mod/forum/discuss.php?d=36444
Other minor changes: Converted "continue" to "break" inside switch statements
(more to the point, although equivalent), change erroneous (but harmless)
"return false" to "break" on failed addition of block instance, removed some
inline comments from block_base (they were duplicated in PHPdoc)
call_user_func is about 3 times faster than eval(). Which is no surpise. ;-)
Faster block_load_class() by checking if the block class is already present
instead of relying on require_once() and include_once() which have include
paths and other nasties to take into account.
Implementing Dan Marsden's great idea for additional hooks when block
instances are deleted (bug 3446). Going a step further and adding hooks
for when block instances are created.
* Block authors no longer need to set $this->content_type
* If you want to make a "list" block, just derive from block_list
instead of block_base
* All switch() statements gone from library code
* Overloaded method is_empty() added to block classes for convenience
display in a page. Previously it returned the FIRST match; now it returns
the BEST match.
This allows things like
array('all' => true, 'mod' => false, 'mod-quiz' => true)
to work correctly regardless of the order the array elements appear in.
Also, encapsulated the check into a function (it has definitely become
non-trivial).
The format for each page is now the same as the id attribute of the
BODY tag, which in turn is a simple function of the script's relative path:
The format for e.g. a quiz view page is "mod-quiz-view". The format for the
site index is "site-index". Exception: the format for courses is not just
"course-view", but "course-view-weeks" etc.
Obviously the applicable_formats() override for each block should now take
this into account. The matching rules now are:
* You can specify the full format, e.g. "mod-quiz-view" => true
will allow the block to be added in quizzes
* Prefixes match the full page format, e.g. "mod" matches ALL activities
* You can use "*" as a wildcard, e.g. "mod-*-view" matches just the view.php
page of all activities
* These rules interoperate, thus "mod-*" is the same as "mod"
* "all" remains as a catch-all situation