login/edit: labeled fields with login and full name
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 9 Jun 2018 03:09:06 +0000 (05:09 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Thu, 14 Jun 2018 12:45:16 +0000 (14:45 +0200)
login/edit.php

index 0a90e0efa0b05e6dda3be6f7ad92e51d89dfccdc..563a3a567b6771c2962ea03a08589acce23676f5 100644 (file)
@@ -8,6 +8,7 @@ if (!empty($User['admin']) and $Page == 'login/edit' and $Args) {
        $username = ltrim($Args, '/');
        $user = [
                'dir' => "profile/$username",
+               'name' => $username,
        ];
        if (!is_writable($user['dir'])) {
                print "<p class=warn>Het is niet mogelijk om de gebruiker <em>{$user['name']}</em> aan te passen.</p>\n\n";
@@ -16,6 +17,7 @@ if (!empty($User['admin']) and $Page == 'login/edit' and $Args) {
 }
 
 $cols = [
+       'name'  => ['label' => 'volledige naam'],
        'email' => ['label' => 'e-mailadres', 'type' => 'email'],
 ];
 
@@ -33,6 +35,10 @@ foreach ($cols as $col => &$colconf) {
        $colconf['target'] = $colpath;  # editing allowed
 }
 
+$cols = [
+       'login' => ['label' => 'login', 'value' => $user['name'], 'target' => NULL],
+] + $cols;
+
 $colwarn = [];
 if ($_POST) {
        foreach ($_POST as $col => $val) {
@@ -61,7 +67,7 @@ if ($_POST) {
 }
 
 ?>
-<form method="post" class="inline">
+<form method="post">
        <p>
        Geef een e-mailadres op waarmee we u kunnen bereiken indien nodig.
        Wij zullen dit adres nooit vrij- of doorgeven.
@@ -69,19 +75,22 @@ if ($_POST) {
        <p>
 <?php
 foreach ($cols as $col => &$colconf) {
-       print "\t<input";
+       print "\t";
+       printf('<label for="%s">%s:</label> ', $col, ucfirst($colconf['label']));
+       print "<input";
        if (empty($colconf['target'])) print ' readonly';
        printf(' type="%s" name="%s" id="%1$s" value="%s"',
                @$colconf['type'] ?: 'text',
                $col,
                htmlspecialchars(@$colconf['value'])
        );
-       print ' placeholder="Geen '.$colconf['label'].' ingesteld"';
-       print " />\n";
+       print ' placeholder="Niet ingesteld"';
+       print " />";
 
        if ($error = @$colwarn[$col]) {
-               print "<span class=warn>$error</span>\n";
+               print " <span class=warn>$error</span>\n";
        }
+       print "<br />\n";
 }
 ?>
        <input type="submit" value="Opslaan" />