Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Changed

- Make the plugin compatible with the Content Security Policy

## [1.11.1] - 2026-11-04

### Added
Expand Down
10 changes: 5 additions & 5 deletions ajax/dropdownExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
"style='margin: 0; padding: 0' target='_blank'>";
echo "<input type='hidden' name='svg_content' value='none' />";
echo "<input type='button' class='submit' id='export_svg_link' target='_blank' href='#' " .
"onClick='return false;' value='" . _sx('button', 'Post') . "' />";
"value='" . _sx('button', 'Post') . "' />";
Html::Closeform();
echo "<script type='text/javascript'>
echo Html::scriptBlock("
$('#export_svg_link').on('click', function () {
var svg_content = vis{" . htmlspecialchars($randname) . "}.scene[0].canvas.innerHTML;

Expand All @@ -79,12 +79,12 @@
});

});
</script>";
");
} else {
echo "&nbsp;<input type='submit' id='export_submit' name='export' value=\"" .
_sx('button', 'Post') . "\" class='submit'>";

echo "<script type='text/javascript'>
echo Html::scriptBlock("
$('#export_submit').on('click', function () {
$.ajax({
url: '../ajax/get_new_crsf_token.php'
Expand All @@ -93,6 +93,6 @@
});
});

</script>";
");
}
}
3 changes: 2 additions & 1 deletion front/popup.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

echo "<div class='center'>";
echo '<br>';
echo "<a href='javascript:window.close()'>" . __s('Back') . '</a>';
echo "<a href='#' id='mreporting_popup_close'>" . __s('Back') . '</a>';
echo Html::scriptBlock("$('#mreporting_popup_close').on('click', function (e) { e.preventDefault(); window.close(); });");
echo '</div>';
Html::popFooter();
40 changes: 28 additions & 12 deletions inc/common.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,9 @@ public static function getSelectAllReports($onchange = false, $setIdInOptionsVal
return '';
}

$js_onchange = $onchange ? " onchange='window.location.href=this.options[this.selectedIndex].value'" : '';
$select_id = 'mreporting_report_select' . mt_rand();

$select = "<select class='form-select' name='report' $js_onchange>";
$select = "<select class='form-select' name='report' id='$select_id'>";
$select .= "<option value='-1' selected>" . Dropdown::EMPTY_VALUE . '</option>';

foreach ($reports as $classname => $report) {
Expand Down Expand Up @@ -319,6 +319,12 @@ function ($a, $b) {
}
$select .= '</select>';

if ($onchange) {
$select .= Html::scriptBlock(
"$('#$select_id').on('change', function () { window.location.href = this.options[this.selectedIndex].value; });",
);
}

return $select;
}

Expand Down Expand Up @@ -394,9 +400,13 @@ public function showCentral($params)

echo "<div class='f_right'>";
echo __s('Export') . ' : ';
echo "<a href='#' onClick=\"var w = window.open('popup.php?classname=" . htmlspecialchars($classname) . "' ,'glpipopup', " .
"'height=" . htmlspecialchars(strval($height)) . ", width=1000, top=100, left=100, scrollbars=yes'); w.focus();\">";
$export_id = 'mreporting_odt_export' . mt_rand();
echo "<a href='#' id='$export_id' data-popup-url='" . htmlspecialchars('popup.php?classname=' . $classname) . "'>";
echo 'ODT</a>';
echo Html::scriptBlock(
"$('#$export_id').on('click', function () { var w = window.open(this.dataset.popupUrl, 'glpipopup', " .
"'height=" . (int) $height . ", width=1000, top=100, left=100, scrollbars=yes'); w.focus(); });",
);
echo '</div>';
} else {
echo __s('No report is available !', 'mreporting');
Expand Down Expand Up @@ -512,16 +522,17 @@ public function showExportForm($opt)

echo '</table>';
$formname = 'exportform';
$rand = mt_rand();
echo "<table width='950px'>";
$arrow = 'fas fa-level-up-alt';

echo '<tr>';
echo "<td><i class='" . htmlspecialchars($arrow) . " fa-flip-horizontal fa-lg mx-2'></i></td>";
echo "<td class='center' style='white-space:nowrap;'>";
echo "<a onclick= \"if ( markCheckboxes('" . htmlspecialchars($formname) . "') ) return false;\" href='#'>" . __s('Check all') . '</a></td>';
echo "<a href='#' id='mreporting_check_all$rand'>" . __s('Check all') . '</a></td>';
echo '<td>/</td>';
echo "<td class='center' style='white-space:nowrap;'>";
echo "<a onclick= \"if ( unMarkCheckboxes('" . htmlspecialchars($formname) . "') ) return false;\" href='#'>" . __s('Uncheck all') . '</a></td>';
echo "<a href='#' id='mreporting_uncheck_all$rand'>" . __s('Uncheck all') . '</a></td>';

$option[0] = __s('Without data', 'mreporting');
$option[1] = __s('With data', 'mreporting');
Expand All @@ -533,7 +544,9 @@ public function showExportForm($opt)
Html::closeForm();
echo '</div>';

echo "<script type='text/javascript'>
echo Html::scriptBlock(
"$('#mreporting_check_all$rand').on('click', function (e) { e.preventDefault(); markCheckboxes('$formname'); });
$('#mreporting_uncheck_all$rand').on('click', function (e) { e.preventDefault(); unMarkCheckboxes('$formname'); });
$('#export_submit').on('click', function () {
//get new crsf
$.ajax({
Expand All @@ -542,8 +555,8 @@ public function showExportForm($opt)
$('#export_form input[name=_glpi_csrf_token]').val(token);
document.getElementById('exportform').submit();
});
});
</script>";
});",
);
}
}

Expand Down Expand Up @@ -987,15 +1000,18 @@ public static function showGraphDatas(
echo "<tr class='tab_bg_1'>";
echo '<th>';

echo "<a href=\"javascript:showHideDiv('view_datas$rand','viewimg','" .
$CFG_GLPI['root_doc'] . "/pics/deplier_down.png','" .
$CFG_GLPI['root_doc'] . "/pics/deplier_up.png');\">";
echo "<a href='#' id='mreporting_toggle_datas$rand'>";

$img = $show_graph ? 'deplier_down.png' : 'deplier_up.png';
echo "<img alt='' name='viewimg' src=\"" .
$CFG_GLPI['root_doc'] . "/pics/" . htmlspecialchars($img) . "\">&nbsp;";

echo __s('data', 'mreporting') . '</a>';
echo Html::scriptBlock(
"$('#mreporting_toggle_datas$rand').on('click', function (e) { e.preventDefault(); showHideDiv('view_datas$rand', 'viewimg', '" .
jsescape($CFG_GLPI['root_doc'] . '/pics/deplier_down.png') . "', '" .
jsescape($CFG_GLPI['root_doc'] . '/pics/deplier_up.png') . "'); });",
);
echo '</th>';
echo '</tr>';
echo '</table>';
Expand Down
24 changes: 13 additions & 11 deletions inc/dashboard.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $
) {
echo "<div id='mreporting_central_dashboard'>";

echo "<script language='javascript' type='text/javascript'>
echo "<iframe id='mreporting_central_iframe' src='" . $CFG_GLPI['root_doc'] . '/plugins/mreporting' .
"/ajax/dashboard.php?action=centralDashboard' " .
"frameborder='0' scrolling='no'></iframe>";
echo Html::scriptBlock("
function resizeIframe(obj) {
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
}
</script>";

echo "<iframe src='" . $CFG_GLPI['root_doc'] . '/plugins/mreporting' .
"/ajax/dashboard.php?action=centralDashboard' " .
"frameborder='0' scrolling='no' onload='javascript:resizeIframe(this);'></iframe>";
$('#mreporting_central_iframe').on('load', function () {
resizeIframe(this);
});
");
echo '</div>';
}

Expand Down Expand Up @@ -115,8 +117,7 @@ public function showDashBoard($show_reports_dropdown = true)
</button>";
echo '</div>';
$modal_html = json_encode($this->getFormForColumn());
echo "
<script type='text/javascript'>
echo Html::scriptBlock("
$(function() {
removeWidget = function(id){
$.ajax({
Expand All @@ -141,7 +142,7 @@ public function showDashBoard($show_reports_dropdown = true)
})
});
});
</script>";
");

if (empty($widgets)) {
echo '</div>';
Expand Down Expand Up @@ -202,7 +203,7 @@ public function showDashBoard($show_reports_dropdown = true)

$rand_widget = mt_rand();

echo "<script type='text/javascript'>
echo Html::scriptBlock("
$(function() {
configWidget$rand_widget = null;

Expand All @@ -226,7 +227,8 @@ public function showDashBoard($show_reports_dropdown = true)
});

});
</script>
");
echo "
<div class='card mreportingwidget' id='mreportingwidget" . htmlspecialchars($data['id']) . "'>
<div class='card-header d-inline-block'>
<button id='closeWidget_button$rand_widget' class='m_right me-1 btn btn-sm btn-outline-secondary'>
Expand Down
1 change: 1 addition & 0 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ function plugin_version_mreporting()
'max' => PLUGIN_MREPORTING_MAX_GLPI,
],
],
'csp_compliant' => true,
];
}

Expand Down