summaryrefslogtreecommitdiff
path: root/inc/common.php
diff options
context:
space:
mode:
authorGerrit Uitslag <klapinklapin@gmail.com>2014-03-14 18:42:25 +0100
committerGerrit Uitslag <klapinklapin@gmail.com>2014-03-14 18:42:25 +0100
commit15f3bc49ed925ccb7c04299e9f614b0a1b739b13 (patch)
treeca1b6a4ce42b55c4f228a832970efdc53edadec6 /inc/common.php
parent533772e1d092bc1b1326f7fe5a31091b58bf9030 (diff)
downloadrpg-15f3bc49ed925ccb7c04299e9f614b0a1b739b13.tar.gz
rpg-15f3bc49ed925ccb7c04299e9f614b0a1b739b13.tar.bz2
enable editorinfo and userinfo to return plain text names
Diffstat (limited to 'inc/common.php')
-rw-r--r--inc/common.php34
1 files changed, 22 insertions, 12 deletions
diff --git a/inc/common.php b/inc/common.php
index 6e7142f0e..f0c935c0c 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -1457,21 +1457,26 @@ function shorten($keep, $short, $max, $min = 9, $char = '…') {
* Return the users realname or e-mail address for use
* in page footer and recent changes pages
*
+ * @param string|bool $username or false when currently logged-in user should be used
+ * @param bool $textonly true returns only plain text, true allows returning html
+ * @return string html or text of formatted user name
+ *
* @author Andy Webber <dokuwiki AT andywebber DOT com>
*/
-function editorinfo($username) {
- return userinfo($username);
+function editorinfo($username, $textonly = false) {
+ return userinfo($username, $textonly);
}
/**
* Returns users realname w/o link
*
* @param string|bool $username or false when currently logged-in user should be used
- * @return string html of formatted user name
+ * @param bool $textonly true returns only plain text, true allows returning html
+ * @return string html or text of formatted user name
*
* @triggers COMMON_USER_LINK
*/
-function userinfo($username = null) {
+function userinfo($username = null, $textonly = false) {
global $conf, $INFO;
/** @var DokuWiki_Auth_Plugin $auth */
global $auth;
@@ -1492,25 +1497,30 @@ function userinfo($username = null) {
'title' => '',
'class' => ''
),
- 'userinfo' => ''
+ 'userinfo' => '', // formatted user name as will be returned
+ 'textonly' => $textonly
);
if($username === null) {
$data['username'] = $username = $INPUT->server->str('REMOTE_USER');
- $data['name'] = '<bdi>' . hsc($INFO['userinfo']['name']) . '</bdi> (<bdi>' . hsc($INPUT->server->str('REMOTE_USER')) . '</bdi>)';
+ if($textonly){
+ $data['name'] = $INFO['userinfo']['name']. ' (' . $INPUT->server->str('REMOTE_USER') . ')';
+ }else {
+ $data['name'] = '<bdi>' . hsc($INFO['userinfo']['name']) . '</bdi> (<bdi>' . hsc($INPUT->server->str('REMOTE_USER')) . '</bdi>)';
+ }
}
$evt = new Doku_Event('COMMON_USER_LINK', $data);
if($evt->advise_before(true)) {
if(empty($data['name'])) {
if($conf['showuseras'] == 'loginname') {
- $data['name'] = hsc($data['username']);
+ $data['name'] = $textonly ? $data['username'] : hsc($data['username']);
} else {
if($auth) $info = $auth->getUserData($username);
if(isset($info) && $info) {
switch($conf['showuseras']) {
case 'username':
case 'username_link':
- $data['name'] = hsc($info['name']);
+ $data['name'] = $textonly ? $info['name'] : hsc($info['name']);
break;
case 'email':
case 'email_link':
@@ -1524,7 +1534,7 @@ function userinfo($username = null) {
/** @var Doku_Renderer_xhtml $xhtml_renderer */
static $xhtml_renderer = null;
- if($data['link'] !== false && empty($data['link']['url'])) {
+ if(!$data['textonly'] && empty($data['link']['url'])) {
if(in_array($conf['showuseras'], array('email_link', 'username_link'))) {
if(!isset($info)) {
@@ -1554,15 +1564,15 @@ function userinfo($username = null) {
}
}
} else {
- $data['link'] = false;
+ $data['textonly'] = true;
}
} else {
- $data['link'] = false;
+ $data['textonly'] = true;
}
}
- if($data['link'] === false) {
+ if($data['textonly']) {
$data['userinfo'] = $data['name'];
} else {
$data['link']['name'] = $data['name'];