Overview
Comment:Fix custom user import
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA1: 315a772f091b3a1986355b16cf07b0710acc412c
User & Date: bohwaz on 2020-11-30 13:02:16
Other Links: branch diff | manifest | tags
Context
2020-11-30
15:04
Make simple tracking use transaction type, not account type check-in: 7427b32fb9 user: bohwaz tags: dev
13:02
Fix custom user import check-in: 315a772f09 user: bohwaz tags: dev
2020-11-27
15:15
Fix import check-in: 4fe6d3b708 user: bohwaz tags: dev, 1.0.0-rc2
Changes

Modified src/templates/admin/membres/import.tpl from [d21814024d] to [a80b676531].

53
54
55
56
57
58
59

60
61
62
63
64
65
        </dl>
    </fieldset>

    {/if}

    <p class="submit">
        {csrf_field key=$csrf_key}

        {button type="submit" name="import" label="Importer" shape="upload" class="main"}
    </p>

</form>

{include file="admin/_foot.tpl"}







>






53
54
55
56
57
58
59
60
61
62
63
64
65
66
        </dl>
    </fieldset>

    {/if}

    <p class="submit">
        {csrf_field key=$csrf_key}
        {if $csv->loaded()}{button type="submit" name="cancel" value="1" label="Annuler" shape="left"}{/if}
        {button type="submit" name="import" label="Importer" shape="upload" class="main"}
    </p>

</form>

{include file="admin/_foot.tpl"}

Modified src/www/admin/common/search.php from [145020cce4] to [19bc74c76e].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
$text_query = trim(qg('qt'));
$result = null;
$sql_query = null;
$search = null;
$id = f('id') ?: qg('id');

// Recherche simple
if ($text_query !== '' && $target === 'membres')
{
	$query = $recherche->buildSimpleMemberQuery($text_query);
}
// Recherche existante
elseif ($id && !f('q'))
{
	$search = $recherche->get($id);

	if (!$search) {
		throw new UserException('Recherche inconnue ou invalide');
	}








|




|







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
$text_query = trim(qg('qt'));
$result = null;
$sql_query = null;
$search = null;
$id = f('id') ?: qg('id');

// Recherche simple
if ($text_query !== '' && $target === 'membres' && empty($query->query))
{
	$query = $recherche->buildSimpleMemberQuery($text_query);
}
// Recherche existante
elseif ($id && empty($query->query))
{
	$search = $recherche->get($id);

	if (!$search) {
		throw new UserException('Recherche inconnue ou invalide');
	}

Modified src/www/admin/membres/import.php from [e4d2ac02de] to [34b02fc73c].

32
33
34
35
36
37
38





39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
    }

    $columns[$key] = $config->title;
}

$csv->setColumns($columns);






$form->runIf(f('import') && $csv->ready(), function () use ($csv, $import, $user) {
    $csv->setTranslationTable(f('translation_table'));
    $csv->skip((int)f('skip_first_line'));
    $import->fromCustomCSV($csv, $user->id);
    $csv->clear();
}, $csrf_key, ADMIN_URL . 'membres/import.php?ok');

$form->runIf(f('import') && f('type') == 'garradin' && !empty($_FILES['upload']['tmp_name']), function () use ($import, $user) {
    $import->fromGarradinCSV($_FILES['upload']['tmp_name'], $user->id);
}, $csrf_key, ADMIN_URL . 'membres/import.php?ok');

$form->runIf(f('import') && f('type') == 'custom' && !empty($_FILES['upload']['tmp_name']), function () use ($csv) {
    $csv->load($_FILES['upload']);
}, $csrf_key, ADMIN_URL . 'membres/import.php?ok');

$tpl->assign('ok', null !== qg('ok') ? true : false);

$tpl->assign(compact('csv', 'csrf_key'));

$tpl->assign('max_upload_size', Utils::getMaxUploadSize());

$tpl->display('admin/membres/import.tpl');







>
>
>
>
>
|












|








32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
    }

    $columns[$key] = $config->title;
}

$csv->setColumns($columns);

if (f('cancel')) {
    $csv->clear();
    Utils::redirect(Utils::getSelfURL(false));
}

$form->runIf(f('import') && $csv->loaded(), function () use ($csv, $import, $user) {
    $csv->setTranslationTable(f('translation_table'));
    $csv->skip((int)f('skip_first_line'));
    $import->fromCustomCSV($csv, $user->id);
    $csv->clear();
}, $csrf_key, ADMIN_URL . 'membres/import.php?ok');

$form->runIf(f('import') && f('type') == 'garradin' && !empty($_FILES['upload']['tmp_name']), function () use ($import, $user) {
    $import->fromGarradinCSV($_FILES['upload']['tmp_name'], $user->id);
}, $csrf_key, ADMIN_URL . 'membres/import.php?ok');

$form->runIf(f('import') && f('type') == 'custom' && !empty($_FILES['upload']['tmp_name']), function () use ($csv) {
    $csv->load($_FILES['upload']);
}, $csrf_key, ADMIN_URL . 'membres/import.php');

$tpl->assign('ok', null !== qg('ok') ? true : false);

$tpl->assign(compact('csv', 'csrf_key'));

$tpl->assign('max_upload_size', Utils::getMaxUploadSize());

$tpl->display('admin/membres/import.tpl');