Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cs): fix CS #19

Merged
merged 11 commits into from
Jan 30, 2024
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
8 changes: 3 additions & 5 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ jobs:
fail-fast: false
matrix:
include:
- {glpi-version: "10.0.x", php-version: "7.4", db-image: "mysql:5.7"}
- {glpi-version: "10.0.x", php-version: "8.0", db-image: "mysql:8.0"}
- {glpi-version: "10.0.x", php-version: "8.1", db-image: "mariadb:10.2"}
- {glpi-version: "10.0.x", php-version: "8.2", db-image: "mariadb:11.0"}
- {glpi-version: "10.0.x", php-version: "8.3-rc", db-image: "mysql:8.0"}
- {glpi-version: "10.1.x", php-version: "8.1", db-image: "mariadb:10.5"}
- {glpi-version: "10.1.x", php-version: "8.2", db-image: "mariadb:11.0"}
- {glpi-version: "10.1.x", php-version: "8.3-rc", db-image: "mysql:8.0"}
uses: "glpi-project/plugin-ci-workflows/.github/workflows/continuous-integration.yml@v1"
with:
plugin-key: "deploy"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: "actions/checkout@v4"
- name: "Build package"
id: "build-package"
uses: "glpi-project/tools/github-actions/[email protected].1"
uses: "glpi-project/tools/github-actions/[email protected].2"
with:
plugin-version: ${{ env.tag_name }}
- name: "Create release"
Expand Down
1 change: 1 addition & 0 deletions .phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<rule ref="PSR12">
<exclude name="Generic.Files.LineLength" />
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
</rule>
<rule ref="Generic.Arrays.ArrayIndent"></rule>
</ruleset>
14 changes: 7 additions & 7 deletions ajax/package.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,28 @@

namespace GlpiPlugin\Deploy;

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

\Session::checkLoginUser();

switch (($_POST['action'] ?? "")) {
case "add_check":
Package_Check::showAdd((int) ($_POST['plugin_deploy_packages_id'] ?? 0));
PackageCheck::showAdd((int) ($_POST['plugin_deploy_packages_id'] ?? 0));
break;
case "edit_check":
Package_Check::showEdit((int) ($_POST['id'] ?? 0));
PackageCheck::showEdit((int) ($_POST['id'] ?? 0));
break;
case "add_file":
Package_File::showAdd((int) ($_POST['plugin_deploy_packages_id'] ?? 0));
PackageFile::showAdd((int) ($_POST['plugin_deploy_packages_id'] ?? 0));
break;
case "edit_file":
Package_File::showEdit((int) ($_POST['id'] ?? 0));
PackageFile::showEdit((int) ($_POST['id'] ?? 0));
break;
case "add_action":
Package_Action::showAdd((int) ($_POST['plugin_deploy_packages_id'] ?? 0));
PackageAction::showAdd((int) ($_POST['plugin_deploy_packages_id'] ?? 0));
break;
case "edit_action":
Package_Action::showEdit((int) ($_POST['id'] ?? 0));
PackageAction::showEdit((int) ($_POST['id'] ?? 0));
break;
case "move_subitem":
Package::moveSubitem(
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"require": {
"php": ">=7.4"
"php": ">=8.1"
},
"require-dev": {
"glpi-project/tools": "^0.7.1",
"glpi-project/tools": "^0.7.2",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.10",
Expand All @@ -13,7 +13,7 @@
"config": {
"optimize-autoloader": true,
"platform": {
"php": "7.4.0"
"php": "8.1"
},
"sort-packages": true,
"allow-plugins": {
Expand Down
173 changes: 96 additions & 77 deletions front/computer/group.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,108 +34,127 @@
use Html;
use Session;

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

Session::checkRight("computer_group", READ);

if (!isset($_GET["id"])) {
$_GET["id"] = "";
$_GET["id"] = "";
}

if (!isset($_GET["withtemplate"])) {
$_GET["withtemplate"] = "";
$_GET["withtemplate"] = "";
}

$computergroup = new Group();
$computergroupstatic = new Group_Static();
$computergroup_dynamic = new Group_Dynamic();
$computergroupstatic = new GroupStatic();
$computergroup_dynamic = new GroupDynamic();

//Add a new computergroup
if (isset($_POST["add"])) {
$computergroup->check(-1, CREATE, $_POST);
if ($newID = $computergroup->add($_POST)) {
Event::log($newID, "Group", 4, "inventory",
sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"]));

if ($_SESSION['glpibackcreated']) {
Html::redirect($computergroup->getLinkURL());
}
}
Html::back();
$computergroup->check(-1, CREATE, $_POST);
if ($newID = $computergroup->add($_POST)) {
Event::log(
$newID,
"Group",
4,
"inventory",
sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"])
);

if ($_SESSION['glpibackcreated']) {
Html::redirect($computergroup->getLinkURL());
}
}
Html::back();

// purge a computergroup
}if (isset($_POST["add_staticcomputer"])) {

if (!$_POST['computers_id']){
Session::addMessageAfterRedirect(__('Please select a computer'), false, ERROR);
Html::back();
}

$computergroupstatic->check(-1, CREATE, $_POST);
if ($newID = $computergroupstatic->add($_POST)) {
Event::log($newID, "Computer_Group_Static", 4, "inventory",
sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $computergroupstatic::getTypeName(0)));

if ($_SESSION['glpibackcreated']) {
$computergroup->getFromDB($_POST['plugin_deploy_computers_groups_id']);
Html::redirect($computergroup->getLinkURL());
}
}
Html::back();
if (!$_POST['computers_id']) {
Session::addMessageAfterRedirect(__('Please select a computer'), false, ERROR);
Html::back();
}

$computergroupstatic->check(-1, CREATE, $_POST);
if ($newID = $computergroupstatic->add($_POST)) {
Event::log(
$newID,
"Computer_GroupStatic",
4,
"inventory",
sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $computergroupstatic::getTypeName(0))
);

if ($_SESSION['glpibackcreated']) {
$computergroup->getFromDB($_POST['plugin_deploy_computers_groups_id']);
Html::redirect($computergroup->getLinkURL());
}
}
Html::back();

// purge a computergroup
} else if (isset($_POST["purge"])) {
$computergroup->check($_POST['id'], PURGE);
if ($computergroup->delete($_POST, 1)) {
Event::log($_POST["id"], "Computer_Group", 4, "inventory",
//TRANS: %s is the user login
sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
}
$computergroup->redirectToList();
$computergroup->check($_POST['id'], PURGE);
if ($computergroup->delete($_POST, 1)) {
Event::log(
$_POST["id"],
"Computer_Group",
4,
"inventory",
//TRANS: %s is the user login
sprintf(__('%s purges an item'), $_SESSION["glpiname"])
);
}
$computergroup->redirectToList();

//update a computergroup
} else if (isset($_POST["update"])) {
$computergroup->check($_POST['id'], UPDATE);
$computergroup->update($_POST);
Event::log($_POST["id"], "Computer_Group", 4, "inventory",
//TRANS: %s is the user login
sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
Html::back();

$computergroup->check($_POST['id'], UPDATE);
$computergroup->update($_POST);
Event::log(
$_POST["id"],
"Computer_Group",
4,
"inventory",
//TRANS: %s is the user login
sprintf(__('%s updates an item'), $_SESSION["glpiname"])
);
Html::back();
} else {//print computergroup information
//save search parameters for dynamic group
if (isset($_GET["save"])) {
$input = ['plugin_deploy_computers_groups_id' => $_GET['plugin_deploy_computers_groups_id']];
$search = serialize(['is_deleted' => isset($_GET['is_deleted']) ? $_GET['is_deleted'] : 0 ,
'as_map' => isset($_GET['as_map']) ? $_GET['as_map'] : 0,
'criteria' => $_GET['criteria'],
'metacriteria' => isset($_GET['metacriteria']) ? $_GET['metacriteria'] : []]);

if (!$computergroup_dynamic->getFromDBByCrit($input)) {
$input['search'] = $search;
$computergroup_dynamic->add($input);
} else {
$input = $computergroup_dynamic->fields;
$input['search'] = $search;
$computergroup_dynamic->update($input);
}
}else if (isset($_GET["reset"])) {
$computergroup_dynamic->deleteByCriteria(["plugin_deploy_computers_groups_id" => $_GET['id']]);
}


Html::header(
Group::getTypeName(Session::getPluralNumber()),
'',
'tools',
'glpiplugin\deploy\menu',
'computer_group'
);
if (isset($_GET["save"])) {
$input = ['plugin_deploy_computers_groups_id' => $_GET['plugin_deploy_computers_groups_id']];
$search = serialize(['is_deleted' => isset($_GET['is_deleted']) ? $_GET['is_deleted'] : 0 ,
'as_map' => isset($_GET['as_map']) ? $_GET['as_map'] : 0,
'criteria' => $_GET['criteria'],
'metacriteria' => isset($_GET['metacriteria']) ? $_GET['metacriteria'] : []
]);

if (!$computergroup_dynamic->getFromDBByCrit($input)) {
$input['search'] = $search;
$computergroup_dynamic->add($input);
} else {
$input = $computergroup_dynamic->fields;
$input['search'] = $search;
$computergroup_dynamic->update($input);
}
} else if (isset($_GET["reset"])) {
$computergroup_dynamic->deleteByCriteria(["plugin_deploy_computers_groups_id" => $_GET['id']]);
}


Html::header(
Group::getTypeName(Session::getPluralNumber()),
'',
'tools',
'glpiplugin\deploy\menu',
'computer_group'
);

//show computergroup form to add
$computergroup->display([
'id' => (int) $_GET["id"],
]);
$computergroup->display([
'id' => (int) $_GET["id"],
]);

Html::footer();
Html::footer();
}
3 changes: 1 addition & 2 deletions front/computer/group.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@
* -------------------------------------------------------------------------
*/


namespace GlpiPlugin\Deploy\Computer;

use Html;
use Search;
use Session;

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

Session::checkRight("computer_group", UPDATE);

Expand Down
22 changes: 11 additions & 11 deletions front/package.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,51 +69,51 @@
Html::back();
} else if (isset($_POST["add_file"])) {
unset($_POST['id']);
$file = new Package_File();
$file = new PackageFile();
$file->add($_POST);
Html::back();
} else if (isset($_POST["edit_file"])) {
$file = new Package_File();
$file = new PackageFile();
$file->update($_POST);
Html::back();
} else if (isset($_POST["delete_file"])) {
$file = new Package_File();
$file = new PackageFile();
$file->delete($_POST);
Html::back();
} else if (isset($_GET["download_file"])) {
$file_id = (int)($_GET["file_id"] ?? 0);
$file = new Package_File();
$file = new PackageFile();
$file->downloadFile($file_id);
Html::back();
} else if (isset($_POST["add_check"])) {
unset($_POST['id']);
$check = new Package_Check();
$check = new PackageCheck();
$check->add($_POST);
Html::back();
} else if (isset($_POST["edit_check"])) {
$check = new Package_Check();
$check = new PackageCheck();
$check->update($_POST);
Html::back();
} else if (isset($_POST["delete_check"])) {
$check = new Package_Check();
$check = new PackageCheck();
$check->delete($_POST);
Html::back();
} else if (isset($_POST["add_action"])) {
unset($_POST['id']);
$action = new Package_Action();
$action = new PackageAction();
$action->add($_POST);
Html::back();
} else if (isset($_POST["edit_action"])) {
$action = new Package_Action();
$action = new PackageAction();
$action->update($_POST);
Html::back();
} else if (isset($_POST["delete_action"])) {
$action = new Package_Action();
$action = new PackageAction();
$action->delete($_POST);
Html::back();
} else if (isset($_POST["add_target"])) {
if ($_POST['plugin_deploy_computers_groups_id'] > 0) {
$package_target = new Package_Target();
$package_target = new PackageTarget();
$package_target->add($_POST);
}
Html::back();
Expand Down
Loading
Loading