DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:user_pages

This is an old revision of the document!


User Pages

This is to have a namespace that is for user pages, where each user has AUTH_EDIT on their own page, without the need to add an entry for every user to the ACL.

This patch has been applied after the Separate Admin Login patch:

--- auth.php.bak	2009-02-24 15:29:16.000000000 +0000
+++ auth.php	2009-02-24 15:42:49.000000000 +0000
@@ -430,6 +430,13 @@
   $max = AUTH_ADMIN;
   if($_SESSION[DOKU_COOKIE]['auth']['admin'] == true) { $max =  AUTH_READ; }
 
+  //if users home page, minimum is AUTH_EDIT (but max above beats min here)
+  $min = AUTH_NONE;
+  $fullname = $_SESSION[DOKU_COOKIE]['auth']['info']['name'];
+  $fullname = str_replace(' ', '_', $fullname);
+  $fullname = strtolower($fullname);
+  if($id == 'users:'.$fullname) { $min = AUTH_EDIT; }
+
   //make sure groups is an array
   if(!is_array($groups)) $groups = array();
 
@@ -471,7 +478,7 @@
     }
     if($perm > -1){
       //we had a match - return it
-      return min($perm,$max);
+      return min(max($perm,$min),$max);
     }
   }
 
@@ -494,7 +501,7 @@
         }
       }
       //we had a match - return it
-      return min($perm,$max);
+      return min(max($perm,$min),$max);
     }
 
     //get next higher namespace

This is a hand-hacked version that doesn't require the other tip to be applied (you may have to fix it up):

--- auth.php.bak	2009-02-24 15:29:16.000000000 +0000
+++ auth.php	2009-02-24 15:42:49.000000000 +0000
@@ -430,6 +430,13 @@
   // if no ACL is used always return upload rights
   if(!$conf['useacl']) return AUTH_UPLOAD;
 
+  //if users home page, minimum is AUTH_EDIT (but max above beats min here)
+  $min = AUTH_NONE;
+  $fullname = $_SESSION[DOKU_COOKIE]['auth']['info']['name'];
+  $fullname = str_replace(' ', '_', $fullname);
+  $fullname = strtolower($fullname);
+  if($id == 'users:'.$fullname) { $min = AUTH_EDIT; }
+
   //make sure groups is an array
   if(!is_array($groups)) $groups = array();
 
@@ -471,7 +478,7 @@
     }
     if($perm > -1){
       //we had a match - return it
-      return $perm;
+      return max($perm,$min;
     }
   }
 
@@ -494,7 +501,7 @@
         }
       }
       //we had a match - return it
-      return $perm;
+      return max($perm,$min);
     }
 
     //get next higher namespace
tips/user_pages.1244039661.txt.gz · Last modified: 2009-11-13 18:53 (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki