Smarty
[ class tree: Smarty ] [ index: Smarty ] [ all elements ]

Source for file function.displayname.php

Documentation is available at function.displayname.php

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

Documentation generated on Wed, 29 Jul 2015 13:56:37 +0000 by phpDocumentor 1.5.0-lsces