From c57e48ce34a56670fd847a4f9e6ae7f02a79ec19 Mon Sep 17 00:00:00 2001 From: studio-prisma <282898618+studio-prisma@users.noreply.github.com> Date: Sun, 8 Nov 2026 15:49:38 +0100 Subject: [PATCH 1/2] feat: agents and API decide about the question when closing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A tick "Send satisfaction question" in the reply form, the note form and the status dialog of the agent panel; removing it means never for this ticket (row state declined, internal note). "No satisfaction question" / "Allow … again" in the ticket's More menu, a POST with osTicket's CSRF token and the agent's ticket permission. Closes without an agent form (API, cron, mass status change in the ticket list) follow a new setting: ask (default, as before), only when the request asks for it, or never. Requests pass feedback_ask=1|0; the flag confirms or suppresses, it never widens the rules. The note after a sent question names what triggered it. --- README.de.md | 13 +++ README.md | 13 +++ SECURITY.md | 2 + class.FeedbackPlugin.php | 9 +- config.php | 25 +++++ docs/INSTALL.de.md | 5 +- docs/INSTALL.md | 5 +- src/FeedbackActions.php | 25 ++++- src/FeedbackI18n.php | 24 +++++ src/FeedbackMail.php | 6 +- src/FeedbackRules.php | 33 +++++++ src/FeedbackSettings.php | 7 ++ src/FeedbackStore.php | 24 +++++ src/FeedbackTrigger.php | 56 +++++++++++- src/FeedbackUi.php | 183 +++++++++++++++++++++++++++++++++++++ tests/e2e/9-decide.spec.js | 161 ++++++++++++++++++++++++++++++++ tests/unit.php | 29 +++++- 17 files changed, 611 insertions(+), 9 deletions(-) create mode 100644 src/FeedbackUi.php create mode 100644 tests/e2e/9-decide.spec.js diff --git a/README.de.md b/README.de.md index 81cfd2a..b3e1b47 100644 --- a/README.de.md +++ b/README.de.md @@ -25,6 +25,17 @@ Die Bewertungen bleiben in der Datenbank des Helpdesks. Kein Umfragedienst, kein - Abteilungen, Hilfethemen und Absender-Domains aus den Einstellungen; standardmäßig die eigenen Domains des Helpdesks - Schließen mit einem Status wie „Dublette“ oder „Spam“ (Einstellung, nach Namen vorausgewählt) - Tickets, zu denen schon gefragt wurde +- Tickets, bei denen ein Agent die Frage abgeschaltet hat: Häkchen „Send satisfaction question“ beim Schließen entfernt oder „Keine Zufriedenheitsfrage“ im Menü „Weitere“ +- je nach Einstellung: Schließen ohne Agentenformular (API, Cron, Massen-Statuswechsel in der Ticketliste) + +## Wer entscheidet + +| Schließen | Standard | Einstellung | +|---|---|---| +| Agent schließt ein Ticket (Antwort, Notiz, Statusdialog) | fragt; der Agent kann das Häkchen entfernen, dann nie für dieses Ticket | „Agents can switch the question off“ | +| API, Cron, Massen-Statuswechsel in der Liste | fragt, wie in 0.1 | „Closing without an agent form“: fragen / nur wenn angefordert / nie | + +Ein Request fordert die Frage mit `feedback_ask=1` in den POST-Daten an und lehnt sie mit `feedback_ask=0` ab. Das Plugin [API Endpoints](https://github.com/studio-prisma/osticket-api-endpoints) (ab 2.9.0) reicht sein Feld `feedback` so weiter. Der Schalter kann eine Frage nur bestätigen oder unterdrücken, die die Regeln erlauben; er erweitert sie nie. ## Voraussetzungen @@ -49,6 +60,8 @@ Schritt für Schritt mit Prüfpunkten: **[docs/INSTALL.de.md](docs/INSTALL.de.md | Link valid for | Tage (1–90) | 14 | | Comment field after the click | an / aus | an | | Note at the ticket when asked | keine / kurz / mit der gesendeten Mail | kurz; ein gescheiterter Versand bekommt immer eine Notiz | +| Agents can switch the question off | an / aus | an | +| Closing without an agent form | fragen / nur wenn angefordert / nie | fragen | | Never ask for | Abteilungen, Hilfethemen, Status beim Schließen, Absender-Domains, eigene Domains | Abteilungen mit „Alert“/„Protokoll“ im Namen, Status mit „Duplicate“/„Spam“/„Hinfällig“ im Namen, eigene Domains | | Texte | Betreff, Mailtext, Frage, Zeile, KI-Hinweis; leer = eingebauter Text | eingebaut, Deutsch (du) oder Englisch | | Accent colour | `#rrggbb` | `#330066` | diff --git a/README.md b/README.md index 6ffee99..78d6b54 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,17 @@ Ratings stay in the help desk's own database. No survey service, no tracking pix - departments, help topics and sender domains from the settings; the help desk's own domains by default - closes with a status like "Duplicate" or "Spam" (setting, preselected by name) - tickets that were already asked +- tickets an agent switched off: the tick "Send satisfaction question" removed when closing, or "No satisfaction question" in the ticket's More menu +- depending on the setting, closes without an agent form (API, cron, mass status change in the ticket list) + +## Who decides + +| Close | Default | Setting | +|---|---|---| +| Agent closes one ticket (reply, note, status dialog) | asks; the agent can remove the tick, which means never for this ticket | "Agents can switch the question off" | +| API, cron, mass status change in the list | asks, as in 0.1 | "Closing without an agent form": ask / only when the request asks for it / never | + +A request asks for it with `feedback_ask=1` in the POST data and declines with `feedback_ask=0`. The [API Endpoints](https://github.com/studio-prisma/osticket-api-endpoints) plugin (2.9.0 or later) passes its `feedback` field this way. The flag can only confirm or suppress a question the rules allow; it never widens them. ## Requirements @@ -49,6 +60,8 @@ Step by step with checkpoints: **[docs/INSTALL.md](docs/INSTALL.md)**. Short ver | Link valid for | days (1–90) | 14 | | Comment field after the click | on / off | on | | Note at the ticket when asked | none / short / with the mail as sent | short; a failed send always gets a note | +| Agents can switch the question off | on / off | on | +| Closing without an agent form | ask / only when requested / never | ask | | Never ask for | departments, help topics, closing statuses, sender domains, own domains | departments named like "Alert"/"Protokoll", statuses named like "Duplicate"/"Spam"/"Hinfällig", own domains | | Texts | subject, mail text, question, line, AI notice; empty = built-in text | built-in, German (informal) or English | | Accent colour | `#rrggbb` | `#330066` | diff --git a/SECURITY.md b/SECURITY.md index b0cd171..cec7907 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -30,6 +30,8 @@ Expected response: an acknowledgement within 7 days, an assessment within 30. Th - **Markup from a comment rendered** on the click page, in a thread note, in the agent mail, in the assignment alert or on the evaluation page. - **The token key or `SECRET_SALT`** in a response, a log line, an error message or the release package; a link that works while `SECRET_SALT` is the sample value. - **The IP address stored in clear text.** +- **Switching the question off or on for a ticket** (`scp/ajax.php/feedback/ticket//decline|allow`) without an agent session, without osTicket's CSRF token, or for a ticket the agent can't access. +- **`feedback_ask` widening the rules**: a request that makes the plugin ask a ticket the rules exclude (AI agent, department, status, domain, already asked). - **A redirect to an address outside the help desk** or a link built from the request's Host header. - **Bypassing the rate limit** with the same IP, or growing the plugin's tables without bound from outside. - **Asking twice for one ticket**, asking for a ticket an AI agent closed, a sub-ticket or an excluded department, help topic or domain. diff --git a/class.FeedbackPlugin.php b/class.FeedbackPlugin.php index 256cac4..d31469f 100644 --- a/class.FeedbackPlugin.php +++ b/class.FeedbackPlugin.php @@ -37,11 +37,12 @@ require_once __DIR__ . '/src/FeedbackActions.php'; require_once __DIR__ . '/src/FeedbackPage.php'; require_once __DIR__ . '/src/FeedbackAdmin.php'; +require_once __DIR__ . '/src/FeedbackUi.php'; class FeedbackPlugin extends Plugin { /** Mirrors plugin.php. */ - public const VERSION = '0.1.1'; + public const VERSION = '0.2.0'; /** Route bases, relative to the help desk root. */ public const CLIENT_BASE = 'ajax.php/feedback'; @@ -75,7 +76,7 @@ public function bootstrap(): void $raw = array(); foreach (array('enabled', 'mode', 'scale', 'on_bad', 'bad_stars', 'bad_nps', 'valid_days', 'exclude_depts', 'exclude_topics', 'exclude_statuses', 'exclude_domains', 'exclude_own', 'comment_on', 'note_sent', - 'language', 'subject', 'text', + 'agent_decline', 'no_session', 'language', 'subject', 'text', 'question', 'line', 'foot_on', 'foot', 'accent') as $k) { $raw[$k] = $config->get($k); } @@ -109,6 +110,7 @@ public function bootstrap(): void } Signal::connect('threadentry.created', array('FeedbackTrigger', 'onEntry')); Signal::connect('model.updated', array('FeedbackTrigger', 'onUpdated')); + FeedbackUi::maybeStart(FeedbackSettings::get()); } // Handlers are closures on purpose: given array('Class', 'method'), the @@ -131,6 +133,9 @@ public static function staffRoutes($dispatcher): void $dispatcher->append(url_get('^/feedback/admin$', static function () { return FeedbackAdmin::page(); })); + $dispatcher->append(url_post('^/feedback/ticket/(?P\d+)/(?Pdecline|allow)$', static function ($id, $what) { + return FeedbackUi::toggle((int) $id, (string) $what); + })); } /** Key material from SECRET_SALT, or null: then nobody is asked and no link is valid. */ diff --git a/config.php b/config.php index becc15b..657ae80 100644 --- a/config.php +++ b/config.php @@ -101,6 +101,31 @@ public function getOptions() . 'opens the ticket sees the customer\'s rating links.', )), + 'sec_decide' => new SectionBreakField(array( + 'label' => 'Who decides', + )), + + 'agent_decline' => new BooleanField(array( + 'label' => 'Agents can switch the question off', + 'default' => true, + 'configuration' => array( + 'desc' => 'A tick "Send satisfaction question" when closing in the agent panel, and ' + . '"No satisfaction question" in the ticket\'s More menu. Off for a ticket means never.', + ), + )), + + 'no_session' => new ChoiceField(array( + 'label' => 'Closing without an agent form', + 'default' => 'ask', + 'choices' => array( + 'ask' => 'Ask (as in 0.1)', + 'requested' => 'Ask only when the request asks for it (feedback_ask=1)', + 'never' => 'Never ask', + ), + 'hint' => 'API, cron and mass status changes in the ticket list. The API Endpoints plugin passes ' + . '"feedback": true/false as feedback_ask.', + )), + 'sec_except' => new SectionBreakField(array( 'label' => 'Never ask for', )), diff --git a/docs/INSTALL.de.md b/docs/INSTALL.de.md index ca288a8..0d3c202 100644 --- a/docs/INSTALL.de.md +++ b/docs/INSTALL.de.md @@ -37,7 +37,7 @@ Abbruch, wenn: `SECRET_SALT` fehlt oder der Beispielwert ist, oder kein Cron lä 1. Das Paket `feedback-.zip` nach `include/plugins/` entpacken. Danach gibt es `include/plugins/feedback/plugin.php`. 2. Rechte wie bei den anderen Plugins: lesbar für den Webserver, nicht schreibbar. -Prüfung: `include/plugins/feedback/` enthält `plugin.php`, `config.php`, `class.FeedbackPlugin.php`, `LICENSE` und `src/` mit 12 Dateien. +Prüfung: `include/plugins/feedback/` enthält `plugin.php`, `config.php`, `class.FeedbackPlugin.php`, `LICENSE` und `src/` mit 13 Dateien. --- @@ -51,6 +51,7 @@ Prüfung: `include/plugins/feedback/` enthält `plugin.php`, `config.php`, `clas - „Closing statuses“: Schließen mit einem dieser Status fragt nie, z. B. „Dublette“ oder „Spam“. Vorausgewählt sind geschlossene Status mit „Duplicate“, „Spam“, „Rejected“ oder „Hinfällig“ im Namen. - „Help topics“ und „Sender domains“ nach Bedarf, z. B. Domains von Partnern, die nicht gefragt werden sollen. - „Note at the ticket when asked“: kurz (Standard), mit der gesendeten Mail oder keine. Mit der Mail sieht jeder Agent, der das Ticket öffnet, die Bewertungslinks des Kunden. + - „Who decides“: „Agents can switch the question off“ (Häkchen beim Schließen, Menü „Weitere“) und „Closing without an agent form“ für API, Cron und Massen-Statuswechsel in der Ticketliste. Schließen Werkzeuge wie ein MCP-Server Tickets über die API, macht „only when requested“ jedes solche Schließen zu einer ausdrücklichen Entscheidung (Feld `feedback` von API Endpoints 2.9.0). - Texte leer lassen für den eingebauten Text (Du-Form). „Language of the built-in texts“ auf „Deutsch (du)“, wenn das Helpdesk nicht auf Deutsch steht. 5. Speichern. 6. **Instanz noch einmal öffnen und die Häkchen prüfen.** osTicket 1.18 speichert beim Anlegen einer Instanz die Standardwerte von Häkchen nicht: Nach dem ersten Speichern können „Comment field after the click“, „Own domains“ und „Footer with AI notice“ aus sein, obwohl sie standardmäßig an sind. Gewünschte Häkchen wieder setzen, Speichern, erneut öffnen und prüfen, dass sie bleiben. @@ -96,6 +97,8 @@ Abbruch, wenn: bei Schritt 3 keine Mail kommt. Dann zuerst prüfen: Steht am Tic | Kommentar mit HTML | `` als Kommentar | Notiz zeigt ‹script›…‹/script› als Text, nichts wird ausgeführt | | Viele Aufrufe | über 60 Aufrufe in 10 Minuten von einer IP | „Zu viele Anfragen“ (HTTP 429) | | Zweites Schließen | Ticket wieder öffnen, erneut schließen | keine zweite Frage | +| Abschalten ohne Token | `curl -X POST …/scp/ajax.php/feedback/ticket//decline` mit gültigem Agenten-Cookie, ohne CSRF-Header | HTTP 400, nichts ändert sich | +| Fremdes Ticket abschalten | derselbe POST als Agent ohne Zugriff auf das Ticket | HTTP 403, nichts ändert sich | --- diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 68b34af..f334758 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -37,7 +37,7 @@ Stop if: `SECRET_SALT` is missing or the sample value, or no cron runs. 1. Unzip `feedback-.zip` into `include/plugins/`. Afterwards `include/plugins/feedback/plugin.php` exists. 2. Permissions as for the other plugins: readable by the web server, not writable. -Check: `include/plugins/feedback/` holds `plugin.php`, `config.php`, `class.FeedbackPlugin.php`, `LICENSE` and `src/` with 12 files. +Check: `include/plugins/feedback/` holds `plugin.php`, `config.php`, `class.FeedbackPlugin.php`, `LICENSE` and `src/` with 13 files. --- @@ -51,6 +51,7 @@ Check: `include/plugins/feedback/` holds `plugin.php`, `config.php`, `class.Feed - "Closing statuses": closing with one of these never asks, e.g. "Duplicate" or "Spam". Preselected are closed statuses with "Duplicate", "Spam", "Rejected" or "Hinfällig" in their name. - "Help topics" and "Sender domains" as needed, e.g. partner domains that shouldn't be asked. - "Note at the ticket when asked": short (default), with the mail as sent, or none. With the mail, every agent who opens the ticket sees the customer's rating links. + - "Who decides": "Agents can switch the question off" (tick when closing, More menu) and "Closing without an agent form" for API, cron and mass changes in the ticket list. If tools such as an MCP server close tickets through the API, "only when requested" makes every such close an explicit decision (`feedback` field of API Endpoints 2.9.0). - Leave the texts empty for the built-in text. "Language of the built-in texts" decides between German (informal "du") and English; "Help desk language" follows the system language. 5. Save. 6. **Open the instance again and check the checkboxes.** osTicket 1.18 doesn't store checkbox defaults when an instance is created: after the first save "Comment field after the click", "Own domains" and "Footer with AI notice" can be off although they are on by default. Tick them again where wanted, Save, open once more and check they stay ticked. @@ -96,6 +97,8 @@ Stop if: no mail arrives in step 3. Check first: is there a note "Satisfaction q | HTML in the comment | `` as comment | the note shows ‹script›…‹/script› as text, nothing runs | | Many requests | more than 60 requests in 10 minutes from one IP | "Too many requests" (HTTP 429) | | Second close | reopen the ticket, close it again | no second question | +| Switch off without token | `curl -X POST …/scp/ajax.php/feedback/ticket//decline` with a valid agent session cookie but no CSRF header | HTTP 400, nothing changes | +| Switch off a foreign ticket | the same POST as an agent without access to the ticket | HTTP 403, nothing changes | --- diff --git a/src/FeedbackActions.php b/src/FeedbackActions.php index 0feecfb..83a8814 100644 --- a/src/FeedbackActions.php +++ b/src/FeedbackActions.php @@ -152,13 +152,34 @@ private static function mailAgent(Ticket $ticket, array $s, array $t, string $la } /** After the question went out: a note, unless switched off. Mail mode only. */ - public static function sentNote(Ticket $ticket, array $s, string $to, int $expires, string $subject, string $body): void + public static function sentNote(Ticket $ticket, array $s, string $to, int $expires, string $subject, string $body, + string $source = ''): void { if ($s['note_sent'] === FeedbackSettings::NOTE_OFF) { return; } $t = self::strings(); - self::note($ticket, $t['note_sent_title'], FeedbackMail::sentNote($s, $t, $to, $expires, $subject, $body)); + self::note($ticket, $t['note_sent_title'], FeedbackMail::sentNote($s, $t, $to, $expires, $subject, $body, $source)); + } + + /** $how: "close" (tick removed at closing, or the API said no), "menu" (switched off in advance). */ + public static function declinedNote(Ticket $ticket, string $how, int $staffId): void + { + $t = self::strings(); + $key = $how === 'menu' ? 'note_declined_menu' : 'note_declined_close'; + self::note($ticket, $t['note_sent_title'], FeedbackMail::e(sprintf($t[$key], self::who($staffId, $t)))); + } + + public static function allowedNote(Ticket $ticket, int $staffId): void + { + $t = self::strings(); + self::note($ticket, $t['note_sent_title'], FeedbackMail::e(sprintf($t['note_allowed'], self::who($staffId, $t)))); + } + + private static function who(int $staffId, array $t): string + { + $staff = $staffId > 0 ? Staff::lookup($staffId) : null; + return $staff instanceof Staff ? (string) $staff->getName() : $t['by_system']; } /** A question that couldn't be sent: always a note, so nobody believes the customer was asked. */ diff --git a/src/FeedbackI18n.php b/src/FeedbackI18n.php index 6c21816..a89ef38 100644 --- a/src/FeedbackI18n.php +++ b/src/FeedbackI18n.php @@ -71,6 +71,18 @@ public static function strings(string $lang): array 'scale_stars' => 'Sterne', 'scale_nps' => 'NPS', 'date_format' => 'd.m.Y', + 'note_source' => 'Ausgelöst durch: %s.', + 'source_web' => 'Schließen im Agentenbereich', + 'source_mass' => 'Statuswechsel in der Ticketliste', + 'source_api' => 'API oder Cron', + 'note_declined_close' => 'Zufriedenheitsfrage beim Schließen abgewählt (%s). Zu diesem Ticket wird nicht mehr gefragt.', + 'note_declined_menu' => 'Zufriedenheitsfrage für dieses Ticket abgeschaltet (%s).', + 'note_allowed' => 'Zufriedenheitsfrage für dieses Ticket wieder erlaubt (%s).', + 'by_system' => 'API oder Cron', + 'ui_ask' => 'Zufriedenheitsfrage senden', + 'ui_menu_off' => 'Keine Zufriedenheitsfrage', + 'ui_menu_on' => 'Zufriedenheitsfrage wieder erlauben', + 'ui_off_hint' => 'Für dieses Ticket ist die Zufriedenheitsfrage abgeschaltet.', 'agent_subject' => 'Schlechte Bewertung: %{ticket.subject} [%{ticket.number}]', 'agent_lead' => 'Der Kunde hat das abgeschlossene Ticket schlecht bewertet. Das Ticket bleibt geschlossen.', 'agent_open' => 'Ticket öffnen', @@ -123,6 +135,18 @@ public static function strings(string $lang): array 'scale_stars' => 'Stars', 'scale_nps' => 'NPS', 'date_format' => 'Y-m-d', + 'note_source' => 'Triggered by: %s.', + 'source_web' => 'closing in the agent panel', + 'source_mass' => 'status change in the ticket list', + 'source_api' => 'API or cron', + 'note_declined_close' => 'Satisfaction question switched off when closing (%s). This ticket won\'t be asked.', + 'note_declined_menu' => 'Satisfaction question switched off for this ticket (%s).', + 'note_allowed' => 'Satisfaction question allowed again for this ticket (%s).', + 'by_system' => 'API or cron', + 'ui_ask' => 'Send satisfaction question', + 'ui_menu_off' => 'No satisfaction question', + 'ui_menu_on' => 'Allow satisfaction question again', + 'ui_off_hint' => 'The satisfaction question is switched off for this ticket.', 'agent_subject' => 'Bad rating: %{ticket.subject} [%{ticket.number}]', 'agent_lead' => 'The customer gave the closed ticket a bad rating. The ticket stays closed.', 'agent_open' => 'Open ticket', diff --git a/src/FeedbackMail.php b/src/FeedbackMail.php index 5e9345e..be36564 100644 --- a/src/FeedbackMail.php +++ b/src/FeedbackMail.php @@ -143,10 +143,14 @@ public static function paragraphs(string $text): string * @param array $s FeedbackSettings::get() * @param array $t FeedbackI18n::strings() */ - public static function sentNote(array $s, array $t, string $to, int $expires, string $subject, string $body): string + public static function sentNote(array $s, array $t, string $to, int $expires, string $subject, string $body, + string $source = ''): string { $scale = $t['scale_' . $s['scale']] ?? $s['scale']; $html = self::e(sprintf($t['note_sent'], $to, $scale, date($t['date_format'], $expires))); + if (isset($t['source_' . $source])) { + $html .= ' ' . self::e(sprintf($t['note_source'], $t['source_' . $source])); + } if ($s['note_sent'] === FeedbackSettings::NOTE_FULL) { $html .= '

' . self::e(sprintf($t['note_mail'], $subject)) . '
' . self::noBeyondBmp($body); } diff --git a/src/FeedbackRules.php b/src/FeedbackRules.php index 033c056..d78d7b4 100644 --- a/src/FeedbackRules.php +++ b/src/FeedbackRules.php @@ -60,6 +60,39 @@ public static function skipReason(array $s, array $facts): string return ''; } + /** + * Who decides about a close that the rules would ask for. + * + * $source: "web" (agent form on one ticket), "mass" (status change of + * selected tickets in the list) or "api" (no agent session: API, cron). + * $ask: the request's feedback_ask, "1", "0" or null when absent. + * + * @return string "ask", "decline" (never for this ticket, noted) or "skip" (not now, no trace) + */ + public static function decide(array $s, string $source, ?string $ask): string + { + if ($source === 'web') { + return $ask === '0' && $s['agent_decline'] ? 'decline' : 'ask'; + } + if ($ask === '0') { + return 'decline'; + } + switch ($s['no_session']) { + case FeedbackSettings::SESSION_NEVER: + return 'skip'; + case FeedbackSettings::SESSION_REQUESTED: + return $ask === '1' ? 'ask' : 'skip'; + default: + return 'ask'; + } + } + + /** "1", "0" or null from a raw request value. */ + public static function askValue($raw): ?string + { + return $raw === '1' || $raw === '0' ? $raw : null; + } + public static function domain(string $email): string { $at = strrpos($email, '@'); diff --git a/src/FeedbackSettings.php b/src/FeedbackSettings.php index 8575f44..bd4ccc3 100644 --- a/src/FeedbackSettings.php +++ b/src/FeedbackSettings.php @@ -15,6 +15,9 @@ final class FeedbackSettings public const NOTE_OFF = 'off'; public const NOTE_SHORT = 'short'; public const NOTE_FULL = 'full'; + public const SESSION_ASK = 'ask'; + public const SESSION_REQUESTED = 'requested'; + public const SESSION_NEVER = 'never'; /** @var array|null */ private static $current = null; @@ -43,6 +46,7 @@ public static function normalise(array $raw): array $lang = (string) ($raw['language'] ?? ''); $accent = (string) ($raw['accent'] ?? ''); $note = (string) ($raw['note_sent'] ?? ''); + $session = (string) ($raw['no_session'] ?? ''); return array( 'enabled' => self::flag($raw['enabled'] ?? false), 'mode' => in_array($mode, array(self::MODE_MAIL, self::MODE_LINE), true) ? $mode : self::MODE_MAIL, @@ -59,6 +63,9 @@ public static function normalise(array $raw): array 'comment_on' => self::flag($raw['comment_on'] ?? true), 'note_sent' => in_array($note, array(self::NOTE_OFF, self::NOTE_SHORT, self::NOTE_FULL), true) ? $note : self::NOTE_SHORT, + 'agent_decline' => self::flag($raw['agent_decline'] ?? true), + 'no_session' => in_array($session, array(self::SESSION_ASK, self::SESSION_REQUESTED, self::SESSION_NEVER), true) + ? $session : self::SESSION_ASK, 'language' => in_array($lang, array('de', 'en'), true) ? $lang : 'auto', 'accent' => preg_match('/^#[0-9a-fA-F]{6}$/D', $accent) === 1 ? strtolower($accent) : '#330066', 'subject' => self::text($raw['subject'] ?? '', 200), diff --git a/src/FeedbackStore.php b/src/FeedbackStore.php index e82531a..539ab63 100644 --- a/src/FeedbackStore.php +++ b/src/FeedbackStore.php @@ -101,6 +101,30 @@ public static function asked(int $ticketId): bool return (bool) db_result(db_query(sprintf("SELECT COUNT(*) FROM `%s` WHERE ticket_id=%d", self::table(), $ticketId))); } + /** The ticket's row state ("pending", "sent", "declined", …) or "" when it has none. */ + public static function stateOf(int $ticketId): string + { + self::ensure(); + return (string) db_result(db_query(sprintf("SELECT state FROM `%s` WHERE ticket_id=%d", self::table(), $ticketId))); + } + + /** Never ask this ticket. False when it already has a row (asked, queued or declined). */ + public static function decline(int $ticketId, string $scale, int $staffId): bool + { + self::ensure(); + db_query(sprintf("INSERT IGNORE INTO `%s` (ticket_id, mode, scale, state, closer_id, created) VALUES (%d, 'mail', %s, 'declined', %d, %d)", + self::table(), $ticketId, db_input($scale), $staffId, time())); + return db_affected_rows() === 1; + } + + /** Undoes decline(). False when the ticket wasn't declined (asking can't be undone). */ + public static function allow(int $ticketId): bool + { + self::ensure(); + db_query(sprintf("DELETE FROM `%s` WHERE ticket_id=%d AND state='declined'", self::table(), $ticketId)); + return db_affected_rows() === 1; + } + /** @return int[] IDs of queued mail requests */ public static function pending(int $limit = 50): array { diff --git a/src/FeedbackTrigger.php b/src/FeedbackTrigger.php index 2c66855..00e793b 100644 --- a/src/FeedbackTrigger.php +++ b/src/FeedbackTrigger.php @@ -34,6 +34,49 @@ final class FeedbackTrigger /** @var bool */ private static $flushing = false; + /** @var array where this request's closes came from, by ticket ID (for the note) */ + private static $sources = array(); + + /** + * "web" for an agent form on one ticket, "mass" for the status change of + * selected tickets in the list, "api" without an agent session (API, cron). + */ + public static function source(int $closer): string + { + if ($closer < 1) { + return 'api'; + } + $info = (string) ($_SERVER['PATH_INFO'] ?? ''); + if (preg_match('#^/tickets/status/#', $info) === 1 || (($_POST['a'] ?? '') === 'mass_process')) { + return 'mass'; + } + return 'web'; + } + + public static function sourceOf(int $ticketId): string + { + return self::$sources[$ticketId] ?? ''; + } + + /** + * Never ask this ticket, with a note. Only when the rules would ask it + * now; a ticket that wouldn't be asked anyway gets no row and no note. + * $how: "close" (tick removed or API said no) or "menu". + */ + public static function decline(Ticket $ticket, array $s, int $staffId, string $how): bool + { + $facts = self::facts($ticket); + $facts['closed'] = true; + if ($how === 'close' && FeedbackRules::skipReason($s, $facts) !== '') { + return false; + } + if (!FeedbackStore::decline((int) $ticket->getId(), $s['scale'], $staffId)) { + return false; + } + FeedbackActions::declinedNote($ticket, $how, $staffId); + return true; + } + public static function onEntry($entry): void { try { @@ -77,6 +120,16 @@ public static function onUpdated($model, $data = null): void if ($closer && self::isAi($closer)) { return; } + // Who decides (0.2): the agent's tick, the API's feedback flag or the setting. + $source = self::source($closer); + $decision = FeedbackRules::decide($s, $source, FeedbackRules::askValue($_POST['feedback_ask'] ?? null)); + if ($decision !== 'ask') { + if ($decision === 'decline') { + self::decline($model, $s, $closer, 'close'); + } + return; + } + self::$sources[(int) $model->getId()] = $source; if ($s['mode'] === FeedbackSettings::MODE_LINE) { self::line($model, $s, $closer); return; @@ -206,7 +259,8 @@ public static function send(int $id): void FeedbackActions::failedNote($ticket, $to); return; } - FeedbackActions::sentNote($ticket, $s, $to, $expires, $subject, (string) $msg['body']); + FeedbackActions::sentNote($ticket, $s, $to, $expires, $subject, (string) $msg['body'], + self::sourceOf((int) $ticket->getId())); } catch (\Throwable $e) { FeedbackStore::failed($id); self::log('send', $e); diff --git a/src/FeedbackUi.php b/src/FeedbackUi.php new file mode 100644 index 0000000..19641c1 --- /dev/null +++ b/src/FeedbackUi.php @@ -0,0 +1,183 @@ +/decline|allow with the + * agent panel's CSRF header (scp.js adds X-CSRFToken to every jQuery call). + * + * The tick is a convenience, not a security boundary: feedback_ask can only + * suppress or confirm a question the rules allow, never widen them. + */ +final class FeedbackUi +{ + /** Starts the buffer on the agent panel's ticket view only. */ + public static function maybeStart(array $s): void + { + if (!$s['enabled'] || !$s['agent_decline']) { + return; + } + $script = str_replace('\\', '/', (string) ($_SERVER['SCRIPT_NAME'] ?? '')); + if (preg_match('#/scp/tickets\.php$#', $script) !== 1 || !isset($_GET['id'])) { + return; + } + ob_start(array(__CLASS__, 'inject')); + } + + /** Output-buffer callback: adds the script to a ticket view (full page or PJAX fragment). */ + public static function inject($buffer) + { + try { + if (!is_string($buffer) || !defined('OSTSCPINC') || strpos($buffer, 'id="reply"') === false + && strpos($buffer, 'action-dropdown-more') === false) { + return $buffer; + } + $staff = $GLOBALS['thisstaff'] ?? null; + $ticket = Ticket::lookup((int) ($_GET['id'] ?? 0)); + if (!$staff instanceof Staff || !$ticket || !$ticket->checkStaffPerm($staff)) { + return $buffer; + } + $config = self::config($ticket, FeedbackSettings::get()); + if ($config === null) { + return $buffer; + } + $tag = ''; + $pos = strripos($buffer, ''); + return $pos === false ? $buffer . $tag : substr_replace($buffer, $tag, $pos, 0); + } catch (\Throwable $e) { + FeedbackTrigger::log('ui', $e); + return $buffer; + } + } + + /** @return array|null null when the ticket would never be asked */ + public static function config(Ticket $ticket, array $s): ?array + { + $facts = FeedbackTrigger::facts($ticket); + // The closing form may carry the first reply; the status is chosen there. + $facts['closed'] = true; + $facts['human_replies'] = max(1, (int) $facts['human_replies']); + $facts['status'] = 0; + if (FeedbackRules::skipReason($s, $facts) !== '') { + return null; + } + $state = FeedbackStore::stateOf((int) $ticket->getId()); + $t = FeedbackI18n::strings(FeedbackPlugin::language()); + return array( + 'tid' => (int) $ticket->getId(), + 'state' => $state === '' ? 'open' : ($state === 'declined' ? 'declined' : 'asked'), + 'closed' => self::askingStatuses($s), + 'url' => 'ajax.php/feedback/ticket/' . (int) $ticket->getId() . '/', + 't' => array('ask' => $t['ui_ask'], 'off' => $t['ui_menu_off'], 'on' => $t['ui_menu_on']), + ); + } + + /** IDs of closed statuses that would ask. @return int[] */ + private static function askingStatuses(array $s): array + { + $out = array(); + $res = db_query(sprintf("SELECT id FROM %s WHERE state='closed'", TICKET_STATUS_TABLE)); + while ($res && ($r = db_fetch_row($res))) { + if (!in_array((int) $r[0], $s['exclude_statuses'], true)) { + $out[] = (int) $r[0]; + } + } + return $out; + } + + /** POST scp/ajax.php/feedback/ticket//decline|allow */ + public static function toggle(int $id, string $what): string + { + global $thisstaff, $ost; + + $s = FeedbackSettings::get(); + if (!$thisstaff instanceof Staff) { + Http::response(403, 'Access denied'); + } + if (!$ost || !$ost->checkCSRFToken()) { + Http::response(400, 'Invalid CSRF token'); + } + $ticket = Ticket::lookup($id); + if (!$s['enabled'] || !$s['agent_decline'] || !$ticket || !$ticket->checkStaffPerm($thisstaff)) { + Http::response(403, 'Access denied'); + } + $staffId = (int) $thisstaff->getId(); + if ($what === 'decline') { + FeedbackTrigger::decline($ticket, $s, $staffId, 'menu'); + } elseif (FeedbackStore::allow($id)) { + FeedbackActions::allowedNote($ticket, $staffId); + } + $state = FeedbackStore::stateOf($id); + header('Content-Type: application/json'); + return (string) json_encode(array('state' => $state === '' ? 'open' : $state)); + } + + /** The script; called with the config object. Plain ES5 for the agent panel's jQuery. */ + private static function js(): string + { + return <<<'JS' +(function (c) { + var $ = window.jQuery; + if (!$ || !c) { return; } + function esc(s) { return $('
').text(s).html(); } + function asking(v) { return c.closed.indexOf(parseInt(v, 10)) >= 0; } + // PJAX swaps tickets without a reload: act only on this ticket's forms. + function mine(form) { return String(form.find('input[name=id]').val()) === String(c.tid); } + function box(form, selector) { + if (c.state !== 'open' || form.find('.spf-ask').length || !mine(form)) { return; } + var field = form.find(selector).first(); + if (!field.length) { return; } + var w = $('
' + + '' + + '
'); + field.after(w); + var update = function () { w.toggle(asking(field.val())); }; + field.on('change', update); + update(); + } + function menu() { + var ul = $('#action-dropdown-more ul'); + if (!ul.length || ul.find('.spf-menu').length || c.state === 'asked' + || ul.html().indexOf('tickets/' + c.tid + '/') < 0) { return; } + var off = c.state === 'declined'; + var li = $('
  • ' + + esc(off ? c.t.on : c.t.off) + '
  • '); + li.find('a').on('click', function (e) { + e.preventDefault(); + $.ajax({ type: 'POST', url: c.url + (off ? 'allow' : 'decline'), dataType: 'json' }) + .always(function () { window.location.reload(); }); + }); + ul.append(li); + } + function scan() { + $('form#reply').each(function () { box($(this), 'select[name=reply_status_id]'); }); + $('form#note').each(function () { box($(this), 'select[name=note_status_id]'); }); + $('form#status').each(function () { + var form = $(this); + if ((form.attr('action') || '').indexOf('tickets/' + c.tid + '/status') < 0) { return; } + // The status dialog has no id field; its action names the ticket. + if (!form.find('input[name=id]').length) { form.append($('').val(c.tid)); } + box(form, '[name=status_id]'); + }); + menu(); + } + var timer = null; + if (window.MutationObserver) { + new MutationObserver(function () { + clearTimeout(timer); + timer = setTimeout(scan, 50); + }).observe(document.body, { childList: true, subtree: true }); + } + $(scan); +}) +JS; + } +} diff --git a/tests/e2e/9-decide.spec.js b/tests/e2e/9-decide.spec.js new file mode 100644 index 0000000..c7d13a5 --- /dev/null +++ b/tests/e2e/9-decide.spec.js @@ -0,0 +1,161 @@ +// @ts-check +// 0.2: who decides – the agent's tick, the ticket menu, the API flag, mass changes. +const { test, expect } = require('@playwright/test'); +const { seed, T, sql, php, q, newTicket, reply, setStatus, row, notes, setting, clearMail, feedbackMails, resetSettings, + staffLogin, watchErrors } = require('./support'); + +test.beforeEach(async ({ request }) => { + resetSettings(); + await clearMail(request); +}); + +/** Status change with a request context: agent (seed key or null), $_POST['feedback_ask'], PATH_INFO. */ +function closeWith(id, who, ask, pathInfo = '') { + const as = who ? `global $thisstaff; $thisstaff = Staff::lookup(${seed.agents[who]});` : ''; + const post = ask === null ? '' : `$_POST['feedback_ask'] = ${q(ask)};`; + const path = pathInfo ? `$_SERVER['PATH_INFO'] = ${q(pathInfo)};` : ''; + return php(`${as} ${post} ${path} $t = Ticket::lookup(${id}); $e = array();` + + ` echo $t->setStatus(${seed.status.closed}, '', $e) ? 'ok' : json_encode($e);`); +} + +const feedbackNotes = (id) => notes(id).filter((n) => n.title === 'Zufriedenheitsfrage'); + +test('web: tick removed → no mail, declined for good, with a note', async ({ request }) => { + const id = newTicket('0.2 web decline'); + reply(id, 'hanna', 'Erledigt.'); + expect(closeWith(id, 'hanna', '0')).toBe('ok'); + expect(await feedbackMails(request, id)).toHaveLength(0); + expect(row(id).state).toBe('declined'); + expect(feedbackNotes(id).at(-1).body).toContain('beim Schließen abgewählt'); + + setStatus(id, 'hanna', seed.status.open); + expect(closeWith(id, 'hanna', null)).toBe('ok'); + expect(await feedbackMails(request, id)).toHaveLength(0); +}); + +test('web: tick on → asks, the note names the source', async ({ request }) => { + const id = newTicket('0.2 web ask'); + reply(id, 'hanna', 'Erledigt.'); + expect(closeWith(id, 'hanna', '1')).toBe('ok'); + expect(await feedbackMails(request, id)).toHaveLength(1); + await expect.poll(() => feedbackNotes(id).length).toBe(1); + expect(feedbackNotes(id)[0].body).toContain('Ausgelöst durch: Schließen im Agentenbereich'); +}); + +test('API with "requested": nothing without the flag, asks with 1, declines with 0', async ({ request }) => { + setting('no_session', 'requested'); + const a = newTicket('0.2 api none'); + reply(a, 'hanna', 'Erledigt.'); + expect(closeWith(a, null, null)).toBe('ok'); + expect(await feedbackMails(request, a)).toHaveLength(0); + expect(row(a)).toBeNull(); + + const b = newTicket('0.2 api ask'); + reply(b, 'hanna', 'Erledigt.'); + expect(closeWith(b, null, '1')).toBe('ok'); + expect(await feedbackMails(request, b)).toHaveLength(1); + await expect.poll(() => feedbackNotes(b).length).toBe(1); + expect(feedbackNotes(b)[0].body).toContain('API oder Cron'); + + const c = newTicket('0.2 api decline'); + reply(c, 'hanna', 'Erledigt.'); + expect(closeWith(c, null, '0')).toBe('ok'); + expect(row(c).state).toBe('declined'); + expect(feedbackNotes(c).at(-1).body).toContain('(API oder Cron)'); +}); + +test('mass status change with "requested": no question', async ({ request }) => { + setting('no_session', 'requested'); + const id = newTicket('0.2 mass'); + reply(id, 'hanna', 'Erledigt.'); + expect(closeWith(id, 'hanna', null, '/tickets/status/closed')).toBe('ok'); + expect(await feedbackMails(request, id)).toHaveLength(0); + expect(row(id)).toBeNull(); +}); + +test('a ticket that would not be asked gets no decline row', async () => { + const id = newTicket('0.2 alert decline', { dept: seed.depts.alerts }); + reply(id, 'admin', 'Gesehen.'); + expect(closeWith(id, 'admin', '0')).toBe('ok'); + expect(row(id)).toBeNull(); + expect(feedbackNotes(id)).toHaveLength(0); +}); + +test('UI: the tick appears for a closing status, the menu switches the question off and on', async ({ page, request }) => { + const errors = watchErrors(page); + const id = newTicket('0.2 ui'); + reply(id, 'admin', 'Antwort.'); + await staffLogin(page, 'admin'); + await page.goto(`/scp/tickets.php?id=${id}`); + + // Reply form: hidden until a closed status is chosen. + await page.locator('a#post-reply, a[href="#reply"]').first().click().catch(() => {}); + const tick = page.locator('form#reply .spf-ask'); + await expect(tick).toHaveCount(1); + await page.selectOption('form#reply select[name=reply_status_id]', String(seed.status.closed)); + await expect(tick).toBeVisible(); + await expect(tick.locator('input[type=checkbox]')).toBeChecked(); + await page.selectOption('form#reply select[name=reply_status_id]', String(seed.status.open)); + await expect(tick).toBeHidden(); + + // More menu → "No satisfaction question" (real POST with the panel's CSRF header). + const off = page.locator('#action-dropdown-more li.spf-menu a'); + await expect(off).toHaveCount(1); + await expect(off).toContainText('Keine Zufriedenheitsfrage'); + await Promise.all([ + page.waitForEvent('load'), + page.evaluate(() => { document.querySelector('#action-dropdown-more li.spf-menu a').click(); }), + ]); + await expect.poll(() => (row(id) || {}).state).toBe('declined'); + expect(notes(id).some((n) => n.body.includes('für dieses Ticket abgeschaltet'))).toBe(true); + + // After the reload: no tick, the menu offers to allow again. + await page.goto(`/scp/tickets.php?id=${id}`); + await expect(page.locator('form#reply .spf-ask')).toHaveCount(0); + const on = page.locator('#action-dropdown-more li.spf-menu a'); + await expect(on).toContainText('wieder erlauben'); + await Promise.all([ + page.waitForEvent('load'), + page.evaluate(() => { document.querySelector('#action-dropdown-more li.spf-menu a').click(); }), + ]); + await expect.poll(() => row(id)).toBeNull(); + expect(notes(id).some((n) => n.body.includes('wieder erlaubt'))).toBe(true); + expect(errors).toEqual([]); +}); + +test('UI: the toggle endpoint refuses a request without the CSRF token', async ({ page }) => { + const id = newTicket('0.2 csrf'); + reply(id, 'admin', 'Antwort.'); + await staffLogin(page, 'admin'); + const res = await page.request.post(`/scp/ajax.php/feedback/ticket/${id}/decline`); + expect(res.status()).toBeGreaterThanOrEqual(400); + expect(row(id)).toBeNull(); +}); + +test('UI: status dialog carries the tick; removing it closes without a question', async ({ page, request }) => { + const errors = watchErrors(page); + const id = newTicket('0.2 ui dialog'); + reply(id, 'admin', 'Antwort.'); + await clearMail(request); + await staffLogin(page, 'admin'); + await page.goto(`/scp/tickets.php?id=${id}`); + await page.evaluate((href) => { document.querySelector(`a[href="${href}"]`).click(); }, + `#tickets/${id}/status/close/${seed.status.closed}`); + const tick = page.locator('form#status .spf-ask'); + await expect(tick).toBeVisible(); + await tick.locator('input[type=checkbox]').uncheck(); + await page.locator('form#status [type=submit]').first().click(); + await expect.poll(() => (row(id) || {}).state).toBe('declined'); + expect(await feedbackMails(request, id)).toHaveLength(0); + expect(errors).toEqual([]); +}); + +test('UI: no tick and no menu entry where the rules never ask (Alerts)', async ({ page }) => { + const id = newTicket('0.2 ui alert', { dept: seed.depts.alerts }); + reply(id, 'admin', 'Gesehen.'); + await staffLogin(page, 'admin'); + await page.goto(`/scp/tickets.php?id=${id}`); + await expect(page.locator('#reply')).toHaveCount(1); + await expect(page.locator('.spf-ask')).toHaveCount(0); + await expect(page.locator('#action-dropdown-more li.spf-menu')).toHaveCount(0); +}); diff --git a/tests/unit.php b/tests/unit.php index cc8dd35..b163f15 100644 --- a/tests/unit.php +++ b/tests/unit.php @@ -57,7 +57,8 @@ function check(string $name, bool $ok, string $detail = ''): void && $builtIn['bad_stars'] === 2 && $builtIn['bad_nps'] === 6); check('config: off until switched on', $builtIn['enabled'] === false); foreach (array('enabled', 'mode', 'scale', 'on_bad', 'bad_stars', 'bad_nps', 'valid_days', 'exclude_depts', 'exclude_topics', - 'exclude_statuses', 'exclude_domains', 'exclude_own', 'comment_on', 'note_sent', 'language', 'subject', 'text', + 'exclude_statuses', 'exclude_domains', 'exclude_own', 'comment_on', 'note_sent', 'agent_decline', 'no_session', + 'language', 'subject', 'text', 'question', 'line', 'foot_on', 'foot', 'accent') as $k) { check("config: field $k exists", isset($opts[$k])); } @@ -210,6 +211,32 @@ function check(string $name, bool $ok, string $detail = ''): void check('sent note: recipient escaped', strpos(FeedbackMail::sentNote($s, $de, 'x', $exp, '', ''), '') === false); check('beyond BMP: entities and literals removed, the rest kept', FeedbackMail::noBeyondBmp('a 👍 b 👎 c 👍 d ★ &') === 'a b c d ★ &', FeedbackMail::noBeyondBmp('a 👍 b 👎 c 👍 d ★ &')); +check('sent note: names the source when known', strpos(FeedbackMail::sentNote($s, $de, 'k@x.example', $exp, '', '', 'api'), + 'Ausgelöst durch: API oder Cron.') !== false && strpos($short, 'Ausgelöst') === false); + +// ----------------------------------------------------------- who decides (0.2) + +$d = FeedbackSettings::normalise(array()); +check('decide: defaults keep 0.1 behaviour', $d['agent_decline'] === true && $d['no_session'] === 'ask' + && FeedbackRules::decide($d, 'web', null) === 'ask' && FeedbackRules::decide($d, 'api', null) === 'ask' + && FeedbackRules::decide($d, 'mass', null) === 'ask'); +check('decide: web tick removed declines', FeedbackRules::decide($d, 'web', '0') === 'decline'); +check('decide: web tick on asks', FeedbackRules::decide($d, 'web', '1') === 'ask'); +$noDecline = FeedbackSettings::normalise(array('agent_decline' => '0')); +check('decide: without agent_decline the tick is ignored', FeedbackRules::decide($noDecline, 'web', '0') === 'ask'); +$req = FeedbackSettings::normalise(array('no_session' => 'requested')); +check('decide: "requested" skips API and mass without a flag', FeedbackRules::decide($req, 'api', null) === 'skip' + && FeedbackRules::decide($req, 'mass', null) === 'skip'); +check('decide: "requested" asks with feedback_ask=1, declines with 0', FeedbackRules::decide($req, 'api', '1') === 'ask' + && FeedbackRules::decide($req, 'api', '0') === 'decline'); +check('decide: "requested" does not touch web closes', FeedbackRules::decide($req, 'web', null) === 'ask'); +$never = FeedbackSettings::normalise(array('no_session' => 'never')); +check('decide: "never" skips even when asked for', FeedbackRules::decide($never, 'api', '1') === 'skip' + && FeedbackRules::decide($never, 'api', '0') === 'decline'); +check('decide: unknown no_session falls back to ask', FeedbackSettings::normalise(array('no_session' => 'x'))['no_session'] === 'ask'); +check('decide: only "1" and "0" count as a flag', FeedbackRules::askValue('1') === '1' && FeedbackRules::askValue('0') === '0' + && FeedbackRules::askValue('yes') === null && FeedbackRules::askValue(array('1')) === null && FeedbackRules::askValue(null) === null); + check('i18n: no 4-byte characters in the sent notes', preg_match('/[\x{10000}-\x{10FFFF}]/u', $de['note_sent_title'] . $de['note_sent'] . $de['note_mail'] . $de['note_failed']) === 0); From 9e20d2120705152eb712d41b9850e854b0843b9d Mon Sep 17 00:00:00 2001 From: studio-prisma <282898618+studio-prisma@users.noreply.github.com> Date: Sun, 8 Nov 2026 15:49:40 +0100 Subject: [PATCH 2/2] chore(release): v0.2.0 --- CHANGELOG.md | 13 ++++++++++++- plugin.php | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0521a01..b495a79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.2.0] - 2026-11-08 + +### Added + +- **Tick "Send satisfaction question"** in the agent panel's reply form, note form and status dialog, shown when a closing status is chosen and the ticket would be asked. Removing it means: never ask this ticket (row state `declined`, internal note). +- **"No satisfaction question" / "Allow satisfaction question again"** in the ticket's More menu, before closing. POST to `scp/ajax.php/feedback/ticket//decline|allow` with osTicket's CSRF token and the agent's ticket permission. +- **Setting "Closing without an agent form"** for API, cron and mass status changes in the ticket list: ask (default, as in 0.1), only when the request asks for it, or never. Requests pass `feedback_ask=1|0`; API Endpoints 2.9.0 forwards its `feedback` field. +- **Setting "Agents can switch the question off"** (default on). +- The note after a sent question names what triggered it (agent panel, ticket list, API or cron). + ## [0.1.1] - 2026-11-08 ### Added @@ -35,6 +45,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Retention: rows are deleted after 24 months; the IP is stored only as a keyed hash. - Mail in the style of a brand line over an accent rule, buttons as table cells, a grey footer with an AI notice; texts editable, German (informal) and English built in. -[Unreleased]: https://github.com/studio-prisma/osticket-plugin-feedback/compare/v0.1.1...HEAD +[Unreleased]: https://github.com/studio-prisma/osticket-plugin-feedback/compare/v0.2.0...HEAD +[0.2.0]: https://github.com/studio-prisma/osticket-plugin-feedback/compare/v0.1.1...v0.2.0 [0.1.1]: https://github.com/studio-prisma/osticket-plugin-feedback/compare/v0.1.0...v0.1.1 [0.1.0]: https://github.com/studio-prisma/osticket-plugin-feedback/releases/tag/v0.1.0 diff --git a/plugin.php b/plugin.php index b18067f..1028210 100644 --- a/plugin.php +++ b/plugin.php @@ -9,7 +9,7 @@ return array( 'id' => 'studio-prisma:feedback', - 'version' => '0.1.1', + 'version' => '0.2.0', 'ost_version' => '1.18', 'name' => 'Feedback', 'author' => 'Studio Prisma',