|
From: FlorinCB <ory...@us...> - 2008-09-12 05:18:01
|
Update of /cvsroot/mxbb/core/includes/sessions/internal In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv9295/core/includes/sessions/internal Modified Files: core.php Log Message: function get_username_string() Index: core.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/sessions/internal/core.php,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** core.php 29 Aug 2008 03:53:50 -0000 1.10 --- core.php 12 Sep 2008 05:17:50 -0000 1.11 *************** *** 494,497 **** --- 494,560 ---- return $sql; } + + /** + * Get username details for placing into templates. + * + * @param string $mode Can be profile (for getting an url to the profile), username (for obtaining the username), colour (for obtaining the user colour) or full (for obtaining a html string representing a coloured link to the users profile). + * @param int $user_id The users id + * @param string $username The users name + * @param string $username_colour The users colour + * @param string $guest_username optional parameter to specify the guest username. It will be used in favor of the GUEST language variable then. + * @param string $custom_profile_url optional parameter to specify a profile url. The user id get appended to this url as &u={user_id} + * + * @return string A string consisting of what is wanted based on $mode. + */ + function get_username_string($mode, $user_id, $username = false, $user_color = false, $guest_username = false, $custom_profile_url = false) + { + global $lang, $userdata; + + $lang['Guest'] = !$guest_username ? $lang['Guest'] : $guest_username; + + $this_userdata = mx_get_userdata($user_id, false); + $username = ($username) ? $username : $this_userdata['username']; + + if ($this_userdata['user_level'] == ADMIN) + { + $user_color = $theme['fontcolor3']; + $user_style = 'style="color:#' . $user_color . '; font-weight : bold;"'; + } + else if ($this_userdata['user_level'] == MOD) + { + $user_color = $theme['fontcolor2']; + $user_style = 'style="color:#' . $user_color . '; font-weight : bold;"'; + } + else + { + $user_colour = $theme['fontcolor1']; + $topic_poster_style = 'style="font-weight : bold;"'; + } + + $profile_url = ''; + + $full_url = (($user_id == ANONYMOUS) || ($user_id == MUSIC_GUEST)) ? '<span ' . $topic_poster_style . '>' . $lang['Guest'] . '</span>' : '<span ' . $topic_poster_style . '>' . $username . '</span>'; + + switch ($mode) + { + case 'profile': + return $profile_url; + break; + + case 'username': + return $username; + break; + + case 'colour': + return $user_colour; + break; + + case 'full': + default: + return $full_url; + break; + } + } + } |