Skip to content

Commit 05d1acd

Browse files
Merge pull request #6523 from christianbeeznest/GH-6355
User: Switch CSV delimiter to comma for export, user update & class import - refs #6355
2 parents 5f3d68a + 857f97b commit 05d1acd

File tree

3 files changed

+50
-35
lines changed

3 files changed

+50
-35
lines changed

public/main/admin/user_update_import.php

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -273,22 +273,22 @@ function parse_xml_data($file)
273273
$defined_auth_sources = array_merge($defined_auth_sources, array_keys($extAuthSource));
274274
}
275275

276-
$tool_name = get_lang('UpdateUserListXMLCSV');
277-
$interbreadcrumb[] = ["url" => 'index.php', "name" => get_lang('PlatformAdmin')];
276+
$tool_name = get_lang('Update user list fromm XML/CSV');
277+
$interbreadcrumb[] = ["url" => 'index.php', "name" => get_lang('Platform admin')];
278278

279279
set_time_limit(0);
280280
$extra_fields = UserManager::get_extra_fields(0, 0, 5, 'ASC', true);
281281

282282
$form = new FormValidator('user_update_import', 'post', api_get_self());
283283
$form->addHeader($tool_name);
284-
$form->addFile('import_file', get_lang('ImportFileLocation'), ['accept' => 'text/csv', 'id' => 'import_file']);
285-
$form->addCheckBox('reset_password', '', get_lang('AutoGeneratePassword'));
284+
$form->addFile('import_file', get_lang('Import file location'), ['accept' => 'text/csv', 'id' => 'import_file']);
285+
$form->addCheckBox('reset_password', '', get_lang('Auto-generate password'));
286286

287287
$group = [
288288
$form->createElement('radio', 'sendMail', '', get_lang('Yes'), 1),
289289
$form->createElement('radio', 'sendMail', null, get_lang('No'), 0),
290290
];
291-
$form->addGroup($group, '', get_lang('SendMailToUsers'));
291+
$form->addGroup($group, '', get_lang('Send mail to users'));
292292
$defaults['sendMail'] = 0;
293293

294294
if ($form->validate()) {
@@ -305,7 +305,7 @@ function parse_xml_data($file)
305305

306306
if ('csv' !== $uploadInfo['extension']) {
307307
Display::addFlash(
308-
Display::return_message(get_lang('YouMustImportAFileAccordingToSelectedOption'), 'error')
308+
Display::return_message(get_lang('You must import a file according to selected option'), 'error')
309309
);
310310

311311
header('Location: '.api_get_self());
@@ -338,7 +338,7 @@ function parse_xml_data($file)
338338

339339
if (empty($errors)) {
340340
Display::addFlash(
341-
Display::return_message(get_lang('FileImported'), 'success')
341+
Display::return_message(get_lang('File imported'), 'success')
342342
);
343343
} else {
344344
$warningMessage = '';
@@ -348,15 +348,15 @@ function parse_xml_data($file)
348348
}
349349

350350
Display::addFlash(
351-
Display::return_message(get_lang('FileImportedJustUsersThatAreNotRegistered'), 'warning')
351+
Display::return_message(get_lang('File imported just users that are not registered'), 'warning')
352352
);
353353
Display::addFlash(Display::return_message($warningMessage, 'warning', false));
354354
}
355355

356356
header('Location: '.api_get_self());
357357
exit;
358358
} else {
359-
Display::addFlash(Display::return_message(get_lang('LinkExpired'), 'warning', false));
359+
Display::addFlash(Display::return_message(get_lang('Link expired'), 'warning', false));
360360
header('Location: '.api_get_self());
361361
exit;
362362
}
@@ -388,20 +388,22 @@ function parse_xml_data($file)
388388
}
389389
}
390390

391-
$content = '<p>'.get_lang('CSVMustLookLike').' ('.get_lang('MandatoryFields').') :</p>
392-
<blockquote>
393-
<pre>
394-
<b>UserName</b>;LastName;FirstName;Email;NewUserName;Password;AuthSource;OfficialCode;PhoneNumber;Status;ExpiryDate;Active;Language;Courses;ClassId;
395-
xxx;xxx;xxx;xxx;xxx;xxx;xxx;xxx;xxx;user/teacher/drh;YYYY-MM-DD 00:00:00;0/1;xxx;
396-
<span style="color:red;">';
397-
if (count($list_reponse) > 0) {
398-
$content .= implode(';', $list_reponse).';';
399-
} else {
400-
$content .= '</span>xxx1|xxx2|xxx3;1;<br/>
401-
</pre>
402-
</blockquote>
403-
<p>
404-
';
405-
}
391+
$content = '
392+
<div class="max-w-full mb-8">
393+
<div class="p-6 bg-white border border-gray-200 rounded-lg shadow-sm">
394+
<h2 class="text-xl font-bold mb-4">'
395+
. get_lang('CSV must look like') .
396+
' <span class="font-medium">(' . get_lang('Mandatory fields') . ')</span>
397+
</h2>
398+
<div class="overflow-x-auto bg-gray-20 p-4 rounded-md">
399+
<pre class="bg-gray-100 text-gray-800 p-4 font-mono text-sm whitespace-pre-wrap mb-0">
400+
UserName,LastName,FirstName,Email,NewUserName,Password,AuthSource,OfficialCode,PhoneNumber,Status,ExpiryDate,Active,Language,Courses,ClassId
401+
xxx,xxx,xxx,xxx,xxx,xxx,xxx,xxx,xxx,user/teacher/drh,YYYY-MM-DD 00:00:00,0/1,xxx,<span class="text-red-600">'
402+
. implode(',', $list_reponse) .
403+
'</span>
404+
</pre>
405+
</div>
406+
</div>
407+
</div>';
406408
echo Display::prose($content);
407409
Display::display_footer();

public/main/admin/usergroup_import.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,25 @@ function save_data($classes)
130130

131131
$form->display();
132132
?>
133-
<p><?php echo get_lang('The CSV file must look like this').' ('.get_lang('Fields in <strong>bold</strong> are mandatory.').')'; ?> :</p>
133+
<div class="max-w-full mb-8">
134+
<div class="p-6 bg-white border border-gray-200 rounded-lg shadow-sm">
135+
<h2 class="text-lg font-semibold mb-4">
136+
<?php
137+
echo get_lang('The CSV file must look like this')
138+
. ' (<span class="font-medium">'
139+
. get_lang('Fields in <strong>bold</strong> are mandatory.')
140+
. '</span>)';
141+
?>
142+
</h2>
143+
<div class="overflow-x-auto bg-gray-20 p-4 rounded-md">
144+
<pre class="bg-gray-100 p-4 font-mono text-sm text-gray-800 whitespace-pre-wrap mb-0">
145+
<b>title,description,</b>users
146+
"User group 1","Description",admin,username1,username2
147+
</pre>
148+
</div>
149+
</div>
150+
</div>
134151

135-
<pre>
136-
<b>title;description;</b>users
137-
"User group 1";"Description";admin,username1,username2
138-
</pre>
139152
<?php
140153
// Displaying the footer.
141154
Display::display_footer();

public/main/inc/lib/display.lib.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2673,12 +2673,12 @@ public static function noDataView(string $title, string $icon, string $buttonTit
26732673
public static function prose(string $contents): string
26742674
{
26752675
return "
2676-
<div class=''>
2677-
<div class='prose prose-blue'>
2678-
$contents
2679-
</div>
2680-
</div>
2681-
";
2676+
<div class='w-full my-8'>
2677+
<div class='prose prose-blue max-w-none px-6 py-4 bg-white rounded-lg shadow'>
2678+
$contents
2679+
</div>
2680+
</div>
2681+
";
26822682
}
26832683

26842684
public static function getFrameReadyBlock(

0 commit comments

Comments
 (0)