Skip to content
Draft
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added

- Make the plugin compatible with the Content Security Policy

### Fixed

- Fix the uploaded file name being lost after the client injection upload step
Expand Down
4 changes: 2 additions & 2 deletions inc/info.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,10 @@ public static function showFormInfos(PluginDatainjectionModel $model)
echo "<tr>";
echo sprintf("<td><i class='%s fa-flip-horizontal fa-lg mx-2'></i></td>", $arrow);
echo "<td class='center' style='white-space:nowrap;'>";
echo sprintf("<a onclick= \"if ( markCheckboxes('%s') ) return false;\" href='#'>", $formname) . __s('Check all') . "</a></td>";
echo sprintf("<a href='#' data-datainjection-mark-checkboxes='%s'>", htmlescape($formname)) . __s('Check all') . "</a></td>";
echo "<td>/</td>";
echo "<td class='center' style='white-space:nowrap;'>";
echo sprintf("<a onclick= \"if ( unMarkCheckboxes('%s') ) return false;\" href='#'>", $formname) . __s('Uncheck all') . "</a></td>";
echo sprintf("<a href='#' data-datainjection-unmark-checkboxes='%s'>", htmlescape($formname)) . __s('Uncheck all') . "</a></td>";
echo "<td class='left' width='80%'>";

echo "<input type='submit' name='delete' ";
Expand Down
2 changes: 1 addition & 1 deletion inc/model.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@ public static function showPreviewMappings($models_id)

Html::closeForm();
echo "<div style='margin-top:15px;text-align:center'>";
echo "<a href='javascript:window.close()'>" . __s('Close') . "</a>";
echo "<a href='#' data-datainjection-close-window>" . __s('Close') . "</a>";
echo "</div>";
}

Expand Down
41 changes: 41 additions & 0 deletions public/js/datainjection.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,44 @@ function show_log(num) {
document.getElementById('log'+num+'_table').style.display = 'none';
}
}

document.addEventListener('click', (e) => {
const markLink = e.target.closest('[data-datainjection-mark-checkboxes]');
if (markLink !== null) {
if (markCheckboxes(markLink.dataset.datainjectionMarkCheckboxes)) {
e.preventDefault();
}
return;
}

const unmarkLink = e.target.closest('[data-datainjection-unmark-checkboxes]');
if (unmarkLink !== null) {
if (unMarkCheckboxes(unmarkLink.dataset.datainjectionUnmarkCheckboxes)) {
e.preventDefault();
}
return;
}

const popupLink = e.target.closest('[data-datainjection-popup]');
if (popupLink !== null) {
const popup = window.open(
popupLink.dataset.datainjectionPopup,
'glpipopup',
popupLink.dataset.datainjectionPopupFeatures
);
popup.focus();
e.preventDefault();
return;
}

const locationLink = e.target.closest('[data-datainjection-location]');
if (locationLink !== null) {
location.href = locationLink.dataset.datainjectionLocation;
return;
}

if (e.target.closest('[data-datainjection-close-window]') !== null) {
e.preventDefault();
window.close();
}
});
1 change: 1 addition & 0 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ function plugin_version_datainjection()
'homepage' => 'https://github.com/pluginsGLPI/datainjection',
'license' => 'GPLv2+',
'version' => PLUGIN_DATAINJECTION_VERSION,
'csp_compliant' => true,
'requirements' => [
'glpi' => [
'min' => PLUGIN_DATAINJECTION_MIN_GLPI,
Expand Down
6 changes: 3 additions & 3 deletions templates/clientinjection_result.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@

<div class="center mt-2">
<div class="d-flex justify-content-center gap-3">
<a href="#" onclick="var w = window.open('{{ popup_url }}', 'glpipopup', 'height=400, width=1000, top=100, left=100, scrollbars=yes');w.focus();" title="{{ __('See the log', 'datainjection') }}">
<a href="#" data-datainjection-popup="{{ popup_url }}" data-datainjection-popup-features="height=400, width=1000, top=100, left=100, scrollbars=yes" title="{{ __('See the log', 'datainjection') }}">
<h2><i class="fa-2x ti ti-file-search"></i></h2>
</a>

{% if has_pdf %}
<a href="#" onclick="location.href='export.pdf.php?models_id={{ model_id }}'" title="{{ __('Export rapport in PDF', 'datainjection') }}">
<a href="#" data-datainjection-location="export.pdf.php?models_id={{ model_id }}" title="{{ __('Export rapport in PDF', 'datainjection') }}">
<h2><i class="fa-2x ti ti-file-type-pdf"></i></h2>
</a>
{% endif %}

{% if has_errors %}
<a href="#" onclick="location.href='export.csv.php'" title="{{ __('Export the log', 'datainjection') }}">
<a href="#" data-datainjection-location="export.csv.php" title="{{ __('Export the log', 'datainjection') }}">
<h2><i class="fa-2x ti ti-file-type-csv" style="color: #dc3545;"></i></h2>
</a>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion templates/clientinjection_upload_file.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
{% else %}
{% set message = __("Watch out, you're about to inject data into GLPI. Are you sure you want to do it ?", 'datainjection') %}
{% endif %}
<input type="submit" class="btn btn-primary" name="upload" value="{{ submit_label }}" onclick="return window.confirm('{{ message|e('js') }}');">
<input type="submit" class="btn btn-primary" name="upload" value="{{ submit_label }}" data-glpi-confirm="{{ message }}">
{% else %}
<input type="submit" class="btn btn-primary" name="upload" value="{{ submit_label }}">
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion templates/log_results.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,6 @@
{% endif %}

<div class="mt-4 text-center">
<a href="javascript:window.close()" class="btn btn-outline-danger">{{ __('Close') }}</a>
<button type="button" class="btn btn-outline-danger" data-datainjection-close-window>{{ __('Close') }}</button>
</div>
</div>
2 changes: 1 addition & 1 deletion templates/mappings_form.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<table class="tab_cadre_fixe">
<tr class="tab_bg_1">
<td class="center">
<a href="#" onclick="var w = window.open('{{ preview_url }}', 'glpipopup', 'height=400, width=600, top=100, left=100, scrollbars=yes'); w.focus(); return false;">
<a href="#" data-datainjection-popup="{{ preview_url }}" data-datainjection-popup-features="height=400, width=600, top=100, left=100, scrollbars=yes">
{{ __('See the file', 'datainjection') }}
</a>
</td>
Expand Down
Loading