1
kevinv
Testing for an installed module during install?
  • 2003/11/24 21:04

  • kevinv

  • Friend of XOOPS

  • Posts: 44

  • Since: 2003/1/4 1


I'm working on a small module that requires another module be installed first. Is it possible in the xoops_version file to test if a module (or a table) is already installed and give an error message if it isn't?

2
skalpa
Re: Testing for an installed module during install?
  • 2003/11/25 0:00

  • skalpa

  • Quite a regular

  • Posts: 300

  • Since: 2003/4/16


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.>

Login

Who's Online

203 user(s) are online (130 user(s) are browsing Support Forums)


Members: 0


Guests: 203


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits