Skip to content
Snippets Groups Projects
Commit 3a20131c authored by Thijs Kinkhorst's avatar Thijs Kinkhorst
Browse files

sanitycheck: formatting changes psr-2, no functional changes

parent 790639cc
No related branches found
No related tags found
No related merge requests found
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
$config = array ( $config = array (
/* /*
* Do you want to generate statistics using the cron module? If so, specify which cron tag to use. * Do you want to generate statistics using the cron module? If so, specify which cron tag to use.
* Examples: daily, weekly * Examples: daily, weekly
* To not run statistics in cron, set value to * To not run statistics in cron, set value to
* 'cron_tag' => NULL, * 'cron_tag' => null,
*/ */
'cron_tag' => 'hourly', 'cron_tag' => 'hourly',
); );
...@@ -4,39 +4,38 @@ ...@@ -4,39 +4,38 @@
* *
* @param array &$croninfo Output * @param array &$croninfo Output
*/ */
function sanitycheck_hook_cron(&$croninfo) { function sanitycheck_hook_cron(&$croninfo)
assert('is_array($croninfo)'); {
assert('array_key_exists("summary", $croninfo)'); assert('is_array($croninfo)');
assert('array_key_exists("tag", $croninfo)'); assert('array_key_exists("summary", $croninfo)');
assert('array_key_exists("tag", $croninfo)');
SimpleSAML\Logger::info('cron [sanitycheck]: Running cron in cron tag [' . $croninfo['tag'] . '] '); SimpleSAML\Logger::info('cron [sanitycheck]: Running cron in cron tag [' . $croninfo['tag'] . '] ');
try { try {
$sconfig = SimpleSAML_Configuration::getOptionalConfig('config-sanitycheck.php');
$sconfig = SimpleSAML_Configuration::getOptionalConfig('config-sanitycheck.php');
$cronTag = $sconfig->getString('cron_tag', NULL); $cronTag = $sconfig->getString('cron_tag', null);
if ($cronTag === NULL || $cronTag !== $croninfo['tag']) { if ($cronTag === null || $cronTag !== $croninfo['tag']) {
return; return;
} }
$info = array(); $info = array();
$errors = array(); $errors = array();
$hookinfo = array( $hookinfo = array(
'info' => &$info, 'info' => &$info,
'errors' => &$errors, 'errors' => &$errors,
); );
SimpleSAML\Module::callHooks('sanitycheck', $hookinfo);
if (count($errors) > 0) {
foreach ($errors AS $err) {
$croninfo['summary'][] = 'Sanitycheck error: ' . $err;
}
}
} catch (Exception $e) {
$croninfo['summary'][] = 'Error executing sanity check: ' . $e->getMessage();
}
SimpleSAML\Module::callHooks('sanitycheck', $hookinfo);
if (count($errors) > 0) {
foreach ($errors AS $err) {
$croninfo['summary'][] = 'Sanitycheck error: ' . $err;
}
}
} catch (Exception $e) {
$croninfo['summary'][] = 'Error executing sanity check: ' . $e->getMessage();
}
} }
...@@ -4,14 +4,14 @@ ...@@ -4,14 +4,14 @@
* *
* @param array &$links The links on the frontpage, split into sections. * @param array &$links The links on the frontpage, split into sections.
*/ */
function sanitycheck_hook_frontpage(&$links) { function sanitycheck_hook_frontpage(&$links)
assert('is_array($links)'); {
assert('array_key_exists("links", $links)'); assert('is_array($links)');
assert('array_key_exists("links", $links)');
$links['config']['santitycheck'] = array(
'href' => SimpleSAML\Module::getModuleURL('sanitycheck/index.php'),
'text' => array('en' => 'Sanity check of your SimpleSAMLphp setup'),
'shorttext' => array('en' => 'SanityCheck'),
);
$links['config']['santitycheck'] = array(
'href' => SimpleSAML\Module::getModuleURL('sanitycheck/index.php'),
'text' => array('en' => 'Sanity check of your SimpleSAMLphp setup'),
'shorttext' => array('en' => 'SanityCheck'),
);
} }
...@@ -4,16 +4,16 @@ ...@@ -4,16 +4,16 @@
* *
* @param array &$moduleinfo The links on the frontpage, split into sections. * @param array &$moduleinfo The links on the frontpage, split into sections.
*/ */
function sanitycheck_hook_moduleinfo(&$moduleinfo) { function sanitycheck_hook_moduleinfo(&$moduleinfo)
assert('is_array($moduleinfo)'); {
assert('array_key_exists("info", $moduleinfo)'); assert('is_array($moduleinfo)');
assert('array_key_exists("info", $moduleinfo)');
$moduleinfo['info']['sanitycheck'] = array( $moduleinfo['info']['sanitycheck'] = array(
'name' => array('en' => 'Sanity check'), 'name' => array('en' => 'Sanity check'),
'description' => array('en' => 'This module adds functionality for other modules to provide santity checks.'), 'description' => array('en' => 'This module adds functionality for other modules to provide santity checks.'),
'dependencies' => array('core'),
'uses' => array('cron'),
);
'dependencies' => array('core'),
'uses' => array('cron'),
);
} }
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
* *
* @param array &$hookinfo hookinfo * @param array &$hookinfo hookinfo
*/ */
function sanitycheck_hook_sanitycheck(&$hookinfo) { function sanitycheck_hook_sanitycheck(&$hookinfo)
assert('is_array($hookinfo)'); {
assert('array_key_exists("errors", $hookinfo)'); assert('is_array($hookinfo)');
assert('array_key_exists("info", $hookinfo)'); assert('array_key_exists("errors", $hookinfo)');
assert('array_key_exists("info", $hookinfo)');
$hookinfo['info'][] = '[sanitycheck] At least the sanity check itself is working :)'; $hookinfo['info'][] = '[sanitycheck] At least the sanity check itself is working :)';
} }
<?php <?php
$config = SimpleSAML_Configuration::getInstance(); $config = SimpleSAML_Configuration::getInstance();
$info = array(); $info = array();
$errors = array(); $errors = array();
$hookinfo = array( $hookinfo = array(
'info' => &$info, 'info' => &$info,
'errors' => &$errors, 'errors' => &$errors,
); );
SimpleSAML\Module::callHooks('sanitycheck', $hookinfo); SimpleSAML\Module::callHooks('sanitycheck', $hookinfo);
if (isset($_REQUEST['output']) && $_REQUEST['output'] == 'text') { if (isset($_REQUEST['output']) && $_REQUEST['output'] == 'text') {
if (count($errors) === 0) { if (count($errors) === 0) {
echo 'OK'; echo 'OK';
} else { } else {
echo 'FAIL'; echo 'FAIL';
} }
exit; exit;
} }
$t = new SimpleSAML_XHTML_Template($config, 'sanitycheck:check.tpl.php'); $t = new SimpleSAML_XHTML_Template($config, 'sanitycheck:check.tpl.php');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment