DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:userhomepage

User HomePage Plugin

Compatible with DokuWiki

  • 2017-02-19 "Frusterick Manners" unknown
  • 2016-06-26 "Elenor Of Tsort" yes
  • 2015-08-10 "Detritus" yes
  • 2014-09-29 "Hrun" yes

plugin Creates users' private namespace and/or public page and redirects them to their own private namespace on login. The pages are base on customizable templates. The current version added the public page feature, a helper and many ACL settings to cover common or uncommon usage.

Last updated on
2017-06-02
Provides
Action
Repository
Source

Installation

Install the plugin using the Plugin Manager and the download URL above, which points to latest version of the plugin. Refer to Plugins on how to install plugins manually.

:!: Important: 2015-02-01's version introduced a crucial change in ACL process to reduce the amount of IO operations on acl.auth.php file and hopefully get rid of a bug that corrupted it from time to time. Please update ! :-)

Upgrading from version 3.0.4

:!: Even if keeping backward compatibility has been a major concern while developing this new version, it is strongly recomended to backup your Dokuwiki (at least conf folder and data related to users' public pages or private namespaces).

Some options were kept only for backward compatibility but pay extra care to all settings concerning private namespace to make sure you get the same file organisation than with previous version.
A new option [Create Private Namespace] wich is disabled by default will prevent any page creation just after the installation of the new version. Before enabling that option, backup your ACL file (conf/acl.auth.php) and then remove ACL rules linked to the old version of the plugin.
Note that the old template file is no longer bundled so it can't be overwritten by the new package ;-)

If you prefer to stick to old 3.0.4 version, here's a package with only a few fixes to enable saving settings (wich didn't work in the most recent package available) and a minor change on ACL to actually protect the created user namespaces.

Settings

:!: Warning about Avatar plugin : if local avatar images and UHP's private namespaces are stored in same place, UHP's ACL rules might block avatars for visitors. Consider changing eighter UHP's ['users_namespace'] or Avatar's ['namespace'] setting.

:!: Warning about templates : some templates include an option for users' pages namespace wich default doesn't correspond to what's expected in a standard Dokuwiki install and that might be a source of conflict (for example wiki:user). Make sure to have the same namespace in template's and User Homepage options.
To my knowledge, concerned templates are Monobook and Vector (please feel free to add any other).

  • create_private_ns : enable creation of users' private namespaces [default: disabled (to make sure no private namespace is created before all settings are set the right way)]
  • use_name_string : use user's full name instead of his login for the name of his private namepsace (ie: user:simon_delage instead of user:simon) [default: disabled]
  • use_start_page use same name as Dokuwiki setting start for the start page of private namespaces (otherwise the same string as the namespace name will be used) [default: enabled]
  • users_namespace : the namespace under wich users' private namespaces will be created [default: user]
  • group_by_name : group private namespaces in alphabetecal sub-namespaces users_namespace
  • edit_before_create : on the creation of his private namespace, a user will get the oportunity to edit the start page right away unless a public page is created too (as users will be redirected to their private namespace start page on login they will not forget to edit it some day while they might forget about the public page so it has precedence) [default : disabled]
  • acl_all_private : ACL for @ALL group on others' private namespaces [default : none]
  • acl_user_private : ACL for @user group on others' private namespaces [default : none]
  • groups_private : list of groups concerned by private namespace creation (nothing will happen for users who don't belong to at least one of set groups) [default : empty (every users' groups are concerned)], added in 2015-11-26 version 8-)
  • create_public_page : enable creation of users' public pages [default: disabled (to make sure no public page is created before all settings are set the right way)]
  • public_pages_ns : namespace under wich users' public pages will be created (:!: if you decide to change this setting, you will have to manually manage interwiki user link used with showuseras setting1)) [default : user]
  • acl_all_public : ACL for @ALL group on others' public pages [default : read]
  • acl_user_public : ACL for @user group on others' public pages [default : none]
  • groups_public : list of groups concerned by public page creation (nothing will happen for users who don't belong to at least one of set groups) [default : empty (every users' groups are concerned)], added in 2015-11-26 version 8-)
  • templates_path : :!:since 2015-06-04 version, this path should be relative to what is set by ['savedir'] option. As an exemple, if ['savedir'] is data, a correct ['templates_path'] to point to …/data/pages/user would be ./pages/user. While a path inside <dokuwiki_data>/pages will make templates editable from within Dokuwiki, a path like lib/plugins/userhomepage will prevent any access to them (wich can be seen as an advantage, depending on your vision) and might be usefull to centralize them in a Dokuwiki farm setting. Old format values like “data/pages/…” still work but a notification will appear untill it is changed, sorry for the disturbance.
  • templatepath : only kept for backward compatibility, this setting should point to the template used in previous version and wich will be used as new private template source if it exists (since the file isn't bundled anymore, leaving this setting to it's default value with a fresh install of the plugin will do no harm and have no effect). [default : lib/plugins/userhomepage/_template.txt or another path as set in previous version]
  • acl_all_templates : ACL for @ALL group on plugin's templates if they are inside <dokuwiki_data>/pages [default : read]
  • acl_all_templates : ACL for @user group on plugin's templates if they are inside <dokuwiki_data>/pages [default : read]
  • no_acl : absolutely no ACL rule will be automatically set (ACL options above will be ignored), including any protection on templates. Rules allready set will have to be manually removed. Only enable this option if you know what you're doing and have a specific need not covered by the options above. [default : disabled]
  • redirection : enable or disable redirection (note that it will however occur on page creation). [default : enabled] (added on 2015/08/20)
  • action : choose wich action is used on redirection to public page right after it's creation between 'do=edit' and 'do=show' (or private namespace start page). [default : edit]
  • userlink_replace : if showuseras global option is set to show interwiki link to user's page (only public page in most cases), this option enables the replacement of the template link by link(s) to either or both or user's public page and/or private namespace. This will only work with templates that trigger the COMMON_USER_LINK event, see below (many thanks to Klap-in for pointing that event ^_^) [default : enabled]
  • userlink_classes : wich CSS classes will be applied to the replacement link(s). Note that if User Homepage's icons don't match the template's ones, adding iw_user might fix it. [default : interwiki wikilink1].
  • userlink_fa : if enabled, this option will switch from image icons to Fontawesome icons for the links sent with COMMON_USER_LINK event. :!: Fontawesome has to be installed with your template or a plugin. [default : disabled].

Right after saving settings, depending on selected options, you will get a success (or error m() message about the creation of the templates:
www.geekitude.fr_externe_dokuwiki_userhomepage_templates_successfull_copy.jpg

Templates

The plugin uses two templates (userhomepage_private.txt and userhomepage_public.txt) that will automatically be created when needed (ie: enabling create_private_ns or create_public_page) in the path set in templates_path setting (from localized source files found in <dokuwiki_plugins>/userhomepage/lang/<language_code> folder). They contain basic informations usefull for users.

:!: Don't edit the localized source files as they will be overwritten by plugin updates

Templates can use any standard template replacement pattern (@NAME@, @USER@, …) and the following specific ones:

  • @TARGETPRIVATEPAGE@ : ID of user's private namespace start page
  • @TARGETPRIVATENS@ : ID of user's private namespace
  • @TARGETPUBLICPAGE@ : ID of user's public page
  • @TARGETPUBLICNS@ : ID of the namespace containing all users' public pages

Once the templates are set, here's what will happen when a user logs in:
www.geekitude.fr_externe_dokuwiki_userhomepage_first_login.jpg

Get more out of templates

  • The Include plugin can be very usefull to include the wiki global start page in private namespace start page template so that the users, while redirected on login to their private page, will still have access to the global wiki start page…
  • Pagequery can also add some magic to User HomePage templates but be carefull because the requests can make the page quite slow to load :
    • {{pagequery>.*;filter=creator:@NAME@,!ns:user;sort=ns,title}} will show user's creations
    • {{pagequery>.*;filter=contrib:@NAME@,!ns:user;sort=ns,title}} will show user's contributions

Private Namespace Skeleton

If tou create a folder named 'uhp_private_skeleton' in same folder as 'Userhomepage' templates (so it should be '…/data/pages/user/uhp_private_skeleton' if you didn't change any option), and place page templates there, they will be added to user's private namespace on login (even is skeleton templates are added after user's private namespace creation).

  • You can add as many templates as you want in skeleton (even in sub folders if you wish)
  • Skeleton templates can use same placeholders as regular 'Userhomepage' templates (see right above)
  • Skeleton templates files should be named as regular wiki pages (spaces must be replaced with underscores, don't use accentuated characters, use 'txt' file extension).

:!: This feature was added in 2015-10-04 version.

About ACL

When possible, the plugin uses wildcards to keep ACL rules as compact as possible.
Here is how they look like for a very short number of users with all settings at their default values:
www.geekitude.fr_externe_dokuwiki_userhomepage_acl_basic.jpg
Note that rules for @user group only apply if they're different from the equivalent setting for @ALL group.
There will be less ACL rules if the private namespaces are not stored in the same namespace as private page as this enables ACL wildcards on public pages:
www.geekitude.fr_externe_dokuwiki_userhomepage_acl_less.jpg
But much more if you enable use_name_string or group_by_name options as they break ACL wildcards on private namespaces. Moreover, in that case, unlike for public pages, acl for each private namespace will only apply when the given user logs in (wich can be a problem if the pages allready exist).

About Redirection

When a user logs in and didn't requested a specific page (or requested the Wiki start page), he will be redirected to his private namespace start page if it exists (works if Wiki start page is localized).

In facts, a timestamp is stored in PHP $_SESSION variable on log in (under the name uhptimestamp) and any request to get Wiki start page within 2 seconds after log in will be redirected (this is to ensures that the redirection works even if user logged in through “Remember Me” process). Let me know if the delay should be customizable in settings.

Helper

To use the helper, use the following code:

<?php
$userhomepage = plugin_load('helper','userhomepage');
if ($userhomepage) echo $userhomepage-><helper_function_call>;
?>

Where you replace the string <helper_function_call> by one of the following:

  • getPrivateID() returns the ID of user's private namespace start page (ie: user:simon:start)
  • getPublicID() returns the ID of user's public page (ie: user:simon)
  • getPrivateLink() returns a simple text link named “Private Space”
  • getPrivateLink(“any string”) returns a simple text link named “any string”
  • getPrivateLink(“loggedinas”) returns an <li> element like the “Logged in as” element of Dokuwiki template with a specific style www.geekitude.fr_externe_dokuwiki_userhomepage_helper_private_loggedinas.jpg
  • getPublicLink(), getPublicLink(“any string) or getPublicLink(“loggedinas”) returns the equivalent link to public page (with another image for last one: www.geekitude.fr_externe_dokuwiki_userhomepage_helper_public_loggedinas.jpg)
  • getComplexLoggedInAs() returns an <li> element like the “Logged in as” element of Dokuwiki template with a specific style and links to both private namespace and public page (if either doesn't exist, will default to relevant more simple link above or to standard string if neither exists) www.geekitude.fr_externe_dokuwiki_userhomepage_helper_complex_loggedinas.jpg (added on 2014/09/19, improved on 2014/09/20, hopefully fixed on 2015/02/03 if neither page exist)
  • getAnyPublicLink(“any user login”) returns an interwiki-like link (colored according to page existence) to provided user's public page (main purpose is to replace showuseras interwiki link in case public pages are not stored in :user namespace) (added on 2014/02/23)
  • getElements() returns an array containing id and localized string to build your own links to Private Namespace Start Page and/or Public Page (added on 2015/08/20)

Here is a way to replace the regular “Logged in as” string to show links to both private Namespace and public page for templates that don't trigger COMMON_USER_LINK event.

The file to change depends on template but with Dokuwiki template, it would be the file …lib/tpl/dokuwiki/tpl_header.php and replace these lines :

                        if (!empty($_SERVER['REMOTE_USER'])) {
                            echo '<li class="user">';
                            tpl_userinfo(); /* 'Logged in as ...' */
                            echo '</li>';
                        }

…with…

if (!plugin_isdisabled('userhomepage')) {
    $userhomepageHelper = plugin_load('helper','userhomepage');
}
// If User HomePage helper is loaded, replace standard 'Logged in as...' link (case where one or both pages don't exist is managed by User HomePage helper
if ($userhomepageHelper) {
    echo $userhomepageHelper->getComplexLoggedInAs();
} else {
    echo '<li class="user">';
    tpl_userinfo(); /* 'Logged in as ...' */
    echo '</li>';
}

Compatibility

That event is triggered by templates when they are ready to print out the Logged in as string and link. User Homepage will then be able to automatically replace the standard link with it's own. Here's a list of tested templates and the compatibility with that feature (feel free to add any other) :

Template name Compatibility Notes
arctic :-/ will look better addingiw_user class but images should still be moved down a bit (will try to find a fix)
arcticut :-/ same as above
bootstrap3 :-) support added by template's author (2011/11/18)
breeze :-)
codowik :-)
default :-/ image should be moved up a bit, preexistant bug, see Last modified link
dokubook :-( no Logged in as link
dokubootstrapsimplified :-( no Logged in as link
dokucms :-( no Logged in as link
dokuwiki :-)
doogiestpl :-/ small visual bug, image's are too high, preexistant so will not fix
fullframe :-)
greensteel :-)
kajukkk NOK :-( no Logged in as link, bugged on my “microapached” test wiki so it's hard to tell
lisps :-( no Logged in as link
monobook :-( no Logged in as link
prsnl10 :-/ small visual bug, image's are too high, preexistant so will not fix
ramtop :-( no Logged in as link
raw :-( apparently no such link, bugged on my “microapached” test wiki so it's hard to tell
roundbox :-/ no icon showing, seems a feature
scanlines :-( no Logged in as link
simplesidebar :-)
starter :-)
starterbootstrap :-( no Logged in as link
taratasy :-(
vector :-/ no icon on logged in link
wallpaper :-( no Logged in as link
writr :-)
zenlink :-( no Logged in as link

Note : I didn't check if there was an option to enable to show Logged in as link when I couldn't see it.

Classes

The following CSS classes are also applied to the links: - classic link (ie. with image icon) to Private Namespace: uhp_private - classic link to Public Page: uhp_public - “Fontawesome” links: uhp_fa.

These classes can be changed by template authors (or with user styles) to tune the style.

Change Log

Known Bugs and Issues

Please refer to the GitHub issue tracker for reporting issues.

Discussion

1)
by creating a <dokuwiki_conf>/interwiki.local.conf file to redirect that link to the correct namespace with something like <choosen_ns> :<choosen_ns>:{NAME}
plugin/userhomepage.txt · Last modified: 2017-06-02 05:28 by Geekitude