login/edit: admin override as template parameter
[minimedit.git] / login / edit.php
index 56451b50303fe2633c8630bdafecc5f2c7c6c177..46b6132a6213f5b10ec2ff01292717468f543755 100644 (file)
@@ -4,8 +4,9 @@ if (empty($user = &$User)) {
        return;
 }
 
-if (!empty($User['admin']) and $Page == 'login/edit' and $Args) {
-       $username = strtolower(ltrim($Args, '/'));
+if (!empty($User['admin']) and !empty($Place['user'])) {
+       $username = strtolower($Place['user']);
+       unset($user);
        $user = [
                'dir' => "profile/$username",
                'name' => $username,
@@ -45,7 +46,7 @@ foreach ($cols as $col => &$colconf) {
 }
 
 $cols = [
-       'login' => [
+       'username' => [
                'label' => 'login',
                'value' => $user['name'],
                'target' => NULL,
@@ -138,7 +139,9 @@ if ($_POST) {
                }
                $cols[$col]['value'] = $val;  # update form value
                if (empty($cols[$col]['target'])) {
-                       $colwarn[$col] = "Kan niet worden aangepast.";
+                       if (empty($cols[$col]['input'])) {
+                               $colwarn[$col] = "Kan niet worden aangepast.";
+                       }
                        continue;
                }
                if (file_put_contents($cols[$col]['target'], $val) === FALSE) {
@@ -216,9 +219,10 @@ foreach ($cols as $col => &$colconf) {
                foreach ($colconf['values'] as $tag => $val) {
                        printf(
                                "\n\t\t" .
-                               '<input type="hidden" name="tags[%1$s]" value="" />' .
-                               '<input type="checkbox" name="tags[%s]" value="1"%s%s /> %s',
-                               $tag,
+                               '<input type="hidden" name="%1$s" value="" />' .
+                               '<input type="checkbox" name="%s" value="1" id="%s"%s%s />' .
+                               '<label for="%2$s"> %s</label>',
+                               "tags[$tag]", "tag-$tag",
                                $val['value'] ? ' checked' : '',
                                isset($val['target']) ? '' : ' readonly',
                                ucfirst($tag)