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) { ...@@ -14,31 +14,38 @@ function metarefresh_hook_cron(&$croninfo) {
try { try {
$config = SimpleSAML_Configuration::getInstance(); $config = SimpleSAML_Configuration::getInstance();
$mconfig = SimpleSAML_Configuration::getConfig('config-metarefresh.php'); $mconfig = SimpleSAML_Configuration::getConfig('config-metarefresh.php');
$sets = $mconfig->getValue('sets'); $sets = $mconfig->getConfigList('sets');
if (count($sets) < 1) return;
foreach ($sets AS $setkey => $set) { foreach ($sets AS $setkey => $set) {
// Only process sets where cron matches the current cron tag. // 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 . ']'); SimpleSAML_Logger::info('cron [metarefresh]: Executing set [' . $setkey . ']');
$expire = NULL; $expireAfter = $set->getInteger('expireAfter', NULL);
if (array_key_exists('expireAfter', $set)) $expire = time() + $set['expireAfter']; if ($expireAfter !== NULL) {
$expire = time() + $expireAfter;
$metaloader = new sspmod_metarefresh_MetaLoader($expire); } else {
$expire = NULL;
foreach($set['sources'] AS $source) { }
$metaloader = new sspmod_metarefresh_MetaLoader($expire);
foreach($set->getArray('sources') AS $source) {
SimpleSAML_Logger::debug('cron [metarefresh]: In set [' . $setkey . '] loading source [' . $source['src'] . ']'); SimpleSAML_Logger::debug('cron [metarefresh]: In set [' . $setkey . '] loading source [' . $source['src'] . ']');
$metaloader->loadSource($source); $metaloader->loadSource($source);
} }
$metaloader->writeMetadataFiles($config->resolvePath($set['outputDir']));
$outputDir = $set->getString('outputDir');
$outputDir = $config->resolvePath($outputDir);
$metaloader->writeMetadataFiles($outputDir);
} }
} catch (Exception $e) { } catch (Exception $e) {
$croninfo['summary'][] = 'Error during metarefresh: ' . $e->getMessage(); $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