function userCheckFlags($user_id, $flags) { $user = userGetById(intval($user_id)); if (!userExistsById($user_id) || !is_array($flags)) { return; } $res = stringCheckForTokens($user["flags"], $flags); $a = userGetGroups($user_id); for ($i = 0; $i < count($a); $i++) { $group = groupGetById($a[$i]); $res1 = stringCheckForTokens($group["flags"], $flags); for ($j = 0, $t = 0; $j < count($res1), $t < count($res); $j++, $t++) { $res[$t] = $res[$t] | $res1[$j]; } } return $res; }
function userCheckFlags($user_id, $flags) { $user = userGetById(intval($user_id)); if (!userExistsById($user_id)) { return; } function merge($a, $b) { if ($a | $b) { return true; } else { return false; } } $res = stringCheckForTokens($user["flags"], $flags); $a = userGetGroups($user_id); for ($i = 0; $i < count($a); $i++) { $group = groupGetById($a[$i]); $res1 = stringCheckForTokens($group["flags"], $flags); $res = array_map("merge", $res1, $res); } return $res; }