<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Actually, the link fixing part should make renaming a page quite reversible. One simply renames it back, and all the damage that was done would be fixed in the same way. <div>This is the code I put in WikiSh.Rename:</div><div>//start code</div><div><div>{(wikish source {$FullName}#RenamePage)}</div><div><br></div><div>(:if false:)</div><div>[[#RenamePage]]</div><div>wikish_form process</div><div>if test -n ${Submit}</div><div>then</div><div> if test "${NewPage}" ~= "/^[\sa-z0-9-]+(\.|\/)[\sa-z0-9-]+$/i"</div><div> then</div><div> if test "${OldPage}" != "/^([\sa-z0-9-]+)(\.|\/)\1$/i"</div><div> then</div><div> set -s NewPagePN = `echo ${NewPage}|sed 's|\s||gi' | sed 's|/|\.|gi'`</div><div> set -s OldPagePN = `echo ${OldPage}|sed 's|\s||gi' | sed 's|/|\.|gi'`</div><div> set -s OldPageR = `echo ${OldPage}|sed 's|\s+|\\s*|gi'| sed 's|/|/|gi'`</div><div> echo "${OldPageR}"</div><div> echo "${NewPage}"</div><div> sed -i 's%${OldPageR}%${NewPage}%gi' `pagelist link=${OldPagePN} sep=\n`</div><div> mv ${OldPagePN} ${NewPagePN}</div><div> wikish_form redirect target=${NewPagePN}</div><div> fi</div><div> fi</div><div>fi</div><div>[[#RenamePage]]</div><div>(:ifend:)</div></div><div>//end code</div><div>This is the code I put in PageActions:</div><div>//start code</div><div><div>(:if equal {$Action} "edit":)</div><div>* %item rel=nofollow% (:input form action="index.php" method="GET":)(:input hidden name=n value="WikiSh.Rename":)(:input hidden name=OldPage value="{*$Groupspaced}/{*$Namespaced}":)Enter New Name:(:input text name=NewPage value="{*$Groupspaced}/{*$Namespaced}" size=30:)(:input submit Submit value="Rename":)(:input end:)</div><div>(:ifend:)</div></div><div>//end code</div><div><br></div><div>This actually works quite well except for the fact that only admin can rename pages. I would like editors to be able to rename pages so long as they have edit permissions for both the old page and the new page. Right now, you need to enter an admin password to run the script. The relevent portion of my config.php looks like this:</div><div>//start code</div><div><div>include_once("$FarmD/cookbook/toolbox.php");</div><div>include_once("$FarmD/cookbook/WikiSh.php");</div><div>if ($group == 'WikiSh')</div><div> include_once("$FarmD/cookbook/WikiShCL.php");</div><div>include_once("$FarmD/cookbook/SecLayer.php"); // note this includes stdconfig.php</div><div>$EnableWikiShWritePage = true;</div><div>$EnableWikiShCreatePage = true;</div><div>$EnableWikiShOverwritePage = true;</div><div>$EnableWikiShRemove = true;</div><div>if (CondAuth($pagename, "admin")) {</div><div> slAddAuth($wshAuthPage, "*.*", "read,create,insert,overwrite,append,prepend,attr,delete");</div><div> $EnableWikiShDeletePage = true;</div><div> $EnableWikiShChmod = true;</div><div>} else {</div><div> slAddAuth($wshAuthPage, "*.*", "read,create");</div><div> slAddAuth($wshAuthPage, "Test.*", "insert,overwrite,append,prepend,delete");</div><div>}</div><div># cookbook/powertools.php is *very* helpful in the wikish environment but is optional. </div><div># If you decide to install it you will need to go that page and download it and install</div><div># it as follows:</div><div>include_once("$FarmD/cookbook/powertools.php");</div></div><div>//end code</div><div><br></div><div>I tried modifying the CondAuth line with an "or $group=='WikiSh'" for starters, but that did not seem to make a difference. I am quite confused as to how to go about doing this.</div><div><br></div><div>Thanks,</div><div>Alex</div><div><br></div><div><br></div><div><br><div><div>On Jul 23, 2012, at 2:46 PM, tamouse mailing lists wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><p><br> On Jul 22, 2012 11:01 PM, "Alex Eftimiades" <<a href="mailto:alexeftimiades@gmail.com">alexeftimiades@gmail.com</a>> wrote:<br> ><br> > Hi again, I tried making this a page action as follows (in Site.PageActions)<br> > * %item rel=nofollow% {(wikish source {$SiteGroup}.PageActions#RenamePage)}Rename Page:(:input text name=NewPage value={$FullName} size=30:)(:input submit name=submit value=Rename:)(:input end:)<br> ><br> > (:if false:)<br> > [[#RenamePage]]<br> > wikish_form quickform process<br> > if test -n "${submit}"<br> > then<br> > if test "${NewPage}" ~= "/^[a-z0-9-]+(\.|\/)[a-z0-9-]+$/i"<br> > then<br> > if test {$Name}!={$Group}<br> > then<br> > set -s NewPagePN = `echo ${NewPage} | sed 's|\s||gi' | sed 's|/|\.|gi'`<br> > sed -i 's%({$Group}|{$Groupspaced})(/|\.)({$Name}|{$NameSpaced})%${NewPage}%g' `pagelist link={$FullName} sep=\n`<br> > mv {$FullName} ${NewPagePN}<br> > wikish_form redirect target=${NewPagePN}<br> > fi<br> > fi<br> > [[#RenamePage]]<br> > (:ifend:)<br> ><br> > But with this setup the rename button is disabled. Could anyone tell me what part of this I need to fix? Perhaps I am going about this wrong.<br> ><br> > Thanks,<br> > Alex<br> ><br> ><br> ><br> > On Jul 21, 2012, at 10:16 PM, Alex Eftimiades wrote:<br> ><br> >> Yes this seems to work now. Thank you very much. I am going to try to modify this into a page action and for renaming groups.<br> >><br> >> Thanks<br> >> Alex<br> >><br> >> On Jul 21, 2012, at 12:53 PM, Peter Bowers wrote:<br> >><br> >>> No that's fine. If it's an action you do on a regular basis then<br> >>> you'll probably want to put the code on a page and put it together<br> >>> with a form, but that can easily be a future step. Doing it in the<br> >>> ControlPanel is a good way to get things working...<br> >>><br> >>> I loaded the first command from your command history and noticed that<br> >>> you have a newline in the middle of the line that should read like<br> >>> this:<br> >>><br> >>> sed -i 's|${OldGroup}([./]\)?)${OldPage}|${NewGroup}$1${NewPage}|gi'<br> >>> `pagelist link=${OldGroupPN}.${OldPagePN} sep=\n`<br> >>><br> >>> That should all be on one line with no newline before the `pagelist...<br> >>><br> >>> It may have gotten confusing because the email may have automatically<br> >>> wordwrapped it when I sent it to you.<br> >>><br> >>> Anyway, I certainly don't want to come anywhere close to actually<br> >>> running code like this on someone else's system, so I'm just letting<br> >>> you know what needs to happen and then leave it up to you.<br> >>><br> >>> If that works, please report back to the list that it was just a<br> >>> newline due to the email wordwrapping. If it doesn't work then let me<br> >>> know and I'll take another look -- just give me the exact error<br> >>> message since I'm wanting to avoid actually executing anything on your<br> >>> system.<br> >>><br> >>> -Peter<br> >><br> >><br> ><br> ><br> > _______________________________________________<br> > pmwiki-users mailing list<br> > <a href="mailto:pmwiki-users@pmichaud.com">pmwiki-users@pmichaud.com</a><br> > <a href="http://www.pmichaud.com/mailman/listinfo/pmwiki-users">http://www.pmichaud.com/mailman/listinfo/pmwiki-users</a><br></p><p>Something about the idea of putting sort of thing in PageActions like this scares me. It seems like a chance for vandalization to occur of a sort that would be hard to recover from. Wikish may be highly useful, but I think this action would be better raised to a first-class recipe with attendant authorization and validation, if one is going to make available on PageActions. Just my deux centimes.</p> </blockquote></div><br></div></body></html>