Skip to content
Snippets Groups Projects
Commit d8b9ade1 authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg
Browse files

Add a new hook to let a module add information about it self, also add a...

Add a new hook to let a module add information about it self, also add a sanitycheck to resolve missing module dependencies 

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@999 44740490-163a-0410-bde0-09ae8108e29a
parent faf9d93b
No related branches found
No related tags found
No related merge requests found
......@@ -31,5 +31,22 @@ function core_hook_sanitycheck(&$hookinfo) {
$hookinfo['errors'][] = '[core] You are running PHP version ' . phpversion() . '. SimpleSAMLphp requires version >= 5.1.2, and reccomends version >= 5.2. Please upgrade!';
}
$info = array();
$mihookinfo = array(
'info' => &$info,
);
$availmodules = SimpleSAML_Module::getModules();
SimpleSAML_Module::callHooks('moduleinfo', $mihookinfo);
foreach($info AS $mi => $i) {
if (isset($i['dependencies']) && is_array($i['dependencies'])) {
foreach ($i['dependencies'] AS $dep) {
// $hookinfo['info'][] = '[core] Module ' . $mi . ' requires ' . $dep;
if (!in_array($dep, $availmodules)) {
$hookinfo['errors'][] = '[core] Module dependency not met: ' . $mi . ' requires ' . $dep;
}
}
}
}
}
?>
\ No newline at end of file
<?php
/**
* This hook lets the module describe itself.
*
* @param array &$moduleinfo The links on the frontpage, split into sections.
*/
function modinfo_hook_moduleinfo(&$moduleinfo) {
assert('is_array($moduleinfo)');
assert('array_key_exists("info", $moduleinfo)');
$moduleinfo['info']['modinfo'] = array(
'name' => array('en' => 'Module information'),
'description' => array('en' => 'This module lists all available modules, and tells whether they are enabled or not.'),
'dependencies' => array('core'),
'uses' => array('sanitycheck'),
);
}
?>
\ No newline at end of file
......@@ -8,7 +8,7 @@ $modinfo = array();
foreach($modules as $m) {
$modinfo[$m] = array(
'enabled' => SimpleSAML_Module::isModuleEnabled($m),
);
);
}
$config = SimpleSAML_Configuration::getInstance();
......
<?php
/**
* This hook lets the module describe itself.
*
* @param array &$moduleinfo The links on the frontpage, split into sections.
*/
function sanitycheck_hook_moduleinfo(&$moduleinfo) {
assert('is_array($moduleinfo)');
assert('array_key_exists("info", $moduleinfo)');
$moduleinfo['info']['sanitycheck'] = array(
'name' => array('en' => 'Sanity check'),
'description' => array('en' => 'This module adds functionality for other modules to provide santity checks.'),
'dependencies' => array('core'),
'uses' => array('cron'),
);
}
?>
\ No newline at end of file
......@@ -9,11 +9,7 @@ function sanitycheck_hook_sanitycheck(&$hookinfo) {
assert('array_key_exists("errors", $hookinfo)');
assert('array_key_exists("info", $hookinfo)');
$hookinfo['info'][] = '[sanitycheck] At least the sanity check it self is working :)';
}
?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment