diff options
author | Andy Webber <dokuwiki@andywebber.com> | 2008-10-01 17:29:14 +0200 |
---|---|---|
committer | Andy Webber <dokuwiki@andywebber.com> | 2008-10-01 17:29:14 +0200 |
commit | dc58b6f4952c9a966ba23101144f00d378746a17 (patch) | |
tree | 8cb135a4c3ad2979c2e90169932cdb8dab9fcc99 /inc | |
parent | 5babd79b8d25882c3af5dccc15157e728e5bda9e (diff) | |
download | rpg-dc58b6f4952c9a966ba23101144f00d378746a17.tar.gz rpg-dc58b6f4952c9a966ba23101144f00d378746a17.tar.bz2 |
editor_info_patch
At present, DW shows the username on the bottom left under "logged in as", and the login name for "last modified", "locked by" and under
revisions/recent changes. In a corporate environment, particularly when integrated with a Single Sign-On system, the login name may be somewhat
unfriendly. This patch makes the "logged in as" the same as the value used elsewhere and also allows an admin to decide whether it should be the
login name, username or e-mail address that is displayed. The e-mail address may also, optionally, be a mailto: link. E-mail addresses are
obfuscated according to the 'mailguard' setting. The default behaviour is to show the login name which is no change from previous behaviour for the
"last modified"/"locked by"/revisions/"recent changes", but is a change for the "logged in as".
darcs-hash:20081001152914-6ad63-9cd7174068ac55de381f1318a4401f8c51de5b0c.gz
Diffstat (limited to 'inc')
-rw-r--r-- | inc/common.php | 37 | ||||
-rw-r--r-- | inc/html.php | 6 | ||||
-rw-r--r-- | inc/template.php | 7 |
3 files changed, 43 insertions, 7 deletions
diff --git a/inc/common.php b/inc/common.php index 5dfc49856..962c05c37 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1271,4 +1271,41 @@ function shorten($keep,$short,$max,$min=9,$char='⌇'){ return $keep.utf8_substr($short,0,$half-1).$char.utf8_substr($short,$len-$half); } +/** + * Return the users realname or e-mail address for use + * in page footer and recent changes pages + * + * @author Andy Webber <dokuwiki AT andywebber DOT com> + */ +function editorinfo($username){ + global $conf; + global $auth; + + switch($conf['showuseras']){ + case 'username': + case 'email': + case 'email_link': + $info = $auth->getUserData($username); + break; + default: + return hsc($username); + } + + if(isset($info) && $info) { + switch($conf['showuseras']){ + case 'username': + return hsc($info['name']); + case 'email': + return obfuscate($info['mail']); + case 'email_link': + $mail=obfuscate($info['mail']); + return '<a href="mailto:'.$mail.'">'.$mail.'</a>'; + default: + return hsc($username); + } + } else { + return hsc($username); + } +} + //Setup VIM: ex: et ts=2 enc=utf-8 : diff --git a/inc/html.php b/inc/html.php index 24b811d29..e7525ae2d 100644 --- a/inc/html.php +++ b/inc/html.php @@ -438,7 +438,7 @@ function html_revisions($first=0){ print ' – '; print htmlspecialchars($INFO['sum']); print ' <span class="user">'; - print (empty($INFO['editor']))?('('.$lang['external_edit'].')'):htmlspecialchars($INFO['editor']); + print (empty($INFO['editor']))?('('.$lang['external_edit'].')'):editorinfo($INFO['editor']); print '</span> '; print '('.$lang['current'].')'; @@ -482,7 +482,7 @@ function html_revisions($first=0){ print htmlspecialchars($info['sum']); print ' <span class="user">'; if($info['user']){ - print htmlspecialchars($info['user']); + print editorinfo($info['user']); }else{ print $info['ip']; } @@ -576,7 +576,7 @@ function html_recent($first=0){ print ' <span class="user">'; if($recent['user']){ - print htmlspecialchars($recent['user']); + print editorinfo($recent['user']); }else{ print $recent['ip']; } diff --git a/inc/template.php b/inc/template.php index 5997e0d33..0b37734d8 100644 --- a/inc/template.php +++ b/inc/template.php @@ -869,9 +869,8 @@ function tpl_youarehere($sep=' » '){ */ function tpl_userinfo(){ global $lang; - global $INFO; if($_SERVER['REMOTE_USER']){ - print $lang['loggedinas'].': '.$INFO['userinfo']['name']; + print $lang['loggedinas'].': '.editorinfo($_SERVER['REMOTE_USER']); return true; } return false; @@ -914,7 +913,7 @@ function tpl_pageinfo($ret=false){ $out .= $date; if($INFO['editor']){ $out .= ' '.$lang['by'].' '; - $out .= $INFO['editor']; + $out .= editorinfo($INFO['editor']); }else{ $out .= ' ('.$lang['external_edit'].')'; } @@ -922,7 +921,7 @@ function tpl_pageinfo($ret=false){ $out .= ' · '; $out .= $lang['lockedby']; $out .= ': '; - $out .= $INFO['locked']; + $out .= editorinfo($INFO['locked']); } if($ret){ return $out; |