login/edit: target user data distinct from login
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 14 Jun 2018 08:59:49 +0000 (10:59 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Thu, 14 Jun 2018 09:09:42 +0000 (11:09 +0200)
Prepare for admin control.

login/edit.php

index ba7e7853d0727975fa0f03d321e926b140e3c57b..0a90e0efa0b05e6dda3be6f7ad92e51d89dfccdc 100644 (file)
@@ -1,15 +1,16 @@
 <?php
 global $User;
-if (empty($User)) {
+if (empty($user = $User)) {
        return;
 }
 
-$userdir = $User['dir'];
 if (!empty($User['admin']) and $Page == 'login/edit' and $Args) {
-       $user = ltrim($Args, '/');
-       $userdir = "profile/$user";
-       if (!is_writable($userdir)) {
-               print "<p class=warn>Het is niet mogelijk om de gebruiker <em>$user</em> aan te passen.</p>\n\n";
+       $username = ltrim($Args, '/');
+       $user = [
+               'dir' => "profile/$username",
+       ];
+       if (!is_writable($user['dir'])) {
+               print "<p class=warn>Het is niet mogelijk om de gebruiker <em>{$user['name']}</em> aan te passen.</p>\n\n";
                return;
        }
 }
@@ -19,11 +20,11 @@ $cols = [
 ];
 
 foreach ($cols as $col => &$colconf) {
-       $colpath = "$userdir/$col.txt";
+       $colpath = "{$user['dir']}/$col.txt";
        if (file_exists($colpath)) {
                $colconf['value'] = file_get_contents($colpath);
        }
-       if (!is_writable($userdir)) {
+       if (!is_writable($user['dir'])) {
                continue;  # locked parent directory
        }
        if (isset($colconf['value']) and !is_writable($colpath)) {