| 1 | ############################################################################## | ||
| 2 | # The Faq-O-Matic is Copyright 1997 by Jon Howell, all rights reserved. # | ||
| 3 | # # | ||
| 4 | # This program is free software; you can redistribute it and/or # | ||
| 5 | # modify it under the terms of the GNU General Public License # | ||
| 6 | # as published by the Free Software Foundation; either version 2 # | ||
| 7 | # of the License, or (at your option) any later version. # | ||
| 8 | # # | ||
| 9 | # This program is distributed in the hope that it will be useful, # | ||
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | ||
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | ||
| 12 | # GNU General Public License for more details. # | ||
| 13 | # # | ||
| 14 | # You should have received a copy of the GNU General Public License # | ||
| 15 | # along with this program; if not, write to the Free Software # | ||
| 16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.# | ||
| 17 | # # | ||
| 18 | # Jon Howell can be contacted at: # | ||
| 19 | # 6211 Sudikoff Lab, Dartmouth College # | ||
| 20 | # Hanover, NH 03755-3510 # | ||
| 21 | # jonh@cs.dartmouth.edu # | ||
| 22 | # # | ||
| 23 | # An electronic copy of the GPL is available at: # | ||
| 24 | # http://www.gnu.org/copyleft/gpl.html # | ||
| 25 | # # | ||
| 26 | ############################################################################## | ||
| 27 | |||
| 28 | use strict; | ||
| 29 | |||
| 30 | package FAQ::OMatic::submitModOptions; | ||
| 31 | |||
| 32 | use CGI; | ||
| 33 | use FAQ::OMatic::Item; | ||
| 34 | use FAQ::OMatic::I18N; | ||
| 35 | use FAQ::OMatic; | ||
| 36 | use FAQ::OMatic::Auth; | ||
| 37 | |||
| 38 | sub main { | ||
| 39 | my $cgi = FAQ::OMatic::dispatch::cgi(); | ||
| 40 | |||
| 41 | my $params = FAQ::OMatic::getParams($cgi); | ||
| 42 | |||
| 43 | FAQ::OMatic::mirrorsCantEdit($cgi, $params); | ||
| 44 | |||
| 45 | my $item = new FAQ::OMatic::Item($params->{'file'}); | ||
| 46 | if ($item->isBroken()) { | ||
| 47 | FAQ::OMatic::gripe('error', gettexta("The file (%0) doesn't exist.", $params->{'file'})); | ||
| 48 | } | ||
| 49 | |||
| 50 | FAQ::OMatic::Auth::ensurePerm('-item'=>$item, | ||
| 51 | '-operation'=>'PermModOptions', | ||
| 52 | '-restart'=>'editModOptions', | ||
| 53 | '-cgi'=>$cgi, | ||
| 54 | '-failexit'=>1); | ||
| 55 | |||
| 56 | # verify that an evil cache hasn't truncated a POST | ||
| 57 | if ($params->{'_zzverify'} ne 'zz') { | ||
| 58 | FAQ::OMatic::gripe('error', | ||
| 59 | "Your browser or WWW cache has truncated your POST."); | ||
| 60 | } | ||
| 61 | |||
| 62 | $item->checkSequence($params); | ||
| 63 | $item->incrementSequence(); | ||
| 64 | |||
| 65 | # set each defined permission from $params | ||
| 66 | my $pi = FAQ::OMatic::Item::permissionsInfo(); | ||
| 67 | my @permSet = map { $pi->{$_}->{'name'} } sort keys %{$pi}; | ||
| 68 | push @permSet, 'Moderator', 'MailModerator', 'Notifier', 'MailNotifier', 'RelaxChildPerms'; | ||
| 69 | my $perm; | ||
| 70 | foreach $perm (@permSet) { | ||
| 71 | if (defined $params->{"_$perm"}) { | ||
| 72 | $item->setProperty($perm, $params->{"_$perm"}); | ||
| 73 | } | ||
| 74 | } | ||
| 75 | |||
| 76 | $item->saveToFile(); | ||
| 77 | |||
| 78 | $item->notifyModerator($cgi, 'edited the moderator options'); | ||
| 79 | |||
| 80 | my $url = FAQ::OMatic::makeAref( | ||
| 81 | '-command'=>'faq', | ||
| 82 | '-params'=>$params, | ||
| 83 | '-changedParams'=>{'checkSequenceNumber'=>''}, | ||
| 84 | '-refType'=>'url'); | ||
| 85 | |||
| 86 | FAQ::OMatic::redirect($cgi, $url); | ||
| 87 | } | ||
| 88 | |||
| 89 | 1; |