Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e805b58
wip - poc / a squash - Liste des RuleTicket
SebSept Feb 12, 2025
a93ed7f
wip - poc / a squash - Liste des RuleTicket + reinit + reorder
SebSept Feb 12, 2025
8ff3def
wip - poc / a squash - Liste des RuleTicket + reinit + reorder
SebSept Feb 12, 2025
2cc5ad1
Merge remote-tracking branch 'perso/rule-collection-generic-controlle…
SebSept Feb 12, 2025
b8a7463
remove legacy controller replaced by RuleListController (dictionnary …
SebSept Feb 13, 2025
6c2adeb
Dictionaries of custom models & types
SebSept Feb 17, 2025
8c4e37a
csfix / typo / notes
SebSept Feb 17, 2025
c1a1760
handle dictionaries form for custom model & custom types (custom assets)
SebSept Feb 18, 2025
45d52dc
polish : csfix, licences, strict_type, phpstan 6
SebSept Feb 19, 2025
b65a125
remove RuleFormController.php. removed all file including '/front/rul…
SebSept Feb 20, 2025
26b16e7
Update phpstan.neon.dist
SebSept Feb 20, 2025
4eba84a
remove legacy controller replaced by RuleListController (dictionnary …
SebSept Feb 13, 2025
900e5a1
Update phpstan.neon.dist
SebSept Feb 20, 2025
5770827
Merge remote-tracking branch 'perso/rule-collection-generic-controlle…
SebSept Feb 20, 2025
aa87e70
Merge branch 'main' into rule-collection-generic-controller
SebSept Feb 20, 2025
8c741a0
do not reorder rules if 'ranking' not set + update tests
SebSept Feb 20, 2025
16b4ad6
Update src/CommonGLPI.php
SebSept Feb 20, 2025
1e3099e
Update src/Rule.php
SebSept Feb 20, 2025
c3d10ed
Update src/Rule.php
SebSept Feb 20, 2025
fc25d4e
fix proposed changes + fix baseline
SebSept Feb 20, 2025
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
36 changes: 36 additions & 0 deletions .phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,42 @@
'count' => 1,
'path' => __DIR__ . '/front/notificationmailingsetting.form.php',
];
$ignoreErrors[] = [
'message' => '#^Instanceof between Glpi\\\\Controller\\\\LegacyFileLoadController and Glpi\\\\Controller\\\\LegacyFileLoadController will always evaluate to true\\.$#',
'identifier' => 'instanceof.alwaysTrue',
'count' => 1,
'path' => __DIR__ . '/front/rule.common.form.php',
];
$ignoreErrors[] = [
'message' => '#^Instanceof between RuleCollection and RuleCollection will always evaluate to true\\.$#',
'identifier' => 'instanceof.alwaysTrue',
'count' => 1,
'path' => __DIR__ . '/front/rule.common.form.php',
];
$ignoreErrors[] = [
'message' => '#^Result of \\|\\| is always false\\.$#',
'identifier' => 'booleanOr.alwaysFalse',
'count' => 1,
'path' => __DIR__ . '/front/rule.common.form.php',
];
$ignoreErrors[] = [
'message' => '#^Instanceof between Glpi\\\\Controller\\\\LegacyFileLoadController and Glpi\\\\Controller\\\\LegacyFileLoadController will always evaluate to true\\.$#',
'identifier' => 'instanceof.alwaysTrue',
'count' => 1,
'path' => __DIR__ . '/front/rule.common.php',
];
$ignoreErrors[] = [
'message' => '#^Instanceof between RuleCollection and RuleCollection will always evaluate to true\\.$#',
'identifier' => 'instanceof.alwaysTrue',
'count' => 1,
'path' => __DIR__ . '/front/rule.common.php',
];
$ignoreErrors[] = [
'message' => '#^Result of \\|\\| is always false\\.$#',
'identifier' => 'booleanOr.alwaysFalse',
'count' => 1,
'path' => __DIR__ . '/front/rule.common.php',
];
$ignoreErrors[] = [
'message' => '#^Match expression does not handle remaining value\\: mixed$#',
'identifier' => 'match.unhandled',
Expand Down
51 changes: 0 additions & 51 deletions front/asset/ruledictionarymodel.form.php

This file was deleted.

51 changes: 0 additions & 51 deletions front/asset/ruledictionarymodel.php

This file was deleted.

51 changes: 0 additions & 51 deletions front/asset/ruledictionarytype.form.php

This file was deleted.

51 changes: 0 additions & 51 deletions front/asset/ruledictionarytype.php

This file was deleted.

61 changes: 13 additions & 48 deletions front/rule.common.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,59 +36,24 @@
/**
* Following variables have to be defined before inclusion of this file:
* @var RuleCollection $rulecollection
* @var LegacyFileLoadController $this
*/

use Glpi\Event;
use Glpi\Controller\GenericFormController;
use Glpi\Controller\LegacyFileLoadController;

$rule = $rulecollection->getRuleClass();
$rulecollection->checkGlobal(READ);

if (!isset($_GET["id"])) {
$_GET["id"] = "";
if (!($this instanceof LegacyFileLoadController) || !($rulecollection instanceof RuleCollection)) {
throw new LogicException('$rulecollection must be an instance of RuleCollection || Not in the context of a LegacyFileLoadController');
}

if (isset($_POST["update"])) {
$rulecollection->checkGlobal(UPDATE);
$rule->update($_POST);
Toolbox::deprecated(sprintf(
'Requiring legacy rule files is deprecated. You can safely remove the %s file and use the new `%s` route, dedicated for items (generic).',
debug_backtrace()[0]['file'] ?? 'including',
'glpi_itemtype_form',
));

Event::log(
$_POST['id'],
"rules",
4,
"setup",
//TRANS: %s is the user login
sprintf(__('%s updates an item'), $_SESSION["glpiname"])
);
Html::back();
} else if (isset($_POST["add"])) {
$rulecollection->checkGlobal(CREATE);
$request = $this->getRequest(); // @phpstan-ignore method.private
$request->attributes->set('class', $rulecollection::getRuleClassName());

$newID = $rule->add($_POST);
Event::log(
$newID,
"rules",
4,
"setup",
sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $newID)
);
Html::redirect($rule->getFormURLWithID($newID));
} else if (isset($_POST["purge"])) {
$rulecollection->checkGlobal(PURGE);
$rulecollection->deleteRuleOrder($_POST["ranking"]);
$rule->delete($_POST, 1);

Event::log(
$_POST["id"],
"rules",
4,
"setup",
//TRANS: %s is the user login
sprintf(__('%s purges an item'), $_SESSION["glpiname"])
);
$rule->redirectToList();
}

$menus = ['admin', $rulecollection->menu_type, $rulecollection->menu_option];
$rule::displayFullPageForItem($_GET["id"], $menus, [
'formoptions' => " data-track-changes='true'"
]);
return GenericFormController::handleLegacyFormAction($request);
Loading