login/edit: user override in page code
[minimedit.git] / widget / login / edit.php
index d6ee4c905c8dc5663e76a9d0febfcd478c0eb408..8fd3824f3dd28ce776bd7ca6dcbc683a9e9e84fb 100644 (file)
@@ -1,21 +1,17 @@
 <?php
-global $User;
-if (empty($user = &$User)) {
-       return;
+global $User, $user;
+if (!$user) {
+       $user = $User;
 }
-
-if ($User->admin
-and !empty($Place['user']) and $Place['user'] !== $User->login) {
-       $username = strtolower($Place['user']);
-       unset($user);
-       $user = new User("profile/$username");
+if (!$user) {
+       return;
 }
 
 require_once('edit.inc.php');
 
 foreach ($cols as $col => &$colconf) {
        if (isset($colconf['visible'])) {
-               if ($colconf['visible'] == 'admin' and !$User->admin) {
+               if ($colconf['visible'] == 'admin' and !$User->admin('user')) {
                        $colconf['visible'] = FALSE;
                        continue;
                }
@@ -161,7 +157,42 @@ if ($_POST) {
        }
 }
 
+if ($User->admin('user')) {
+?>
+<aside>
+<h2>Gebruikersbeheer</h2>
+<dl>
+<?php if ($time = @fileatime($user->dir)) { // assume noatime ?>
+<dt>Aangemaakt</dt>
+<dd><?php print strftime('%F %H:%M', $time); ?></dd>
+<?php } ?>
+<?php if ($time = @filemtime("{$user->dir}/.passwd")) { ?>
+<dt>Wachtwoord ingesteld</dt>
+<dd><?php print strftime('%F %H:%M', $time); ?></dd>
+<?php } ?>
+<?php if ($user->seen) { ?>
+<dt>Laatste bezoek</dt>
+<dd><?php print strftime('%F %H:%M', $user->seen); ?></dd>
+<?php } ?>
+</dl>
+<?php
+       $postdir = 'doc/post';
+       if (is_dir($postdir)) {
+               print "<h3>Brieven</h3><ul>\n";
+               foreach (glob("$postdir/*.html") as $link) {
+                       $page = new ArchiveArticle($link);
+                       printf('<li><a href="/%s?login=%s">%s</a></li>'."\n",
+                               $page->link, $user->login, $page->name
+                       );
+               }
+               print "</ul>\n";
+       }
+?>
+</aside>
+<?php
+}
 ?>
+
 <form method="post" enctype="multipart/form-data">
        <ul class="grid">
 <?php
@@ -173,7 +204,7 @@ foreach ($cols as $col => &$colconf) {
        print "\t";
        printf('<li><label for="%s">%s:</label>', $col, ucfirst($colconf['label']));
        if (@$colconf['type'] == 'file' and isset($colconf['value'])) {
-               $target = $user['dir'] . '/' . $colconf['filename'];
+               $target = $user->dir . '/' . $colconf['filename'];
                printf('<a href="/%s"><img src="/thumb/%s/%s?%s" /></a><br />',
                        $target,
                        200, $target, filemtime($target)