From: <Pet...@nt...> - 2005-07-03 01:17:08
|
Author: PeterNixon Date: 2005-07-02 18:16:25 -0700 (Sat, 02 Jul 2005) New Revision: 4502 Modified: twiki/scratch/MultiLevelWikiWebs/lib/TWiki/Store.pm twiki/scratch/MultiLevelWikiWebs/lib/TWiki/UI/Manage.pm twiki/scratch/MultiLevelWikiWebs/templates/renameweb.pattern.tmpl twiki/scratch/MultiLevelWikiWebs/templates/renameweb.tmpl Log: MultiLevelWikiWebs: RenameWeb root web renaming fixes Modified: twiki/scratch/MultiLevelWikiWebs/lib/TWiki/Store.pm =================================================================== --- twiki/scratch/MultiLevelWikiWebs/lib/TWiki/Store.pm 2005-07-03 00:33:51 UTC (rev 4501) +++ twiki/scratch/MultiLevelWikiWebs/lib/TWiki/Store.pm 2005-07-03 01:16:25 UTC (rev 4502) @@ -402,23 +402,19 @@ my $accessCheckWeb=$newParent; my $accessCheckTopic=$TWiki::cfg{WebPrefsTopicName}; - if( $newParent eq "" ) { - $newParent = ""; - $accessCheckWeb=$TWiki::cfg; - $accessCheckTopic=$TWiki::cfg{SystemWebName}; - } else { + if( $newParent ne "" ) { if(!$this->webExists($newParent)) { return 1; } - } - my ( $nmeta, $ntext ) = $this->readTopic( undef, $accessCheckWeb, $accessCheckTopic ); - if( $user && - !$this->{session}->{security}->checkAccessPermission - ( 'change', $user, $ntext, $accessCheckWeb, $accessCheckTopic )) { - throw TWiki::AccessControlException( 'CHANGE', $user, - $newParent, $accessCheckTopic, - $this->{session}->{security}->getReason()); + my ( $nmeta, $ntext ) = $this->readTopic( undef, $accessCheckWeb, $accessCheckTopic ); + if( $user && + !$this->{session}->{security}->checkAccessPermission + ( 'change', $user, $ntext, $accessCheckWeb, $accessCheckTopic )) { + throw TWiki::AccessControlException( 'CHANGE', $user, + $newParent, $accessCheckTopic, + $this->{session}->{security}->getReason()); + } } # Should whole webs have handlers? @@ -472,25 +468,21 @@ my $accessCheckWeb=$newParent; my $accessCheckTopic=$TWiki::cfg{WebPrefsTopicName}; - if( $newParent eq "/" ) { - $newParent = ""; - $accessCheckWeb=$TWiki::cfg; - $accessCheckTopic=$TWiki::cfg{SystemWebName}; - } else { + if( $newParent ne "" ) { if(!$this->webExists($newParent)) { $error=1; return $error; } + my ( $nmeta, $ntext ) = $this->readTopic( undef, $accessCheckWeb, $accessCheckTopic ); + if( $user && + !$this->{session}->{security}->checkAccessPermission + ( 'change', $user, $ntext, $accessCheckWeb, $accessCheckTopic )) { + throw TWiki::AccessControlException( 'CHANGE', $user, + $newParent, $accessCheckTopic, + $this->{session}->{security}->getReason()); + } } - my ( $nmeta, $ntext ) = $this->readTopic( undef, $accessCheckWeb, $accessCheckTopic ); - if( $user && - !$this->{session}->{security}->checkAccessPermission - ( 'change', $user, $ntext, $accessCheckWeb, $accessCheckTopic )) { - throw TWiki::AccessControlException( 'CHANGE', $user, - $newParent, $accessCheckTopic, - $this->{session}->{security}->getReason()); - } return $error; } Modified: twiki/scratch/MultiLevelWikiWebs/lib/TWiki/UI/Manage.pm =================================================================== --- twiki/scratch/MultiLevelWikiWebs/lib/TWiki/UI/Manage.pm 2005-07-03 00:33:51 UTC (rev 4501) +++ twiki/scratch/MultiLevelWikiWebs/lib/TWiki/UI/Manage.pm 2005-07-03 01:16:25 UTC (rev 4502) @@ -408,9 +408,16 @@ my $newParentWeb = $query->param( 'newparentweb' ) || ''; my $newSubWeb = $query->param( 'newsubweb' ) || '';; my $newWeb; - if($newParentWeb && $newSubWeb) { - $newWeb="$newParentWeb/$newSubWeb"; + if($newSubWeb) { + if($newParentWeb) { + $newWeb="$newParentWeb/$newSubWeb"; + } else { + $newWeb=$newSubWeb; + } } + my (@tmp)=split(/[\/\.]/,$oldWeb); + pop(@tmp); + my $oldParentWeb=join("/",@tmp); my $newTopic; my $theUrl = $query->url; my $lockFailure = ''; @@ -425,7 +432,9 @@ if( $newWeb ) { ( $newWeb, $newTopic ) = $session->normalizeWebTopicName( $newWeb, $TWiki::cfg{WebPrefsTopicName} ); - TWiki::UI::checkWebExists( $session, $newParentWeb, $TWiki::cfg{WebPrefsTopicName}, 'rename' ); + if($newParentWeb) { + TWiki::UI::checkWebExists( $session, $newParentWeb, $TWiki::cfg{WebPrefsTopicName}, 'rename' ); + } if( $store->topicExists( $newWeb, $TWiki::cfg{WebPrefsTopicName})) { throw TWiki::OopsException( 'attention', def => 'rename_web_exists', @@ -457,8 +466,8 @@ if ( $newWeb =~ /^$TWiki::cfg{TrashWebName}\// && $oldWeb !~ /^$TWiki::cfg{TrashWebName}\// ) { # redirect to parent: ending in Trash is not the expected way - if($newParentWeb) { - $new_url = $session->getScriptUrl( $newParentWeb, $TWiki::cfg{HomeTopicName}, 'view' ); + if($oldParentWeb) { + $new_url = $session->getScriptUrl( $oldParentWeb, $TWiki::cfg{HomeTopicName}, 'view' ); } else { $new_url = $session->getScriptUrl( $TWiki::cfg{UsersWebName}, $TWiki::cfg{HomeTopicName}, 'view' ); } @@ -697,8 +706,7 @@ web => $oldWeb, topic => '', def => 'rename_err', - params => [ $error, $newWeb, - '' ] ); + params => [ $error, $newWeb, '' ] ); } # update referrers. We need to do this before moving, @@ -714,8 +722,7 @@ web => $oldWeb, topic => '', def => 'rename_err', - params => [ $error, $newWeb, - '' ] ); + params => [ $error, $newWeb, '' ] ); } Modified: twiki/scratch/MultiLevelWikiWebs/templates/renameweb.pattern.tmpl =================================================================== --- twiki/scratch/MultiLevelWikiWebs/templates/renameweb.pattern.tmpl 2005-07-03 00:33:51 UTC (rev 4501) +++ twiki/scratch/MultiLevelWikiWebs/templates/renameweb.pattern.tmpl 2005-07-03 01:16:25 UTC (rev 4502) @@ -12,7 +12,7 @@ %TMPL:DEF{"newsubweb"}%<input name="newsubweb" value="%NEW_SUBWEB%" size="36" />%TMPL:END% -%TMPL:DEF{"newparentweb"}%<select name="newparentweb">%WEBLIST{"<option $marker value=$qname>$name</option>" webs="%TRASHWEB%,public" selection="%NEW_PARENTWEB%" separator=" "}%</select>%TMPL:END% +%TMPL:DEF{"newparentweb"}%<select name="newparentweb"><option value=""></option>%WEBLIST{"<option $marker value=$qname>$name</option>" webs="%TRASHWEB%,public" selection="%NEW_PARENTWEB%" separator=" "}%</select>%TMPL:END% Modified: twiki/scratch/MultiLevelWikiWebs/templates/renameweb.tmpl =================================================================== --- twiki/scratch/MultiLevelWikiWebs/templates/renameweb.tmpl 2005-07-03 00:33:51 UTC (rev 4501) +++ twiki/scratch/MultiLevelWikiWebs/templates/renameweb.tmpl 2005-07-03 01:16:25 UTC (rev 4502) @@ -2,7 +2,7 @@ %TMPL:DEF{"titleaction"}%(rename) %TMPL:END% %TMPL:DEF{"webaction"}%Rename%TMPL:END% %TMPL:DEF{"newsubweb"}%<input name="newsubweb" value="%NEW_SUBWEB%" size="36" />%TMPL:END% -%TMPL:DEF{"newparentweb"}%<select name="newparentweb">%WEBLIST{"<option $marker value=$qname>$name</option>" webs="%TRASHWEB%,public" selection="%NEW_PARENTWEB%" separator=" "}%</select>%TMPL:END% +%TMPL:DEF{"newparentweb"}%<select name="newparentweb"><option value=""></option>%WEBLIST{"<option $marker value=$qname>$name</option>" webs="%TRASHWEB%,public" selection="%NEW_PARENTWEB%" separator=" "}%</select>%TMPL:END% %TMPL:DEF{"notes"}% <br /> __Note:__ It's usually best to choose a |