Skip to content

Commit 90fce1f

Browse files
committed
PR #32: Update Plugin for Moodle 3.5
Merge branch 'feature/Moodle35-PrivacyAPI'
2 parents 2c0966c + 7221e23 commit 90fce1f

File tree

6 files changed

+91
-4
lines changed

6 files changed

+91
-4
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ matrix:
4545

4646
before_install:
4747
- phpenv config-rm xdebug.ini
48-
- nvm install --lts
48+
- nvm install 8.9.4
4949
- cd ../..
5050
- composer selfupdate
5151
- composer create-project -n --no-dev --prefer-dist moodlerooms/moodle-plugin-ci ci ^2

classes/privacy/provider.php

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* Provider Class to implement the Privacy API of Moodle35.
19+
*
20+
* @package repository_owncloud
21+
* @copyright 2018 Nina Herrmann (Learnweb, University of Münster)
22+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23+
*/
24+
namespace repository_owncloud\privacy;
25+
26+
defined('MOODLE_INTERNAL') || die();
27+
28+
use core_privacy\local\metadata\collection;
29+
use core_privacy\local\request\approved_contextlist;
30+
use core_privacy\local\request\contextlist;
31+
32+
class provider implements
33+
\core_privacy\local\metadata\provider,
34+
\core_privacy\local\request\plugin\provider {
35+
use \core_privacy\local\legacy_polyfill;
36+
37+
public static function _get_metadata(collection $collection) {
38+
// The repository uses a user specific acesstoken (called confirmation token), provided by the oauthlib, ...
39+
// Saved in the session to access files. However, the oauthlib Privacy API is outsourced to the oauth2 plugin.
40+
// For this reason the collections includes the oauth2 subplugin.
41+
$collection->add_subsystem_link(
42+
'auth_oauth2',
43+
[],
44+
'privacy:metadata:auth_oauth2'
45+
);
46+
return $collection;
47+
}
48+
49+
/**
50+
* Get the list of contexts that contain user information for the specified user.
51+
*
52+
* @param int $userid The user to search.
53+
* @return contextlist $contextlist The contextlist containing the list of contexts used in this plugin.
54+
*/
55+
public static function _get_contexts_for_userid($userid) {
56+
return new contextlist();
57+
}
58+
59+
/**
60+
* Export all user data for the specified user, in the specified contexts.
61+
*
62+
* @param approved_contextlist $contextlist The approved contexts to export information for.
63+
*/
64+
public static function _export_user_data(approved_contextlist $contextlist) {
65+
}
66+
67+
/**
68+
* Delete all data for all users in the specified context.
69+
*
70+
* @param context $context The specific context to delete data for.
71+
*/
72+
public static function _delete_data_for_all_users_in_context(\context $context) {
73+
}
74+
75+
/**
76+
* Delete all user data for the specified user, in the specified contexts.
77+
*
78+
* @param approved_contextlist $contextlist The approved contexts and user information to delete information for.
79+
*/
80+
public static function _delete_data_for_user(approved_contextlist $contextlist) {
81+
}
82+
}

lang/en/repository_owncloud.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
For additional help with the OAuth 2 API please refer to the Moodle documentation.';
4141
$string['chooseissuer_link'] = 'OAuth_2_services';
4242
$string['oauth2serviceslink'] = '<a href="{$a}" title="Link to OAuth 2 services configuration">OAuth 2 services configuration</a>';
43+
$string['privacy:metadata:auth_oauth2'] = 'The repository uses a user specific acesstoken (called confirmation token), provided by the oauthlib, saved in the session to access files.';
4344

4445
// Exceptions.
4546
$string['configuration_exception'] = 'An error in the configuration of the OAuth 2 client occurred: {$a}';

tests/generator/lib.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
/**
2828
* Data generator for repository plugin.
2929
*
30+
* @group repository_owncloud
3031
* @package repository_owncloud
3132
* @copyright 2017 Project seminar (Learnweb, University of Münster)
3233
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -80,4 +81,4 @@ public function test_create_single_endpoint($issuerid, $endpointtype, $url="http
8081
$return = \core\oauth2\api::create_endpoint($endpoint);
8182
return $return;
8283
}
83-
}
84+
}

tests/lib_test.php

100755100644
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
/**
2828
* Class repository_owncloud_testcase
29+
* @group repository_owncloud
2930
* @copyright 2017 Project seminar (Learnweb, University of Münster)
3031
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3132
*/
@@ -560,6 +561,7 @@ public function test_logout() {
560561
$mock->expects($this->exactly(2))->method('log_out');
561562
$this->set_private_property($mock, 'client');
562563
$this->repo->options['ajax'] = false;
564+
$this->expectOutputString('<a target="_blank" rel="noopener noreferrer">Log in to your account</a><a target="_blank" rel="noopener noreferrer">Log in to your account</a>');
563565

564566
$this->assertEquals($this->repo->print_login(), $this->repo->logout());
565567

@@ -726,4 +728,4 @@ protected function get_initialised_return_array() {
726728

727729
return $ret;
728730
}
729-
}
731+
}

tests/ocs_test.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
/**
2828
* Class repository_owncloud_ocs_testcase
29+
* @group repository_owncloud
2930
* @copyright 2017 Jan Dageförde (Learnweb, University of Münster)
3031
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3132
*/
@@ -64,4 +65,4 @@ public function test_api_functions() {
6465
// Assert that relevant (and used) functions are actually present.
6566
$this->assertArrayHasKey('create_share', $functions);
6667
}
67-
}
68+
}

0 commit comments

Comments
 (0)