Code Duplication    Length = 23-23 lines in 2 locations

include/functions.php 2 locations

@@ 859-881 (lines=23) @@
856
/**
857
 * @return array
858
 */
859
function smallworld_worstratedusers()
860
{
861
    $swUserHandler = Helper::getInstance()->getHandler('SwUser');
862
    $array   = [];
863
    $counter = 1;
864
    $sql     = 'SELECT owner, (';
865
    $sql     .= 'sum( up ) - sum( down )';
866
    $sql     .= ') AS total';
867
    $sql     .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_vote') . '';
868
    $sql     .= ' GROUP BY owner ORDER by total ASC LIMIT 5';
869
    $result  = $GLOBALS['xoopsDB']->queryF($sql);
870
    while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
871
        $array[$counter]['counter']   = $counter;
872
        $array[$counter]['img']       = $swUserHandler->getAvatarLink($row['owner'], $swUserHandler->gravatar($row['owner']));
873
        $array[$counter]['user']      = $GLOBALS['xoopsUser']->getUnameFromId($row['owner']);
874
        $array[$counter]['rating']    = $row['total'];
875
        $array[$counter]['user_link'] = "<a href = '" . Helper::getInstance()->url('userprofile.php?username=' . $array[$counter]['user']) . "'>";
876
        $array[$counter]['user_link'] .= $array[$counter]['user'] . ' (' . $array[$counter]['rating'] . ')</a>';
877
        ++$counter;
878
    }
879
880
    return $array;
881
}
882
883
// Find best rated users overall
884
/**
@@ 887-909 (lines=23) @@
884
/**
885
 * @return array
886
 */
887
function smallworld_topratedusers()
888
{
889
    $swUserHandler = Helper::getInstance()->getHandler('SwUser');
890
    $array   = [];
891
    $counter = 1;
892
    $sql     = 'SELECT owner, (';
893
    $sql     .= 'sum( up ) - sum( down )';
894
    $sql     .= ') AS total';
895
    $sql     .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_vote') . '';
896
    $sql     .= ' GROUP BY owner ORDER by total DESC LIMIT 5';
897
    $result  = $GLOBALS['xoopsDB']->queryF($sql);
898
    while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
899
        $array[$counter]['counter']   = $counter;
900
        $array[$counter]['img']       = $swUserHandler->getAvatarLink($row['owner'], $swUserHandler->gravatar($row['owner']));
901
        $array[$counter]['user']      = $GLOBALS['xoopsUser']->getUnameFromId($row['owner']);
902
        $array[$counter]['rating']    = $row['total'];
903
        $array[$counter]['user_link'] = "<a href = '" . $helper->url('userprofile.php?username=' . $array[$counter]['user']) . "'>";
904
        $array[$counter]['user_link'] .= $array[$counter]['user'] . ' (' . $array[$counter]['rating'] . ')</a>';
905
        ++$counter;
906
    }
907
908
    return $array;
909
}
910
911
/**
912
 * @return array