Table of Contents
How to create user homepages
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.
User's name linking to homepages
The showuseras config setting can be set to “User's full name as interwiki user link”. Setting this option will display all the usernames in the wiki with a link to the user:<loginname>
page.
The default location of the user page can be modified via the interwiki configuration.
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 %USER%
and %GROUP%
. The placeholders are replaced by the loginname or respectively the group of current logged-in user. This allows to define generally with some lines for all users the wanted read and write access.
Currently %USER%
and %GROUP%
cannot be used via the Config Manager. Therefore you need to manually modify the file conf/acl.auth.php
to add the lines using them.
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 %USER%
placeholder.
Example:
- conf/acl.auth.php
# Additional lines for conf/acl.auth.php : # # user can modify/delete page in his/her namespace user:%USER%:* %USER% AUTH_DELETE # user can create/delete his/her own page # (AUTH_EDIT is not enough, because page is not exist before) user:%USER% %USER% AUTH_DELETE # all logged-in users can read the user pages user:* @user AUTH_READ
More about ACL and wildcards, with examples at: ACL User wildcards.
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.
See at namespace templates how to create your namespace template. When you create a template for the default user:<loginname>
pages, you want to create e.g. user:_template.txt
via your filesystem.
Tip: If you would like to modify the namespace template via the browser, you need the plugin Templatepagename. This plugin lets you configure via the Configuration manager a page name that is recognized as template page. Default c_template
, but of course you can choice your own name.
See also
- Customizing Interwiki links let you modify the user page location
- Change showuseras config setting to use the user's name with interwiki link to its homepage.
- Access Control List (ACL) about configuring access permissions.
- Namespace templates for prefilling content in new pages
How To: Autocreate homespace for users
Please move this example into a plugin. |
Use case: Because users are not able to create an own page in namespace “user:” in our wiki setup, we must provide them one. Best place to do this is when adding the user with the usermanager. The usermanager is a default plugin of DokuWiki and it's code is found at:
lib/plugins/usermanager/
You can create the functionality by doing changes in lib/plugins/usermanager/admin.php
:
append new function
/** * Create homedir (namespace) for user */ function _createHomedir($user, $name){ $userhome = dirname(wikiFN("home:$user:index")); $homebase = dirname($userhome); // create directory if(! @is_dir($userhome)) { io_makeFileDir($userhome.'/dummy.txt'); msg("Homedir for user created", 1); } // copy template from parent (modify this to fit YOUR needs !) $userpage = $userhome.'/index.txt'; if(! @is_file($userpage)){ $tpl = $homebase.'/template.txt'; if(@is_file($tpl)) { $page = io_readFile($tpl); $page = preg_replace('/@USERNAME@/', $name, $page); io_saveFile($userpage, $page); msg("Template copied to homedir", 1); } } }
change _modifyUser()
if (empty($newuser)) return false; # create homedir for new/existing user $this->_createHomedir($newuser,$newname); $changes = array();
change _addUser()
if (empty($user)) return false; # create homedir for new/existing user $this->_createHomedir($user,$name); return $this->_auth->createUser($user,$pass,$name,$mail,$grps);
General note
Please read everything carefully and be aware that if you change the sourcecode of DokuWiki, that you need to update it every time DokuWiki is updated.