34 lines
1.0 KiB
PHP
34 lines
1.0 KiB
PHP
<?php
|
|
|
|
use Insallah\Db;
|
|
|
|
class UserStats
|
|
{
|
|
/**
|
|
* Ñîáèðàåò ñóììû âñåõ áîíóñîâ ñ îäåòûõ ïðåäìåòîâ è àêòèâíûõ ýôåêòîâ.
|
|
* @param $userId
|
|
* @return array
|
|
*/
|
|
public static function getAllBonuses($userId, $showAll = false)
|
|
{
|
|
require_once '_incl_data/class/Insallah/Core/Db.php';
|
|
$db = new Db();
|
|
$q = 'select data from items_users where uid = ? and inOdet > 0 and `delete` = 0
|
|
union all select data from eff_users where uid = ? and `delete` = 0';
|
|
$iData = $db::getColumn($q, [$userId, $userId]);
|
|
$params = [];
|
|
foreach ($iData as $datum) {
|
|
foreach (explode('|', $datum) as $inner) {
|
|
list($a, $b) = explode('=', $inner);
|
|
if (strpos($a, 'add') !== false || strpos($a, 'sv') !== false || $showAll) {
|
|
if (isset($params[$a])) {
|
|
$params[$a] += $b;
|
|
} else {
|
|
$params[$a] = $b;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return $params;
|
|
}
|
|
} |