diff options
-rw-r--r-- | IkiWiki.pm | 7 | ||||
-rw-r--r-- | IkiWiki/CGI.pm | 50 | ||||
-rw-r--r-- | IkiWiki/UserInfo.pm | 2 | ||||
-rw-r--r-- | debian/NEWS | 12 | ||||
-rw-r--r-- | debian/changelog | 5 | ||||
-rw-r--r-- | doc/banned_users.mdwn | 4 | ||||
-rw-r--r-- | po/ikiwiki.pot | 50 |
7 files changed, 85 insertions, 45 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm index bfa85343d..d11ceb896 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -284,6 +284,13 @@ sub getsetup () { #{{{ safe => 0, # regexp rebuild => 1, }, + banned_users => { + type => "string", + default => [], + description => "users who cannot use the wiki", + safe => 1, + rebuild => 0, + }, wiki_file_prune_regexps => { type => "internal", default => [qr/(^|\/)\.\.(\/|$)/, qr/^\./, qr/\/\./, diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 4cb45895b..97ca6714f 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -18,7 +18,6 @@ sub printheader ($) { #{{{ } else { print $session->header(-charset => 'utf-8'); } - } #}}} sub showform ($$$$;@) { #{{{ @@ -231,16 +230,24 @@ sub cgi_prefs ($$) { #{{{ fieldset => "admin"); my $user_name=$session->param("name"); + + # XXX deprecated, should be removed eventually 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)) { - $form->field(name => "banned_users", force => 1, - value => join(" ", get_banned_users())); + 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"); + } } } @@ -258,12 +265,18 @@ sub cgi_prefs ($$) { #{{{ userinfo_set($user_name, 'email', $form->field('email')) || 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.")); } @@ -638,6 +651,25 @@ sub cgi_editpage ($$) { #{{{ } } } #}}} + +sub check_banned ($$) { #{{{ + my $q=shift; + my $session=shift; + + 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}}) { + print $q->header(-status => "403 Forbidden"); + $session->delete(); + print gettext("You are banned."); + cgi_savesession($session); + exit; + } + } +} sub cgi_getsession ($) { #{{{ my $q=shift; @@ -722,14 +754,8 @@ sub cgi (;$$) { #{{{ } } - if (defined $session->param("name") && - userinfo_get($session->param("name"), "banned")) { - print $q->header(-status => "403 Forbidden"); - $session->delete(); - print gettext("You are banned."); - cgi_savesession($session); - } - + check_banned($q, $session); + run_hooks(sessioncgi => sub { shift->($q, $session) }); if ($do eq 'signin') { diff --git a/IkiWiki/UserInfo.pm b/IkiWiki/UserInfo.pm index 109a6cb5f..dcf99da09 100644 --- a/IkiWiki/UserInfo.pm +++ b/IkiWiki/UserInfo.pm @@ -74,6 +74,7 @@ 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(); @@ -83,6 +84,7 @@ sub get_banned_users () { #{{{ return @ret; } #}}} +# XXX deprecated, should be removed eventually sub set_banned_users (@) { #{{{ my %banned=map { $_ => 1 } @_; my $userinfo=userinfo_retrieve(); diff --git a/debian/NEWS b/debian/NEWS index 4aac33b80..0f9db4ea3 100644 --- a/debian/NEWS +++ b/debian/NEWS @@ -1,3 +1,15 @@ +ikiwiki (2.60) unstable; urgency=low + + Admin preferences are moving from the web interface to the setup file. + There are three new options in the setup file: locked_pages, banned_users, + and allowed_attachments. The admin prefs page can still be used, but + that's deprecated, and the prefs will be hidden if a value is not already + set. If a value is set in the web interface, you're encouraged to move that + setting to your setup file now, since version 3.0 will remove the deprecated + web interface. + + -- Joey Hess <joeyh@debian.org> Fri, 01 Aug 2008 17:02:14 -0400 + ikiwiki (2.52) unstable; urgency=low All wikis need to be rebuilt on upgrade to this version. If you listed your diff --git a/debian/changelog b/debian/changelog index 033b9fbc6..f40701691 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,10 +11,7 @@ ikiwiki (2.60) UNRELEASED; urgency=low * Version control backends promoted to first-class plugins. * ikiwiki-update-wikilist: Add -r switch to remove. Default behavior is now always to add. - * The locked pages configuration is moving to a locked_pages option in the - setup file, and the allowed attachments configuration to - allowed_attachments. The admin prefs page can still be used for these, but - that's depreacted and will only be shown if there's currently a value. + * Start moving admin preferences from the web interface to the setup file. -- Joey Hess <joeyh@debian.org> Mon, 21 Jul 2008 11:35:46 -0400 diff --git a/doc/banned_users.mdwn b/doc/banned_users.mdwn index 11e744b10..d2bec90f0 100644 --- a/doc/banned_users.mdwn +++ b/doc/banned_users.mdwn @@ -1,6 +1,4 @@ -Wiki admins can ban users via their Preferences. - -The list of banned users is space delimited. +Banned users can be configured in the setup file. If a banned user attempts to use the ikiwiki CGI, they will receive a 403 Forbidden webpage indicating they are banned. diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot index cefd4d711..69a1851f7 100644 --- a/po/ikiwiki.pot +++ b/po/ikiwiki.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-08-01 15:43-0400\n" +"POT-Creation-Date: 2008-08-01 17:10-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -16,62 +16,62 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: ../IkiWiki/CGI.pm:140 +#: ../IkiWiki/CGI.pm:139 msgid "You need to log in first." msgstr "" -#: ../IkiWiki/CGI.pm:172 +#: ../IkiWiki/CGI.pm:171 msgid "login failed, perhaps you need to turn on cookies?" msgstr "" -#: ../IkiWiki/CGI.pm:190 ../IkiWiki/CGI.pm:526 +#: ../IkiWiki/CGI.pm:189 ../IkiWiki/CGI.pm:539 msgid "Your login session has expired." msgstr "" -#: ../IkiWiki/CGI.pm:211 +#: ../IkiWiki/CGI.pm:210 msgid "Login" msgstr "" -#: ../IkiWiki/CGI.pm:212 +#: ../IkiWiki/CGI.pm:211 msgid "Preferences" msgstr "" -#: ../IkiWiki/CGI.pm:213 +#: ../IkiWiki/CGI.pm:212 msgid "Admin" msgstr "" -#: ../IkiWiki/CGI.pm:267 +#: ../IkiWiki/CGI.pm:280 msgid "Preferences saved." msgstr "" -#: ../IkiWiki/CGI.pm:326 +#: ../IkiWiki/CGI.pm:339 #, perl-format msgid "%s is not an editable page" msgstr "" -#: ../IkiWiki/CGI.pm:437 ../IkiWiki/Plugin/brokenlinks.pm:24 +#: ../IkiWiki/CGI.pm:450 ../IkiWiki/Plugin/brokenlinks.pm:24 #: ../IkiWiki/Plugin/inline.pm:306 ../IkiWiki/Plugin/opendiscussion.pm:17 #: ../IkiWiki/Plugin/orphans.pm:28 ../IkiWiki/Render.pm:78 #: ../IkiWiki/Render.pm:148 msgid "discussion" msgstr "" -#: ../IkiWiki/CGI.pm:493 +#: ../IkiWiki/CGI.pm:506 #, perl-format msgid "creating %s" msgstr "" -#: ../IkiWiki/CGI.pm:511 ../IkiWiki/CGI.pm:539 ../IkiWiki/CGI.pm:549 -#: ../IkiWiki/CGI.pm:584 ../IkiWiki/CGI.pm:629 +#: ../IkiWiki/CGI.pm:524 ../IkiWiki/CGI.pm:552 ../IkiWiki/CGI.pm:562 +#: ../IkiWiki/CGI.pm:597 ../IkiWiki/CGI.pm:642 #, perl-format msgid "editing %s" msgstr "" -#: ../IkiWiki/CGI.pm:729 +#: ../IkiWiki/CGI.pm:667 msgid "You are banned." msgstr "" -#: ../IkiWiki/CGI.pm:758 ../IkiWiki/CGI.pm:759 ../IkiWiki.pm:1086 +#: ../IkiWiki/CGI.pm:784 ../IkiWiki/CGI.pm:785 ../IkiWiki.pm:1096 msgid "Error" msgstr "" @@ -182,11 +182,11 @@ msgstr "" msgid "prohibited by allowed_attachments" msgstr "" -#: ../IkiWiki/Plugin/attachment.pm:184 +#: ../IkiWiki/Plugin/attachment.pm:187 msgid "bad attachment filename" msgstr "" -#: ../IkiWiki/Plugin/attachment.pm:226 +#: ../IkiWiki/Plugin/attachment.pm:229 msgid "attachment upload" msgstr "" @@ -203,12 +203,6 @@ msgstr "" msgid "There are no broken links!" msgstr "" -#: ../IkiWiki/Plugin/bzr.pm:12 ../IkiWiki/Plugin/git.pm:15 -#: ../IkiWiki/Plugin/mercurial.pm:12 ../IkiWiki/Plugin/monotone.pm:15 -#: ../IkiWiki/Plugin/svn.pm:11 ../IkiWiki/Plugin/tla.pm:10 -msgid "cannot use multiple rcs plugins" -msgstr "" - #: ../IkiWiki/Plugin/conditional.pm:18 ../IkiWiki/Plugin/cutpaste.pm:22 #: ../IkiWiki/Plugin/cutpaste.pm:37 ../IkiWiki/Plugin/cutpaste.pm:53 #: ../IkiWiki/Plugin/testpagespec.pm:17 @@ -817,15 +811,19 @@ msgstr "" msgid "refreshing wiki.." msgstr "" -#: ../IkiWiki.pm:410 +#: ../IkiWiki.pm:417 msgid "Must specify url to wiki with --url when using --cgi" msgstr "" -#: ../IkiWiki.pm:1069 +#: ../IkiWiki.pm:461 +msgid "cannot use multiple rcs plugins" +msgstr "" + +#: ../IkiWiki.pm:1079 #, perl-format msgid "preprocessing loop detected on %s at depth %i" msgstr "" -#: ../IkiWiki.pm:1557 +#: ../IkiWiki.pm:1567 msgid "yes" msgstr "" |