Skip to content
Snippets Groups Projects
Commit 4f7857d4 authored by Patrick Radtke's avatar Patrick Radtke
Browse files

Use namespace for cron module; fix $summary display in www/cron.php

parent 35183510
No related branches found
No related tags found
No related merge requests found
...@@ -33,7 +33,7 @@ if (!array_key_exists('t', $options)) { ...@@ -33,7 +33,7 @@ if (!array_key_exists('t', $options)) {
} }
$tag = $options['t']; $tag = $options['t'];
$cron = new sspmod_cron_Cron(); $cron = new SimpleSAML\Module\cron\Cron();
if (!$cron->isValidTag($tag)) { if (!$cron->isValidTag($tag)) {
echo "Invalid tag option '$tag'.\n"; echo "Invalid tag option '$tag'.\n";
exit(2); exit(2);
......
<?php <?php
namespace SimpleSAML\Module\cron;
/** /**
* Handles interactions with SSP's cron system/hooks. * Handles interactions with SSP's cron system/hooks.
*/ */
class sspmod_cron_Cron class Cron
{ {
/** /**
* The configuration for the Cron module * The configuration for the Cron module
* @var SimpleSAML_Configuration * @var \SimpleSAML_Configuration
*/ */
private $cronconfig; private $cronconfig;
/* /*
* @param SimpleSAML_Configuration $cronconfig The cron configuration to use. If not specified defaults * @param \SimpleSAML_Configuration $cronconfig The cron configuration to use. If not specified defaults
* to `config/module_cron.php` * to `config/module_cron.php`
*/ */
public function __construct(SimpleSAML_Configuration $cronconfig = null) public function __construct(\SimpleSAML_Configuration $cronconfig = null)
{ {
if ($cronconfig == null) { if ($cronconfig == null) {
$cronconfig = SimpleSAML_Configuration::getConfig('module_cron.php'); $cronconfig = \SimpleSAML_Configuration::getConfig('module_cron.php');
} }
$this->cronconfig = $cronconfig; $this->cronconfig = $cronconfig;
} }
...@@ -42,10 +44,10 @@ class sspmod_cron_Cron ...@@ -42,10 +44,10 @@ class sspmod_cron_Cron
'tag' => $tag, 'tag' => $tag,
); );
SimpleSAML\Module::callHooks('cron', $croninfo); \SimpleSAML\Module::callHooks('cron', $croninfo);
foreach ($summary as $s) { foreach ($summary as $s) {
SimpleSAML\Logger::debug('Cron - Summary: ' . $s); \SimpleSAML\Logger::debug('Cron - Summary: ' . $s);
} }
return $croninfo; return $croninfo;
......
...@@ -10,7 +10,7 @@ if (!is_null($cronconfig->getValue('key'))) { ...@@ -10,7 +10,7 @@ if (!is_null($cronconfig->getValue('key'))) {
} }
} }
$cron = new sspmod_cron_Cron($cronconfig); $cron = new SimpleSAML\Module\cron\Cron();
if (!$cron->isValidTag($_REQUEST['tag'])) { if (!$cron->isValidTag($_REQUEST['tag'])) {
SimpleSAML\Logger::error('Cron - Illegal tag [' . $_REQUEST['tag'] . '].'); SimpleSAML\Logger::error('Cron - Illegal tag [' . $_REQUEST['tag'] . '].');
exit; exit;
...@@ -21,6 +21,7 @@ $url = \SimpleSAML\Utils\HTTP::getSelfURL(); ...@@ -21,6 +21,7 @@ $url = \SimpleSAML\Utils\HTTP::getSelfURL();
$time = date(DATE_RFC822); $time = date(DATE_RFC822);
$croninfo = $cron->runTag($_REQUEST['tag']); $croninfo = $cron->runTag($_REQUEST['tag']);
$summary = $croninfo['summary'];
if ($cronconfig->getValue('sendemail', TRUE) && count($summary) > 0) { if ($cronconfig->getValue('sendemail', TRUE) && count($summary) > 0) {
......
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