Skip to content

Commit

Permalink
rebase (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rom1-B authored Sep 27, 2024
1 parent df39c6d commit 1ef5260
Show file tree
Hide file tree
Showing 101 changed files with 7,314 additions and 7,320 deletions.
20 changes: 20 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$finder = Finder::create()
->in(__DIR__)
->name('*.php');

$config = new Config();

$rules = [
'@PER-CS2.0' => true,
'trailing_comma_in_multiline' => ['elements' => ['arguments', 'array_destructuring', 'arrays']], // For PHP 7.4 compatibility
];

return $config
->setRules($rules)
->setFinder($finder)
->setUsingCache(false);
4 changes: 2 additions & 2 deletions ajax/common.tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
* -------------------------------------------------------------------------
*/

include("../../../inc/includes.php");
header("Content-Type: text/html; charset=UTF-8");
include('../../../inc/includes.php');
header('Content-Type: text/html; charset=UTF-8');
Html::header_nocache();

Session::checkLoginUser();
Expand Down
6 changes: 3 additions & 3 deletions ajax/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@

case 'centralDashboard':
Html::includeHeader();
echo "<body>";
echo '<body>';
$dashboard = new PluginMreportingDashboard();
$dashboard->showDashboard(false);

//load protovis lib for dashboard render
//load protovis lib for dashboard render
$version = Plugin::getInfo('mreporting', 'version');
$php_dir = Plugin::getPhpDir('mreporting', false);
echo Html::script($php_dir . "/lib/protovis/protovis.js", ['version' => $version]);
echo Html::script($php_dir . '/lib/protovis/protovis.js', ['version' => $version]);

Html::popFooter();
break;
Expand Down
20 changes: 10 additions & 10 deletions ajax/dropdownExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
* -------------------------------------------------------------------------
*/

include("../../../inc/includes.php");
header("Content-Type: text/html; charset=UTF-8");
include('../../../inc/includes.php');
header('Content-Type: text/html; charset=UTF-8');
Html::header_nocache();

Session::checkLoginUser();
Expand All @@ -38,16 +38,16 @@
isset($_POST['ext'])
&& !empty($_POST['ext'])
) {
if ($_POST['ext'] == "odt") {
echo "&nbsp;";
$option = [];
$option[1] = __("With data", 'mreporting');
$option[0] = __("Without data", 'mreporting');
Dropdown::showFromArray("withdata", $option, []);
if ($_POST['ext'] == 'odt') {
echo '&nbsp;';
$option = [];
$option[1] = __('With data', 'mreporting');
$option[0] = __('Without data', 'mreporting');
Dropdown::showFromArray('withdata', $option, []);
}

if ($_POST['ext'] == "svg") {
//close previous form
if ($_POST['ext'] == 'svg') {
//close previous form
Html::Closeform();

$randname = $_POST['randname'];
Expand Down
14 changes: 7 additions & 7 deletions ajax/dropdownGraphs.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@
* -------------------------------------------------------------------------
*/

if (strpos($_SERVER['PHP_SELF'], "dropdownGraphs.php")) {
include("../../../inc/includes.php");
header("Content-Type: text/html; charset=UTF-8");
if (strpos($_SERVER['PHP_SELF'], 'dropdownGraphs.php')) {
include('../../../inc/includes.php');
header('Content-Type: text/html; charset=UTF-8');
Html::header_nocache();
}

Session::checkLoginUser();

if ($_POST['graphname'] != -1) {
$test = explode(";", $_POST['graphname']);
$test = explode(';', $_POST['graphname']);
if (isset($test[0])) {
$_POST['classname'] = $test[0];
$_POST['name'] = $test[1];
$_POST['classname'] = $test[0];
$_POST['name'] = $test[1];

$config = new PluginMreportingConfig();
echo "&nbsp;<a href='" . $config->getFormURL() . "?name=" . $_POST['name'] . "&classname=" . $_POST['classname'] . "'>" . __('Send') . "</a>";
echo "&nbsp;<a href='" . $config->getFormURL() . '?name=' . $_POST['name'] . '&classname=' . $_POST['classname'] . "'>" . __('Send') . '</a>';
}
}
4 changes: 2 additions & 2 deletions ajax/get_new_crsf_token.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
*/

$AJAX_INCLUDE = 1;
include("../../../inc/includes.php");
include('../../../inc/includes.php');

header("Content-Type: text/html; charset=UTF-8");
header('Content-Type: text/html; charset=UTF-8');
Html::header_nocache();

Session::checkLoginUser();
Expand Down
2 changes: 1 addition & 1 deletion ajax/homepage_link.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@

echo '<li id="menu99"><a href="' . Plugin::getWebDir('mreporting') .
'/front/dashboard.form.php" class="itemP">&nbsp;&nbsp;' .
__("Dashboard", 'mreporting') . '&nbsp;&nbsp;</a></li>';
__('Dashboard', 'mreporting') . '&nbsp;&nbsp;</a></li>';
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"glpi-project/tools": "^0.7",
"php-parallel-lint/php-parallel-lint": "^1.4",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^1.11",
"squizlabs/php_codesniffer": "^3.10"
"phpstan/phpstan": "^1.11"
},
"config": {
"optimize-autoloader": true,
Expand Down
82 changes: 1 addition & 81 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions front/central.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,39 +28,39 @@
* -------------------------------------------------------------------------
*/

include("../../../inc/includes.php");
include('../../../inc/includes.php');

Session::checkLoginUser();
Html::header(__("More Reporting", 'mreporting'), '', 'tools', 'PluginMreportingCommon', 'dashboard_list');
Html::header(__('More Reporting', 'mreporting'), '', 'tools', 'PluginMreportingCommon', 'dashboard_list');
$common = new PluginMreportingCommon();

/*** Regular Tab ***/
$reports = $common->getAllReports();
$tabs = [];
$tabs = [];
foreach ($reports as $classname => $report) {
$tabs[$classname] = ['title' => $report['title'],
'url' => Plugin::getWebDir('mreporting') . "/ajax/common.tabs.php",
'params' => "target=" . $_SERVER['PHP_SELF'] . "&classname=$classname"
'url' => Plugin::getWebDir('mreporting') . '/ajax/common.tabs.php',
'params' => 'target=' . $_SERVER['PHP_SELF'] . "&classname=$classname",
];
}

if (count($tabs) > 0) {
//foreach tabs
//foreach tabs
foreach ($tabs as $tab) {
global $DB;
$params = (isset($tab['params']) ? $tab['params'] : '');
//we get the classname
$classname = str_replace("target=" . $_SERVER['PHP_SELF'] . "&classname=", '', $params);
//we get the classname
$classname = str_replace('target=' . $_SERVER['PHP_SELF'] . '&classname=', '', $params);

//we found all reports for classname where current profil have right
//we found all reports for classname where current profil have right
$query = "SELECT *
FROM `glpi_plugin_mreporting_configs`,`glpi_plugin_mreporting_profiles`
WHERE `glpi_plugin_mreporting_configs`.`id` = `glpi_plugin_mreporting_profiles`.`reports`
AND `glpi_plugin_mreporting_configs`.`classname` = '$classname'
AND `glpi_plugin_mreporting_profiles`.`right` = " . READ . "
AND `glpi_plugin_mreporting_profiles`.`profiles_id` = " . $_SESSION['glpiactiveprofile']['id'];
AND `glpi_plugin_mreporting_profiles`.`right` = " . READ . '
AND `glpi_plugin_mreporting_profiles`.`profiles_id` = ' . $_SESSION['glpiactiveprofile']['id'];

//for this classname if current user have no right on any reports
//for this classname if current user have no right on any reports
if ($result = $DB->query($query)) {
if ($DB->numrows($result) == 0) {
//we unset the index
Expand All @@ -69,15 +69,15 @@
}
}

//finally if tabs is empty
//finally if tabs is empty
if (empty($tabs)) {
echo "<div class='center'><br>" . __("No report is available !", 'mreporting') . "</div>";
echo "<div class='center'><br>" . __('No report is available !', 'mreporting') . '</div>';
} else {
echo "<div id='tabspanel' class='center-h'></div>";
Ajax::createTabs('tabspanel', 'tabcontent', $tabs, 'PluginMreportingCommon');
}
} else {
echo "<div class='center'><br>" . __("No report is available !", 'mreporting') . "</div>";
echo "<div class='center'><br>" . __('No report is available !', 'mreporting') . '</div>';
}

Html::footer();
30 changes: 15 additions & 15 deletions front/config.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,35 @@
* -------------------------------------------------------------------------
*/

include("../../../inc/includes.php");
include('../../../inc/includes.php');

Session::checkRight("config", UPDATE);
Session::checkRight('config', UPDATE);

if (!isset($_GET["id"])) {
$_GET["id"] = 0;
if (!isset($_GET['id'])) {
$_GET['id'] = 0;
}
if (!isset($_GET["preconfig"])) {
$_GET["preconfig"] = -1;
if (!isset($_GET['preconfig'])) {
$_GET['preconfig'] = -1;
}

$config = new PluginMreportingConfig();

if (isset($_POST["add"])) {
if (isset($_POST['add'])) {
$newID = $config->add($_POST);
Html::back();
} else if (isset($_POST["update"])) {
} elseif (isset($_POST['update'])) {
$config->update($_POST);
Html::back();
} else if (isset($_POST["delete"])) {
} elseif (isset($_POST['delete'])) {
$config->delete($_POST, 1);
Html::redirect("./config.form.php");
Html::redirect('./config.form.php');
} else {
Html::header(__("More Reporting", 'mreporting'), '', 'tools', 'PluginMreportingCommon', 'config');
Html::header(__('More Reporting', 'mreporting'), '', 'tools', 'PluginMreportingCommon', 'config');

//Link from graph
if (isset($_GET["name"]) && isset($_GET["classname"])) {
if ($config->getFromDBByFunctionAndClassname($_GET["name"], $_GET["classname"])) {
$_GET["id"] = $config->fields['id'];
//Link from graph
if (isset($_GET['name']) && isset($_GET['classname'])) {
if ($config->getFromDBByFunctionAndClassname($_GET['name'], $_GET['classname'])) {
$_GET['id'] = $config->fields['id'];
}
}
$config->display($_GET);
Expand Down
Loading

0 comments on commit 1ef5260

Please sign in to comment.