Weight Scales/Presets:

* moved wt_presets to DB
 * scales are now saved sensibly instead of just being dumped as is (also, tables have now constrains)
 * added admin=weight-presets to edit presets
 * added an internal user on id:0 who 'owns' the wt-presets and the +1 rates on new comments
 * consequently added constraints to comment-related tables

Misc:
 * Util::toJSON() priorizes its flags over CFG_DEBUG, wich fixes the modelviewer-redButton
 * moved terrible javascript-dump from admin-page to template
This commit is contained in:
Sarjuuk
2016-02-27 18:47:47 +01:00
parent 71e44e572a
commit e80015a7cd
18 changed files with 1516 additions and 411 deletions

View File

@@ -521,31 +521,17 @@ class User
public static function getWeightScales()
{
$data = [];
$result = [];
$res = DB::Aowow()->select('SELECT * FROM ?_account_weightscales WHERE userId = ?d', self::$id);
foreach ($res as $i)
{
$set = array (
'name' => $i['name'],
'id' => $i['id']
);
$res = DB::Aowow()->selectCol('SELECT id AS ARRAY_KEY, name FROM ?_account_weightscales WHERE userId = ?d', self::$id);
if (!$res)
return $result;
$weights = explode(',', $i['weights']);
foreach ($weights as $weight)
{
$w = explode(':', $weight);
$weights = DB::Aowow()->selectCol('SELECT id AS ARRAY_KEY, `field` AS ARRAY_KEY2, val FROM ?_account_weightscale_data WHERE id IN (?a)', array_keys($res));
foreach ($weights as $id => $data)
$result[] = array_merge(['name' => $res[$id], 'id' => $id], $data);
if ($w[1] === 'undefined')
$w[1] = 0;
$set[$w[0]] = $w[1];
}
$data[] = $set;
}
return $data;
return $result;
}
public static function getCharacters()