There's a way to include an install routine in your module, but it will only get executed
after it is installed.
And even if you can insert some kind of check within xoops_version.php , I don't see how you could really prevent the users from installing your module anyway.
So here are the few ideas I have, try playing with them...
1) To check if a module is available:
$hmod =& xoops_gethandler('module');
if ( false === ( $mod = $hmod->getByDirName('requiredmodname') ) ) {
// unavail
} else {
// avail
}
2) There's a tut on how to use the module install feature
here.
3) What I would try is (both untested):
- Check if module is installed within xoops_version.php
and enclose all the $modversion[] declarations within an
if block.
Bad point: 'A module file not found' will appear, not a user-friendly message.
OR
Implement the 'onInstall' function as described in the dev wiki, check the required module, and if not echo() an error message before uninstalling your module (not quite efficient as your mod will get installed, then uninstalled).
So you would do:
if ( false === ......) {
$mymod = $hmod->getByDirName('myownmodule');
$hmod->delete($mymod);
return false;
} else {
return true;
}
As I said, I'm not promising anything, so play around.
And anyway, I think this feature should really be here, so I'll add it on my list for XOOPS 2.1
Skalpa.>