您需要在模块文件中创建一个函数(DIR = modules/YourModuleFolder/YourModuleName.php)。这里
function vtlib_handler($modulename, $event_type) {
if ($event_type == 'module.postinstall') {
$this->setModuleRelatedDependencies();
} else if ($event_type == 'module.disabled') {
$this->unsetModuleRelatedDependencies();
} else if ($event_type == 'module.enabled') {
$this->setModuleRelatedDependencies();
} else if ($event_type == 'module.preuninstall') {
$this->unsetModuleRelatedDependencies();
} else if ($event_type == 'module.preupdate') {
// TODO Handle actions before this module is updated.
} else if ($event_type == 'module.postupdate') {
// TODO Handle actions before this module is updated.
}
}
然后在您的文件中创建这些函数setModuleRelatedDependencies或unsetModuleRelatedDependencies
像这样
function setModuleRelatedDependencies(){
global $log;
$moduleName = Vtiger_Module::getInstance('YourModule');
foreach ($this->dependentModules as $module) { //Defind How many module you want in dependent
$moduleInstance = Vtiger_Module::getInstance($module);
$moduleInstance->setRelatedList($moduleName, 'YourModule', array(),'get_dependents_list' );
}
$log->fatal('Successfully added Module Related lists');
}
这是为了卸载你的插件
function unsetModuleRelatedDependencies(){
global $log;
$moduleName = Vtiger_Module::getInstance('YourModule');
foreach ($this->dependentModules as $module) {//Defind How many module you want in dependent
$moduleInstance = Vtiger_Module::getInstance($module);
$moduleInstance->unsetRelatedList($moduleName, 'YourModule', 'get_dependents_list');
}
$log->fatal('Successfully removed Module Related lists');
}