Skip to content
Open
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: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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]
## [Unreleased]

### Fixed

Expand All @@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## Add

- Add rector config
- Implementation of the basic concept of escalation
- Add the "Escalate to group" action to the ticket, change and problem business rules, and a page to switch the rules "Technician group" actions to it
- Add the escalation hierarchy between groups: graph editor in the "Escalation" tab of the groups, with basic links (limited to their entity) and inherited links (replicated in the child entities). Changing it requires the right to update the GLPI configuration
- Filter the groups of the "Escalate" form with the escalation tree

## [1.0.0-rc2]

Expand Down
50 changes: 50 additions & 0 deletions ajax/escalation_form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

/**
* -------------------------------------------------------------------------
* MoreOptions plugin for GLPI
* -------------------------------------------------------------------------
*
* MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2025 by the MoreOptions plugin team.
* @license MIT https://opensource.org/licenses/mit-license.php
* @link https://github.com/pluginsGLPI/moreoptions
* @link https://gitlab.teclib.com/glpi-network/moreoptions/
* -------------------------------------------------------------------------
*/

use Glpi\Exception\Http\AccessDeniedHttpException;
use GlpiPlugin\Moreoptions\Escalation;

Session::checkLoginUser();

$item = getItemForItemtype($_GET['itemtype'] ?? '');
if (
!$item instanceof CommonITILObject
|| !$item->getFromDB((int) ($_GET['items_id'] ?? 0))
|| !$item->canAssign()
|| !Escalation::isEnabledFor($item)
) {
throw new AccessDeniedHttpException();
}

Escalation::showEscalationForm($item);
44 changes: 44 additions & 0 deletions ajax/group_link.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/**
* -------------------------------------------------------------------------
* MoreOptions plugin for GLPI
* -------------------------------------------------------------------------
*
* MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2025 by the MoreOptions plugin team.
* @license MIT https://opensource.org/licenses/mit-license.php
* @link https://github.com/pluginsGLPI/moreoptions
* @link https://gitlab.teclib.com/glpi-network/moreoptions/
* -------------------------------------------------------------------------
*/

use GlpiPlugin\Moreoptions\EscalationTree\TreeEditor;

/**
* Applies a change made in the escalation graph of an entity, or saves it, then renders the editor
* again (see TreeEditor::respond()).
*/

Session::checkLoginUser();

TreeEditor::respond($_POST)->display();
54 changes: 54 additions & 0 deletions front/escalation.form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

/**
* -------------------------------------------------------------------------
* MoreOptions plugin for GLPI
* -------------------------------------------------------------------------
*
* MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2025 by the MoreOptions plugin team.
* @license MIT https://opensource.org/licenses/mit-license.php
* @link https://github.com/pluginsGLPI/moreoptions
* @link https://gitlab.teclib.com/glpi-network/moreoptions/
* -------------------------------------------------------------------------
*/

use Glpi\Exception\Http\AccessDeniedHttpException;
use GlpiPlugin\Moreoptions\Escalation;

Session::checkLoginUser();

if (isset($_POST['add'])) {
$item = getItemForItemtype($_POST['itemtype'] ?? '');
if (
!$item instanceof CommonITILObject
|| !$item->getFromDB((int) ($_POST['items_id'] ?? 0))
|| !$item->canAssign()
|| !Escalation::isEnabledFor($item)
) {
throw new AccessDeniedHttpException();
}

(new Escalation())->add($_POST);
}

Html::back();
65 changes: 65 additions & 0 deletions front/escalation_rules.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

/**
* -------------------------------------------------------------------------
* MoreOptions plugin for GLPI
* -------------------------------------------------------------------------
*
* MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2025 by the MoreOptions plugin team.
* @license MIT https://opensource.org/licenses/mit-license.php
* @link https://github.com/pluginsGLPI/moreoptions
* @link https://gitlab.teclib.com/glpi-network/moreoptions/
* -------------------------------------------------------------------------
*/

use Glpi\Exception\Http\AccessDeniedHttpException;
use GlpiPlugin\Moreoptions\EscalationRule;

Session::checkLoginUser();

if (!EscalationRule::canManageRules()) {
throw new AccessDeniedHttpException();
}

if (isset($_POST['update'])) {
$result = EscalationRule::switchActions(is_array($_POST['fields'] ?? null) ? $_POST['fields'] : []);
if ($result['updated'] > 0) {
Session::addMessageAfterRedirect(htmlescape(sprintf(
_n('%d rule action has been updated.', '%d rule actions have been updated.', $result['updated'], 'moreoptions'),
$result['updated'],
)));
}

if ($result['failed'] > 0) {
Session::addMessageAfterRedirect(htmlescape(sprintf(
_n('%d rule action cannot be updated.', '%d rule actions cannot be updated.', $result['failed'], 'moreoptions'),
$result['failed'],
)), false, ERROR);
}

Html::back();
}

Html::header(__('Escalation in business rules', 'moreoptions'), '', 'admin', 'rule');
EscalationRule::showRulesList();
Html::footer();
20 changes: 20 additions & 0 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,17 @@
declare(strict_types=1);

use GlpiPlugin\Moreoptions\Config;
use GlpiPlugin\Moreoptions\Escalation;
use GlpiPlugin\Moreoptions\EscalationRule;
use GlpiPlugin\Moreoptions\Group_Link;

function plugin_moreoptions_install(): bool
{
$migration = new Migration(PLUGIN_MOREOPTIONS_VERSION);

Config::install($migration);
Escalation::install($migration);
Group_Link::install($migration);
$migration->executeMigration();
return true;
}
Expand All @@ -49,6 +54,21 @@ function plugin_moreoptions_uninstall(): bool
$migration = new Migration(PLUGIN_MOREOPTIONS_VERSION);

Config::uninstall($migration);
Escalation::uninstall($migration);
EscalationRule::uninstall($migration);
Group_Link::uninstall($migration);

return true;
}

/**
* Adds the "Escalate to group" action to the ticket / change / problem rules (see the `use_rules`
* hook in setup.php).
*
* @param array<string, mixed> $params
* @return array<string, array<string, mixed>>
*/
function plugin_moreoptions_getRuleActions(array $params = []): array
{
return EscalationRule::getRuleActions($params);
}
Loading
Loading