Skip to content
Snippets Groups Projects
Commit 80cd321c authored by Olav Morken's avatar Olav Morken
Browse files

metarefresh: Use Configuration class for parsing configuration.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1452 44740490-163a-0410-bde0-09ae8108e29a
parent ef43ddee
No related branches found
No related tags found
No related merge requests found
......@@ -14,31 +14,38 @@ function metarefresh_hook_cron(&$croninfo) {
try {
$config = SimpleSAML_Configuration::getInstance();
$mconfig = SimpleSAML_Configuration::getConfig('config-metarefresh.php');
$sets = $mconfig->getValue('sets');
if (count($sets) < 1) return;
$sets = $mconfig->getConfigList('sets');
foreach ($sets AS $setkey => $set) {
// Only process sets where cron matches the current cron tag.
if (!in_array($croninfo['tag'], $set['cron'])) continue;
$cronTags = $set->getArray('cron');
if (!in_array($croninfo['tag'], $cronTags)) continue;
SimpleSAML_Logger::info('cron [metarefresh]: Executing set [' . $setkey . ']');
$expire = NULL;
if (array_key_exists('expireAfter', $set)) $expire = time() + $set['expireAfter'];
$metaloader = new sspmod_metarefresh_MetaLoader($expire);
foreach($set['sources'] AS $source) {
$expireAfter = $set->getInteger('expireAfter', NULL);
if ($expireAfter !== NULL) {
$expire = time() + $expireAfter;
} else {
$expire = NULL;
}
$metaloader = new sspmod_metarefresh_MetaLoader($expire);
foreach($set->getArray('sources') AS $source) {
SimpleSAML_Logger::debug('cron [metarefresh]: In set [' . $setkey . '] loading source [' . $source['src'] . ']');
$metaloader->loadSource($source);
}
$metaloader->writeMetadataFiles($config->resolvePath($set['outputDir']));
$outputDir = $set->getString('outputDir');
$outputDir = $config->resolvePath($outputDir);
$metaloader->writeMetadataFiles($outputDir);
}
} catch (Exception $e) {
$croninfo['summary'][] = 'Error during metarefresh: ' . $e->getMessage();
}
}
?>
\ 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