diff --git a/.travis.yml b/.travis.yml index 1b085f9..3d1aacc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,23 +18,18 @@ cache: php: - 7.0 - 7.1 - - 7.2 env: - DB=pgsql MOODLE_BRANCH=MOODLE_33_STABLE - DB=mysqli MOODLE_BRANCH=MOODLE_33_STABLE - - DB=mysqli MOODLE_BRANCH=MOODLE_34_STABLE - - DB=mysqli MOODLE_BRANCH=master matrix: include: - php: 5.6 - env: DB=mysqli MOODLE_BRANCH=MOODLE_33_STABLE # Moodle 3.4+ requires 7.0.0 + env: DB=mysqli MOODLE_BRANCH=MOODLE_33_STABLE # Moodle 3.3 is still compatible with PHP 5.6 exclude: - - php: 7.2 + - php: 7.1 env: DB=mysqli MOODLE_BRANCH=MOODLE_33_STABLE - - php: 7.2 - env: DB=pgsql MOODLE_BRANCH=MOODLE_33_STABLE before_install: - phpenv config-rm xdebug.ini diff --git a/CHANGES.md b/CHANGES.md index daf634a..36e3121 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +# v1.3.0.0 (Build: 2018040900) +Starting from this versione the minor number indicates the supported Moodle version: +_x.3.y.z_ means that this version supports Moodle 3.3 but not 3.4+. +- Implemented the Moodle Privacy API + # v1.0.4 (Build: 2017121000) - Fixed an error when the course summary is not provided. diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php new file mode 100644 index 0000000..3113e45 --- /dev/null +++ b/classes/privacy/provider.php @@ -0,0 +1,54 @@ +. + +/** + * Privacy Subsystem implementation for local_twittercard. + * + * @package local_twittercard + * @copyright 2018 Matteo Scaramuccia + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace local_twittercard\privacy; + +defined('MOODLE_INTERNAL') || die(); + +// Backward compat. +interface_exists('\core_privacy\local\metadata\null_provider') || die(); + +// 3.3 runs even on PHP 5.6 so 'return type declaration' is not supported: +// the privacy null_provider interface has been implemented in 3.3 accordingly. + +/** + * Privacy Subsystem implementation for local_twittercard implementing null_provider. + * + * @package local_twittercard + * @copyright 2018 Matteo Scaramuccia + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class provider implements + // This plugin does not store any personal user data. + \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() { + return 'privacy:metadata'; + } +} diff --git a/lang/en/local_twittercard.php b/lang/en/local_twittercard.php index 154c033..32e17c4 100644 --- a/lang/en/local_twittercard.php +++ b/lang/en/local_twittercard.php @@ -30,6 +30,7 @@ $string['enabled'] = 'Enabled'; $string['enabled_help'] = 'Enable a Twitter summary card for courses.'; $string['pluginname'] = 'Twitter card'; +$string['privacy:metadata'] = 'The Twitter Card local plugin displays information from the Course, but does not effect or store any data itself.'; $string['twittercard'] = 'Twitter card'; $string['twittersite'] = 'Twitter site'; $string['twittersite_help'] = 'The Twitter @username of website the card should be attributed to.'; diff --git a/tests/privacy_test.php b/tests/privacy_test.php new file mode 100644 index 0000000..ba80e20 --- /dev/null +++ b/tests/privacy_test.php @@ -0,0 +1,49 @@ +. + +/** + * Tests for the Privacy API implementation in Twitter summary card. + * + * @package local_twittercard + * @copyright 2018 Matteo Scaramuccia + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +/** + * Class local_twittercard_privacy_testcase + * + * @package local_twittercard + * @copyright 2017 Matteo Scaramuccia + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class local_twittercard_privacy_testcase extends advanced_testcase { + /** + * Tests that local_twittercard actually implements the Privacy API null_provider. + */ + public function test_null_provider() { + if (!interface_exists('\core_privacy\local\metadata\null_provider')) { + $this->markTestSkipped('The Moodle code does not implement the Moodle Privacy API'); + } + + $this->assertTrue(class_exists('\local_twittercard\privacy\provider')); + $this->assertEquals( + [ 'core_privacy\local\metadata\null_provider' => 'core_privacy\local\metadata\null_provider' ], + class_implements('\local_twittercard\privacy\provider') + ); + } +} diff --git a/version.php b/version.php index 3122ca5..9d135d4 100644 --- a/version.php +++ b/version.php @@ -28,8 +28,13 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'local_twittercard'; -$plugin->version = 2017121000; -$plugin->release = '1.0.4 (Build: 2017121000)'; +// HACK - Do not install this plugin version on Moodle 3.4+. +global $CFG, $branch; +$currentbranch = isset($CFG->branch) ? $CFG->branch : $branch; +if ($currentbranch === '33') { + $plugin->version = 2018040900; + $plugin->release = '1.3.0.0 (Build: 2018040900)'; +} $plugin->requires = 2017051500; $plugin->maturity = MATURITY_STABLE; $plugin->cron = 0;