Posted by liquidcms on January 4, 2008 at 6:43pm
Is there a good way to have modules disabled or enabled for a specific site?
To clarify:
- i have a multiple user development project
- our std practice is that each developer gets their own site folder where they can use the $conf array to define system variables (e.g. site email address)
this is a very useful Drupal feature.
Is there anyway to add this same concept for modules status (enable/disable)?
ideally something as simple as adding:
db_query("update system set status = 0 where name = 'securepages'");would work; but settings.php runs before bootstrap so we don't get access to commands such as db_query.
so short of doing this with base php db commands; is there a cleaner way?
Comments
If each user gets their own
If each user gets their own site, why not just give them access to the modules page? To have different sets of modules enabled, you need a different database for each site already, might as well give the users free reign.
-----
Übercart -- One cart to rule them all.
thanks but this is not the
thanks but this is not the problem i am trying to solve - this is to improve the sites multi-developer environment. All site developers of course already do have access to everything - including all admin pages. The point was to not have to go into db and re-set everything every time a new copy of production db is pulled.
The ability i am looking for would be exactly the way the $conf array is used. So developers would be able to enable/disable certain modules regardless of what is in the db and specific to their own test/devel needs.
Peter Lindstrom
LiquidCMS - Content Management Solution Experts
Peter Lindstrom
LiquidCMS - Content Solution Experts
That is a different problem
Since this sounds like a private project, you may be able to get away with creating some nodes that run the PHP to enable the modules. Of course, I would have it check to see those modules are already enabled so they aren't run when they need to be edited. If your databases are reset by a script, it might be able to view those nodes with cURL or something. That would be a little more reliable than viewing the nodes manually.
-----
Übercart -- One cart to rule them all.
lockdown on hook_init
I just tried this. It works (D5 anyway).
function system_init doesn't exist, so I hijacked the name.
Inserted into the localized settings.php
<?php/**
* A fake hook - use to ensure a few security things are locked down on the dev
* site. Can't do it directly as DB is unavailable at settings.php time, so
* insert these actions into the bootstrap
*
* dman 2010-04-15 <a href="http://drupal.org/node/206368
" title="http://drupal.org/node/206368
" rel="nofollow">http://drupal.org/node/206368
</a> */
function system_init() {
if (! module_exists('securesite')) {
db_query("update system set status = 1 where name = 'securesite'");
}
}
?>
My env also has frequent dumps and DB syncs from live back to dev, but dev needs to be locked. Don't want to leave it open by accident.
.dan. is the New Zealand Drupal Developer working on Government Web Standards
I threw the following into
I threw the following into hook_init() in a custom module:
<?php// If we're on local.example.com, disable dblog module if enabled.
if (variable_get('running_on_localhost', FALSE) && module_exists('dblog')) {
module_disable(array('dblog'));
}
?>
I simply add the 'running_on_localhost' configuration variable in settings.php for the local environment...
__________________
Me, to webchick, in IRC: "ice cream kittens!"
Work: Midwestern Mac, LLC | Personal: Life is a Prayer.com
For D6 and latest version of
For D6 and latest version of securesite, in settings.php you can set
$conf['securesite_enabled'] = 0;So, just install the module, and enable and configure it. Then set that variable appropriately in each version of your site.
--
Tom
www.systemseed.com - drupal development. drupal training. drupal support.
That sounds much tidier!
That sounds much tidier! Thanks!
.dan. is the New Zealand Drupal Developer working on Government Web Standards
Environment
Might also be worth looking at http://drupal.org/project/environment
Environment "Creates a drush command line interface for setting an environment for a site instance".
_
yet another option http://drupal.org/project/system_features
_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.