Skip to content

Commit

Permalink
MDL-63919 tool_dataprivacy: admin & notify fixes
Browse files Browse the repository at this point in the history
This includes the following:

1) Replace $ADMIN->id by get_admin()->id. The former doesn't exist.
2) Only change the notify parameter when it has not been specified
   at creation time (null). If specified, observe it.
3) Set the current user in tests to admin, able to create those
   requests.
  • Loading branch information
stronk7 authored and andrewnicols committed Nov 10, 2018
1 parent c0ac0bd commit 51894a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions admin/tool/dataprivacy/classes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public static function is_site_dpo($userid) {
*/
public static function create_data_request($foruser, $type, $comments = '',
$creationmethod = data_request::DATAREQUEST_CREATION_MANUAL) {
global $USER, $ADMIN;
global $USER;

$datarequest = new data_request();
// The user the request is being made for.
Expand All @@ -245,7 +245,7 @@ public static function create_data_request($foruser, $type, $comments = '',
// NOTE: This should probably be changed. We should leave the default value for $requestinguser if
// the request is not explicitly created by a specific user.
$requestinguser = (isguestuser() && $creationmethod == data_request::DATAREQUEST_CREATION_AUTO) ?
$ADMIN->id : $USER->id;
get_admin()->id : $USER->id;
// The user making the request.
$datarequest->set('requestedby', $requestinguser);
// Set status.
Expand Down
4 changes: 4 additions & 0 deletions admin/tool/dataprivacy/tests/user_deleted_observer_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public function test_create_delete_data_request_automatic_creation_disabled() {
*/
public function test_create_delete_data_request_export_data_request_preexists() {
$this->resetAfterTest();
$this->setAdminUser();

// Enable automatic creation of delete data requests.
set_config('automaticdeletionrequests', 1, 'tool_dataprivacy');
Expand All @@ -106,6 +107,7 @@ public function test_create_delete_data_request_export_data_request_preexists()
*/
public function test_create_delete_data_request_ongoing_delete_data_request_preexists() {
$this->resetAfterTest();
$this->setAdminUser();

// Enable automatic creation of delete data requests.
set_config('automaticdeletionrequests', 1, 'tool_dataprivacy');
Expand All @@ -130,6 +132,7 @@ public function test_create_delete_data_request_ongoing_delete_data_request_pree
*/
public function test_create_delete_data_request_canceled_delete_data_request_preexists() {
$this->resetAfterTest();
$this->setAdminUser();

// Enable automatic creation of delete data requests.
set_config('automaticdeletionrequests', 1, 'tool_dataprivacy');
Expand Down Expand Up @@ -159,6 +162,7 @@ public function test_create_delete_data_request_canceled_delete_data_request_pre
*/
public function test_create_delete_data_request_completed_delete_data_request_preexists() {
$this->resetAfterTest();
$this->setAdminUser();

// Enable automatic creation of delete data requests.
set_config('automaticdeletionrequests', 1, 'tool_dataprivacy');
Expand Down

0 comments on commit 51894a8

Please sign in to comment.