88 Commits

Author SHA1 Message Date
tjhunt
b1a308bee0 Merge from 1.6 branch. 2006-05-17 11:38:34 +00:00
martinlanghoff
66c7e47b27 blocklib: cache (and used cached) block instances properly in $pageblocks
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
2006-05-17 04:39:43 +00:00
stronk7
f809df70ce Avoided some notices when one block has been deleted from moodle/blocks
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.
2006-04-24 15:01:35 +00:00
vyshane
a2c28054b8 Added $CFG->pagepath to the blocks_execute_action() function for the config
action. This is used to generate the Moodle Docs URL for configuration of an
instance of a block.
2006-03-16 04:55:43 +00:00
mjollnir_
f9648e77cf Added cron support for blocks - it was already there in the tables, now we just need to use it 2006-02-14 03:24:08 +00:00
mjollnir_
ddf1935f30 For pinned blocks (that don't have a pageid), make one up on the fly (Fixes bug #4497) 2005-12-20 20:55:37 +00:00
defacer
1130633117 NEW FEATURE:
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)
2005-12-17 04:37:55 +00:00
defacer
a9033ad5f8 Faster block_method_result(), my back-of-the-envelope benchmarks say that
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.
2005-12-17 03:09:13 +00:00
moodler
b9709905c7 Merged CSS fix for bug 4045 from stable 2005-09-09 16:52:47 +00:00
mjollnir_
a9b3afb7b1 Merged from MOODLE_15_STABLE: Performance fix: in postgres, sometimes indexes are not used because of type casting. block_instance.pageid is a big int field so the index wasn't being used. Wrapping in '' prevents the typecast. See http://www.postgresql.org/docs/7.4/interactive/datatype.html#DATATYPE-INT for more information 2005-09-07 22:00:55 +00:00
defacer
3cdc4597f5 Fixing copy/paste typo, caught by Howard Miller.
Penny can you please confirm that this is how it's supposed to be?
2005-08-23 18:16:06 +00:00
mjollnir_
4374ee2ca9 Fixing warnings in my moodle/ blocks /pagelib, plus moved page->edit_always to base class 2005-08-23 04:48:34 +00:00
mjollnir_
ee6055eb89 Fixing up the my moodle blocks to use blocks_setup instead of the old way. 2005-08-23 04:03:56 +00:00
mjollnir_
0d6b9d4f4d MyMoodle: new /my/ page, contains course overview (module based, forum done). User defined blocks on /my/ page, admin defined stickyblocks. Needs lots of testing. Held off bumping version.php for blocks because of the postgres upgrade fixes Patrick is putting in. 2005-08-16 00:25:39 +00:00
defacer
2e477369d3 Merging from STABLE:
Fix for bug 3510:

Due to stupidly copy/pasting some code, deleting a block instance could,
under some circumstances, throw a fatal error.
2005-06-14 20:33:39 +00:00
defacer
b33dd23adc Merging from STABLE:
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.
2005-06-13 03:32:31 +00:00
defacer
b011f733bf Fix for bug 2635:
The "current blocks code older than the one that made the database" message
tweaked so that it's different from the corresponding Moodle core warning.
2005-05-17 15:28:06 +00:00
thepurpleblob
2d81e9080a Changed include to require for base_block class. Won't get far without this
and puts error message in the right place if there is a problem
2005-05-03 12:23:48 +00:00
defacer
ff6191b742 On second thought, moving the cache retrieval out of the loop should eliminate
up to ten or so function calls per page view. I don't know how expensive they
are, but let's take what we can.
2005-04-30 03:18:02 +00:00
defacer
9b68732055 Extra check in blocks_preferred_width: don't examine any instance if that
block is not visible. Apart from fixing a bug, this is also they key to
fixing broken behavior with legacy 1.4 blocks.
2005-04-30 03:14:42 +00:00
defacer
61abc65bb9 New function block_is_compatible(), if it returns anything but true and you
decide to do anything with the block your warranty is void.
2005-04-30 03:08:04 +00:00
moodler
7a3290ed20 No need to flag notices about missing database stuff in blocks 2005-04-10 13:51:19 +00:00
defacer
b35fc18250 Fix for bug 2731. 2005-03-12 15:56:19 +00:00
mjollnir_
3f05218715 In blocks_print_group, if we just return if pageblocks are empty, we never get to print the admin block 2005-03-08 23:24:10 +00:00
defacer
3ef642d96a Implemented discussion from bug 2547:
* 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
2005-03-02 19:22:26 +00:00
defacer
831cd87f77 Er, print the adminblock only if editing is turned on. 2005-03-02 05:57:50 +00:00
defacer
dffd4bb948 You know you are beyond hope of redemption when you make "API uniformity" changes. ;-) 2005-03-02 05:56:24 +00:00
defacer
664923229c Since $PAGE knows where the adminblock should be printed, let it do the printing. 2005-03-02 05:47:39 +00:00
defacer
ec79d3e428 One-line-setup function for using blocks in a page. 2005-03-02 05:15:39 +00:00
defacer
ff67989728 Fix for bug 2628. 2005-02-23 18:51:00 +00:00
defacer
e82d6cac81 Improvement when configuring a block instance: the heading shows the
block's original title as it appears in the lang files, not its "internal"
name.
2005-02-18 17:05:49 +00:00
defacer
afd8402cfa Changed id attribute of adminblock to class, just like every other block. 2005-02-18 03:37:07 +00:00
moodler
4a4c30d24d Sort the blocks menu.. 2005-02-17 02:19:55 +00:00
defacer
eca3b01f48 Remove needless sort. 2005-02-16 21:39:35 +00:00
defacer
5bbbe0be91 Changing the matching function that decides if a block is applicable for
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).
2005-02-10 18:43:18 +00:00
moodler
c7a9e29326 Just a robustness test 2005-02-08 17:07:31 +00:00
defacer
8a47e075b3 Changing the way that applicable formats for each block are defined:
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
2005-02-08 02:59:44 +00:00
defacer
d49a3fc5a8 Removing the inline style, migrating to styles_layout.css 2005-02-08 00:22:37 +00:00
defacer
e1f76e76a9 Give an id attribute to the "Add Blocks" block so that the new hide/show
provisions in weblib don't print notices.
2005-02-08 00:00:21 +00:00
defacer
c1d8705fd2 Change the semantics of blocks_print_adminblock() to make life easier to
developers who use pages. Conversely simplified the code a bit in courses.
2005-02-02 02:41:56 +00:00
defacer
c6a2a401ed Making the "Add block..." menu list alphabetically sorted ;-) 2005-02-01 07:59:09 +00:00
defacer
3edc57e189 Even more automation: now blocks_execute_url_action() checks if the user
has sufficient rights to execute the action automatically. It's therefore
safe to call without ANY checks being done first.
2005-02-01 06:55:02 +00:00
defacer
da71112bed Refining the way that blocks work: now you don't have to know anything
about what editing the blocks adds to your URL. blocklib will take care
of that internally.
2005-02-01 06:24:28 +00:00
defacer
7542a4e574 Dropping the use of MOODLE_PAGE_COURSE <gasp>!
The new constant is PAGE_COURSE_VIEW, and it's more streamlined with the
new CSS-related ids for 1.5. There are great possibilities for the future
here, so we 're getting ready.

On the other hand, this has to be the ugliest hack I 've ever inflicted
on any program (look at pagelib.php). Thankfully it will only stay for just
a little while.
2005-01-31 02:18:15 +00:00
defacer
febeb16113 Removing two error-suppression prefixes (@). I think that in the end,
the only purpose they served was to make debugging harder.
2005-01-27 23:57:37 +00:00
defacer
1345403a7c Renaming 4 internal-use-only class methods by prefixing an underscore.
I want to make a point that people should NOT be calling them.
2005-01-25 02:57:30 +00:00
moodler
7933cc6be5 Just a little bit more reobust in the face of badly-behaved blocks 2005-01-18 06:03:26 +00:00
defacer
3cacefda86 Fix for bug 2377:
Make it more difficult for instances with invalid blockid to be added to
mdl_block_instance. This could result in warnings, although nothing more
serious than that.

Credits to Eloy and especially Dan Marsden for reporting and providing info.
2005-01-17 14:26:17 +00:00
defacer
edb42f0924 Fix for bug 2328:
* When configuring a block instance, "Turn editing off" button is not
  shown anymore.

* When configuring a block instance, the breadcrumbs are now better,
  providing a link to the course page. This could be done in a much
  better way if we had a comprehensive template system but it will
  suffice for now.
2005-01-02 15:20:15 +00:00
defacer
9b12850043 Fix for bug 2241:
I hope this time I got everything changed to the new Page interface! I 'm
really sorry for messing up and breaking new installations... :(

Also moved the only two functions of the API outside the page_base class.
2004-11-29 04:19:05 +00:00