* * 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. */ /** * \file idsconnect/lib/idsconnect.lib.php * \ingroup idsconnect * \brief Bibliotheksfunktionen für IDS Connect */ /** * Admin-Tabs vorbereiten * * @return array */ function idsconnectAdminPrepareHead() { global $langs, $conf; $langs->load("idsconnect@idsconnect"); $h = 0; $head = array(); $head[$h][0] = dol_buildpath("/idsconnect/admin/setup.php", 1); $head[$h][1] = $langs->trans("Settings"); $head[$h][2] = 'settings'; $h++; $head[$h][0] = dol_buildpath("/idsconnect/admin/about.php", 1); $head[$h][1] = $langs->trans("About"); $head[$h][2] = 'about'; $h++; complete_head_from_modules($conf, $langs, null, $head, $h, 'idsconnect@idsconnect'); complete_head_from_modules($conf, $langs, null, $head, $h, 'idsconnect@idsconnect', 'remove'); return $head; } /** * Großhändler-Karte Tabs vorbereiten * * @param object $object Großhändler-Objekt * @return array */ function idsconnectSupplierPrepareHead($object) { global $langs, $conf; $langs->load("idsconnect@idsconnect"); $h = 0; $head = array(); $head[$h][0] = dol_buildpath("/idsconnect/supplier_card.php", 1).'?id='.$object->id; $head[$h][1] = $langs->trans("IdsconnectSupplierCard"); $head[$h][2] = 'supplier'; $h++; $head[$h][0] = dol_buildpath("/idsconnect/log_list.php", 1).'?supplier_id='.$object->id; $head[$h][1] = $langs->trans("IdsconnectLog"); $head[$h][2] = 'log'; $h++; return $head; } /** * Sendet Benachrichtigung über GlobalNotify (falls verfügbar). * Fallback: Schreibt ins Dolibarr-Log. * * @param string $type 'error', 'warning', 'info', 'action' * @param string $title Kurzer Titel * @param string $message Detaillierte Nachricht * @param string $actionUrl URL für Aktions-Button (optional) * @param string $actionLabel Label für Aktions-Button (optional) * @return bool True wenn über GlobalNotify gesendet */ function idsconnect_notify($type, $title, $message, $actionUrl = '', $actionLabel = '') { if (!isModEnabled('globalnotify')) { dol_syslog("IDSCONNECT [{$type}]: {$title} - {$message}", LOG_WARNING); return false; } $classFile = dol_buildpath('/globalnotify/class/globalnotify.class.php', 0); if (!file_exists($classFile)) { dol_syslog("IDSCONNECT [{$type}]: {$title} - {$message}", LOG_WARNING); return false; } require_once $classFile; if (!class_exists('GlobalNotify')) { dol_syslog("IDSCONNECT [{$type}]: {$title} - {$message}", LOG_WARNING); return false; } try { switch ($type) { case 'error': GlobalNotify::error('idsconnect', $title, $message, $actionUrl, $actionLabel); break; case 'warning': GlobalNotify::warning('idsconnect', $title, $message, $actionUrl, $actionLabel); break; case 'action': GlobalNotify::actionRequired('idsconnect', $title, $message, $actionUrl, $actionLabel ?: 'Jetzt beheben'); break; default: GlobalNotify::info('idsconnect', $title, $message, $actionUrl, $actionLabel); } return true; } catch (Exception $e) { dol_syslog("GlobalNotify error in idsconnect: ".$e->getMessage(), LOG_ERR); return false; } } /** * Prüft die Supplier-Konfiguration auf Vollständigkeit vor dem Launch. * * @param object $supplier IdsSupplier-Objekt * @return array ['errors' => string[], 'warnings' => string[]] */ function idsconnect_validateSupplierConfig($supplier) { $result = array('errors' => array(), 'warnings' => array()); if (empty($supplier->ids_password)) { $result['errors'][] = 'Kein Passwort konfiguriert für "'.$supplier->label.'" – IDS-Login nicht möglich.'; } if (empty($supplier->ids_username)) { $result['warnings'][] = 'Kein Benutzername (name_kunde) konfiguriert für "'.$supplier->label.'" – Login könnte fehlschlagen und der "Weiter"-Button fehlt ggf. im Shop.'; } return $result; } /** * Testmodus-Banner ausgeben * * @return void */ function idsconnectShowTestModeBanner() { global $langs; $langs->load("idsconnect@idsconnect"); if (getDolGlobalInt('IDSCONNECT_TESTMODE')) { print '
'; } else { print ''; } }