forked from KETSE/casebox
/
Users.php
52 lines (42 loc) · 1.17 KB
/
Users.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace CB;
use CB\DataModel as DM;
class Users
{
/**
* get user colors
* @return array associative array of userId => color
*/
public static function getColors()
{
$rez = array();
$uid = User:: getId();
$recs = DM\UsersGroups::readAll();
$noColors = array();
foreach ($recs as &$r) {
if (empty($r['cfg']['color']) && ($r['type'] == 2)) {
$noColors[] = &$r;
}
}
if (!empty($noColors)) {
$colors = \Colors\RandomColor::many(
sizeof($noColors),
array(
'luminosity'=>'random'
,'hue'=>'random'
)
);
foreach ($noColors as &$r) {
$r['cfg']['color'] = array_shift($colors);
User::setUserConfigParam('color', $r['cfg']['color'], $r['id']);
}
unset($r);
}
foreach ($recs as $r) {
$rez[$r['id']] = empty($r['cfg']['customColor'][$uid])
? @$r['cfg']['color']
: $r['cfg']['customColor'][$uid];
}
return $rez;
}
}