MDL-61889 tool_dataprivacy: Fix CI errors

This commit is contained in:
Jun Pataleta 2018-05-17 17:00:03 +08:00
parent 6153be6850
commit dd26f1be12
23 changed files with 109 additions and 83 deletions

View file

@ -234,6 +234,7 @@ define(['jquery', 'core/str', 'core/ajax', 'core/notification', 'core/templates'
}, },
fail: Notification.exception fail: Notification.exception
}]); }]);
return;
}).catch(Notification.exception); }).catch(Notification.exception);
}; };

View file

@ -34,7 +34,6 @@ define(['jquery', 'core/url', 'core/str'], function($, url, str) {
* *
* @param {object} targetnode The node that we want to expand / collapse * @param {object} targetnode The node that we want to expand / collapse
* @param {object} thisnode The node that was clicked. * @param {object} thisnode The node that was clicked.
* @return {null}
*/ */
expandCollapse: function(targetnode, thisnode) { expandCollapse: function(targetnode, thisnode) {
if (targetnode.hasClass('hide')) { if (targetnode.hasClass('hide')) {
@ -58,7 +57,6 @@ define(['jquery', 'core/url', 'core/str'], function($, url, str) {
* Expand or collapse all nodes on this page. * Expand or collapse all nodes on this page.
* *
* @param {string} nextstate The next state to change to. * @param {string} nextstate The next state to change to.
* @return {null}
*/ */
expandCollapseAll: function(nextstate) { expandCollapseAll: function(nextstate) {
var currentstate = (nextstate == 'visible') ? 'hide' : 'visible'; var currentstate = (nextstate == 'visible') ? 'hide' : 'visible';
@ -75,6 +73,7 @@ define(['jquery', 'core/url', 'core/str'], function($, url, str) {
str.get_string(currentstate, 'tool_dataprivacy').then(function(langString) { str.get_string(currentstate, 'tool_dataprivacy').then(function(langString) {
$('.tool_dataprivacy-expand-all').html(langString); $('.tool_dataprivacy-expand-all').html(langString);
return;
}).catch(Notification.exception); }).catch(Notification.exception);
$(':header i.fa').each(function() { $(':header i.fa').each(function() {

View file

@ -24,6 +24,8 @@
require_once(__DIR__ . '/../../../config.php'); require_once(__DIR__ . '/../../../config.php');
require_login(null, false);
$url = new moodle_url("/admin/tool/dataprivacy/categories.php"); $url = new moodle_url("/admin/tool/dataprivacy/categories.php");
$title = get_string('editcategories', 'tool_dataprivacy'); $title = get_string('editcategories', 'tool_dataprivacy');

View file

@ -197,7 +197,7 @@ class api {
} else { } else {
// If not a DPO, only users with the capability to make data requests for the user should be allowed. // If not a DPO, only users with the capability to make data requests for the user should be allowed.
// (e.g. users with the Parent role, etc). // (e.g. users with the Parent role, etc).
if (!api::can_create_data_request_for_user($foruser)) { if (!self::can_create_data_request_for_user($foruser)) {
$forusercontext = \context_user::instance($foruser); $forusercontext = \context_user::instance($foruser);
throw new required_capability_exception($forusercontext, throw new required_capability_exception($forusercontext,
'tool/dataprivacy:makedatarequestsforchildren', 'nopermissions', ''); 'tool/dataprivacy:makedatarequestsforchildren', 'nopermissions', '');

View file

@ -289,7 +289,8 @@ class data_registry {
* @param int $forcedcategoryvalue Use this value as if this was this context level category. * @param int $forcedcategoryvalue Use this value as if this was this context level category.
* @return int[] * @return int[]
*/ */
public static function get_effective_default_contextlevel_purpose_and_category($contextlevel, $forcedpurposevalue = false, $forcedcategoryvalue = false) { public static function get_effective_default_contextlevel_purpose_and_category($contextlevel, $forcedpurposevalue = false,
$forcedcategoryvalue = false) {
list($purposeid, $categoryid) = self::get_defaults($contextlevel); list($purposeid, $categoryid) = self::get_defaults($contextlevel);

View file

@ -23,10 +23,7 @@
*/ */
namespace tool_dataprivacy; namespace tool_dataprivacy;
use tool_dataprivacy\api; use core_privacy\manager;
use tool_dataprivacy\purpose;
use tool_dataprivacy\context_instance;
use tool_dataprivacy\data_registry;
use tool_dataprivacy\expired_context; use tool_dataprivacy\expired_context;
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
@ -90,7 +87,7 @@ abstract class expired_contexts_manager {
return $numprocessed; return $numprocessed;
} }
$privacymanager = new \core_privacy\manager(); $privacymanager = new manager();
$privacymanager->set_observer(new \tool_dataprivacy\manager_observer()); $privacymanager->set_observer(new \tool_dataprivacy\manager_observer());
foreach ($this->get_context_levels() as $level) { foreach ($this->get_context_levels() as $level) {
@ -118,11 +115,11 @@ abstract class expired_contexts_manager {
/** /**
* Deletes user data from the provided context. * Deletes user data from the provided context.
* *
* @param \core_privacy\manager $privacymanager * @param manager $privacymanager
* @param \tool_dataprivacy\expired_context $expiredctx * @param expired_context $expiredctx
* @return \context|false * @return \context|false
*/ */
protected function delete_expired_context(\core_privacy\manager $privacymanager, \tool_dataprivacy\expired_context $expiredctx) { protected function delete_expired_context(manager $privacymanager, expired_context $expiredctx) {
$context = \context::instance_by_id($expiredctx->get('contextid'), IGNORE_MISSING); $context = \context::instance_by_id($expiredctx->get('contextid'), IGNORE_MISSING);
if (!$context) { if (!$context) {

View file

@ -23,8 +23,7 @@
*/ */
namespace tool_dataprivacy; namespace tool_dataprivacy;
use tool_dataprivacy\purpose; use core_privacy\manager;
use tool_dataprivacy\context_instance;
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
@ -110,11 +109,11 @@ class expired_user_contexts extends \tool_dataprivacy\expired_contexts_manager {
* *
* Overwritten to delete the user. * Overwritten to delete the user.
* *
* @param \core_privacy\manager $privacymanager * @param manager $privacymanager
* @param \tool_dataprivacy\expired_context $expiredctx * @param expired_context $expiredctx
* @return \context|false * @return \context|false
*/ */
protected function delete_expired_context(\core_privacy\manager $privacymanager, \tool_dataprivacy\expired_context $expiredctx) { protected function delete_expired_context(manager $privacymanager, expired_context $expiredctx) {
$context = \context::instance_by_id($expiredctx->get('contextid'), IGNORE_MISSING); $context = \context::instance_by_id($expiredctx->get('contextid'), IGNORE_MISSING);
if (!$context) { if (!$context) {
api::delete_expired_context($expiredctx->get('contextid')); api::delete_expired_context($expiredctx->get('contextid'));

View file

@ -27,6 +27,7 @@ defined('MOODLE_INTERNAL') || die();
use tool_dataprivacy\api; use tool_dataprivacy\api;
use tool_dataprivacy\data_registry; use tool_dataprivacy\data_registry;
use tool_dataprivacy\purpose;
/** /**
* Context instance data form. * Context instance data form.
@ -186,12 +187,12 @@ class context_instance extends \core\form\persistent {
/** /**
* Returns the purpose display text. * Returns the purpose display text.
* *
* @param \tool_dataprivacy\purpose $effectivepurpose * @param purpose $effectivepurpose
* @param int $retentioncontextlevel * @param int $retentioncontextlevel
* @param \context $context The context, just for displaying (filters) purposes. * @param \context $context The context, just for displaying (filters) purposes.
* @return string * @return string
*/ */
protected static function get_retention_display_text(\tool_dataprivacy\purpose $effectivepurpose, $retentioncontextlevel, \context $context) { protected static function get_retention_display_text(purpose $effectivepurpose, $retentioncontextlevel, \context $context) {
global $PAGE; global $PAGE;
$renderer = $PAGE->get_renderer('tool_dataprivacy'); $renderer = $PAGE->get_renderer('tool_dataprivacy');

View file

@ -132,7 +132,7 @@ class helper {
'contextlevel' => CONTEXT_USER 'contextlevel' => CONTEXT_USER
]; ];
// The final list of users that we will return; // The final list of users that we will return.
$finalresults = []; $finalresults = [];
// Our prospective list of users. // Our prospective list of users.

View file

@ -64,7 +64,7 @@ class purpose extends \core\persistent {
// Replicate self::read. // Replicate self::read.
$this->from_record($data); $this->from_record($data);
// Using validate() as self::$validated is private. // Validate the purpose record.
$this->validate(); $this->validate();
// Now replicate the parent constructor. // Now replicate the parent constructor.

View file

@ -25,6 +25,8 @@
require_once(__DIR__ . '/../../../config.php'); require_once(__DIR__ . '/../../../config.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/dataprivacy/lib.php'); require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/dataprivacy/lib.php');
require_login(null, false);
$filter = optional_param('filter', CONTEXT_COURSE, PARAM_INT); $filter = optional_param('filter', CONTEXT_COURSE, PARAM_INT);
$url = new moodle_url('/admin/tool/dataprivacy/datadeletion.php'); $url = new moodle_url('/admin/tool/dataprivacy/datadeletion.php');

View file

@ -25,6 +25,8 @@
require_once(__DIR__ . '/../../../config.php'); require_once(__DIR__ . '/../../../config.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/dataprivacy/lib.php'); require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/dataprivacy/lib.php');
require_login(null, false);
$contextlevel = optional_param('contextlevel', CONTEXT_SYSTEM, PARAM_INT); $contextlevel = optional_param('contextlevel', CONTEXT_SYSTEM, PARAM_INT);
$contextid = optional_param('contextid', 0, PARAM_INT); $contextid = optional_param('contextid', 0, PARAM_INT);

View file

@ -25,6 +25,8 @@
require_once("../../../config.php"); require_once("../../../config.php");
require_once('lib.php'); require_once('lib.php');
require_login(null, false);
$url = new moodle_url('/admin/tool/dataprivacy/datarequests.php'); $url = new moodle_url('/admin/tool/dataprivacy/datarequests.php');
$title = get_string('datarequests', 'tool_dataprivacy'); $title = get_string('datarequests', 'tool_dataprivacy');

View file

@ -25,6 +25,8 @@
require_once(__DIR__ . '/../../../config.php'); require_once(__DIR__ . '/../../../config.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/dataprivacy/lib.php'); require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/dataprivacy/lib.php');
require_login(null, false);
$url = new \moodle_url('/admin/tool/dataprivacy/defaults.php'); $url = new \moodle_url('/admin/tool/dataprivacy/defaults.php');
$title = get_string('setdefaults', 'tool_dataprivacy'); $title = get_string('setdefaults', 'tool_dataprivacy');

View file

@ -24,6 +24,8 @@
require_once(__DIR__ . '/../../../config.php'); require_once(__DIR__ . '/../../../config.php');
require_login(null, false);
$id = optional_param('id', 0, PARAM_INT); $id = optional_param('id', 0, PARAM_INT);
$url = new \moodle_url('/admin/tool/dataprivacy/editcategory.php', array('id' => $id)); $url = new \moodle_url('/admin/tool/dataprivacy/editcategory.php', array('id' => $id));

View file

@ -24,6 +24,8 @@
require_once(__DIR__ . '/../../../config.php'); require_once(__DIR__ . '/../../../config.php');
require_login(null, false);
$id = optional_param('id', 0, PARAM_INT); $id = optional_param('id', 0, PARAM_INT);
$url = new \moodle_url('/admin/tool/dataprivacy/editpurpose.php', array('id' => $id)); $url = new \moodle_url('/admin/tool/dataprivacy/editpurpose.php', array('id' => $id));

View file

@ -25,6 +25,8 @@
require_once(__DIR__ . '/../../../config.php'); require_once(__DIR__ . '/../../../config.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/dataprivacy/lib.php'); require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/dataprivacy/lib.php');
require_login(null, false);
$contextlevel = optional_param('contextlevel', CONTEXT_SYSTEM, PARAM_INT); $contextlevel = optional_param('contextlevel', CONTEXT_SYSTEM, PARAM_INT);
$contextid = optional_param('contextid', 0, PARAM_INT); $contextid = optional_param('contextid', 0, PARAM_INT);

View file

@ -24,6 +24,8 @@
require_once(__DIR__ . '/../../../config.php'); require_once(__DIR__ . '/../../../config.php');
require_login(null, false);
$url = new moodle_url("/admin/tool/dataprivacy/purposes.php"); $url = new moodle_url("/admin/tool/dataprivacy/purposes.php");
$title = get_string('editpurposes', 'tool_dataprivacy'); $title = get_string('editpurposes', 'tool_dataprivacy');

View file

@ -46,7 +46,7 @@
} }
}} }}
<div classs="container-fluid"> <div class="container-fluid">
<hr /> <hr />
<div class="row"> <div class="row">
{{#compliant}} {{#compliant}}
@ -64,17 +64,17 @@
</div> </div>
{{#compliant}} {{#compliant}}
<div class="hide" data-section="{{raw_component}}" aria-expanded="false"> <div class="hide" data-section="{{raw_component}}" aria-expanded="false" role="contentinfo">
{{#metadata}} {{#metadata}}
<hr /> <hr />
<div class="p-l-3"> <div class="p-l-3">
<dl class="row"> <dl class="row">
<dt class="span3 col-xs-3"> <dt class="span3 col-xs-3">
{{#link}} {{#link}}
<a href="#{{name}}"><h5 style="word-wrap:break-word">{{name}}</h5></a> <a href="#{{name}}"><strong style="word-wrap:break-word">{{name}}</strong></a>
{{/link}} {{/link}}
{{^link}} {{^link}}
<h5 style="word-wrap:break-word">{{name}}</h5> <strong style="word-wrap:break-word">{{name}}</strong>
{{/link}} {{/link}}
<div class="small text-muted" style="word-wrap:break-word">{{type}}</div> <div class="small text-muted" style="word-wrap:break-word">{{type}}</div>
</dt> </dt>

File diff suppressed because one or more lines are too long

View file

@ -55,7 +55,7 @@
<h3 id="{{plugin_type_raw}}">{{#pix}}t/collapsed, moodle, {{#str}}expandplugintype, tool_dataprivacy{{/str}}{{/pix}}{{plugin_type}}</h3> <h3 id="{{plugin_type_raw}}">{{#pix}}t/collapsed, moodle, {{#str}}expandplugintype, tool_dataprivacy{{/str}}{{/pix}}{{plugin_type}}</h3>
</a> </a>
</div> </div>
<div class="hide p-b-1" data-plugintarget="{{plugin_type_raw}}" aria-expanded="false"> <div class="hide p-b-1" data-plugintarget="{{plugin_type_raw}}" aria-expanded="false" role="contentinfo">
{{#plugins}} {{#plugins}}
{{> tool_dataprivacy/component_status}} {{> tool_dataprivacy/component_status}}
{{/plugins}} {{/plugins}}

View file

@ -47,59 +47,68 @@
"datarequestsurl": "#" "datarequestsurl": "#"
} }
}} }}
<style> <!DOCTYPE html>
table, th, td { <html>
border: 1px solid black; <head>
padding: 0.5em; <meta charset="UTF-8">
} <style>
</style> table, th, td {
<div> border: 1px solid black;
<p>{{#str}}emailsalutation, tool_dataprivacy, {{dponame}}{{/str}}</p> padding: 0.5em;
<p>{{#str}}requestemailintro, tool_dataprivacy{{/str}}</p> }
<table> </style>
<tr> <title>{{#str}}datarequestemailsubject, tool_dataprivacy, {{requesttype}}{{/str}}</title>
<th scope="row"> </head>
{{#str}}requesttype, tool_dataprivacy{{/str}} <body>
</th> <div>
<td> <p>{{#str}}emailsalutation, tool_dataprivacy, {{dponame}}{{/str}}</p>
{{requesttype}} <p>{{#str}}requestemailintro, tool_dataprivacy{{/str}}</p>
</td> <table>
</tr> <tr>
<tr> <th scope="row">
<th scope="row"> {{#str}}requesttype, tool_dataprivacy{{/str}}
{{#str}}requestfor, tool_dataprivacy{{/str}} </th>
</th> <td>
<td> {{requesttype}}
{{requestfor}} </td>
</td> </tr>
</tr> <tr>
{{^forself}} <th scope="row">
<tr> {{#str}}requestfor, tool_dataprivacy{{/str}}
<th scope="row"> </th>
{{#str}}requestby, tool_dataprivacy{{/str}} <td>
</th> {{requestfor}}
<td> </td>
{{requestedby}} </tr>
</td> {{^forself}}
</tr> <tr>
{{/forself}} <th scope="row">
<tr> {{#str}}requestby, tool_dataprivacy{{/str}}
<th scope="row"> </th>
{{#str}}requestcomments, tool_dataprivacy{{/str}} <td>
</th> {{requestedby}}
<td> </td>
{{{requestcomments}}} </tr>
</td> {{/forself}}
</tr> <tr>
<tr> <th scope="row">
<th scope="row"> {{#str}}requestcomments, tool_dataprivacy{{/str}}
{{#str}}daterequested, tool_dataprivacy{{/str}} </th>
</th> <td>
<td> {{{requestcomments}}}
{{requestdate}} </td>
</td> </tr>
</tr> <tr>
</table> <th scope="row">
<hr> {{#str}}daterequested, tool_dataprivacy{{/str}}
<a href="{{datarequestsurl}}">{{#str}}viewrequest, tool_dataprivacy{{/str}}</a> </th>
</div> <td>
{{requestdate}}
</td>
</tr>
</table>
<hr>
<a href="{{datarequestsurl}}">{{#str}}viewrequest, tool_dataprivacy{{/str}}</a>
</div>
</body>
</html>

View file

@ -30,6 +30,7 @@
Example context (json): Example context (json):
{ {
"title": "Data request modal title"
} }
}} }}
{{< core/modal }} {{< core/modal }}