Code Duplication    Length = 41-41 lines in 2 locations

class/utility.php 1 location

@@ 608-648 (lines=41) @@
605
     * @param  array   $users
606
     * @return string
607
     */
608
    public static function sf_getLinkedUnameFromId($userid = 0, $name = 0, $users = array())
609
    {
610
        if (!is_numeric($userid)) {
611
            return $userid;
612
        }
613
614
        $userid = (int)$userid;
615
        if ($userid > 0) {
616
            if ($users == array()) {
617
                //fetching users
618
                $memberHandler = xoops_getHandler('member');
619
                $user          = $memberHandler->getUser($userid);
620
            } else {
621
                if (!isset($users[$userid])) {
622
                    return $GLOBALS['xoopsConfig']['anonymous'];
623
                }
624
                $user =& $users[$userid];
625
            }
626
627
            if (is_object($user)) {
628
                $ts       = MyTextSanitizer::getInstance();
629
                $username = $user->getVar('uname');
630
                $fullname = '';
631
632
                $fullname2 = $user->getVar('name');
633
634
                if ($name && !empty($fullname2)) {
635
                    $fullname = $user->getVar('name');
636
                }
637
                if (!empty($fullname)) {
638
                    $linkeduser = "$fullname [<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . $ts->htmlSpecialChars($username) . '</a>]';
639
                } else {
640
                    $linkeduser = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . ucwords($ts->htmlSpecialChars($username)) . '</a>';
641
                }
642
643
                return $linkeduser;
644
            }
645
        }
646
647
        return $GLOBALS['xoopsConfig']['anonymous'];
648
    }
649
650
    /**
651
     * @param  string $url

include/functions.php 1 location

@@ 468-508 (lines=41) @@
465
 * @param  array   $users
466
 * @return string
467
 */
468
function sf_getLinkedUnameFromId($userid = 0, $name = 0, $users = array())
469
{
470
    if (!is_numeric($userid)) {
471
        return $userid;
472
    }
473
474
    $userid = (int)$userid;
475
    if ($userid > 0) {
476
        if ($users == array()) {
477
            //fetching users
478
            $memberHandler = xoops_getHandler('member');
479
            $user          = $memberHandler->getUser($userid);
480
        } else {
481
            if (!isset($users[$userid])) {
482
                return $GLOBALS['xoopsConfig']['anonymous'];
483
            }
484
            $user =& $users[$userid];
485
        }
486
487
        if (is_object($user)) {
488
            $ts       = MyTextSanitizer::getInstance();
489
            $username = $user->getVar('uname');
490
            $fullname = '';
491
492
            $fullname2 = $user->getVar('name');
493
494
            if ($name && !empty($fullname2)) {
495
                $fullname = $user->getVar('name');
496
            }
497
            if (!empty($fullname)) {
498
                $linkeduser = "$fullname [<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . $ts->htmlSpecialChars($username) . '</a>]';
499
            } else {
500
                $linkeduser = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . ucwords($ts->htmlSpecialChars($username)) . '</a>';
501
            }
502
503
            return $linkeduser;
504
        }
505
    }
506
507
    return $GLOBALS['xoopsConfig']['anonymous'];
508
}
509
510
/**
511
 * @param  string $url