fixed minor error

This commit is contained in:
Daniel Barbero Martin 2021-03-26 11:28:34 +01:00
parent b9f0ac8239
commit 021675d825
2 changed files with 17 additions and 8 deletions

View File

@ -113,7 +113,7 @@ function custom_graphs_create(
* @param $returnAllGroup Wheter to return graphs of group All or not.
* @param $privileges Privileges to check in user group
*
* @return Custom graphs of a an user. Empty array if none.
* @return array graphs of a an user. Empty array if none.
*/
function custom_graphs_get_user($id_user=0, $only_names=false, $returnAllGroup=true, $privileges='RR')
{

View File

@ -245,17 +245,26 @@ class CustomGraphWidget extends Widget
$return_all_group = false;
if (users_can_manage_group_all('RM')) {
if (users_can_manage_group_all('RM') === true) {
$return_all_group = true;
}
// Custom graph.
$fields = \custom_graphs_get_user(0, false, $return_all_group);
// If currently selected graph is not included in fields array (it belongs to a group over which user has no permissions), then add it to fields array.
// This is aimed to avoid overriding this value when a user with narrower permissions edits widget configuration.
if ($values['id_graph'] !== null && !array_key_exists($values['id_graph'], $fields)) {
$selected_graph = db_get_row('tgraph', 'id_graph', $values['id_graph']);
// If currently selected graph is not included in fields array
// (it belongs to a group over which user has no permissions),
// then add it to fields array.
// This is aimed to avoid overriding this value when a user
// with narrower permissions edits widget configuration.
if ($values['id_graph'] !== null
&& array_key_exists($values['id_graph'], $fields) === false
) {
$selected_graph = db_get_row(
'tgraph',
'id_graph',
$values['id_graph']
);
$fields[$values['id_graph']] = $selected_graph;
}
@ -366,7 +375,8 @@ class CustomGraphWidget extends Widget
);
$hackLegendHight = (30 * count($sources));
if ($hackLegendHight > ($size['height'] - 10 - $hackLegendHight)) {
$operation = ($size['height'] - 10 - $hackLegendHight);
if ($hackLegendHight < $operation) {
$height = ($size['height'] - $hackLegendHight);
} else {
$height = ($size['height'] - 10);
@ -406,7 +416,6 @@ class CustomGraphWidget extends Widget
'height' => $height,
'only_image' => false,
'homeurl' => $config['homeurl'],
'percentil' => $percentil,
'backgroundColor' => 'transparent',
'menu' => false,
'show_legend' => $this->values['showLegend'],