dolibarr.idsconnect/core/modules/modIdsconnect.class.php
data d91f9dbc9a IDS Connect v2.1 - WKE + WKS mit Sonepar live getestet
- WKE-Flow (Warenkorb empfangen): Sonepar-Integration komplett funktionsfähig
  inkl. PriceBasis-Handling, Namespace-Stripping, OCI-Unterstützung
- WKS-Flow (Warenkorb senden): Lieferantenbestellung → Shop mit vorausgefüllten
  Artikeln, IDS Connect 2.0 XML-Format
- Callback v2.0: NOLOGIN-Seite statt Redirect, 7 Datenquellen, Debug-Daten
- URL-Handling: user_base_url-Tracking für Cross-Domain-Szenarien
- Sicherheit: CSRF, HMAC-SHA256 Tokens, XXE-Schutz, PIN für WKS
- Mock-Server für lokale Tests
- Dokumentation mit Roadmap (fehlende Features, Möglichkeiten)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 06:37:15 +01:00

290 lines
8.6 KiB
PHP
Executable file

<?php
/* Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018-2019 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2026 Eduard Wisch <data@data-it-solution.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \defgroup idsconnect Module IDS Connect
* \brief IDS Connect Schnittstelle zum Elektrogroßhandel (Kluxen, Sonepar etc.)
*
* \file htdocs/idsconnect/core/modules/modIdsconnect.class.php
* \ingroup idsconnect
* \brief Modul-Deskriptor für IDS Connect
*/
include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
/**
* Modul-Deskriptor für IDS Connect
*/
class modIdsconnect extends DolibarrModules
{
/**
* Constructor. Define names, constants, directories, boxes, permissions
*
* @param DoliDB $db Database handler
*/
public function __construct($db)
{
global $conf, $langs;
$this->db = $db;
$this->numero = 500025;
$this->rights_class = 'idsconnect';
$this->family = "interface";
$this->module_position = '90';
$this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "IdsconnectDescription";
$this->descriptionlong = "IdsconnectDescriptionLong";
$this->editor_name = 'Alles Watt laeuft';
$this->editor_url = '';
$this->version = '1.8';
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
$this->picto = 'fa-plug';
$this->module_parts = array(
'triggers' => 0,
'login' => 0,
'substitutions' => 0,
'menus' => 0,
'tpl' => 0,
'barcode' => 0,
'models' => 0,
'printing' => 0,
'theme' => 0,
'css' => array(
'/idsconnect/css/idsconnect.css',
),
'js' => array(),
'hooks' => array(
'data' => array(
'ordersuppliercard',
),
'entity' => '0',
),
'moduleforexternal' => 0,
'websitetemplates' => 0,
'captcha' => 0
);
$this->dirs = array("/idsconnect/temp");
$this->config_page_url = array("setup.php@idsconnect");
$this->hidden = getDolGlobalInt('MODULE_IDSCONNECT_DISABLED');
$this->depends = array('modFournisseur');
$this->requiredby = array();
$this->conflictwith = array();
$this->langfiles = array("idsconnect@idsconnect");
$this->phpmin = array(7, 4);
$this->need_dolibarr_version = array(19, -3);
$this->need_javascript_ajax = 0;
$this->warnings_activation = array();
$this->warnings_activation_ext = array();
// Konstanten - Testmodus ist Standard AN
$this->const = array(
1 => array('IDSCONNECT_TESTMODE', 'chaine', '1', 'Testmodus aktiv - keine echten Verbindungen zum Großhandel', 0),
2 => array('IDSCONNECT_LOG_ENABLED', 'chaine', '1', 'Logging aller IDS-Transaktionen', 0),
3 => array('IDSCONNECT_CALLBACK_SECRET', 'chaine', bin2hex(random_bytes(16)), 'Secret für Callback-Token-Generierung', 0),
);
if (!isModEnabled("idsconnect")) {
$conf->idsconnect = new stdClass();
$conf->idsconnect->enabled = 0;
}
// Tab in Lieferantenbestellungen
$this->tabs = array(
'supplier_order:+idsconnect:IdsConnectTab:idsconnect@idsconnect:$user->hasRight(\'idsconnect\', \'use\'):/idsconnect/tab_supplierorder.php?id=__ID__',
);
$this->dictionaries = array();
$this->boxes = array();
$this->cronjobs = array();
// ============================================================
// Berechtigungen
// ============================================================
$this->rights = array();
$r = 0;
// Lesen - Modul sehen, Logs anschauen
$this->rights[$r][0] = $this->numero . '01';
$this->rights[$r][1] = 'IDS Connect Modul sehen und Logs lesen';
$this->rights[$r][4] = 'read';
$this->rights[$r][5] = '';
$r++;
// Nutzen - Warenkörbe senden/empfangen, Shop öffnen
$this->rights[$r][0] = $this->numero . '02';
$this->rights[$r][1] = 'IDS Connect Schnittstelle nutzen (Warenkörbe, Deep-Links)';
$this->rights[$r][4] = 'use';
$this->rights[$r][5] = '';
$r++;
// Konfigurieren - Großhändler verwalten, Zugangsdaten ändern
$this->rights[$r][0] = $this->numero . '03';
$this->rights[$r][1] = 'IDS Connect Großhändler und Zugangsdaten verwalten';
$this->rights[$r][4] = 'config';
$this->rights[$r][5] = '';
$r++;
// Löschen - Logs und Großhändler löschen
$this->rights[$r][0] = $this->numero . '04';
$this->rights[$r][1] = 'IDS Connect Daten löschen';
$this->rights[$r][4] = 'delete';
$this->rights[$r][5] = '';
$r++;
// ============================================================
// Menüs
// ============================================================
$this->menu = array();
$r = 0;
// Top-Menü
$this->menu[$r++] = array(
'fk_menu' => '',
'type' => 'top',
'titre' => 'ModuleIdsconnectName',
'prefix' => img_picto('', $this->picto, 'class="pictofixedwidth valignmiddle"'),
'mainmenu' => 'idsconnect',
'leftmenu' => '',
'url' => '/idsconnect/idsconnectindex.php',
'langs' => 'idsconnect@idsconnect',
'position' => 1000 + $r,
'enabled' => 'isModEnabled("idsconnect")',
'perms' => '$user->hasRight("idsconnect", "read")',
'target' => '',
'user' => 0,
);
// Links-Menü: Übersicht
$this->menu[$r++] = array(
'fk_menu' => 'fk_mainmenu=idsconnect',
'type' => 'left',
'titre' => 'IdsconnectOverview',
'prefix' => img_picto('', 'fa-home', 'class="pictofixedwidth valignmiddle paddingright"'),
'mainmenu' => 'idsconnect',
'leftmenu' => 'idsconnect_overview',
'url' => '/idsconnect/idsconnectindex.php',
'langs' => 'idsconnect@idsconnect',
'position' => 1000 + $r,
'enabled' => 'isModEnabled("idsconnect")',
'perms' => '$user->hasRight("idsconnect", "read")',
'target' => '',
'user' => 0,
);
// Links-Menü: Großhändler
$this->menu[$r++] = array(
'fk_menu' => 'fk_mainmenu=idsconnect',
'type' => 'left',
'titre' => 'IdsconnectSuppliers',
'prefix' => img_picto('', 'fa-building', 'class="pictofixedwidth valignmiddle paddingright"'),
'mainmenu' => 'idsconnect',
'leftmenu' => 'idsconnect_suppliers',
'url' => '/idsconnect/supplier_list.php',
'langs' => 'idsconnect@idsconnect',
'position' => 1000 + $r,
'enabled' => 'isModEnabled("idsconnect")',
'perms' => '$user->hasRight("idsconnect", "read")',
'target' => '',
'user' => 0,
);
// Links-Menü: Großhändler anlegen
$this->menu[$r++] = array(
'fk_menu' => 'fk_mainmenu=idsconnect,fk_leftmenu=idsconnect_suppliers',
'type' => 'left',
'titre' => 'IdsconnectNewSupplier',
'mainmenu' => 'idsconnect',
'leftmenu' => 'idsconnect_supplier_new',
'url' => '/idsconnect/supplier_card.php?action=create',
'langs' => 'idsconnect@idsconnect',
'position' => 1000 + $r,
'enabled' => 'isModEnabled("idsconnect")',
'perms' => '$user->hasRight("idsconnect", "config")',
'target' => '',
'user' => 0,
);
// Links-Menü: Transaktionslog
$this->menu[$r++] = array(
'fk_menu' => 'fk_mainmenu=idsconnect',
'type' => 'left',
'titre' => 'IdsconnectLog',
'prefix' => img_picto('', 'fa-list-alt', 'class="pictofixedwidth valignmiddle paddingright"'),
'mainmenu' => 'idsconnect',
'leftmenu' => 'idsconnect_log',
'url' => '/idsconnect/log_list.php',
'langs' => 'idsconnect@idsconnect',
'position' => 1000 + $r,
'enabled' => 'isModEnabled("idsconnect")',
'perms' => '$user->hasRight("idsconnect", "read")',
'target' => '',
'user' => 0,
);
}
/**
* Modul aktivieren
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, <=0 if KO
*/
public function init($options = '')
{
global $conf, $langs;
$result = $this->_load_tables('/idsconnect/sql/');
if ($result < 0) {
return -1;
}
$this->remove($options);
$sql = array();
return $this->_init($sql, $options);
}
/**
* Modul deaktivieren
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, <=0 if KO
*/
public function remove($options = '')
{
$sql = array();
return $this->_remove($sql, $options);
}
}