Skip to content

Commit

Permalink
Notification Center 2.x implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzmg committed May 13, 2024
1 parent 35c0d00 commit 1d9d779
Show file tree
Hide file tree
Showing 29 changed files with 773 additions and 315 deletions.
104 changes: 53 additions & 51 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,55 +1,57 @@
{
"name": "contaoacademy/contao-zammad-nc-api-bundle",
"description": "API Anbindung zum Ticket System Zammad über ein Gateway des Notification-Center",
"type": "contao-bundle",
"keywords": [
"contao",
"zammad",
"notification-center"
],
"homepage": "https://contao-academy.de",
"authors": [
{
"name": "Contao Academy",
"homepage": "https://contao-academy.de"
}
],
"license": "LGPL-3.0-or-later",
"autoload": {
"psr-4": {
"Contaoacademy\\ZammadNCApiBundle\\": "src/"
},
"classmap": [
"src/Resources/contao/"
"name": "contaoacademy/contao-zammad-nc-api-bundle",
"description": "API Anbindung zum Ticket System Zammad über ein Gateway des Notification-Center",
"type": "contao-bundle",
"keywords": [
"contao",
"zammad",
"notification-center"
],
"exclude-from-classmap": [
"src/Resources/contao/config/",
"src/Resources/contao/dca/",
"src/Resources/contao/languages/",
"src/Resources/contao/templates/"
]
},
"require": {
"php": "^7.1 || ^8.0",
"contao/core-bundle": "^4.4",
"terminal42/notification_center": "^1.5"
},
"config": {
"preferred-install": "dist"
},
"replace": {
"contao-legacy/contao-zammad-nc-api-bundle": "self.version"
},
"extra": {
"contao": {
"sources": {
"": "system/modules/contao-zammad-nc-api-bundle"
}
"homepage": "https://contao-academy.de",
"authors": [
{
"name": "Contao Academy",
"homepage": "https://contao-academy.de",
"role": "Owner"
},
{
"name": "Fritz Michael Gschwantner",
"email": "fmg@inspiredminds.at",
"role": "Developer"
}
],
"license": "LGPL-3.0-or-later",
"autoload": {
"psr-4": {
"ContaoAcademy\\ZammadNCApiBundle\\": "src/"
}
},
"require": {
"php": ">=8.1",
"codefog/contao-haste": "^4.25 || ^5.1",
"contao/core-bundle": "^4.13 || ^5.3",
"terminal42/notification_center": "^2.0",
"symfony/config": "^5.4 || ^6.4",
"symfony/dependency-injection": "^5.4 || ^6.4",
"symfony/http-client": "^5.4 || ^6.4",
"symfony/http-kernel": "^5.4 || ^6.4"
},
"contao-manager-plugin": "Contaoacademy\\ZammadNCApiBundle\\ContaoManager\\Plugin"
},
"support": {
"issues": "https://github.com/contaoacademy/contao-zammad-nc-api-bundle/issues",
"source": "https://github.com/contaoacademy/contao-zammad-nc-api-bundle"
}
"extra": {
"contao-manager-plugin": "ContaoAcademy\\ZammadNCApiBundle\\ContaoManager\\Plugin"
},
"support": {
"issues": "https://github.com/contaoacademy/contao-zammad-nc-api-bundle/issues",
"source": "https://github.com/contaoacademy/contao-zammad-nc-api-bundle"
},
"require-dev": {
"contao/easy-coding-standard": "^6.0",
"contao/rector": "^1.0"
},
"config": {
"allow-plugins": {
"contao-components/installer": true,
"php-http/discovery": false,
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
8 changes: 8 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
_defaults:
autowire: true
autoconfigure: true

ContaoAcademy\ZammadNCApiBundle\:
resource: ../src/
exclude: ../src/{ContaoManager,DependencyInjection}
73 changes: 73 additions & 0 deletions contao/dca/tl_nc_gateway.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Contao Zammad Gateway extension.
*
* (c) Contao Academy
*
* @license LGPL-3.0-or-later
*/

use ContaoAcademy\ZammadNCApiBundle\Gateway\ZammadGateway;

$GLOBALS['TL_DCA']['tl_nc_gateway']['palettes']['__selector__'][] = 'zammadAuthType';
$GLOBALS['TL_DCA']['tl_nc_gateway']['palettes'][ZammadGateway::NAME] = '{title_legend},title,type;{gateway_legend},zammadHost,zammadAuthType';
$GLOBALS['TL_DCA']['tl_nc_gateway']['subpalettes']['zammadAuthType_basic'] = 'zammadUser,zammadPassword';
$GLOBALS['TL_DCA']['tl_nc_gateway']['subpalettes']['zammadAuthType_token'] = 'zammadToken';

$GLOBALS['TL_DCA']['tl_nc_gateway']['fields']['zammadHost'] = [
'inputType' => 'text',
'eval' => [
'tl_class' => 'w50',
'maxlength' => 255,
'rgxp' => 'httpurl',
'mandatory' => true,
],
'sql' => ['type' => 'string', 'length' => 255, 'default' => ''],
];

$GLOBALS['TL_DCA']['tl_nc_gateway']['fields']['zammadAuthType'] = [
'inputType' => 'select',
'eval' => [
'tl_class' => 'clr w50',
'submitOnChange' => true,
'includeBlankOption' => true,
'mandatory' => true,
],
'options' => ['basic', 'token'],
'reference' => &$GLOBALS['TL_LANG']['tl_nc_gateway']['zammadAuthTypes'],
'exclude' => true,
'sql' => ['type' => 'string', 'length' => 8, 'default' => ''],
];

$GLOBALS['TL_DCA']['tl_nc_gateway']['fields']['zammadToken'] = [
'inputType' => 'text',
'eval' => [
'tl_class' => 'w50',
'maxlength' => 255,
'mandatory' => true,
],
'sql' => ['type' => 'string', 'length' => 255, 'default' => ''],
];

$GLOBALS['TL_DCA']['tl_nc_gateway']['fields']['zammadUser'] = [
'inputType' => 'text',
'eval' => [
'tl_class' => 'w50',
'maxlength' => 255,
'mandatory' => true,
],
'sql' => ['type' => 'string', 'length' => 255, 'default' => ''],
];

$GLOBALS['TL_DCA']['tl_nc_gateway']['fields']['zammadPassword'] = [
'inputType' => 'text',
'eval' => [
'tl_class' => 'w50',
'maxlength' => 255,
'mandatory' => true,
],
'sql' => ['type' => 'string', 'length' => 255, 'default' => ''],
];
58 changes: 58 additions & 0 deletions contao/dca/tl_nc_message.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Contao Zammad Gateway extension.
*
* (c) Contao Academy
*
* @license LGPL-3.0-or-later
*/

use Doctrine\DBAL\Platforms\MySQLPlatform;
use Terminal42\NotificationCenterBundle\Token\TokenContext;

$GLOBALS['TL_DCA']['tl_nc_message']['fields']['zammad_email'] = [
'inputType' => 'text',
'eval' => ['mandatory' => true, 'maxlength' => 255, 'tl_class' => 'clr w50'],
'exclude' => true,
'nc_context' => TokenContext::Email,
'sql' => ['type' => 'string', 'length' => 255, 'default' => ''],
];

$GLOBALS['TL_DCA']['tl_nc_message']['fields']['zammad_params'] = [
'exclude' => true,
'inputType' => 'keyValueWizard',
'eval' => ['tl_class' => 'clr'],
'sql' => ['type' => 'blob', 'notnull' => false],
];

$GLOBALS['TL_DCA']['tl_nc_message']['fields']['zammad_title'] = [
'exclude' => true,
'inputType' => 'text',
'default' => '',
'eval' => ['tl_class' => 'w50', 'maxlength' => 64, 'mandatory' => true],
'nc_context' => TokenContext::Text,
'sql' => ['type' => 'string', 'length' => 64, 'default' => ''],
];

$GLOBALS['TL_DCA']['tl_nc_message']['fields']['zammad_group'] = [
'exclude' => true,
'inputType' => 'text',
'default' => '',
'eval' => ['tl_class' => 'w50', 'maxlength' => 64, 'mandatory' => true],
'nc_context' => TokenContext::Text,
'sql' => ['type' => 'string', 'length' => 64, 'default' => ''],
];

$GLOBALS['TL_DCA']['tl_nc_message']['fields']['zammad_body'] = [
'exclude' => true,
'inputType' => 'textarea',
'default' => '',
'eval' => ['mandatory' => true, 'tl_class' => 'clr'],
'nc_context' => TokenContext::Html,
'sql' => ['type' => 'text', 'length' => MySQLPlatform::LENGTH_LIMIT_TEXT, 'notnull' => false],
];

$GLOBALS['TL_DCA']['tl_nc_message']['palettes']['zammad'] = '{title_legend},title,gateway;{zammad_customer_legend},zammad_email,zammad_params;{zammad_ticket_legend},zammad_title,zammad_group,zammad_body;{publish_legend},published';
23 changes: 23 additions & 0 deletions contao/languages/de/tl_nc_gateway.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Contao Zammad Gateway extension.
*
* (c) Contao Academy
*
* @license LGPL-3.0-or-later
*/

use ContaoAcademy\ZammadNCApiBundle\Gateway\ZammadGateway;

$GLOBALS['TL_LANG']['tl_nc_gateway']['type'][ZammadGateway::NAME] = 'Zammad-API';
$GLOBALS['TL_LANG']['tl_nc_gateway']['zammad_settings'] = 'Zammad-Einstellungen';
$GLOBALS['TL_LANG']['tl_nc_gateway']['zammadAuthType'] = ['Authentication Type', 'Bitte wählen Sie einen authentication type aus.'];
$GLOBALS['TL_LANG']['tl_nc_gateway']['zammadHost'] = ['Host', 'Bitte geben Sie die URL der verwendeten Zammad Instanz ein z.B https://yourname.zammad.com'];
$GLOBALS['TL_LANG']['tl_nc_gateway']['zammadUser'] = ['Benutzer', 'Bitte geben Sie Ihren zammad Benutzer ein.'];
$GLOBALS['TL_LANG']['tl_nc_gateway']['zammadPassword'] = ['Passwort', 'Bitte geben Sie Ihren zammad Passwort ein.'];
$GLOBALS['TL_LANG']['tl_nc_gateway']['zammadToken'] = ['Token', 'Bitte geben Sie Ihr zammad token ein.'];
$GLOBALS['TL_LANG']['tl_nc_gateway']['zammadAuthTypes']['token'] = 'Token';
$GLOBALS['TL_LANG']['tl_nc_gateway']['zammadAuthTypes']['basic'] = 'HTTP Basic Authentication';
19 changes: 19 additions & 0 deletions contao/languages/de/tl_nc_message.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Contao Zammad Gateway extension.
*
* (c) Contao Academy
*
* @license LGPL-3.0-or-later
*/

$GLOBALS['TL_LANG']['tl_nc_message']['zammad_customer_legend'] = 'Zammad-Kundeneinstellungen';
$GLOBALS['TL_LANG']['tl_nc_message']['zammad_ticket_legend'] = 'Zammad-Ticketeinstellungen';
$GLOBALS['TL_LANG']['tl_nc_message']['zammad_email'] = ['E-Mail Adresse', 'E-Mail Adresse mit der ein Kunde identifiziert wird (z. B. ##form_email##).'];
$GLOBALS['TL_LANG']['tl_nc_message']['zammad_params'] = ['Kunden-Parameter', 'Kundendaten für neue Kontakte in der Zammad-API (empfohlen firstname, lastname). Schlüssel = Zammad-Feld | Wert = Contao-Formular'];
$GLOBALS['TL_LANG']['tl_nc_message']['zammad_title'] = ['Ticket-Titel', 'Der Text oder Simple Token für den Titel des Tickets (z. B. ##form_subject##).'];
$GLOBALS['TL_LANG']['tl_nc_message']['zammad_group'] = ['Ticket-Gruppe', 'Die Zammad-Gruppe zu der das Ticket zugeordnet wird.'];
$GLOBALS['TL_LANG']['tl_nc_message']['zammad_body'] = ['Nachricht', 'Die Nachricht des Tickets. Kann Text und Simple Token enthalten.'];
23 changes: 23 additions & 0 deletions contao/languages/en/tl_nc_gateway.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Contao Zammad Gateway extension.
*
* (c) Contao Academy
*
* @license LGPL-3.0-or-later
*/

use ContaoAcademy\ZammadNCApiBundle\Gateway\ZammadGateway;

$GLOBALS['TL_LANG']['tl_nc_gateway']['type'][ZammadGateway::NAME] = 'Zammad API';
$GLOBALS['TL_LANG']['tl_nc_gateway']['zammad_settings'] = 'Zammad settings';
$GLOBALS['TL_LANG']['tl_nc_gateway']['zammadAuthType'] = ['Authentication type', 'Choose the authentication type for the Zammad API.'];
$GLOBALS['TL_LANG']['tl_nc_gateway']['zammadHost'] = ['Host', 'Enter the URL of the Zammad instance, e.g. https://yourname.zammad.com'];
$GLOBALS['TL_LANG']['tl_nc_gateway']['zammadUser'] = ['Username', 'Enter the username for the authentication.'];
$GLOBALS['TL_LANG']['tl_nc_gateway']['zammadPassword'] = ['Password', 'Enter the password for the authentiaction.'];
$GLOBALS['TL_LANG']['tl_nc_gateway']['zammadToken'] = ['Token', 'Enter the token for the authentication.'];
$GLOBALS['TL_LANG']['tl_nc_gateway']['zammadAuthTypes']['token'] = 'Token';
$GLOBALS['TL_LANG']['tl_nc_gateway']['zammadAuthTypes']['basic'] = 'HTTP Basic Authentication';
19 changes: 19 additions & 0 deletions contao/languages/en/tl_nc_message.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Contao Zammad Gateway extension.
*
* (c) Contao Academy
*
* @license LGPL-3.0-or-later
*/

$GLOBALS['TL_LANG']['tl_nc_message']['zammad_customer_legend'] = 'Zammad customer settings';
$GLOBALS['TL_LANG']['tl_nc_message']['zammad_ticket_legend'] = 'Zammad ticket settings';
$GLOBALS['TL_LANG']['tl_nc_message']['zammad_email'] = ['E-mail address', 'E-mail address with which to identify a customer (e.g. ##form_email##).'];
$GLOBALS['TL_LANG']['tl_nc_message']['zammad_params'] = ['Customer parameters', 'Parameters for the Zammad API when creating a new customer (recommended: firstname, lastname). Key = Zammad | Value = Contao'];
$GLOBALS['TL_LANG']['tl_nc_message']['zammad_title'] = ['Ticket title', "The text or simple token that should be used for the ticket's title (e.g. ##form_subject##)."];
$GLOBALS['TL_LANG']['tl_nc_message']['zammad_group'] = ['Ticket group', 'The Zammad group to which this ticket will be assigned.'];
$GLOBALS['TL_LANG']['tl_nc_message']['zammad_body'] = ['Message body', 'The message body for the ticket. Can contain text and simple tokens.'];
23 changes: 23 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Fixer\Comment\HeaderCommentFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;

return static function (ECSConfig $ecsConfig): void {
$ecsConfig->sets([__DIR__.'/vendor/contao/easy-coding-standard/config/contao.php']);

$ecsConfig->paths([
__DIR__.'/src',
__DIR__.'/contao',
]);

$ecsConfig->ruleWithConfiguration(HeaderCommentFixer::class, [
'header' => "This file is part of the Contao Zammad Gateway extension.\n\n(c) Contao Academy\n\n@license LGPL-3.0-or-later",
]);

$ecsConfig->parallel();
$ecsConfig->lineEnding("\n");
$ecsConfig->cacheDirectory(sys_get_temp_dir().'/ecs_default_cache');
};
17 changes: 17 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([__DIR__.'/vendor/contao/rector/config/contao.php']);

$rectorConfig->paths([
__DIR__.'/src',
__DIR__.'/contao',
]);

$rectorConfig->parallel();
$rectorConfig->cacheDirectory(sys_get_temp_dir().'/rector_cache');
};
Loading

0 comments on commit 1d9d779

Please sign in to comment.