login/edit: declare column file storage
authorMischa POSLAWSKY <perl@shiar.org>
Tue, 10 Jul 2018 21:36:59 +0000 (23:36 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 14 Jul 2018 11:47:54 +0000 (13:47 +0200)
Allow other columns to be declared before initialisation.

login/edit.php

index e38ebc1c4586657d1f8030c4ff366597eaad1530..e174b065045182d0996eedf332a42da481a86f2f 100644 (file)
@@ -20,22 +20,28 @@ $cols = [
                'explain' => "Alleen zichtbaar voor andere leden.",
                'filter' => ["\n", '; '],
                'size' => 30,
+               'filename' => 'name.txt',
        ],
        'email' => [
                'label' => 'e-mailadres',
                'type' => 'email',
                'explain' => "Voor contact van of met deze site. Wij zullen dit nooit vrij- of doorgeven.",
                'size' => 30,
+               'filename' => 'email.txt',
        ],
        'avatar' => [
                'label' => 'portretfoto',
                'type' => 'file',
+               'filename' => 'avatar.jpg',
        ],
 ];
 
 foreach ($cols as $col => &$colconf) {
+       if (!isset($colconf['filename'])) {
+               continue;  # exceptional storage
+       }
        $filetype = @$colconf['type'] == 'file' ? 'jpg' : 'txt';
-       $colpath = "{$user['dir']}/$col.$filetype";
+       $colpath = $user['dir'] . '/' . $colconf['filename'];
        if (file_exists($colpath)) {
                $colconf['value'] = $filetype != 'txt' ? '' :
                        file_get_contents($colpath);