10 sub userinfo_retrieve () { #{{{
11 my $userinfo=eval{ Storable::lock_retrieve("$config{wikistatedir}/userdb") };
15 sub userinfo_store ($) { #{{{
18 my $newfile="$config{wikistatedir}/userdb.new";
19 my $oldmask=umask(077);
20 my $ret=Storable::lock_nstore($userinfo, $newfile);
22 if (defined $ret && $ret) {
23 if (! rename($newfile, "$config{wikistatedir}/userdb")) {
31 sub userinfo_get ($$) { #{{{
35 my $userinfo=userinfo_retrieve();
36 if (! defined $userinfo ||
37 ! exists $userinfo->{$user} || ! ref $userinfo->{$user} ||
38 ! exists $userinfo->{$user}->{$field}) {
41 return $userinfo->{$user}->{$field};
44 sub userinfo_set ($$$) { #{{{
49 my $userinfo=userinfo_retrieve();
50 if (! defined $userinfo ||
51 ! exists $userinfo->{$user} || ! ref $userinfo->{$user}) {
55 $userinfo->{$user}->{$field}=$value;
56 return userinfo_store($userinfo);
59 sub userinfo_setall ($$) { #{{{
63 my $userinfo=userinfo_retrieve();
64 if (! defined $userinfo) {
67 $userinfo->{$user}=$info;
68 return userinfo_store($userinfo);
71 sub is_admin ($) { #{{{
74 return grep { $_ eq $user_name } @{$config{adminuser}};
77 sub get_banned_users () { #{{{
79 my $userinfo=userinfo_retrieve();
80 foreach my $user (keys %{$userinfo}) {
81 push @ret, $user if $userinfo->{$user}->{banned};
86 sub set_banned_users (@) { #{{{
87 my %banned=map { $_ => 1 } @_;
88 my $userinfo=userinfo_retrieve();
89 foreach my $user (keys %{$userinfo}) {
90 $userinfo->{$user}->{banned} = $banned{$user};
92 return userinfo_store($userinfo);