login/edit: initial code cleanup to prepare for other columns
[minimedit.git] / login / edit.php
1 <?php
2 global $User;
3 if (empty($User)) {
4         return;
5 }
6
7 $userdir = $User['dir'];
8 $setfile = "$userdir/email.txt";
9
10 $error = NULL;
11 if ($_POST) {
12         foreach (@$_POST['email'] as $val) {
13                 if (!isset($val)) {
14                         continue;
15                 }
16                 if (!is_writable(file_exists($setfile) ? $setfile : $userdir)) {
17                         $error = "Kan niet worden aangepast.";
18                         continue;
19                 }
20                 if (!file_put_contents($setfile, $val)) {
21                         $error = "Fout bij opslaan.";
22                 }
23         }
24
25         if ($error) {
26                 print "<p class=warn>Instellingen zijn niet (volledig) opgeslagen. Probeer het later nog eens.</p>\n\n";
27         }
28         else {
29                 print "<p>Het e-mailadres is ingesteld.</p>\n\n";
30         }
31 }
32
33 $usermail = @file_get_contents($setfile);
34 ?>
35 <form method="post" class="inline">
36         <p>
37         Geef een e-mailadres op waarmee we u kunnen bereiken indien nodig.
38         Wij zullen dit adres nooit vrij- of doorgeven.
39         </p>
40         <p>
41 <?php
42         print "\t<input";
43         printf(' type="%s" name="%s" id="%1$s" value="%s"',
44                 'email',
45                 'email',
46                 htmlspecialchars($usermail)
47         );
48         print ' placeholder="Geen e-mailadres ingesteld"';
49         print " />\n";
50
51         if ($error) {
52                 print "<span class=warn>$error</span>\n";
53         }
54 ?>
55         <input type="submit" value="Opslaan" />
56         </p>
57 </form>