Revision [15562]

This is an old revision of InheritACL made by MasinAlDujaili on 2006-10-26 16:31:27.

 

Inheriting of ACL

As wished in #139, a simple way for setting ACL at creation time might be useful. The idea is to take the ACL of the page where the link leading to page creation has been clicked by the user.

As JavaWoman states on HierarchiesAndInheritance, there are five different ways of creating a new page:

  1. By creating a URL with the new page name (and optionally immediately adding the /edit handler)
  1. By using the form presented by the "newpage" action
  1. By following a "missing page" link from another page and following the "create" link from the resulting dummy page
  1. By cloning from a template page
  1. By cloning from another (non-template) page

Cases 4 & 5 have been taken care by BrianKoontz with his CloneACLs patch. Case 1 just needs to get the defaut ACL of the config file while case 2 might be more difficult to implement something elegant. I want to take care of the third case: The page creation by following a "missing page" link from another page.

As I'm not very familiar with the WikkaWiki code, some solutions might look clumsy -- I greatly appreciate if someone would take a look into the code.

Ensuring to get the 'parent' page

Almost at the end of the Link() function in libs/wakka.class.php you'll find this line
            return ($linkedPage ? "<a href=\"".$this->Href($method, $linkedPage['tag'])."\" title=\"$title\">".$text."</a>" : "<a class=\"missingpage\" href=\"".$this->Href("edit", $tag)."\" title=\"Create this page\">".$text."</a>");


Might look somewhat different, as I have tuned it a little bit to fit my needs (memo: create a test installation with a native 1.1.6.2). Replace the line with this line (fit it to your installation as needed):
            return ($linkedPage ? "<a href=\"".$this->Href($method, $linkedPage['tag'])."\" title=\"$title\">".$text."</a>" : "<a class=\"missingpage\" href=\"".$this->Href("edit", $tag, "page=".$this->GetPageTag())."\" title=\"Create this page\">".$text."</a>");


If a page is not existing in the Wikka database, it gets a link with the edit handler appended to it. I further append the tag of the current page to it.

I don't know a simpler way of doing this, but in the next step, I put the page tag from above in the edit form of the next page. Around line 200 of handlers/page/edit.php you should find the following code block:
        $output .=
            $this->FormOpen('edit').
            '<input type="hidden" name="previous" value="'.$previous.'" />'."\n".
            // We need to escape ALL entity refs before display so we display them _as_ entities instead of interpreting them
            // hence htmlspecialchars() instead of htmlspecialchars_ent() which UNescapes entities!
            '<textarea id="body" name="body">'.htmlspecialchars($body).'</textarea><br />'."\n";
            //note add Edit
            // We need to escape ALL entity refs before display so we display them _as_ entities instead of interpreting them
            // so we use htmlspecialchars on the edit note (as on the body)


Replace it with this code block:
        $ref_page = '';
        if (isset($_GET['page']) $ref_page = $_GET['page'];
        $output .=
            $this->FormOpen('edit').
            '<input type="hidden" name="previous" value="'.$previous.'" />'."\n";
        if ($ref_page != '') $output .= '<input type="hidden" name="page" value="'.$ref_page.'" />'."\n";
        $output .=
            // We need to escape ALL entity refs before display so we display them _as_ entities instead of interpreting them
            // hence htmlspecialchars() instead of htmlspecialchars_ent() which UNescapes entities!
            '<textarea id="body" name="body">'.htmlspecialchars($body).'</textarea><br />'."\n";
            //note add Edit
            // We need to escape ALL entity refs before display so we display them _as_ entities instead of interpreting them
            // so we use htmlspecialchars on the edit note (as on the body)


This code is not tested! It's still under development; I publish this just for review by more experienced developers.

In our next episode we will see how I'll incredibly fail at cloning the ACL. Coming soon to a Wiki near you!
 

CategoryUserContributions
There are 3 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki