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
4 changes: 3 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 @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## Add

- Add rector config
- Implementation of the basic concept of escalation

## [1.0.0-rc2]

Expand All @@ -22,3 +23,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Fixed the issue where a ticket could be solved without a solution

## [1.0.0-rc1]

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);
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();
6 changes: 6 additions & 0 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@
declare(strict_types=1);

use GlpiPlugin\Moreoptions\Config;
use GlpiPlugin\Moreoptions\Escalation;
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 +53,8 @@ function plugin_moreoptions_uninstall(): bool
$migration = new Migration(PLUGIN_MOREOPTIONS_VERSION);

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

return true;
}
125 changes: 125 additions & 0 deletions public/css/moreoptions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,128 @@
}
}
}

:root {
--mo-escalation-color: #fff0f0ca;

--mo-escalation-background: var(--mo-escalation-color);
--mo-escalation-border: color-mix(in srgb, var(--mo-escalation-color), #a81313 50%);
}

// "Escalate" button, next to the "Assigned to" field (see escalation_button.html.twig).
.moreoptions-escalate-btn,
.moreoptions-escalate-btn:focus {
color: var(--mo-escalation-border) !important;
border-color: var(--mo-escalation-border) !important;
}

.moreoptions-escalate-btn:hover {
background-color: var(--mo-escalation-border) !important;
border-color: var(--mo-escalation-border) !important;
color: white !important;
}

// Escalation entries in the timeline (see Escalation::getTimelineContent() and
// escalation_timeline.html.twig): a centered card with a dashed border, holding the
// "<icon> | <source groups> -> <target group>" summary next to the "Created: ... by ..." badge,
// then the escalation comment, which can be collapsed.
.timeline-item.moreoptions-escalation {
width: 100%;

.user-part {
display: none !important;
}

.content-part {
align-items: center;
margin-left: 75px;
margin-right: 83px;

.timeline-content {
flex-grow: 0 !important;
// Core stretches timeline entries to the full width: fit the content instead, so a
// collapsed (or comment-less) entry is no wider than its header line.
min-width: 0;
max-width: 100%;
background: var(--mo-escalation-background);
// Core squares the corner the (hidden) speech bubble arrow points to.
border-radius: var(--tblr-border-radius-lg) !important;
// Also replaces the thicker dashed border of "internal" entries (`.private-item`).
border: 1px dashed var(--mo-escalation-border);
box-shadow: none;

// Speech bubble arrow pointing to the (hidden) avatar
&::before,
&::after {
display: none;
}

.card-body {
padding: 0.5rem 1rem !important;
}
}
}

.timeline-header {
flex-wrap: wrap;
align-items: center;
justify-content: center;
gap: 0.5rem;
margin: 0;
}

.timeline-item-buttons {
align-items: center;
gap: 0.5rem;
margin-left: 0 !important;
}

.moreoptions-escalation-separator {
opacity: 0.4;
}

.moreoptions-escalation-summary {
display: inline-flex;
align-items: center;
gap: 0.5rem;
color: var(--mo-escalation-border);
}

.moreoptions-escalation-groups {
display: inline-flex;
flex-wrap: wrap;
align-items: center;
gap: 0.5rem;
font-style: italic;
}

.moreoptions-escalation-group {
display: inline-flex;
align-items: center;
gap: 0.25rem;

a {
color: inherit;

&:hover {
text-decoration: underline;
}
}
}

.moreoptions-escalation-toggle {
padding: 0 0.25rem;

i {
transition: transform 0.2s;
}

&.collapsed i {
transform: rotate(180deg);
}
}

.moreoptions-escalation-comment {
margin-top: 0.75rem;
}
}
18 changes: 17 additions & 1 deletion setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
use Glpi\Plugin\Hooks;
use GlpiPlugin\Moreoptions\Config;
use GlpiPlugin\Moreoptions\Controller;
use GlpiPlugin\Moreoptions\Escalation;
use GlpiPlugin\Moreoptions\Group_Link;

/** @phpstan-ignore theCodingMachineSafe.function (safe to assume this isn't already defined) */
define('PLUGIN_MOREOPTIONS_VERSION', '1.0.0-rc2');
Expand Down Expand Up @@ -66,6 +68,8 @@ function plugin_init_moreoptions(): void

Plugin::registerClass(Config::class, ['addtabon' => 'Entity']);

Plugin::registerClass(Group_Link::class, ['addtabon' => 'Group']);

$PLUGIN_HOOKS[Hooks::ADD_CSS]['moreoptions'][] = 'css/moreoptions.scss';

$PLUGIN_HOOKS[Hooks::ITEM_ADD]['moreoptions'][Entity::class] = Config::addConfig(...);
Expand All @@ -81,10 +85,22 @@ function plugin_init_moreoptions(): void
// Both hooks below are called by GLPI core with an array of parameters (not an item
// instance), so they must be registered without an itemtype key: the callback filters
// on $params['item'] itself.
$PLUGIN_HOOKS[Hooks::TIMELINE_ACTIONS]['moreoptions'] = Controller::showSolutionRequirementsWarning(...);
$PLUGIN_HOOKS[Hooks::TIMELINE_ACTIONS]['moreoptions'] = Controller::showTimelineActions(...);


$PLUGIN_HOOKS[Hooks::POST_ITEM_FORM]['moreoptions'] = Controller::markMandatoryTaskFields(...);

$PLUGIN_HOOKS[Hooks::TIMELINE_ITEMS]['moreoptions'] = Escalation::showInTimeline(...);

// Group links added with `_plugin_moreoptions_escalade => true` are escalations.
$PLUGIN_HOOKS[Hooks::ITEM_ADD]['moreoptions'][Group_Ticket::class] = Escalation::escalate(...);

$PLUGIN_HOOKS[Hooks::ITEM_ADD]['moreoptions'][Change_Group::class] = Escalation::escalate(...);

$PLUGIN_HOOKS[Hooks::ITEM_ADD]['moreoptions'][Group_Problem::class] = Escalation::escalate(...);

$PLUGIN_HOOKS[Hooks::PRE_ITEM_UPDATE]['moreoptions'][Ticket::class] = Controller::beforeCloseITILObject(...);

$PLUGIN_HOOKS[Hooks::PRE_ITEM_UPDATE]['moreoptions'][Ticket::class] = Controller::beforeCloseITILObject(...);

$PLUGIN_HOOKS[Hooks::PRE_ITEM_UPDATE]['moreoptions'][Change::class] = Controller::beforeCloseITILObject(...);
Expand Down
21 changes: 19 additions & 2 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ public static function getScreenTabs(): array
['id' => 'change', 'label' => __('Change'), 'icon' => 'ti-git-branch'],
['id' => 'problem', 'label' => __('Problem'), 'icon' => 'ti-alert-circle'],
['id' => 'task', 'label' => _n('Task', 'Tasks', 2), 'icon' => 'ti-checklist'],
['id' => 'escalate', 'label' => __('Escalate', 'moreoptions'), 'icon' => 'ti-arrow-up'],
];
}

Expand Down Expand Up @@ -397,6 +398,15 @@ private static function getScreenSections(): array
],
],
],
'escalate' => [
[
'title' => __('Escalate', 'moreoptions'),
'icon' => 'ti-arrow-up',
'rows' => [
['key' => 'escalate_is_active', 'kind' => 'yes_no', 'label' => __('Activate escalation', 'moreoptions')],
],
],
],
];
}

Expand All @@ -409,8 +419,13 @@ private static function getScreenSections(): array
*/
private static function getSectionsForTab(string $tab_id): array
{
$group = $tab_id === 'task' ? 'task' : 'itil';
$suffix = $tab_id === 'task' ? '' : ('_' . $tab_id);
if ($tab_id === 'task' || $tab_id === 'escalate') {
$group = $tab_id;
$suffix = '';
} else {
$group = 'itil';
$suffix = '_' . $tab_id;
}

$sections = [];
foreach (self::getScreenSections()[$group] as $section) {
Expand Down Expand Up @@ -561,6 +576,7 @@ public static function install(Migration $migration): void
`assign_technician_from_task_ticket` tinyint NOT NULL DEFAULT '0',
`assign_technician_from_task_change` tinyint NOT NULL DEFAULT '0',
`assign_technician_from_task_problem` tinyint NOT NULL DEFAULT '0',
`escalate_is_active` tinyint NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `entities_id` (`entities_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
Expand All @@ -579,6 +595,7 @@ public static function install(Migration $migration): void
'assign_technician_from_task_ticket',
'assign_technician_from_task_change',
'assign_technician_from_task_problem',
'escalate_is_active',
] as $field
) {
if (!$DB->fieldExists($table, $field)) {
Expand Down
Loading
Loading