login/edit: column visibility option to restrict to admins
authorMischa POSLAWSKY <perl@shiar.org>
Tue, 17 Jul 2018 20:11:22 +0000 (22:11 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Fri, 10 Aug 2018 23:24:25 +0000 (01:24 +0200)
Read-only tags become invisible, and now configurable per site.

login/edit.inc.php
login/edit.php

index 86b35b265e35d7b46388eddf89b53afd00ea3c09..b94fa7cd786a63bc4707bafc1ff374b6aaabbad6 100644 (file)
@@ -30,6 +30,7 @@ $cols = [
                'label' => 'groepen',
                'filename' => 'profile/.tags',
                'values' => [],
+               'visible' => 'admin',
        ],
 ];
 
index 49b8ed8c43e821092694b4c9953cbb154f507595..8f39f09df5ee36f9d05c5ef2ce297f4d692b4450 100644 (file)
@@ -17,7 +17,15 @@ and !empty($Place['user']) and $Place['user'] !== $User['name']) {
 require_once('edit.inc.php');
 
 foreach ($cols as $col => &$colconf) {
-       $colconf['visible'] = TRUE;
+       if (isset($colconf['visible'])) {
+               if ($colconf['visible'] == 'admin' and empty($User['admin'])) {
+                       $colconf['visible'] = FALSE;
+                       continue;
+               }
+       }
+       else {
+               $colconf['visible'] = TRUE;
+       }
 
        if (!isset($colconf['filename'])) {
                continue;  # exceptional storage
@@ -34,9 +42,6 @@ foreach ($cols as $col => &$colconf) {
                        $target = "$tag/{$user['name']}";
                        $val = file_exists($target);
                        $tags[$tagname] = ['value' => $val];
-                       if (empty($User['admin'])) {
-                               continue;  # forbidden
-                       }
                        if (!is_writable($tag)) {
                                continue;  # locked tag directory
                        }