From 6e3d9fee00e2608c5b5b4fd7366c47c8b7dbe609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no> Date: Fri, 14 Mar 2008 11:01:29 +0000 Subject: [PATCH] Adding a new function for deleting consent into ConsentStorage git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@416 44740490-163a-0410-bde0-09ae8108e29a --- lib/SimpleSAML/Consent/ConsentStorage.php | 46 ++++++++++++++++++++--- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/lib/SimpleSAML/Consent/ConsentStorage.php b/lib/SimpleSAML/Consent/ConsentStorage.php index 9561d58e3..f92c362fe 100644 --- a/lib/SimpleSAML/Consent/ConsentStorage.php +++ b/lib/SimpleSAML/Consent/ConsentStorage.php @@ -85,19 +85,55 @@ class SimpleSAML_Consent_Storage { * Store user consent in database */ public function store($user_id, $targeted_id, $attribute_hash) { - - SimpleSAML_Logger::debug('Library - ConsentStorage store(): user_id : ' . $user_id); - SimpleSAML_Logger::debug('Library - ConsentStorage store(): targeted_id : ' . $targeted_id); - SimpleSAML_Logger::debug('Library - ConsentStorage store(): attribute_hash : ' . $attribute_hash); - /** * insert new entry into consent storage. */ $stmt = $this->dbh->prepare("REPLACE INTO consent VALUES (?,?,?,NOW(),NOW())"); $stmt->execute(array($user_id, $targeted_id, $attribute_hash)); + $rows = $stmt->rowCount(); + SimpleSAML_Logger::debug('Library - ConsentStorage store(): user_id : ' . $user_id); + SimpleSAML_Logger::debug('Library - ConsentStorage store(): targeted_id : ' . $targeted_id); + SimpleSAML_Logger::debug('Library - ConsentStorage store(): attribute_hash : ' . $attribute_hash); + + SimpleSAML_Logger::debug('Library - ConsentStorage store(): Number of rows : [' . $rows . ']'); + + return ($rows === 1); } + /** + * Delete specific user consent in database + */ + public function delete($user_id, $targeted_id, $attribute_hash) { + + SimpleSAML_Logger::debug('Library - ConsentStorage delete(): user_id : ' . $user_id); + SimpleSAML_Logger::debug('Library - ConsentStorage delete(): targeted_id : ' . $targeted_id); + SimpleSAML_Logger::debug('Library - ConsentStorage delete(): attribute_hash : ' . $attribute_hash); + + /** + * delete specific entry from consent storage. + */ + $stmt = $this->dbh->prepare("DELETE FROM consent WHERE hashed_user_id = ? AND service_id = ? AND attribute = ?"); + $stmt->execute(array($user_id, $targeted_id, $attribute_hash)); + + return $stmt->rowCount(); + } + + /** + * Delete user consent in database + */ + public function deleteUserConsent($user_id) { + + SimpleSAML_Logger::debug('Library - ConsentStorage deleteUserConsent(): user_id : ' . $user_id); + + /** + * delete specific entry from consent storage. + */ + $stmt = $this->dbh->prepare("DELETE FROM consent WHERE hashed_user_id = ?"); + $stmt->execute(array($user_id)); + + return $stmt->rowCount(); + } } ?> \ No newline at end of file -- GitLab