aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2008-12-24 16:16:03 -0500
committerJoey Hess <joey@gnu.kitenet.net>2008-12-24 16:16:03 -0500
commit7ba65e7f4bd53c4cbd865fa35a515ef12c183757 (patch)
tree618574a4475953adfede43d7d53e2f5fc5ea2d3d /IkiWiki
parentc58f0eaa7093a01cd37bb1ab2ae732c8c2659526 (diff)
downloadikiwiki-7ba65e7f4bd53c4cbd865fa35a515ef12c183757.tar
ikiwiki-7ba65e7f4bd53c4cbd865fa35a515ef12c183757.tar.gz
remove deprecated admin prefs
A new ikiwiki-transition moveprefs subcommand can pull the old data out of the userdb and inject it into the setup file. Note that it leaves the old values behind in the userdb too. I did this because I didn't want to lose data if it fails writing the setup file for some reason, and the old data in the userdb will only use a small amount of space. Running the command multiple times will mostly not change anything.
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/CGI.pm32
-rw-r--r--IkiWiki/Plugin/attachment.pm50
-rw-r--r--IkiWiki/Plugin/lockedit.pm58
-rw-r--r--IkiWiki/UserInfo.pm20
4 files changed, 1 insertions, 159 deletions
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
index 81cb42d13..3fadc462e 100644
--- a/IkiWiki/CGI.pm
+++ b/IkiWiki/CGI.pm
@@ -203,25 +203,9 @@ sub cgi_prefs ($$) {
my $user_name=$session->param("name");
- # XXX deprecated, should be removed eventually
- $form->field(name => "banned_users", size => 50, fieldset => "admin");
- if (! is_admin($user_name)) {
- $form->field(name => "banned_users", type => "hidden");
- }
if (! $form->submitted) {
$form->field(name => "email", force => 1,
value => userinfo_get($user_name, "email"));
- if (is_admin($user_name)) {
- my $value=join(" ", get_banned_users());
- if (length $value) {
- $form->field(name => "banned_users", force => 1,
- value => join(" ", get_banned_users()),
- comment => "deprecated; please move to banned_users in setup file");
- }
- else {
- $form->field(name => "banned_users", type => "hidden");
- }
- }
}
if ($form->submitted eq 'Logout') {
@@ -239,17 +223,6 @@ sub cgi_prefs ($$) {
error("failed to set email");
}
- # XXX deprecated, should be removed eventually
- if (is_admin($user_name)) {
- set_banned_users(grep { ! is_admin($_) }
- split(' ',
- $form->field("banned_users"))) ||
- error("failed saving changes");
- if (! length $form->field("banned_users")) {
- $form->field(name => "banned_users", type => "hidden");
- }
- }
-
$form->text(gettext("Preferences saved."));
}
@@ -262,10 +235,7 @@ sub check_banned ($$) {
my $name=$session->param("name");
if (defined $name) {
- # XXX banned in userinfo is deprecated, should be removed
- # eventually, and only banned_users be checked.
- if (userinfo_get($session->param("name"), "banned") ||
- grep { $name eq $_ } @{$config{banned_users}}) {
+ if (grep { $name eq $_ } @{$config{banned_users}}) {
print $q->header(-status => "403 Forbidden");
$session->delete();
print gettext("You are banned.");
diff --git a/IkiWiki/Plugin/attachment.pm b/IkiWiki/Plugin/attachment.pm
index e1b4d4363..087c315a9 100644
--- a/IkiWiki/Plugin/attachment.pm
+++ b/IkiWiki/Plugin/attachment.pm
@@ -61,23 +61,6 @@ sub check_canattach ($$;$) {
);
}
- # XXX deprecated, should be removed eventually
- if ($allowed) {
- foreach my $admin (@{$config{adminuser}}) {
- my $allowed_attachments=IkiWiki::userinfo_get($admin, "allowed_attachments");
- if (defined $allowed_attachments &&
- length $allowed_attachments) {
- $allowed=pagespec_match($dest,
- $allowed_attachments,
- file => $file,
- user => $session->param("name"),
- ip => $ENV{REMOTE_ADDR},
- );
- last if $allowed;
- }
- }
- }
-
if (! $allowed) {
error(gettext("prohibited by allowed_attachments")." ($allowed)");
}
@@ -120,39 +103,6 @@ sub formbuilder_setup (@) {
$form->tmpl_param("attachments-class" => "toggleable-open");
}
}
- elsif ($form->title eq "preferences") {
- # XXX deprecated, should remove eventually
- my $session=$params{session};
- my $user_name=$session->param("name");
-
- $form->field(name => "allowed_attachments", size => 50,
- fieldset => "admin",
- comment => "deprecated; please move to allowed_attachments in setup file",
- );
- if (! IkiWiki::is_admin($user_name)) {
- $form->field(name => "allowed_attachments", type => "hidden");
- }
- if (! $form->submitted) {
- my $value=IkiWiki::userinfo_get($user_name, "allowed_attachments");
- if (length $value) {
- $form->field(name => "allowed_attachments", force => 1,
- value => IkiWiki::userinfo_get($user_name, "allowed_attachments"));
- }
- else {
- $form->field(name => "allowed_attachments", type => "hidden");
- }
- }
- if ($form->submitted && $form->submitted eq 'Save Preferences') {
- if (defined $form->field("allowed_attachments")) {
- IkiWiki::userinfo_set($user_name, "allowed_attachments",
- $form->field("allowed_attachments")) ||
- error("failed to set allowed_attachments");
- if (! length $form->field("allowed_attachments")) {
- $form->field(name => "allowed_attachments", type => "hidden");
- }
- }
- }
- }
}
sub formbuilder (@) {
diff --git a/IkiWiki/Plugin/lockedit.pm b/IkiWiki/Plugin/lockedit.pm
index c2c7414c3..0fa329251 100644
--- a/IkiWiki/Plugin/lockedit.pm
+++ b/IkiWiki/Plugin/lockedit.pm
@@ -8,8 +8,6 @@ use IkiWiki 3.00;
sub import {
hook(type => "getsetup", id => "lockedit", call => \&getsetup);
hook(type => "canedit", id => "lockedit", call => \&canedit);
- hook(type => "formbuilder_setup", id => "lockedit",
- call => \&formbuilder_setup);
}
sub getsetup () {
@@ -52,63 +50,7 @@ sub canedit ($$) {
}
}
- # XXX deprecated, should be removed eventually
- foreach my $admin (@{$config{adminuser}}) {
- if (pagespec_match($page, IkiWiki::userinfo_get($admin, "locked_pages"),
- user => $session->param("name"),
- ip => $ENV{REMOTE_ADDR},
- )) {
- if (! defined $user ||
- ! IkiWiki::userinfo_get($session->param("name"), "regdate")) {
- return sub { IkiWiki::needsignin($cgi, $session) };
- }
- else {
- return sprintf(gettext("%s is locked and cannot be edited"),
- htmllink("", "", $page, noimageinline => 1));
- }
- }
- }
-
return undef;
}
-sub formbuilder_setup (@) {
- my %params=@_;
-
- # XXX deprecated, should be removed eventually
- my $form=$params{form};
- if ($form->title eq "preferences") {
- my $session=$params{session};
- my $cgi=$params{cgi};
- my $user_name=$session->param("name");
-
- $form->field(name => "locked_pages", size => 50,
- fieldset => "admin",
- comment => "deprecated; please move to locked_pages in setup file"
- );
- if (! IkiWiki::is_admin($user_name)) {
- $form->field(name => "locked_pages", type => "hidden");
- }
- if (! $form->submitted) {
- my $value=IkiWiki::userinfo_get($user_name, "locked_pages");
- if (length $value) {
- $form->field(name => "locked_pages", force => 1, value => $value);
- }
- else {
- $form->field(name => "locked_pages", type => "hidden");
- }
- }
- if ($form->submitted && $form->submitted eq 'Save Preferences') {
- if (defined $form->field("locked_pages")) {
- IkiWiki::userinfo_set($user_name, "locked_pages",
- $form->field("locked_pages")) ||
- error("failed to set locked_pages");
- if (! length $form->field("locked_pages")) {
- $form->field(name => "locked_pages", type => "hidden");
- }
- }
- }
- }
-}
-
1
diff --git a/IkiWiki/UserInfo.pm b/IkiWiki/UserInfo.pm
index 3423dc923..0bf100a95 100644
--- a/IkiWiki/UserInfo.pm
+++ b/IkiWiki/UserInfo.pm
@@ -74,24 +74,4 @@ sub is_admin ($) {
return grep { $_ eq $user_name } @{$config{adminuser}};
}
-# XXX deprecated, should be removed eventually
-sub get_banned_users () {
- my @ret;
- my $userinfo=userinfo_retrieve();
- foreach my $user (keys %{$userinfo}) {
- push @ret, $user if $userinfo->{$user}->{banned};
- }
- return @ret;
-}
-
-# XXX deprecated, should be removed eventually
-sub set_banned_users (@) {
- my %banned=map { $_ => 1 } @_;
- my $userinfo=userinfo_retrieve();
- foreach my $user (keys %{$userinfo}) {
- $userinfo->{$user}->{banned} = $banned{$user};
- }
- return userinfo_store($userinfo);
-}
-
1