|
2 | 2 |
|
3 | 3 | /* For licensing terms, see /license.txt */ |
4 | 4 |
|
| 5 | +use Chamilo\UserBundle\Entity\User; |
5 | 6 | use Doctrine\Common\Collections\Criteria; |
6 | 7 |
|
7 | 8 | /** |
|
40 | 41 | $step2Form->addButtonUpdate(get_lang('Anonymize')); |
41 | 42 |
|
42 | 43 | if ($step1Form->validate() && $usernameListFile->isUploadedFile()) { |
43 | | - $filePath = $usernameListFile->getValue()['tmp_name']; |
| 44 | + $usernameListFileUploaded = $usernameListFile->getValue(); |
| 45 | + $usernameListFileUploaded['name'] = api_htmlentities($usernameListFileUploaded['name']); |
| 46 | + $filePath = $usernameListFileUploaded['tmp_name']; |
44 | 47 | if (!file_exists($filePath)) { |
45 | 48 | throw new Exception(get_lang('CouldNotReadFile').' '.$filePath); |
46 | 49 | } |
47 | 50 | $submittedUsernames = file($filePath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
48 | 51 | if (false === $submittedUsernames) { |
49 | 52 | throw new Exception(get_lang('CouldNotReadFileLines').' '.$filePath); |
50 | 53 | } |
| 54 | + |
| 55 | + $submittedUsernames = array_map('api_htmlentities', $submittedUsernames); |
| 56 | + $submittedUsernames = array_filter($submittedUsernames); |
| 57 | + |
51 | 58 | if (empty($submittedUsernames)) { |
52 | 59 | printf( |
53 | 60 | '<p>'.get_lang('FileXHasNoData').'</p>', |
54 | | - '<em>'.$usernameListFile->getValue()['name'].'</em>' |
| 61 | + '<em>'.$usernameListFileUploaded['name'].'</em>' |
55 | 62 | ); |
56 | 63 | } else { |
57 | 64 | printf( |
58 | 65 | '<p>'.get_lang('FileXHasYNonEmptyLines').'</p>', |
59 | | - '<em>'.$usernameListFile->getValue()['name'].'</em>', |
| 66 | + '<em>'.$usernameListFileUploaded['name'].'</em>', |
60 | 67 | count($submittedUsernames) |
61 | 68 | ); |
62 | 69 | $uniqueSubmittedUsernames = array_values(array_unique($submittedUsernames)); |
|
116 | 123 | $anonymized = []; |
117 | 124 | $errors = []; |
118 | 125 | $tableSession = Database::get_main_table(TABLE_MAIN_SESSION); |
| 126 | + /** @var User $user */ |
119 | 127 | foreach ($users as $user) { |
120 | 128 | $username = $user->getUsername(); |
121 | 129 | $userId = $user->getId(); |
|
0 commit comments