Created
March 21, 2018 02:10
-
-
Save andrewnicols/8c613c803d81ddd9c8d44ca8a80c8ffe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('CLI_SCRIPT', true); | |
require_once('config.php'); | |
$user = \core_user::get_user(2); | |
\core\session\manager::init_empty_session(); | |
\core\session\manager::set_user($user); | |
$manager = new \core_privacy\manager(); | |
$approvedlist = new \core_privacy\local\request\contextlist_collection($user->id); | |
$contextlists = $manager->get_contexts_for_userid($user->id); | |
foreach ($contextlists as $contextlist) { | |
$approvedlist->add_contextlist(new \core_privacy\local\request\approved_contextlist( | |
$user, | |
$contextlist->get_component(), | |
$contextlist->get_contextids() | |
)); | |
} | |
$exportedcontent = $manager->export_user_data($approvedlist); | |
echo "\n"; | |
echo "== File was successfully exported to {$exportedcontent}\n"; | |
$basedir = make_temp_directory('privacy'); | |
$exportpath = make_unique_writable_directory($basedir, true); | |
$fp = get_file_packer(); | |
$fp->extract_to_pathname($exportedcontent, $exportpath); | |
echo "== File export was uncompressed to {$exportpath}\n"; | |
echo "============================================================================\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment