login/edit: filter to replace newlines in input values
authorMischa POSLAWSKY <perl@shiar.org>
Sun, 8 Jul 2018 15:18:23 +0000 (17:18 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 9 Jul 2018 23:52:57 +0000 (01:52 +0200)
Multiple names on Lijtweg.

login/edit.php

index 46b6132a6213f5b10ec2ff01292717468f543755..6f3eff211002b818a0f3e698eacb31a3c05d4869 100644 (file)
@@ -17,6 +17,7 @@ $cols = [
        'name'  => [
                'label' => 'volledige naam',
                'explain' => "Alleen zichtbaar voor andere leden.",
+               'filter' => ["\n", '; '],
        ],
        'email' => [
                'label' => 'e-mailadres',
@@ -134,6 +135,11 @@ if ($_POST) {
                        }
                        continue;
                }
+
+               if (isset($cols[$col]['filter'])) {
+                       list ($targetstr, $inputstr) = $cols[$col]['filter'];
+                       $val = str_replace($inputstr, $targetstr, $val);
+               }
                if (isset($cols[$col]['value']) and $cols[$col]['value'] === $val) {
                        continue; # unaltered
                }
@@ -230,6 +236,11 @@ foreach ($cols as $col => &$colconf) {
                }
        }
        else {
+               if (isset($cols[$col]['filter'])) {
+                       list ($targetstr, $inputstr) = $cols[$col]['filter'];
+                       $colconf['value'] = str_replace($targetstr, $inputstr, $colconf['value']);
+               }
+
                $attrs = [
                        'type'        => @$colconf['type'] ?: 'text',
                        'name'        => $col,