From 86aa37ba1c67272a32ac6b68c203ad582cf55e02 Mon Sep 17 00:00:00 2001
From: Tim van Dijen <tvdijen@gmail.com>
Date: Thu, 4 Jan 2018 13:31:35 +0100
Subject: [PATCH] consent: remove unused method

---
 .../consent/lib/Consent/Store/Database.php    | 42 +++----------------
 1 file changed, 5 insertions(+), 37 deletions(-)

diff --git a/modules/consent/lib/Consent/Store/Database.php b/modules/consent/lib/Consent/Store/Database.php
index 6e5383fbb..d23f2c6a1 100644
--- a/modules/consent/lib/Consent/Store/Database.php
+++ b/modules/consent/lib/Consent/Store/Database.php
@@ -45,9 +45,9 @@ class sspmod_consent_Consent_Store_Database extends sspmod_consent_Store
     /**
      * The timeout of the database connection.
      *
-     * @var int|NULL
+     * @var int|null
      */
-    private $_timeout = NULL;
+    private $_timeout = null;
 
     /**
      * Database handle.
@@ -70,7 +70,6 @@ class sspmod_consent_Consent_Store_Database extends sspmod_consent_Store
     {
         parent::__construct($config);
 
-
         if (!array_key_exists('dsn', $config)) {
             throw new Exception('consent:Database - Missing required option \'dsn\'.');
         }
@@ -374,14 +373,13 @@ class sspmod_consent_Consent_Store_Database extends sspmod_consent_Store
      * ' services: Total number of services that has been given consent to
      *
      * @return array Array containing the statistics
-     * @TODO Change fixed table name to config option
      */
     public function getStatistics()
     {
         $ret = array();
 
         // Get total number of consents
-        $st = $this->_execute('SELECT COUNT(*) AS no FROM consent', array());
+        $st = $this->_execute('SELECT COUNT(*) AS no FROM '.$this->_table, array());
         
         if ($st === false) {
             return array();
@@ -394,7 +392,7 @@ class sspmod_consent_Consent_Store_Database extends sspmod_consent_Store
         // Get total number of users that has given consent
         $st = $this->_execute(
             'SELECT COUNT(*) AS no ' .
-            'FROM (SELECT DISTINCT hashed_user_id FROM consent ) AS foo',
+            'FROM (SELECT DISTINCT hashed_user_id FROM '.$this->_table.' ) AS foo',
             array()
         );
         
@@ -408,7 +406,7 @@ class sspmod_consent_Consent_Store_Database extends sspmod_consent_Store
 
         // Get total number of services that has been given consent to
         $st = $this->_execute(
-            'SELECT COUNT(*) AS no FROM (SELECT DISTINCT service_id FROM consent) AS foo',
+            'SELECT COUNT(*) AS no FROM (SELECT DISTINCT service_id FROM '.$this->_table.') AS foo',
             array()
         );
         
@@ -424,36 +422,6 @@ class sspmod_consent_Consent_Store_Database extends sspmod_consent_Store
     }
 
 
-    /**
-     * Create consent table.
-     *
-     * This function creates the table with consent data.
-     *
-     * @return True if successful, false if not.
-     *
-     * @TODO Remove this function since it is not used
-     */
-    private function _createTable()
-    {
-        $db = $this->_getDB();
-        if ($db === false) {
-            return false;
-        }
-
-        $res = $this->db->exec(
-            'CREATE TABLE ' . $this->_table . ' (consent_date TIMESTAMP NOT null, usage_date TIMESTAMP NOT null,' .
-            'hashed_user_id VARCHAR(80) NOT null, service_id VARCHAR(255) NOT null, attribute VARCHAR(80) NOT null,' .
-            'UNIQUE (hashed_user_id, service_id)'
-        );
-        if ($res === false) {
-            SimpleSAML\Logger::error('consent:Database - Failed to create table \'' . $this->_table . '\'.');
-            return false;
-        }
-
-        return true;
-    }
-
-
     /**
      * Get database handle.
      *
-- 
GitLab