1
Catzwolf
Updated xoops_getLinkedUnameFromId
  • 2007/11/4 0:02

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Updated XOOPS Function:
This update addresses an issue if $usereal = 1 and Var $user->getVar( 'name' ) is empty. I have corrected this with the following Function.


function xoops_getLinkedUnameFromId$userid 0$usereal 0$is_linked ) {
    global 
$xoopsUser$fct;

    
$member_handler = &xoops_gethandler'member' );
    
$name '';
    
$userid intval$userid ) > intval$userid ) : $xoopsUser->getVar'uid' );
    
$user = &$member_handler->getUser$userid );
    if ( 
is_object$user ) ) {
        
$name '';
        if ( 
$is_linked ) {
            
$url = ( intval$usereal ) && $user->getVar'uname' ) != '' ) ? XOOPS_URL '/userinfo.php?uid=' XOOPS_URL '/modules/system/index.php?fct=users&op=edit&uid=';
            
$name .= '$url $userid '">';
        }
        
$name .= ( intval$usereal ) && $user->getVar'name' ) != '' ) ? $user->getVar'name' ) : $user->getVar'uname' );
        if ( 
$is_linked ) {
            
$name .= '';
        }
    } else {
        
$name $GLOBALS['xoopsConfig']['anonymous'];
    }
    return 
$name;
}

2
skenow
Re: Updated xoops_getLinkedUnameFromId
  • 2007/11/4 3:15

  • skenow

  • Home away from home

  • Posts: 993

  • Since: 2004/11/17


I think I understand, but could you explain further?

3
Alex_Grey
Re: Updated xoops_getLinkedUnameFromId
  • 2007/11/4 3:51

  • Alex_Grey

  • Just popping in

  • Posts: 43

  • Since: 2007/6/16


John. i was reading your code and i dont understand some of the things you are coding.

can i suggest this code? (based on your code)

function xoops_getLinkedUnameFromId$userid 0$usereal 0$is_linked ) {
   
        
$userid intval$userid ) > intval$userid ) : 0;
        
$member_handler = &xoops_gethandler'member' );
        
$user = &$member_handler->getUser$userid );
            
$name '';        
            if ( 
is_object$user ) ) {
                if ( 
$is_linked ) {
                    
$url XOOPS_URL '/userinfo.php?uid=';
                    
$name .= '$url $userid '">';
                }
            
$name .= ( intval$usereal ) && $user->getVar'name' ) != '' ) ? $user->getVar'name' ) : $user->getVar'uname' );
                if ( 
$is_linked ) {
                    
$name .= '';
                }
        } else {
            
$name $GLOBALS['xoopsConfig']['anonymous'];
        }
    return 
$name;
}

untested code though.
(sry about my 8 space tabs..)
“There is nothing impossible to him who will try.” ~Alex The Great~
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

4
Catzwolf
Re: Updated xoops_getLinkedUnameFromId
  • 2007/11/4 6:22

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Hi,

The problem is an error checking one.

There is no checking to see if a person realname (i.e.) 'name' var 'is_null' or 'empty'. The result being that if it is an 'empty' value is returned for 'name' and breaks the function (Basically you cannot see anything)

What I have done is to check that 'name' value is used else return 'uname' instead.

I also did a check to see that 'fct' is not 'empty' if it is not then edit the player in admin (as 'fct' would only be valid is if the administrator was in the admin side), but with some better hindsight, maybe a switch could be used within the function to better use here.

ps: I just remembered I wrote that for my personal version of XOOPS and would need rewriting for 2.17 instead. I will do that shortly.

5
Catzwolf
Re: Updated xoops_getLinkedUnameFromId
  • 2007/11/4 6:27

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Yes that would work, but I would prefer it if the admin check (or switch used) was actually (corrected of course) was left in for flexability reasons. i.e. I would like to use this function to direct the administrator to edit a users profile in the admin area (actually now I think about it we could use a switch to allow for displaying or editing both user and admin side).

Also the XoopsUser::getUnameFromId() should be updated to reflect those changes also.

Login

Who's Online

192 user(s) are online (88 user(s) are browsing Support Forums)


Members: 0


Guests: 192


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits