The following patch adds several functions that can be used by any module:
system_set_default_theme($theme)
block_set_status($module, $delta, $status, $theme)
block_set_position($module, $delta, $region, $position, $theme)
It also adds two functions to install.inc, which can only be called when that file is included:
drupal_install_module($module)
drupal_uninstall_module($module)
The uninstall function in particular calls a module's 'uninstall' hook, then *deletes* its entry from the system table. There's no UI for it yet, but the feature has been requested by a number of users -- modules would be expected to drop their tables and so on in the 'uninstall' hook.
The main purpose of all of these functions is to make more of Drupal's system management work available via API functions. With the installer, and the advent of install profiles, making it easier to do this work without a long list of db_query() calls is a good thing.
Comment | File | Size | Author |
---|---|---|---|
utility_functions.patch | 3.67 KB | eaton | |
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedI +1 the principle, I think having these available will be a good thing; they'll be useful in refactoring the modules/themes admin page.
Comment #2
Dries CreditAttribution: Dries commentedCan't we use these in core itself?
Comment #3
merlinofchaos CreditAttribution: merlinofchaos commentedDries: I sure hope so =)
Comment #4
eaton CreditAttribution: eaton commentedDries: Actually I'm in the process of making a new version of this patch that would use the same functions on admin/theme, admin/module, and so on. Once I'm finished with it (hopefully in the next day or so) even the install system would be able to use single-call 'install module x' functions.
So, yes. Eating our own dogfood, coming soon to a patch near you. :-)
Comment #5
eaton CreditAttribution: eaton commentedSome of the module install/enabling related functions in this patch ended up being important for an actual bug-fix over at http://drupal.org/node/76209. I've split out those changes in particular to that patch, and will be re-rolling a version of this patch that *just* includes the block and theme management code (as well as changes to system.module and block.module to use the new centralized functions.)
Comment #6
webchickWhile the patch still (surprisingly!) applies, I'm pretty sure the module_install and module_uninstall functions are totally irrelevant at this point. Marking CNW. It would be nice to have those block helper functions for install profiles.
Comment #7
catchComment #8
casey CreditAttribution: casey commentedWe do have now:
http://api.drupal.org/api/function/drupal_install_modules/7
http://api.drupal.org/api/function/drupal_uninstall_modules/7
Leaves this issue to:
system_set_default_theme($theme)
block_set_status($module, $delta, $status, $theme)
block_set_position($module, $delta, $region, $position, $theme)
Comment #9
valthebaldComment #22
quietone CreditAttribution: quietone as a volunteer commented@eaton, thanks for patch.
With the move to OO code this is not outdated.