<p>Hi, Peter,<br></p>
<p>On Jul 14, 2012 6:20 AM, "Peter Bowers" <<a href="mailto:pbowers@pobox.com">pbowers@pobox.com</a>> wrote:<br>
><br>
> On Fri, Jul 13, 2012 at 7:58 PM, Alex Eftimiades<br>
> <<a href="mailto:alexeftimiades@gmail.com">alexeftimiades@gmail.com</a>> wrote:<br>
> > I was looking for an easy way for editors to password protect something so<br>
> > that only other editors could see/edit it. I tried making a password<br>
> > protected group, but that quickly became an organizational hindrance. I want<br>
> > this to be very easy for editors, so the logical thing seemed to be to<br>
> > password protect a category with the editors' password, then just have<br>
> > editors tag articles in the password protected category. The problem is that<br>
> > I have no idea how go about doing this. Could anyone help me password<br>
> > protect a category or come up with a better idea to accomplish the same<br>
> > thing?<br>
><br>
> I can think of 4 ways to do this:<br>
><br>
> (1) Copy and modify the security mechanism of pmwiki so that it looks<br>
> for the presence of a given category as part of the way it checks<br>
> whether someone is authorized.  Difficulty: 9/10.  NOT recommended.<br>
><br>
> (2) Write an additional filter and place it in $EditFunctions to be<br>
> used by UpdatePage().  It would simply check the new text for the<br>
> presence/absence of a given category and add or strip out a password<br>
> based on this.  Difficulty: 3/10 (as long as you don't have to worry<br>
> about any other per-page passwords)<br>
><br>
> (3) In config.php simply check if the current $action is 'edit' and,<br>
> if so, set or unset a site-wide edit password based on the<br>
> presence/absence of the given category in the text.  Difficulty: 2/10<br>
> (if you run into caching problems because you're reading the page<br>
> during config.php processing then this may move up to 6 or even 8 out<br>
> of 10)<br>
><br>
> (4) Rather than using the category solution at all, simply set up a<br>
> form which you can put in the page header or footer.  This form would<br>
> be visible only to users with appropriate authorization and it would<br>
> be a simple toggle button (protect / unprotect page).  Difficulty:<br>
> 4-5/10 (or even easier if you've worked with forms in pmwiki before)<br>
><br>
> I would suggest #4 as it avoids getting into the potentially thorny<br>
> areas of authorizations, caching, etc.<br>
><br>
> I'm not sure if pmform or fox forms supports setting passwords -- if<br>
> so then that would ease things quite a bit.  WikiSh supports it, but<br>
> it's probably not worth the learning curve unless you're going to do<br>
> more than just this project...<br>
><br>
> -Peter<br>
><br>
> Some *thoughts* on implementation -- much of this is syntactically<br>
> incorrect, far less tested...  Just to give you an idea.<br>
><br>
> Site.PageHeader:<br>
><br>
> ===(snip)===<br>
> (:if authid:)<br>
> >>float right<<<br>
> (:input form <a href="http://url/to/your/formscript.php">http://url/to/your/formscript.php</a> method=GET:)</p>
<p>You're doing something here I don't quite get. The action is going to be done by formscript.php, yet ...<br>
(See below)<br></p>
<p>> (:input hidden name=n [I forget how to make the default here...]:)<br>
> (:if1 equal "{$Protected}" 1:)<br>
> (:input submit name=unsetpw label="Unprotect Page":)<br>
> (:else1:)<br>
> (:input submit name=setpw label="Protect Page":)<br>
> (:if1 end:)<br>
> (:input end:)<br>
> >><<<br>
> (:if end:)<br>
> ===(snip)===<br>
><br>
> Oh, on second thought, it would be even better putting this into<br>
> PageActions -- better for screen real estate, logically/intuitively,<br>
> etc.<br>
><br>
> in config.php:<br>
><br>
> ===(snip)===<br>
> # See Cookbook/OpenPass for an example how to set a PV based<br>
> # on the presence/absence of a password.  Your conditional in PageActions<br>
> # or PageHeader will use this PV to determine whether to offer<br>
> # "Protect Page" or "Unprotect Page" or etc.  I called it {$Protected} above.<br>
> ===(snip)===<br>
><br>
> in formscript.php:<br>
><br>
> ===(snip)===<br>
> # Rough (!!) pseudo-code for handling the form<br>
> if (@$_GET['setpw']) {</p>
<p>Here, you calling PmWiki routines?</p>
<p>How do you do that?<br></p>
<p>>    $page = RetrieveAuthPage($pagename, 'edit'); // make sure we have auth<br>
>    if ($page['passwdedit']) ... or not ... yada, yada ...<br>
>       $page['passwdedit'] = encrypt($myStandardPassword); // add passwd<br>
>    UpdatePage(args); // save the page<br>
>    // fix the URL to get rid of $_GET['setpw'] and anything else that<br>
> should be dumped<br>
>    Redirect(args); // redirect back to current page (n) without $_GET values<br>
>                            // now that the page password has been set<br>
> } elseif (@$_GET['unsetpw']) {<br>
>    // do the same kind of stuff, but you're getting rid of the passwd<br>
> rather than<br>
>    // adding it...<br>
> }<br>
> ===(snip)===<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>