Merge branch 'MDL-36412-m23' of git://github.com/sammarshallou/moodle into MOODLE_23_...
[moodle.git] / backup / util / helper / backup_anonymizer_helper.class.php
CommitLineData
69dd0c8c
EL
1<?php
2
3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
18/**
19 * @package moodlecore
20 * @subpackage backup-helper
21 * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25/**
26 * Helper class for anonymization of data
27 *
28 * This functions includes a collection of methods that are invoked
29 * from the backup process when anonymization services have been
30 * requested.
31 *
32 * The name of each method must be "process_parentname_name", as defined
33 * byt the @anonymizer_final_element final element class, where
34 * parentname is the name ob the parent tag and name the name of the tag
35 * contents to be anonymized (i.e. process_user_username) with one param
36 * being the value to anonymize.
37 *
38 * Note: current implementation of anonymization is pretty simple, just some
39 * sequential values are used. If we want more elaborated generation, it
40 * can be replaced later (using generators or wathever). Don't forget we must
41 * ensure some fields (username, idnumber, email) are unique always.
42 *
43 * TODO: Improve to use more advanced anonymization
44 *
45 * TODO: Finish phpdocs
46 */
47class backup_anonymizer_helper {
48
49 public static function process_user_auth($value) {
50 return 'manual'; // Set them to manual always
51 }
52
53 public static function process_user_username($value) {
54 static $counter = 0;
55 $counter++;
56 return 'anon' . $counter; // Just a counter
57 }
58
59 public static function process_user_idnumber($value) {
60 return ''; // Just blank it
61 }
62
63 public static function process_user_firstname($value) {
64 static $counter = 0;
65 $counter++;
66 return 'anonfirstname' . $counter; // Just a counter
67 }
68
69 public static function process_user_lastname($value) {
70 static $counter = 0;
71 $counter++;
72 return 'anonlastname' . $counter; // Just a counter
73 }
74
75 public static function process_user_email($value) {
76 static $counter = 0;
77 $counter++;
78 return 'anon' . $counter . '@doesntexist.com'; // Just a counter
79 }
80
482aac65
EL
81 public static function process_user_icq($value) {
82 return ''; // Clean icq
83 }
84
85 public static function process_user_skype($value) {
86 return ''; // Clean skype
87 }
88
89 public static function process_user_yahoo($value) {
90 return ''; // Clean yahoo
91 }
92
93 public static function process_user_aim($value) {
94 return ''; // Clean aim
95 }
96
97 public static function process_user_msn($value) {
98 return ''; // Clean msn
99 }
100
101 public static function process_user_phone1($value) {
102 return ''; // Clean phone1
103 }
104
105 public static function process_user_phone2($value) {
106 return ''; // Clean phone2
107 }
108
109 public static function process_user_institution($value) {
110 return ''; // Clean institution
111 }
112
113 public static function process_user_department($value) {
114 return ''; // Clean department
115 }
116
117 public static function process_user_address($value) {
118 return ''; // Clean address
119 }
120
121 public static function process_user_city($value) {
122 return 'Perth'; // Set city
123 }
124
125 public static function process_user_country($value) {
126 return 'AU'; // Set country
127 }
128
69dd0c8c
EL
129 public static function process_user_lastip($value) {
130 return '127.0.0.1'; // Set lastip to localhost
131 }
132
133 public static function process_user_picture($value) {
134 return 0; // No picture
135 }
136
137 public static function process_user_url($value) {
138 return ''; // No url
139 }
140
141 public static function process_user_description($value) {
142 return ''; // No user description
143 }
144
c44d4aee
EL
145 public static function process_user_descriptionformat($value) {
146 return 0; // Format moodle
147 }
148
69dd0c8c
EL
149 public static function process_user_imagealt($value) {
150 return ''; // No user imagealt
151 }
152}