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