<?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 {
		$consentconfig = SimpleSAML_Configuration::getConfig('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();	
	}
	
}
?>
<?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 {
		$consentconfig = SimpleSAML_Configuration::getConfig('module_consentSimpleAdmin.php');
	
		// Parse consent config
		$consent_storage = sspmod_consent_Store::parseStoreConfig($consentconfig->getValue('store'));

		if (!is_callable(array($consent_storage, 'selftest'))) {
			/* Doesn't support a selftest. */
			return;
		}
		$testres = $consent_storage->selftest();
		if ($testres) {
			$hookinfo['info'][] = '[consentSimpleAdmin] Consent Storage selftest OK.';
		} else {
			$hookinfo['errors'][] = '[consentSimpleAdmin] Consent Storage selftest failed.';
		}

	} catch (Exception $e) {
		$hookinfo['errors'][] = '[consentSimpleAdmin] Error connecting to storage: ' . $e->getMessage();	
	}
	
}
?>
Use new selftest-function on database backend.
consentSimpleAdmin: Use new selftest-function on database backend.

git-svn-id: a243b28a2a52d65555a829a95c8c333076d39ae1@3309 44740490-163a-0410-bde0-09ae8108e29a
