tips:homepages
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tips:homepages [2014-03-24 18:03] – Klap-in | tips:homepages [2020-05-12 17:11] (current) – add her because previous comment use her too gholk | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== How to create user homepages ====== | ====== How to create user homepages ====== | ||
- | [[devel: | + | DokuWiki can be configured so that it links user's name to a user's personal wiki page. Additionally the ACL rights for these user pages can be set precisely to your wishes. |
- | DokuWiki can be configured using user links to a personal wiki page. Additionally the ACL right for these pages can be set precisely to your wishes. | + | ==== User's name linking |
- | ==== User links==== | + | The [[config: |
- | The [[config: | + | |
The default location of the user page can be modified via the [[: | The default location of the user page can be modified via the [[: | ||
==== ACL for user pages ==== | ==== ACL for user pages ==== | ||
- | The access permissions for the user pages can be set with several | + | The access permissions for the user pages can be set with some configuration lines. The Access Control List (ACL) of DokuWiki can handle two placeholders '' |
Currently '' | Currently '' | ||
- | **Tip:** Create first the desired line for one user page using the Config Manager. Next you modify the user page config line by replacing the username | + | **Tip:** Create first the desired line for one user page using the Config Manager. Next you modify the user page config line by replacing the loginname |
Example: | Example: | ||
Line 20: | Line 19: | ||
# Additional lines for conf/ | # Additional lines for conf/ | ||
# | # | ||
- | # user can modify/ | + | # user can modify/ |
user: | user: | ||
- | # all loggedin | + | # user can create/ |
+ | # (AUTH_EDIT is not enough, because page is not exist before) | ||
+ | user: | ||
+ | # all logged-in | ||
user: | user: | ||
</ | </ | ||
- | More about ACL and wildcards, with examples at: [[:acl#User wildcards]]. | + | More about ACL and wildcards, with examples at: [[:acl#User wildcards|ACL |
- | =====See also===== | + | ====Prefilled template==== |
- | * Customizing [[: | + | You can create a template |
- | * Change [[config: | + | |
- | * [[: | + | |
- | =====OLD STUFF===== | + | See at [[: |
- | | Author: | [[oliver.geisen@kreisbote.de|Oliver Geisen]] | | + | **Tip:** If you would like to modify the namespace template via the browser, you need the plugin |
- | | Overview: | Create homepages for dokuwiki-users without the need of complex ACLs | | + | |
- | | Based on: | dokuwiki-2006-03-09 | | + | |
- | | Plugins needed: | none | | + | |
- | **:!: Please note: This TIP is a simple hack. It would even be better | + | =====See also===== |
+ | | ||
+ | | ||
+ | * [[:ACL|Access Control List]] (ACL) about configuring access permissions. | ||
+ | | ||
- | update: just use %USER% in your acl.auth.php, | + | \\ \\ |
- | **:!: A more recent description (valid | + | ===== How To: Autocreate homespace |
+ | |:!: Please move this example into a plugin. | | ||
- | ===== Motivation ===== | + | Use case: Because |
- | + | ||
- | We (dokuwiki admins) want to give our dokuwiki-users the ability | + | |
- | + | ||
- | ===== How is it all done ? ===== | + | |
- | + | ||
- | Each page the user see's is requested from the browser like: | + | |
- | + | ||
- | http://< | + | |
- | + | ||
- | doku.php itself will initialize some environment, | + | |
- | + | ||
- | lib/ | + | |
- | + | ||
- | So we must decide where to hack the code: Inside ACL checking or where page is shown. I decided to do all the work needed just before the page is shown because I want to keep ACLs clean and simple. Therefore we must make some decicions now: | + | |
- | + | ||
- | - Where should the homepage | + | |
- | - Should other users have access (mostly read-only) to homepages ? | + | |
- | + | ||
- | I decide to: | + | |
- | + | ||
- | * start my user namespace at: '' | + | |
- | * keep users pages private. In order to edit the pages add < | + | |
- | home: | + | |
- | + | ||
- | ===== Extend ACL if user requests his own homepage-namespace ===== | + | |
- | + | ||
- | The next challenge was to find the place in code where user should be given full access to his namespace. We've discovered that main.php is called at least, so let's look inside and we found a call like: | + | |
- | + | ||
- | <?php tpl_content()?> | + | |
- | + | ||
- | Let's do a simple grep-search inside the dokuwiki base-directory to find the lib which exports this function: | + | |
- | + | ||
- | grep -r "function tpl_content" | + | |
- | + | ||
- | The answer is: '' | + | |
- | + | ||
- | So this leads us to " | + | |
- | + | ||
- | <code php> | + | |
- | ... global imports ... | + | |
- | + | ||
- | // if $ID (requested page) starts with ' | + | |
- | if((substr($ID, | + | |
- | $userid = $_SESSION[$conf[' | + | |
- | $allowed = 'home:' | + | |
- | // if user requests the page of another users homedir, deny access to it | + | |
- | if(substr($ID, | + | |
- | print p_locale_xhtml(' | + | |
- | return; | + | |
- | } | + | |
- | } | + | |
- | // only admins, users requesting pages from their own homespace, or users requesting other namespaces will get here | + | |
- | + | ||
- | ... regular code continues ... | + | |
- | </ | + | |
- | + | ||
- | + | ||
- | ===== Add "My page" button to navigation bar ===== | + | |
- | + | ||
- | Add the code to display the new button inside main.php of the template: | + | |
- | + | ||
- | <code php> | + | |
- | <?php tpl_button(' | + | |
- | </ | + | |
- | + | ||
- | Now let's find out where tpl_button comes from. Just use grep-search again and see it's inside inc/ | + | |
- | + | ||
- | Ok, i just added a new case-statement for my button: | + | |
- | <code php> | + | |
- | ... | + | |
- | case ' | + | |
- | $uid = $_SESSION[$conf[' | + | |
- | $id = ' | + | |
- | print html_btn(' | + | |
- | break; | + | |
- | ... | + | |
- | </ | + | |
- | + | ||
- | Next, we need to add the button-label for " | + | |
- | + | ||
- | inc/ | + | |
- | + | ||
- | Here i append a new line containing: | + | |
- | <code php> | + | |
- | $lang[' | + | |
- | </ | + | |
- | + | ||
- | **Please note "Meine Seite" is German. Just put whatever YOU want, of course ;-)** | + | |
- | + | ||
- | Now you can try it, and find a good place for the button inside main.php. | + | |
- | + | ||
- | ===== Autocreate homespace for users ===== | + | |
- | + | ||
- | Because users are not able to create own namespace in " | + | |
lib/ | lib/ | ||
- | Next we must find the place where the new user is created to add our code to create the homespace as well. In the " | + | You can create the functionality |
- | + | ||
- | So lets follow the call to the function " | + | |
- | + | ||
- | I use " | + | |
- | + | ||
- | Because our solution should not depend upon the selected authentication method, it's best to add it to the usermanager code. The problem here is how to build up the path to the namespace for the user to create with mkdir (or better io_mkdir_p() from inc/ | + | |
- | + | ||
- | So lets start thinking reverse again. What happens if one clicks on " | + | |
- | + | ||
- | Here i found two very interesting things: | + | |
- | + | ||
- | - the call to " | + | |
- | - and the call to " | + | |
- | + | ||
- | For now " | + | |
- | + | ||
- | io_makeFileDir($file); | + | |
- | + | ||
- | creates the needed directory structure upon the given filepath. So this is the function to use in the usermanager plugin. | + | |
- | + | ||
- | Now all there is to do is just create the path to the wanted namespace-id, | + | |
- | + | ||
- | //One note about the wikiFN-function. If the last part of the argument given is ':', | + | |
- | + | ||
- | Now it's time to fill our code into the appropriate functions of /lib/ | + | |
- | ==== append new function | + | === append new function === |
<code php> | <code php> | ||
- | /* | + | /** |
* Create homedir (namespace) for user | * Create homedir (namespace) for user | ||
*/ | */ | ||
Line 203: | Line 86: | ||
</ | </ | ||
- | ==== change _modifyUser() | + | === change _modifyUser() === |
<code php> | <code php> | ||
Line 214: | Line 97: | ||
</ | </ | ||
- | ==== change _addUser() | + | === change _addUser() === |
<code php> | <code php> | ||
Line 225: | Line 108: | ||
</ | </ | ||
- | ===== Comments ===== | + | ===General note=== |
- | + | Please read everything carefully and be aware that if you change the sourcecode of DokuWiki, that you need to update | |
- | Ok, thats it! Please read everything carefully and be aware that if you change the sourcecode of dokuwiki, you are unable | + | |
- | + | ||
- | + | ||
- | * This should become a standard feature. | + | |
- | Please make this a standard feature. Giving users their own user page helps a community grow. Maybe take it further by adding in some badges/ |
tips/homepages.1395680600.txt.gz · Last modified: 2014-03-24 18:03 by Klap-in