Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
moodle-tool_lifecycle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elc
moodle-tool_lifecycle
Commits
b574c77e
Commit
b574c77e
authored
5 years ago
by
Justus Dieckmann
Committed by
Tobias Reischmann
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Privacy: Implement get_metadata, get_contexts_for_userid, export_user_data
parent
be223a7e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
classes/privacy/provider.php
+117
-0
117 additions, 0 deletions
classes/privacy/provider.php
lang/en/tool_lifecycle.php
+10
-0
10 additions, 0 deletions
lang/en/tool_lifecycle.php
with
127 additions
and
0 deletions
classes/privacy/provider.php
0 → 100644
+
117
−
0
View file @
b574c77e
<?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/>.
/**
* Privacy Subsystem implementation for tool_lifecycle.
*
* @package tool_lifecycle
* @copyright 2019 Justus Dieckmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace
tool_lifecycle\privacy
;
use
core_privacy
\local\metadata\collection
;
use
core_privacy\local\request\approved_contextlist
;
use
core_privacy
\local\request\context
;
use
core_privacy
\local\request\contextlist
;
use
core_privacy\local\request\core_user_data_provider
;
use
core_privacy
\local\request\writer
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
/**
* Implementation of the privacy subsystem plugin provider for the Life Cycle tool.
*
* @copyright 2019 Justus Dieckmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
provider
implements
\core_privacy\local\metadata\provider
,
\core_privacy\local\request\plugin\provider
{
/**
* Returns meta data about this system.
*
* @param collection $collection The initialised collection to add items to.
* @return collection A listing of user data stored through this system.
*/
public
static
function
get_metadata
(
collection
$collection
):
collection
{
$collection
->
add_database_table
(
'tool_lifecycle_action_log'
,
array
(
'processid'
=>
'privacy:metadata:tool_lifecycle_action_log:processid'
,
'workflowid'
=>
'privacy:metadata:tool_lifecycle_action_log:workflowid'
,
'courseid'
=>
'privacy:metadata:tool_lifecycle_action_log:courseid'
,
'stepindex'
=>
'privacy:metadata:tool_lifecycle_action_log:stepindex'
,
'time'
=>
'privacy:metadata:tool_lifecycle_action_log:time'
,
'userid'
=>
'privacy:metadata:tool_lifecycle_action_log:userid'
,
'action'
=>
'privacy:metadata:tool_lifecycle_action_log:action'
),
'privacy:metadata:tool_lifecycle_action_log'
);
return
$collection
;
}
/**
* Get the list of contexts that contain user information for the specified user.
*
* @param int $userid The user to search.
* @return contextlist $contextlist The contextlist containing the list of contexts used in this plugin.
*/
public
static
function
get_contexts_for_userid
(
int
$userid
):
contextlist
{
global
$DB
;
$contextlist
=
new
contextlist
();
if
(
$DB
->
record_exists
(
'tool_lifecycle_action_log'
,
array
(
'userid'
=>
$userid
)))
{
$contextlist
->
add_system_context
();
}
return
$contextlist
;
}
/**
* Export all user data for the specified user, in the specified contexts.
*
* @param approved_contextlist $contextlist The approved contexts to export information for.
*/
public
static
function
export_user_data
(
approved_contextlist
$contextlist
)
{
global
$DB
;
foreach
(
$contextlist
->
get_contexts
()
as
$context
)
{
if
(
$context
->
contextlevel
===
CONTEXT_SYSTEM
)
{
$records
=
$DB
->
get_records
(
'tool_lifecycle_action_log'
,
array
(
'userid'
=>
$contextlist
->
get_user
()
->
id
));
$writer
=
writer
::
with_context
(
$contextlist
->
current
());
foreach
(
$records
as
$record
)
{
$writer
->
export_data
([
'tool_lifecycle'
,
'action_log'
],
$record
);
}
}
}
}
/**
* Delete all data for all users in the specified context.
*
* @param context $context The specific context to delete data for.
*/
public
static
function
delete_data_for_all_users_in_context
(
\context
$context
)
{
}
/**
* Delete all user data for the specified user, in the specified contexts.
*
* @param approved_contextlist $contextlist The approved contexts and user information to delete information for.
*/
public
static
function
delete_data_for_user
(
approved_contextlist
$contextlist
)
{
// TODO: Implement delete_data_for_user() method.
}
}
This diff is collapsed.
Click to expand it.
lang/en/tool_lifecycle.php
+
10
−
0
View file @
b574c77e
...
...
@@ -176,3 +176,13 @@ $string['restore_trigger_does_not_exist'] = 'The trigger {$a} is not installed,
$string
[
'process_triggered_event'
]
=
'A process has been triggered'
;
$string
[
'process_proceeded_event'
]
=
'A process has been proceeded'
;
$string
[
'process_rollback_event'
]
=
'A process has been rolled back'
;
// Privacy API
$string
[
'privacy:metadata:tool_lifecycle_action_log'
]
=
'A log of actions done by course managers.'
;
$string
[
'privacy:metadata:tool_lifecycle_action_log:processid'
]
=
'ID of the Process the action was done in.'
;
$string
[
'privacy:metadata:tool_lifecycle_action_log:workflowid'
]
=
'ID of the Workflow the action was done in.'
;
$string
[
'privacy:metadata:tool_lifecycle_action_log:courseid'
]
=
'ID of the Course the action was done for'
;
$string
[
'privacy:metadata:tool_lifecycle_action_log:stepindex'
]
=
'Index of the Step in the Workflow, the action was done for.'
;
$string
[
'privacy:metadata:tool_lifecycle_action_log:time'
]
=
'Time when the action was done.'
;
$string
[
'privacy:metadata:tool_lifecycle_action_log:userid'
]
=
'ID of the user that did the action.'
;
$string
[
'privacy:metadata:tool_lifecycle_action_log:action'
]
=
'Identifier of the action that was done.'
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment