Committer: akanashin
LJSUP-13036: Create subroutine for get social capital by userU trunk/cgi-bin/LJ/User.pm
Modified: trunk/cgi-bin/LJ/User.pm =================================================================== --- trunk/cgi-bin/LJ/User.pm 2012-07-19 12:12:05 UTC (rev 22474) +++ trunk/cgi-bin/LJ/User.pm 2012-07-19 12:33:35 UTC (rev 22475) @@ -33,6 +33,7 @@ use LJ::User::InfoHistory; use LJ::User::PropStorage; use LJ::Response::CachedTemplate; +use LJ::PersonalStats::DB; # TODO: get rid of Class::Autouse, maybe? it's pretty useless # in web context and leads to some nasty bugs otherwise, so probably @@ -2876,6 +2877,19 @@ return 1; } +# return social capital by user +sub get_social_capital { + my ($u) = @_; + + my $soc_capital = LJ::PersonalStats::DB->fetch_raw('ratings', {func => 'get_authority', journal_id => $u->userid}); + + if ($soc_capital) { + return int($soc_capital->{result}->{authority}/1000); + } + + return 0; +} + # <LJFUNC> # name: LJ::User::activate_userpics # des: Sets/unsets userpics as inactive based on account caps.