2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * This file contains the core_privacy\local\request helper.
20 * @package core_privacy
21 * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 namespace core_privacy\local\request;
26 defined('MOODLE_INTERNAL') || die();
29 * A class containing a set of data transformations for core data types.
31 * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36 * Translate a userid into the standard user format for exports.
38 * We have not determined if we will do this or not, but we provide the functionality and encourgae people to use
39 * it so that it can be retrospectively fitted if required.
41 * @param int $userid the userid to translate
44 public static function user(int $userid) {
45 // For the moment we do not think we should transform as this reveals information about other users.
46 // However this function is implemented should the need arise in the future.
51 * Translate a unix timestamp into a datetime string.
53 * @param int $datetime the unixtimestamp to translate.
54 * @return string The translated string.
56 public static function datetime($datetime) {
57 return userdate($datetime, get_string('strftimedaydatetime', 'langconfig'));
61 * Translate a unix timestamp into a date string.
63 * @param int $date the unixtimestamp to translate.
64 * @return string The translated string.
66 public static function date($date) {
67 return userdate($date, get_string('strftimedate', 'langconfig'));
71 * Translate a bool or int (0/1) value into a translated yes/no string.
73 * @param bool $value The value to translate
76 public static function yesno($value) {
78 return get_string('yes');
80 return get_string('no');