login/edit: prepare input restriction for user names
[minimedit.git] / login / edit.php
index bd39f5eba87f096bcdc6a96dab172f5886f9cfec..4002cb989098d65db18a1f6c225c283050c0aecd 100644 (file)
@@ -13,8 +13,15 @@ if (!empty($User['admin']) and $Page == 'login/edit' and $Args) {
 }
 
 $cols = [
-       'name'  => ['label' => 'volledige naam'],
-       'email' => ['label' => 'e-mailadres', 'type' => 'email'],
+       'name'  => [
+               'label' => 'volledige naam',
+               'explain' => "Alleen zichtbaar voor andere leden.",
+       ],
+       'email' => [
+               'label' => 'e-mailadres',
+               'type' => 'email',
+               'explain' => "Voor contact van of met deze site. Wij zullen dit nooit vrij- of doorgeven.",
+       ],
        'avatar' => [
                'label' => 'portretfoto',
                'type' => 'file',
@@ -38,7 +45,12 @@ foreach ($cols as $col => &$colconf) {
 }
 
 $cols = [
-       'login' => ['label' => 'login', 'value' => $user['name'], 'target' => NULL],
+       'login' => [
+               'label' => 'login',
+               'value' => $user['name'],
+               'target' => NULL,
+               'pattern' => "[a-z0-9-]+",
+       ],
 ] + $cols;
 
 if (isset($user['pass'])) {
@@ -122,10 +134,6 @@ if ($_POST) {
 
 ?>
 <form method="post" enctype="multipart/form-data">
-       <p>
-       Geef een e-mailadres op waarmee we u kunnen bereiken indien nodig.
-       Wij zullen dit adres nooit vrij- of doorgeven.
-       </p>
        <ul class="grid">
 <?php
 foreach ($cols as $col => &$colconf) {
@@ -156,6 +164,7 @@ foreach ($cols as $col => &$colconf) {
                        'value'       => htmlspecialchars(@$colconf['value']),
                        'placeholder' => "Niet ingesteld",
                        'readonly'    => empty($colconf['target']),
+                       'pattern'     => @$colconf['pattern'] ?: FALSE,
                ];
                if (@$colconf['type'] == 'file') {
                        $attrs['accept'] = "image/jpeg";
@@ -173,6 +182,9 @@ foreach ($cols as $col => &$colconf) {
                }
                print ' />';
        }
+       if (!empty($colconf['explain'])) {
+               printf(' <span>(%s)</span>', $colconf['explain']);
+       }
 
        if ($hide) {
                print '</span>';