Tags:
create new tag
view all tags

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

action %SCRIPTURLPATH%/save%SCRIPTSUFFIX%/Sandbox/
topic
templatetopic
onlynewtopic

Environment

TWiki version: TWikiRelease01Sep2004
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  

-- 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

Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2005-02-13 - SamHasler
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.