Revision [15106]

This is an old revision of CloneACLs made by BrianKoontz on 2006-08-10 11:18:20.

 

Clone ACLs


Implemented in release 1.1.6.3
 


A patch you can apply to handlers/page/clone.php that will optionally copy the ACLs from the source page to the new page while cloning a page.

A note about patches
The patch utility is included in most *nix systems and allows all changes to files to be packaged into one convenient
'patch file' for distribution. I've found that in the process of transferring files with embedded tabs from the development machine to the wiki environment, the tabs are lost when using copy-and-paste. Consequently, the patch command will sometimes fail, since the tabs have been munged up. I've found that patch -p0 -l < some.patch (note the "dash el" option -- not "dash one") seems to handle munged-up whitespace quite nicely.

 


Clone ACLs Patch

--- clone.php	2006/03/11 05:26:01	1.1
+++ clone.php	2006/03/11 06:03:04
@@ -29,6 +29,8 @@
  * 
  * @input             boolean $editoption optional: if true, the new page will be opened for edition on creation
  *                            default is false (to allow multiple cloning of the same source)
+ * @input             boolean $cloneaclsoption optional: if true, ACLs will be copied from the source page to the new page
+ *                            default is false
  *
  * @todo              Use central library for valid pagenames.
  *        
@@ -39,6 +41,7 @@
 $to = $this->tag;
 $note = 'Cloned from '.$from; #i18n
 $editoption = ''; 
+$cloneaclsoption = '';
 $box = 'Please fill in a valid target ""PageName"" and an (optional) edit note.'; #i18n
 
 // print header
@@ -65,6 +68,8 @@
 			$to = ($_POST['to'])? $_POST['to'] : $to;
 			$note = ($_POST['note'])? $_POST['note'] : $note;
 			$editoption = (isset($_POST['editoption']))? 'checked="checked"' : '';
+			$cloneaclsoption = (isset($_POST['cloneaclsoption']))? 'checked="checked"' : '';
+
 		
 			// 3. check target pagename validity
 			if (!preg_match("/^[A-Zƒ÷‹]+[a-z&#64258;‰ˆ¸]+[A-Z0-9ƒ÷‹][A-Za-z0-9ƒ÷‹&#64258;‰ˆ¸]*$/s", $to)) 
@@ -90,6 +95,17 @@
 						$thepage=$this->LoadPage($from); # load the source page
 						if ($thepage) $pagecontent = $thepage['body']; # get its content
 						$this->SavePage($to, $pagecontent, $note); #create target page
+                        // Clone ACLs if requested
+                        if($cloneaclsoption == 'checked="checked"')
+                        {
+                            $read_acl = $this->LoadACL($from, "read", 0);
+                            $write_acl = $this->LoadACL($from, "write", 0);
+                            $comment_acl = $this->LoadACL($from, "comment", 0);
+                            $this->SaveACL($to, "read", $this->TrimACLs($read_acl["read_acl"]));
+                            $this->SaveACL($to, "write", $this->TrimACLs($write_acl["write_acl"]));
+                            $this->SaveACL($to, "comment", $this->TrimACLs($comment_acl["comment_acl"]));
+                        }
+                        // Open editor if requested
 						if ($editoption == 'checked="checked"')
 						{
 							// quick edit
@@ -118,6 +134,11 @@
 			'<td></td>'.
 			'<td>'.
 			'<input type="checkbox" name="editoption" '.$editoption.' /> Edit after creation '.
+            '<input type="checkbox" name="cloneaclsoption" '.$cloneaclsoption.' /> Clone ACLs '.
+            '</tr>'.
+            '<tr>'.
+            '<td></td>'.
+            '<td>'.
 			'<input type="submit" name="create" value="Clone" />'.
 			'</td>'.
 			'</tr>'.



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