Bug: Direct save is not honoring the onlynewtopic Flag
FlagForEditScriptToAvoidFormDataOverwrite should also be honored by the save script so that direct saving can avoid overwriting topics.
Test case
Environment
--
SamHasler - 10 Sep 2004
Follow up
Fix record
Fix for
onlynewtopic flag and also for
onlywikiname flag is now in
SVN.
Index: Save.pm
===================================================================
--- Save.pm (revision 1740)
+++ Save.pm (working copy)
@@ -76,12 +76,32 @@
my $dontNotify = $query->param( "dontnotify" ) || "";
my $changeform = $query->param( 'submitChangeForm' ) || "";
my $theParent = $query->param( 'topicparent' ) || "";
+ my $onlyWikiName = $query->param( 'onlywikiname' ) || "";
+ my $onlyNewTopic = $query->param( 'onlynewtopic' ) || "";
my $formTemplate = $query->param( "formtemplate" );
+ my $topicExists = TWiki::Store::topicExists( $webName, $topic );
+
return 0 unless TWiki::UI::webExists( $webName, $topic );
return 0 if TWiki::UI::isMirror( $webName, $topic );
+ # Prevent saving existing topic?
+ if( $onlyNewTopic && $topicExists ) {
+ # Topic exists and user requested oops if it exists
+ TWiki::UI::oops( $webName, $topic, "createnewtopic" );
+ return 0;
+ }
+
+ # prevent non-Wiki names?
+ if( ( $onlyWikiName )
+ && ( ! $topicExists )
+ && ( ! ( &TWiki::isWikiName( $topic ) || &TWiki::isAbbrev( $topic ) ) ) ) {
+ # do not allow non-wikinames, redirect to view topic
+ TWiki::UI::redirect( TWiki::getViewUrl( $webName, $topic ) );
+ return 0;
+ }
+
my $wikiUserName = TWiki::userToWikiName( $userName );
return 0 unless TWiki::UI::isAccessPermitted( $webName, $topic,
"change", $wikiUserName );
--
PeterThoeny - 16 Sep 2004