Skip to content
Snippets Groups Projects
Commit 6e3d9fee authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg
Browse files

Adding a new function for deleting consent into ConsentStorage

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@416 44740490-163a-0410-bde0-09ae8108e29a
parent 95b9047b
No related branches found
No related tags found
No related merge requests found
...@@ -85,19 +85,55 @@ class SimpleSAML_Consent_Storage { ...@@ -85,19 +85,55 @@ class SimpleSAML_Consent_Storage {
* Store user consent in database * Store user consent in database
*/ */
public function store($user_id, $targeted_id, $attribute_hash) { 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. * insert new entry into consent storage.
*/ */
$stmt = $this->dbh->prepare("REPLACE INTO consent VALUES (?,?,?,NOW(),NOW())"); $stmt = $this->dbh->prepare("REPLACE INTO consent VALUES (?,?,?,NOW(),NOW())");
$stmt->execute(array($user_id, $targeted_id, $attribute_hash)); $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
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