模組開發 : Xoops 安裝與反安裝
原始出處 http://www.xoops.org/modules/mediawiki/index.php/Dev:xoops_install_uninstall
onInstall, onUninstall, onUpdate
模組安裝系統有個功能可以讓Xoops 核心在模組安裝或解除安裝後執行一段開發者指定的程式碼。編輯xoops_version.php:
$modversion['onInstall'] = 'install_funcs.php';
$modversion['onUninstall'] = 'install_funcs.php';
$modversion['onUpdate'] = 'install_funcs.php';
在install_funcs.php:
$xoopsMod 是該模組的$XoopsModule 物件。
function xoops_module_install_<DIRNAME>( $xoopsMod ) {
if (everythingIsOK) {
return true;
} else {
return false;
}
}
function xoops_module_uninstall_<DIRNAME>( $xoopsMod ) {
if (everythingIsOK) {
return true;
} else {
return false;
}
}
function xoops_module_update_<DIRNAME> ( $xoopsMod, $oldversion) {
switch ($oldversion) { //remember that version is multiplied with 100 to get an integer
case 100: //perform actions to upgrade from version 1.00
break;
case 110: //perform actions to upgrade from version 1.10
break;
}
}