Skip to content
Draft
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Added

<<<<<<< HEAD
- Add translations management through Transifex
- "Email followup" destination field to disable the followup per actor source, with a command to import it from Formcreator
- Add "Allow specific languages" form access policy
- Add "GLPI system information" and "GLPI core or plugins concerned" question types
=======
- Add an "Email" form destination, sending a customized email when a form is submitted
- "Email followup" destination field to disable the followup per actor source, with a command to import it from Formcreator
>>>>>>> 6c51cde (Fix email follow up by actor (GLPI 11.0.x) (#97))

### Fixed

Expand Down
21 changes: 21 additions & 0 deletions src/Console/ImportFormcreatorActorsNotificationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
namespace GlpiPlugin\Advancedforms\Console;

use Config;
<<<<<<< HEAD

Check failure on line 37 in src/Console/ImportFormcreatorActorsNotificationCommand.php

View workflow job for this annotation

GitHub Actions / GLPI 12.0.x - php:8.3 - mysql:8.0 / Continuous integration

Syntax error, unexpected T_SL on line 37

Check failure on line 37 in src/Console/ImportFormcreatorActorsNotificationCommand.php

View workflow job for this annotation

GitHub Actions / GLPI 12.0.x - php:8.5 - mariadb:10.11 / Continuous integration

Syntax error, unexpected T_SL on line 37
=======
use DBmysql;
>>>>>>> 6c51cde (Fix email follow up by actor (GLPI 11.0.x) (#97))
use Glpi\Console\AbstractCommand;
use Glpi\Form\Destination\CommonITILField\ITILActorFieldConfig;
use Glpi\Form\Destination\CommonITILField\ITILActorFieldStrategy;
Expand All @@ -47,6 +51,10 @@
use GlpiPlugin\Advancedforms\Model\Destination\ActorNotificationFieldConfig;
use Override;
use Ramsey\Uuid\Uuid;
<<<<<<< HEAD
=======
use RuntimeException;
>>>>>>> 6c51cde (Fix email follow up by actor (GLPI 11.0.x) (#97))
use Supplier;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
Expand Down Expand Up @@ -207,17 +215,30 @@
return $this->has_failed_destinations ? Command::FAILURE : Command::SUCCESS;
}

<<<<<<< HEAD
=======
/** GLPI 11 has no AbstractCommand::getDb() (added in GLPI 12). */
private function getDb(): DBmysql
{
if ($this->db === null) {
throw new RuntimeException('No database connection available.');
}

return $this->db;
}

>>>>>>> 6c51cde (Fix email follow up by actor (GLPI 11.0.x) (#97))
/** @return list<string> */
private function getMissingFormcreatorTables(): array
{
$tables = [self::ACTORS_TABLE, self::FORMS_TABLE, self::QUESTIONS_TABLE];
foreach (self::TARGETS as [$table]) {
$tables[] = $table;

Check failure on line 236 in src/Console/ImportFormcreatorActorsNotificationCommand.php

View workflow job for this annotation

GitHub Actions / GLPI 12.0.x - php:8.3 - mysql:8.0 / Continuous integration

Syntax error, unexpected ']', expecting '-' or T_STRING or T_VARIABLE or T_NUM_STRING on line 236

Check failure on line 236 in src/Console/ImportFormcreatorActorsNotificationCommand.php

View workflow job for this annotation

GitHub Actions / GLPI 12.0.x - php:8.5 - mariadb:10.11 / Continuous integration

Syntax error, unexpected ']', expecting '-' or T_STRING or T_VARIABLE or T_NUM_STRING on line 236
}

return array_values(array_filter(
$tables,
fn(string $table): bool => !$this->getDb()->tableExists($table, usecache: false),

Check failure on line 241 in src/Console/ImportFormcreatorActorsNotificationCommand.php

View workflow job for this annotation

GitHub Actions / GLPI 12.0.x - php:8.3 - mysql:8.0 / Continuous integration

Syntax error, unexpected T_ENCAPSED_AND_WHITESPACE on line 241

Check failure on line 241 in src/Console/ImportFormcreatorActorsNotificationCommand.php

View workflow job for this annotation

GitHub Actions / GLPI 12.0.x - php:8.5 - mariadb:10.11 / Continuous integration

Syntax error, unexpected T_ENCAPSED_AND_WHITESPACE on line 241
));
}

Expand All @@ -226,7 +247,7 @@
{
$destinations = [];
foreach (Config::getConfigurationValues(self::IMPORTED_DESTINATIONS_CONFIG_CONTEXT) as $id) {
$destinations[$this->toInt($id)] = true;

Check failure on line 250 in src/Console/ImportFormcreatorActorsNotificationCommand.php

View workflow job for this annotation

GitHub Actions / GLPI 12.0.x - php:8.3 - mysql:8.0 / Continuous integration

Syntax error, unexpected ']' on line 250

Check failure on line 250 in src/Console/ImportFormcreatorActorsNotificationCommand.php

View workflow job for this annotation

GitHub Actions / GLPI 12.0.x - php:8.3 - mysql:8.0 / Continuous integration

Syntax error, unexpected '>' on line 250

Check failure on line 250 in src/Console/ImportFormcreatorActorsNotificationCommand.php

View workflow job for this annotation

GitHub Actions / GLPI 12.0.x - php:8.5 - mariadb:10.11 / Continuous integration

Syntax error, unexpected ']' on line 250

Check failure on line 250 in src/Console/ImportFormcreatorActorsNotificationCommand.php

View workflow job for this annotation

GitHub Actions / GLPI 12.0.x - php:8.5 - mariadb:10.11 / Continuous integration

Syntax error, unexpected '>' on line 250
}

return $destinations;
Expand All @@ -236,7 +257,7 @@
private function saveImportedDestinations(): void
{
$values = [];
foreach (array_keys(array_diff_key($this->destinations, $this->imported_destinations)) as $id) {

Check failure on line 260 in src/Console/ImportFormcreatorActorsNotificationCommand.php

View workflow job for this annotation

GitHub Actions / GLPI 12.0.x - php:8.3 - mysql:8.0 / Continuous integration

Syntax error, unexpected T_ENCAPSED_AND_WHITESPACE on line 260

Check failure on line 260 in src/Console/ImportFormcreatorActorsNotificationCommand.php

View workflow job for this annotation

GitHub Actions / GLPI 12.0.x - php:8.5 - mariadb:10.11 / Continuous integration

Syntax error, unexpected T_ENCAPSED_AND_WHITESPACE on line 260
$values['destination_' . $id] = (string) $id;
}

Expand All @@ -249,7 +270,7 @@
private function getUncheckedActors(): iterable
{
/** @var iterable<array<string, mixed>> */
return $this->getDb()->request([

Check failure on line 273 in src/Console/ImportFormcreatorActorsNotificationCommand.php

View workflow job for this annotation

GitHub Actions / GLPI 12.0.x - php:8.3 - mysql:8.0 / Continuous integration

Syntax error, unexpected T_ENCAPSED_AND_WHITESPACE on line 273

Check failure on line 273 in src/Console/ImportFormcreatorActorsNotificationCommand.php

View workflow job for this annotation

GitHub Actions / GLPI 12.0.x - php:8.5 - mariadb:10.11 / Continuous integration

Syntax error, unexpected T_ENCAPSED_AND_WHITESPACE on line 273
'SELECT' => ['itemtype', 'items_id', 'actor_role', 'actor_type', 'actor_value'],
'FROM' => self::ACTORS_TABLE,
'WHERE' => [
Expand All @@ -263,9 +284,9 @@
/** @param array<string, mixed> $actor */
private function handleUncheckedActor(array $actor): void
{
$role = self::ROLES[$this->toInt($actor['actor_role'])] ?? null;

Check failure on line 287 in src/Console/ImportFormcreatorActorsNotificationCommand.php

View workflow job for this annotation

GitHub Actions / GLPI 12.0.x - php:8.3 - mysql:8.0 / Continuous integration

Syntax error, unexpected T_ENCAPSED_AND_WHITESPACE on line 287

Check failure on line 287 in src/Console/ImportFormcreatorActorsNotificationCommand.php

View workflow job for this annotation

GitHub Actions / GLPI 12.0.x - php:8.5 - mariadb:10.11 / Continuous integration

Syntax error, unexpected T_ENCAPSED_AND_WHITESPACE on line 287
$actor_type = $this->toInt($actor['actor_type']);

Check failure on line 288 in src/Console/ImportFormcreatorActorsNotificationCommand.php

View workflow job for this annotation

GitHub Actions / GLPI 12.0.x - php:8.3 - mysql:8.0 / Continuous integration

Syntax error, unexpected T_ENCAPSED_AND_WHITESPACE on line 288

Check failure on line 288 in src/Console/ImportFormcreatorActorsNotificationCommand.php

View workflow job for this annotation

GitHub Actions / GLPI 12.0.x - php:8.5 - mariadb:10.11 / Continuous integration

Syntax error, unexpected T_ENCAPSED_AND_WHITESPACE on line 288
$actor_value = $this->toInt($actor['actor_value']);

Check failure on line 289 in src/Console/ImportFormcreatorActorsNotificationCommand.php

View workflow job for this annotation

GitHub Actions / GLPI 12.0.x - php:8.3 - mysql:8.0 / Continuous integration

Syntax error, unexpected T_ENCAPSED_AND_WHITESPACE on line 289

Check failure on line 289 in src/Console/ImportFormcreatorActorsNotificationCommand.php

View workflow job for this annotation

GitHub Actions / GLPI 12.0.x - php:8.5 - mariadb:10.11 / Continuous integration

Syntax error, unexpected T_ENCAPSED_AND_WHITESPACE on line 289
if ($role === null || !$this->hasEmailFollowup($actor_type)) {
return;
}
Expand Down
31 changes: 31 additions & 0 deletions src/Service/InitManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@
namespace GlpiPlugin\Advancedforms\Service;

use Config;
<<<<<<< HEAD
use Glpi\Form\Destination\FormDestinationChange;
use Glpi\Form\AccessControl\FormAccessControlManager;
=======
use Glpi\Form\Destination\FormDestination;
use Glpi\Form\Destination\FormDestinationChange;
>>>>>>> 6c51cde (Fix email follow up by actor (GLPI 11.0.x) (#97))
use Glpi\Form\Destination\FormDestinationManager;
use Glpi\Form\Destination\FormDestinationProblem;
use Glpi\Form\Destination\FormDestinationTicket;
Expand All @@ -46,6 +51,10 @@
use GlpiPlugin\Advancedforms\Model\AccessControl\LanguageAccessControl;
use GlpiPlugin\Advancedforms\Model\Config\ConfigTab;
use GlpiPlugin\Advancedforms\Model\Destination\ActorNotificationField;
<<<<<<< HEAD
=======
use GlpiPlugin\Advancedforms\Model\Destination\Email\EmailDestinationConfigNormalizer;
>>>>>>> 6c51cde (Fix email follow up by actor (GLPI 11.0.x) (#97))
use GlpiPlugin\Advancedforms\Model\Destination\PreReservationField;
use GlpiPlugin\Advancedforms\Model\QuestionType\AdvancedCategory;
use GlpiPlugin\Advancedforms\Model\QuestionType\LegacyQuestionTypeInterface;
Expand Down Expand Up @@ -147,6 +156,28 @@ private function registerDestinationFields(): void
fn($registered_field) => $registered_field instanceof $field,
);
if ($already_registered !== []) {
<<<<<<< HEAD
=======
continue;
}

$destination_manager->registerPluginCommonITILConfigField($destination_class, $field);
}
}

private function registerDestinationTypes(): void
{
$destination_manager = FormDestinationManager::getInstance();

// init() may run multiple times per process; avoid double-registering a type.
$registered_classes = array_map(
get_class(...),
$destination_manager->getDestinationTypes(),
);

foreach (ConfigManager::getInstance()->getEnabledDestinations() as $destination) {
if (in_array($destination::class, $registered_classes, true)) {
>>>>>>> 6c51cde (Fix email follow up by actor (GLPI 11.0.x) (#97))
continue;
}

Expand Down
3 changes: 3 additions & 0 deletions src/Service/InstallManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
use Glpi\Form\AccessControl\FormAccessControl;
use Glpi\Toolbox\SingletonTrait;
use GlpiPlugin\Advancedforms\Console\ImportFormcreatorActorsNotificationCommand;
<<<<<<< HEAD
use GlpiPlugin\Advancedforms\Model\AccessControl\LanguageAccessControl;
=======
>>>>>>> 6c51cde (Fix email follow up by actor (GLPI 11.0.x) (#97))
use GlpiPlugin\Advancedforms\Model\TicketReservationRequest;
use Migration;
use Notification;
Expand Down
Loading