mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-04-08 18:55:09 +02:00
2012-02-09 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_html.php: cleaned source code style, and into the function "html_print_select" fixed when the data hasn't "optgroup" items. * include/functions_reports.php: cleaned source code style, and into the function "reports_get_report" fixed empty arrays of reports. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5532 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
eb9025635e
commit
21401d8b3b
pandora_console/include
@ -307,14 +307,16 @@ function html_print_select ($fields, $name, $selected = '', $script = '', $nothi
|
||||
$lastopttype = '';
|
||||
foreach ($fields as $value => $label) {
|
||||
$optlabel = $label;
|
||||
if(is_array($label)){
|
||||
if($label['optgroup'] != $lastopttype) {
|
||||
if($lastopttype != '') {
|
||||
$output .= '</optgroup>';
|
||||
if(is_array($label)) {
|
||||
if (isset($label['optgroup'])) {
|
||||
if($label['optgroup'] != $lastopttype) {
|
||||
if($lastopttype != '') {
|
||||
$output .= '</optgroup>';
|
||||
}
|
||||
$output .= '<optgroup label="'.$label['optgroup'].'">';
|
||||
$lastopttype = $label['optgroup'];
|
||||
}
|
||||
$output .= '<optgroup label="'.$label['optgroup'].'">';
|
||||
$lastopttype = $label['optgroup'];
|
||||
}
|
||||
}
|
||||
$optlabel = $label['name'];
|
||||
}
|
||||
|
||||
|
@ -36,17 +36,21 @@ function reports_get_report ($id_report, $filter = false, $fields = false) {
|
||||
$id_report = safe_int ($id_report);
|
||||
if (empty ($id_report))
|
||||
return false;
|
||||
|
||||
if (! is_array ($filter))
|
||||
$filter = array ();
|
||||
$filter['id_report'] = $id_report;
|
||||
if (!is_user_admin ($config["id_user"]))
|
||||
$filter[] = sprintf ('private = 0 OR (private = 1 AND id_user = "%s")', $config['id_user']);
|
||||
$filter[] = sprintf ('private = 0 OR (private = 1 AND id_user = "%s")',
|
||||
$config['id_user']);
|
||||
if (is_array ($fields))
|
||||
$fields[] = 'id_group';
|
||||
|
||||
$report = db_get_row_filter ('treport', $filter, $fields);
|
||||
|
||||
if (! check_acl ($config['id_user'], $report['id_group'], 'AR'))
|
||||
return false;
|
||||
|
||||
return $report;
|
||||
}
|
||||
|
||||
@ -70,21 +74,25 @@ function reports_get_reports ($filter = false, $fields = false, $returnAllGroup
|
||||
if (! is_array ($filter))
|
||||
$filter = array ();
|
||||
if (!is_user_admin ($config["id_user"]))
|
||||
$filter[] = sprintf ('private = 0 OR (private = 1 AND id_user = "%s")', $config['id_user']);
|
||||
$filter[] = sprintf ('private = 0 OR (private = 1 AND id_user = "%s")',
|
||||
$config['id_user']);
|
||||
if (is_array ($fields)) {
|
||||
$fields[] = 'id_group';
|
||||
$fields[] = 'id_user';
|
||||
}
|
||||
|
||||
$groups = users_get_groups ($config['id_user'], $privileges, $returnAllGroup);
|
||||
|
||||
$reports = array ();
|
||||
$all_reports = @db_get_all_rows_filter ('treport', $filter, $fields);
|
||||
if ($all_reports !== FALSE)
|
||||
foreach ($all_reports as $report){
|
||||
if (empty($all_reports))
|
||||
$all_reports = array();
|
||||
|
||||
//Recheck in all reports if the user have permissions to see each report.
|
||||
$groups = users_get_groups ($config['id_user'], $privileges, $returnAllGroup);
|
||||
foreach ($all_reports as $report) {
|
||||
if (!in_array($report['id_group'], array_keys($groups)))
|
||||
continue;
|
||||
if ($config['id_user'] != $report['id_user'] && ! check_acl ($config['id_user'], $report['id_group'], 'AR'))
|
||||
if ($config['id_user'] != $report['id_user']
|
||||
&& ! check_acl ($config['id_user'], $report['id_group'], 'AR'))
|
||||
continue;
|
||||
array_push ($reports, $report);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user