login/edit: list user existence in tags
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 7 Jul 2018 13:01:46 +0000 (15:01 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 7 Jul 2018 16:50:48 +0000 (18:50 +0200)
Grouping for avatars page.

login/edit.php

index 4002cb989098d65db18a1f6c225c283050c0aecd..759eba5f10e61a359cb61027d1ae1fcbb7696487 100644 (file)
@@ -53,6 +53,36 @@ $cols = [
        ],
 ] + $cols;
 
+$tagdir = 'profile/.tags';
+if (file_exists($tagdir)) {
+       $tags = [];
+       foreach (glob("$tagdir/*") as $tag) {
+               $tagname = pathinfo($tag, PATHINFO_BASENAME);
+               $target = "$tag/{$user['name']}";
+               $tags[$tagname] = file_exists($tagname);
+       }
+
+       if ($tags) {
+               $options = '';
+               foreach ($tags as $tag => $val) {
+                       $options .= sprintf(
+                               "\n\t\t" .
+                               '<input type="hidden" name="tags[%1$s]" value="" />' .
+                               '<input type="checkbox" name="tags[%s]" value="1"%s%s /> %s',
+                               $tag,
+                               $val ? ' checked' : '',
+                               ' readonly',
+                               ucfirst($tag)
+                       );
+               }
+
+               $cols['tags'] = [
+                       'label' => 'groepen',
+                       'input' => $options,
+               ];
+       }
+}
+
 if (isset($user['pass'])) {
        $cols['newpass'] = [
                'label' => 'wachtwoord',