From 45fd740d5cc43161bef0bcb77ca899dcfd6af565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no> Date: Tue, 17 Feb 2009 09:55:11 +0000 Subject: [PATCH] Add sanity check to check if database connection is OK. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1281 44740490-163a-0410-bde0-09ae8108e29a --- .../hooks/hook_sanitycheck.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 modules/consentSimpleAdmin/hooks/hook_sanitycheck.php diff --git a/modules/consentSimpleAdmin/hooks/hook_sanitycheck.php b/modules/consentSimpleAdmin/hooks/hook_sanitycheck.php new file mode 100644 index 000000000..9c207dc3a --- /dev/null +++ b/modules/consentSimpleAdmin/hooks/hook_sanitycheck.php @@ -0,0 +1,28 @@ +<?php +/** + * + * @param array &$hookinfo hookinfo + */ +function consentSimpleAdmin_hook_sanitycheck(&$hookinfo) { + assert('is_array($hookinfo)'); + assert('array_key_exists("errors", $hookinfo)'); + assert('array_key_exists("info", $hookinfo)'); + + try { + $config = SimpleSAML_Configuration::getInstance(); + $consentconfig = $config->copyFromBase('consentSimpleAdminConfig', 'module_consentSimpleAdmin.php'); + + // Parse consent config + $consent_storage = sspmod_consent_Store::parseStoreConfig($consentconfig->getValue('store')); + + // Get all consents for user + $stats = $consent_storage->getStatistics(); + + $hookinfo['info'][] = '[consentSimpleAdmin] Consent Storage connection OK.'; + + } catch (Exception $e) { + $hookinfo['errors'][] = '[consentSimpleAdmin] Error connecting to storage: ' . $e->getMessage(); + } + +} +?> \ No newline at end of file -- GitLab