blob: 78c87bde7e0a1c7db7ac47b09de8edb9eb966f8d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**** smarty_function_displayName
* This is a smarty function which will allow different values to be
* output to identify users (real_name, user, user_id) as opposed todo
* only allowing the 'login' to be output.
* hash=fooHash is a short cut to specifying each parameter by hand
* usage: {displayname user= user_id= real_name= link_title=}
*/
function smarty_function_displayname( $pParams, &$gBitSmarty ) {
global $gBitUser;
if( !empty( $pParams['hash'] ) ) {
if( is_array( $pParams['hash'] ) ) {
$hash = array_merge( $pParams, $pParams['hash'] );
unset( $hash['hash'] );
// if the hash only has a user_id, we need to look up the user
if( @BitBase::verifyId( $hash['user_id'] ) && empty( $hash['user'] ) && empty( $hash['email'] ) && empty( $hash['login'] )) {
$lookupHash['user_id'] = $hash['user_id'];
}
} else {
// We were probably just passed the 'login' due to legacy code which has yet to be converted
if( strpos( '@', $pParams['hash'] ) ) {
$lookupHash['email'] = $hash;
} elseif( is_numeric( $pParams['hash'] ) ) {
$lookupHash['user_id'] = $hash;
} else {
$lookupHash['login'] = $hash;
}
}
} elseif( !empty( $pParams['user_id'] ) ) {
$lookupHash['user_id'] = $pParams['user_id'];
} elseif( !empty( $pParams['email'] ) ) {
$lookupHash['email'] = $pParams['email'];
} elseif( !empty( $pParams['login'] ) ) {
$lookupHash['login'] = $pParams['login'];
} elseif( !empty( $pParams['user'] ) ) {
$lookupHash['login'] = $pParams['user'];
} elseif( empty( $pParams ) ) {
global $gBitUser;
$hash = $gBitUser->mInfo;
}
if( !empty( $lookupHash ) ) {
$hash = $gBitUser->getUserInfo( $lookupHash );
}
if( !empty( $hash ) ) {
$displayName = BitUser::getDisplayName( empty( $pParams['nolink'] ), $hash );
} else {
// Now we're really in trouble. We don't even have a user_id to work with
$displayName = "Unknown";
}
return( $displayName );
}
?>
|