tips:homepages
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tips:homepages [2013-11-28 13:43] – [How to create user homepages] 92.50.79.91 | 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 ====== | ||
- | | Author: | [[oliver.geisen@kreisbote.de|Oliver Geisen]] | | + | DokuWiki can be configured so that it links user's name to a user's personal wiki page. Additionally |
- | | Overview: | Create homepages for dokuwiki-users without | + | |
- | | Based on: | dokuwiki-2006-03-09 | | + | |
- | | Plugins needed: | none | | + | |
- | **:!: Please note: This TIP is a simple hack. It would even be better | + | ==== User's name linking |
- | update: just use %USER% in your acl.auth.php, it will be subsituted by the current logged | + | The [[config:showuseras]] config setting can be set to " |
+ | The default location of the user page can be modified via the [[:interwiki]] configuration. | ||
- | **:!: A more recent description (valid | + | ==== ACL for user pages ==== |
+ | 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 '' | ||
- | ===== Motivation ===== | + | **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 by the '' |
- | We (dokuwiki admins) want to give our dokuwiki-users the ability to create their own homepages. These should be in their own responsibility and therefore in their own namespace. The user may create as many pages as he want inside this namespace (Think twice: " | + | Example: |
- | + | <code - conf/acl.auth.php> | |
- | ===== How is it all done ? ===== | + | # Additional lines for conf/acl.auth.php : |
- | + | # | |
- | Each page the user see's is requested from the browser like: | + | # user can modify/delete page in his/her namespace |
- | + | user:%USER%:* | |
- | http://<server>/doku.php? | + | # user can create/delete his/her own page |
- | + | # (AUTH_EDIT | |
- | doku.php itself will initialize some environment, | + | user:%USER% |
- | + | # all logged-in | |
- | lib/tpl/< | + | user: |
- | + | ||
- | 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 " | + | |
- | + | ||
- | The answer | + | |
- | + | ||
- | So this leads us to " | + | |
- | + | ||
- | <code php> | + | |
- | ... global imports ... | + | |
- | + | ||
- | // if $ID (requested page) starts with ' | + | |
- | if((substr($ID, | + | |
- | | + | |
- | $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, | + | |
- | + | ||
- | ... regular code continues ... | + | |
</ | </ | ||
+ | More about ACL and wildcards, with examples at: [[:acl#User wildcards|ACL User wildcards]]. | ||
- | ===== Add "My page" button to navigation bar ===== | + | ====Prefilled template==== |
+ | You can create a template page, which is put in the edit window when an user creates his/her user page. Here you can suggest some minimal content you like the user completes. | ||
- | Add the code to display the new button inside main.php of the template: | + | See at [[: |
- | <code php> | + | **Tip:** If you would like to modify the namespace template via the browser, you need the plugin [[plugin: |
- | <?php tpl_button('mypage') ?> | + | |
- | </ | + | |
- | Now let's find out where tpl_button comes from. Just use grep-search again and see it' | + | =====See also===== |
+ | * Customizing [[: | ||
+ | * Change [[config: | ||
+ | * [[: | ||
+ | * [[: | ||
- | 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 " | + | ===== How To: Autocreate homespace for users ===== |
- | inc/ | + | |:!: Please move this example into a plugin. | |
- | Here i append a new line containing: | + | Use case: Because users are not able to create |
- | <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 | + | |
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 169: | Line 86: | ||
</ | </ | ||
- | ==== change _modifyUser() | + | === change _modifyUser() === |
<code php> | <code php> | ||
Line 180: | Line 97: | ||
</ | </ | ||
- | ==== change _addUser() | + | === change _addUser() === |
<code php> | <code php> | ||
Line 191: | 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.1385642623.txt.gz · Last modified: 2013-11-28 13:43 by 92.50.79.91