added $scope to getModuleAlias,
added dependency/conflict checks
This commit is contained in:
parent
31f1e75beb
commit
b27e550dde
|
@ -44,10 +44,13 @@ while ($stay<7) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns the alias name of a module
|
// returns the alias name of a module
|
||||||
function getModuleAlias($name) {
|
function getModuleAlias($name, $scope) {
|
||||||
$eval = '$return = '.$name.'::get_alias();';
|
return call_user_func(array($name, "get_alias"), $scope);
|
||||||
eval ($eval);
|
}
|
||||||
return $return;
|
|
||||||
|
// returns if the module is a base module
|
||||||
|
function is_base_module($name, $scope) {
|
||||||
|
return call_user_func(array($name, "is_base_module"), $scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns a hash array (module name => dependencies) of all user module dependencies
|
// returns a hash array (module name => dependencies) of all user module dependencies
|
||||||
|
@ -69,6 +72,62 @@ function getModulesDependencies($scope) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// checks if there are missing dependencies between modules
|
||||||
|
// $selected is an array of selected module names
|
||||||
|
// $deps is an array of module dependencies
|
||||||
|
// returns false if no misssing dependency was found
|
||||||
|
// returns an array of array(selected module, depending module) if missing dependencies were found
|
||||||
|
function check_module_depends($selected, $deps) {
|
||||||
|
$ret = array();
|
||||||
|
for ($m = 0; $m < sizeof($selected); $m++) { // check selected modules
|
||||||
|
for ($i = 0; $i < sizeof($deps[$selected[$m]]['depends']); $i++) { // check dependencies of module
|
||||||
|
// check if we have OR-combined modules
|
||||||
|
if (is_array($deps[$selected[$m]]['depends'][$i])) {
|
||||||
|
// one of the elements is needed
|
||||||
|
$found = false;
|
||||||
|
$depends = $deps[$selected[$m]]['depends'][$i];
|
||||||
|
for ($d = 0; $d < sizeof($depends); $d++) {
|
||||||
|
if (in_array($depends[$d], $selected)) {
|
||||||
|
$found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (! $found) {
|
||||||
|
// missing dependency, add to return value
|
||||||
|
$ret[] = array($selected[$m], implode(" || ", $depends));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// single dependency
|
||||||
|
if (! in_array($deps[$selected[$m]]['depends'][$i], $selected)) {
|
||||||
|
// missing dependency, add to return value
|
||||||
|
$ret[] = array($selected[$m], $deps[$selected[$m]]['depends'][$i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sizeof($ret) > 0) return $ret;
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// checks if there are conflicts between modules
|
||||||
|
// $selected is an array of selected module names
|
||||||
|
// $deps is an array of module dependencies
|
||||||
|
// returns false if no conflict was found
|
||||||
|
// returns an array of array(selected module, conflicting module) if conflicts were found
|
||||||
|
function check_module_conflicts($selected, $deps) {
|
||||||
|
$ret = array();
|
||||||
|
for ($m = 0; $m < sizeof($selected); $m++) {
|
||||||
|
for ($i = 0; $i < sizeof($deps[$selected[$m]]['conflicts']); $i++) {
|
||||||
|
if (in_array($deps[$selected[$m]]['conflicts'][$i], $selected)) {
|
||||||
|
$ret[] = array($selected[$m], $deps[$selected[$m]]['conflicts'][$i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sizeof($ret) > 0) return $ret;
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
|
||||||
// returns an array with all available user module names
|
// returns an array with all available user module names
|
||||||
function getAvailableModules($scope) {
|
function getAvailableModules($scope) {
|
||||||
// scope = suer, group, host, ....
|
// scope = suer, group, host, ....
|
||||||
|
@ -79,7 +138,7 @@ function getAvailableModules($scope) {
|
||||||
$entry = substr($entry, 0, strpos($entry, '.'));
|
$entry = substr($entry, 0, strpos($entry, '.'));
|
||||||
$eval = '$module = '.$entry."::get_dependencies(".$scope.");";
|
$eval = '$module = '.$entry."::get_dependencies(".$scope.");";
|
||||||
eval ($eval);
|
eval ($eval);
|
||||||
if ($module != -1) $return[] = getModuleAlias($entry);
|
if ($module != -1) $return[] = getModuleAlias($entry, $scope);
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue