From 1dc8bde9a54d1f652fc347c22f9b2ad76ae3096b Mon Sep 17 00:00:00 2001
From: Alexander Bias <alexander.bias@uni-ulm.de>
Date: Thu, 17 May 2018 12:31:48 +0200
Subject: [PATCH] Implement Privacy API

---
 CHANGES.md                     |  4 +++
 classes/privacy/provider.php   | 47 ++++++++++++++++++++++++++++++++++
 lang/en/auth_ldap_syncplus.php |  1 +
 version.php                    |  2 +-
 4 files changed, 53 insertions(+), 1 deletion(-)
 create mode 100644 classes/privacy/provider.php

diff --git a/CHANGES.md b/CHANGES.md
index 8ee4147..b89bea6 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -4,6 +4,10 @@ moodle-auth_ldap_syncplus
 Changes
 -------
 
+### Unreleased
+
+* 2018-05-16 - Implement Privacy API.
+
 ### v3.4-r3
 
 * 2018-02-07 - Bugfix: Login via email for first-time LDAP logins did not work if multiple LDAP contexts were configured; Credits to derhelge.
diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php
new file mode 100644
index 0000000..8b81de0
--- /dev/null
+++ b/classes/privacy/provider.php
@@ -0,0 +1,47 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Auth plugin "LDAP SyncPlus" - Privacy provider
+ *
+ * @package    auth_ldap_syncplus
+ * @copyright  2018 Alexander Bias, Ulm University <alexander.bias@uni-ulm.de>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+namespace auth_ldap_syncplus\privacy;
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Privacy Subsystem implementing null_provider.
+ *
+ * @package    auth_ldap_syncplus
+ * @copyright  2018 Alexander Bias, Ulm University <alexander.bias@uni-ulm.de>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class provider implements \core_privacy\local\metadata\null_provider {
+
+    /**
+     * Get the language string identifier with the component's language
+     * file to explain why this plugin stores no data.
+     *
+     * @return string
+     */
+    public static function get_reason() : string {
+        return 'privacy:metadata';
+    }
+}
diff --git a/lang/en/auth_ldap_syncplus.php b/lang/en/auth_ldap_syncplus.php
index 977f18b..13f5e12 100644
--- a/lang/en/auth_ldap_syncplus.php
+++ b/lang/en/auth_ldap_syncplus.php
@@ -30,6 +30,7 @@ $string['auth_ldap_syncplusdescription'] = 'This method provides authentication
                                   password are checked.';
 $string['auth_remove_deletewithgraceperiod'] = 'Suspend internal and fully delete internal after grace period';
 $string['nouserentriestosuspend'] = 'No user entries to be suspended';
+$string['privacy:metadata'] = 'The LDAP server (Sync Plus) authentication plugin does not store any personal data.';
 $string['removeuser_graceperiod'] = 'Fully deleting grace period';
 $string['removeuser_graceperiod_desc'] = 'After suspending a user internally, the synchronization script will wait for this number of days until the user will be fully deleted internal. If the user re-appears in LDAP within this grace period, the user will be reactivated. Note: This setting is only used if "Removed ext user" is set to "Suspend internal and fully delete internal after grace period"';
 $string['sync_script_createuser_enabled'] = 'If enabled (default), the synchronization script will create Moodle accounts for all LDAP users if they have never logged into Moodle before. If disabled, the synchronization script will not create Moodle accounts for all LDAP users.';
diff --git a/version.php b/version.php
index 304433e..97f2767 100644
--- a/version.php
+++ b/version.php
@@ -25,7 +25,7 @@
 defined('MOODLE_INTERNAL') || die();
 
 $plugin->component = 'auth_ldap_syncplus';
-$plugin->version = 2018020800;
+$plugin->version = 2018051600;
 $plugin->release = 'v3.4-r3';
 $plugin->requires = 2017111300;
 $plugin->maturity = MATURITY_STABLE;
-- 
GitLab