From 77e101e2cad239990812789314e21fa755d7e951 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Jan 2024 02:04:43 +0100 Subject: [PATCH 1/5] Debug AI module --- htdocs/ai/README.md | 3 ++- htdocs/core/modules/modAi.class.php | 6 +++--- htdocs/core/modules/modModuleBuilder.class.php | 5 +++-- htdocs/langs/en_US/ai.lang | 2 ++ 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/ai/README.md b/htdocs/ai/README.md index e0f33ef5f69..b25be05f570 100644 --- a/htdocs/ai/README.md +++ b/htdocs/ai/README.md @@ -2,8 +2,9 @@ ## Features -Provides an api key for chatchpt for use it in other modules +Provides AI (Artificial Intelligence) features in different part of the application. Need external AI API. +## Licenses ### Main code diff --git a/htdocs/core/modules/modAi.class.php b/htdocs/core/modules/modAi.class.php index b2546e2553d..8d4304489a1 100644 --- a/htdocs/core/modules/modAi.class.php +++ b/htdocs/core/modules/modAi.class.php @@ -39,7 +39,7 @@ class modAi extends DolibarrModules */ public function __construct($db) { - global $langs, $conf; + global $conf; $this->db = $db; @@ -52,7 +52,7 @@ class modAi extends DolibarrModules // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' // It is used to group modules by family in module setup page - $this->family = "mailings"; + $this->family = "technic"; // Module position in the family on 2 digits ('01', '10', '20', ...) $this->module_position = '50'; @@ -65,7 +65,7 @@ class modAi extends DolibarrModules // Module description, used if translation string 'ModuleAiDesc' not found (Ai is name of module). $this->description = "AiDescription"; // Used only if file README.md and README-LL.md not found. - $this->descriptionlong = "AiDescription"; + $this->descriptionlong = "AiDescriptionLong"; // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' $this->version = 'development'; diff --git a/htdocs/core/modules/modModuleBuilder.class.php b/htdocs/core/modules/modModuleBuilder.class.php index 8e1fa8bac06..8ca370bc2e4 100644 --- a/htdocs/core/modules/modModuleBuilder.class.php +++ b/htdocs/core/modules/modModuleBuilder.class.php @@ -19,12 +19,13 @@ /** * \defgroup modulebuilder Module ModuleBuilder * \brief Add a log into a block chain for some actions. - * \file htdocs/core/modules/modBlockedLog.class.php - * \ingroup blockedlog + * \file htdocs/core/modules/modModuleBuilder.class.php + * \ingroup modulebuilder * \brief Description and activation file for the module ModuleBuilder */ include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; + /** * Class to describe a ModuleBuilder module */ diff --git a/htdocs/langs/en_US/ai.lang b/htdocs/langs/en_US/ai.lang index 5f685967132..287e652b7ec 100644 --- a/htdocs/langs/en_US/ai.lang +++ b/htdocs/langs/en_US/ai.lang @@ -1 +1,3 @@ +AiDescription=AI (Artificial Intelligence) features +AiDescriptionLong=Provides AI (Artificial Intelligence) features in different part of the application. Need external AI API. AI_KEY_API_CHATGPT= Key for IA api \ No newline at end of file From 279f9e715a0136ea67f4f31ef71f18a5fe537a6a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Jan 2024 02:22:25 +0100 Subject: [PATCH 2/5] WIP API --- htdocs/ai/admin/setup.php | 33 +++++++------------ htdocs/langs/en_US/ai.lang | 3 +- htdocs/modulebuilder/template/admin/setup.php | 17 ++++++---- 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/htdocs/ai/admin/setup.php b/htdocs/ai/admin/setup.php index 6a6e15db8ed..af410762a88 100644 --- a/htdocs/ai/admin/setup.php +++ b/htdocs/ai/admin/setup.php @@ -31,11 +31,6 @@ global $langs, $user; require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once '../lib/ai.lib.php'; -// Access control -if (!$user->admin) { - accessforbidden(); -} - // Parameters $action = GETPOST('action', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); @@ -46,10 +41,15 @@ $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); $type = 'myobject'; - $error = 0; $setupnotempty = 0; +// Access control +if (!$user->admin) { + accessforbidden(); +} + + // Set this to 1 to use the factory to manage constants. Warning, the generated module will be compatible with version v15+ only $useFormSetup = 1; @@ -59,20 +59,16 @@ if (!class_exists('FormSetup')) { $formSetup = new FormSetup($db); -// Setup conf AI_PUBLIC_INTERFACE_TOPIC -$item = $formSetup->newItem('AI_KEY_API_CHATGPT'); -$item->defaultFieldValue = ''; +$arrayofia = array('chatgpt'); - -// Save API Key -if ($_SERVER["REQUEST_METHOD"] == "POST") { - $apiKey = GETPOST('api_key', 'alpha'); - // Validate and clean $apiKey here - dolibarr_set_const($db, 'MAIN_AI_CHATGPT_API_KEY', $apiKey, 'chaine', 0, '', $conf->entity); +foreach($arrayofia as $ia) { + // Setup conf AI_PUBLIC_INTERFACE_TOPIC + $item = $formSetup->newItem('AI_KEY_API_'.strtoupper($ia)); + $item->defaultFieldValue = ''; } // Retrieve existing API Key -$apiKey = dolibarr_get_const($db, 'MAIN_AI_CHATGPT_API_KEY'); +//$apiKey = dolibarr_get_const($db, 'MAIN_AI_CHATGPT_API_KEY'); $setupnotempty =+ count($formSetup->items); @@ -84,11 +80,6 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); * Actions */ -// For retrocompatibility Dolibarr < 15.0 -if (versioncompare(explode('.', DOL_VERSION), array(15)) < 0 && $action == 'update' && !empty($user->admin)) { - $formSetup->saveConfFromPost(); -} - include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { diff --git a/htdocs/langs/en_US/ai.lang b/htdocs/langs/en_US/ai.lang index 287e652b7ec..0f595c2d022 100644 --- a/htdocs/langs/en_US/ai.lang +++ b/htdocs/langs/en_US/ai.lang @@ -1,3 +1,4 @@ AiDescription=AI (Artificial Intelligence) features AiDescriptionLong=Provides AI (Artificial Intelligence) features in different part of the application. Need external AI API. -AI_KEY_API_CHATGPT= Key for IA api \ No newline at end of file +AI_KEY_API_CHATGPT= Key for IA api +AiSetup=AI module setup \ No newline at end of file diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index d23368dbfc2..0129689133b 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -64,11 +64,6 @@ $langs->loadLangs(array("admin", "mymodule@mymodule")); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('mymodulesetup', 'globalsetup')); -// Access control -if (!$user->admin) { - accessforbidden(); -} - // Parameters $action = GETPOST('action', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); @@ -79,10 +74,15 @@ $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); $type = 'myobject'; - $error = 0; $setupnotempty = 0; +// Access control +if (!$user->admin) { + accessforbidden(); +} + + // Set this to 1 to use the factory to manage constants. Warning, the generated module will be compatible with version v15+ only $useFormSetup = 1; @@ -91,6 +91,11 @@ if (!class_exists('FormSetup')) { } $formSetup = new FormSetup($db); +// Access control +if (!$user->admin) { + accessforbidden(); +} + // Enter here all parameters in your setup page From 9d96c6c4d3d28f924a73a066fff86e0a256a29f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Jan 2024 02:23:33 +0100 Subject: [PATCH 3/5] Trans --- htdocs/langs/en_US/ai.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/ai.lang b/htdocs/langs/en_US/ai.lang index 0f595c2d022..60332e76457 100644 --- a/htdocs/langs/en_US/ai.lang +++ b/htdocs/langs/en_US/ai.lang @@ -1,4 +1,4 @@ AiDescription=AI (Artificial Intelligence) features AiDescriptionLong=Provides AI (Artificial Intelligence) features in different part of the application. Need external AI API. -AI_KEY_API_CHATGPT= Key for IA api +AI_KEY_API_CHATGPT= Key for ChatGPT IA api AiSetup=AI module setup \ No newline at end of file From e0f818d759744e64c15ce7f4b2ab74cded0e1458 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Jan 2024 02:44:56 +0100 Subject: [PATCH 4/5] Debug webportal --- htdocs/core/lib/functions.lib.php | 8 ++- htdocs/webportal/admin/configcss.php | 50 +++------------- htdocs/webportal/admin/setup.php | 59 ++++--------------- htdocs/webportal/admin/setup_theme.php | 52 +++------------- .../core/modules/modWebPortal.class.php | 2 +- htdocs/webportal/langs/en_US/webportal.lang | 1 + 6 files changed, 36 insertions(+), 136 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 482a757cc38..6dabfe46290 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4387,7 +4387,7 @@ function getPictoForType($key) */ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $srconly = 0, $notitle = 0, $alt = '', $morecss = '', $marginleftonlyshort = 2) { - global $conf, $langs; + global $conf; // We forge fullpathpicto for image to $path/img/$picto. By default, we take DOL_URL_ROOT/theme/$conf->theme/img/$picto $url = DOL_URL_ROOT; @@ -4496,7 +4496,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'timespent', 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda', 'uncheck', 'url', 'user-cog', 'user-injured', 'user-md', 'vat', 'website', 'workstation', 'webhook', 'world', 'private', 'conferenceorbooth', 'eventorganization', - 'stamp', 'signature' + 'stamp', 'signature', + 'webportal' ))) { $fakey = $pictowithouttext; $facolor = ''; @@ -4548,7 +4549,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'uncheck'=>'times', 'uparrow'=>'share', 'url'=>'external-link-alt', 'vat'=>'money-check-alt', 'vcard'=>'arrow-alt-circle-down', 'jabber'=>'comment-o', 'website'=>'globe-americas', 'workstation'=>'pallet', 'webhook'=>'bullseye', 'world'=>'globe', 'private'=>'user-lock', - 'conferenceorbooth'=>'chalkboard-teacher', 'eventorganization'=>'project-diagram' + 'conferenceorbooth'=>'chalkboard-teacher', 'eventorganization'=>'project-diagram', + 'webportal'=>'door-open' ); if ($conf->currency == 'EUR') { $arrayconvpictotofa['currency'] = 'euro-sign'; diff --git a/htdocs/webportal/admin/configcss.php b/htdocs/webportal/admin/configcss.php index 77fd759e9c7..5bc8effa778 100644 --- a/htdocs/webportal/admin/configcss.php +++ b/htdocs/webportal/admin/configcss.php @@ -24,42 +24,9 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"] . "/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; -$tmp2 = realpath(__FILE__); -$i = strlen($tmp) - 1; -$j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; - $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)) . "/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1)) . "/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - -global $conf, $db, $hookmanager, $langs, $user; - -// Libraries -require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; -dol_include_once('/webportal/lib/webportal.lib.php'); +require_once "../../main.inc.php"; +require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT . "/webportal/lib/webportal.lib.php"; // Translations $langs->loadLangs(array("admin", "hrm", "other")); @@ -67,14 +34,15 @@ $langs->loadLangs(array("admin", "hrm", "other")); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('webportalsetup', 'globalsetup')); +// Parameters +$action = GETPOST('action', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); + // Access control if (!$user->admin) { accessforbidden(); } -// Parameters -$action = GETPOST('action', 'aZ09'); -$backtopage = GETPOST('backtopage', 'alpha'); /* * Actions @@ -106,7 +74,7 @@ if ($action == 'updatecss') { * View */ -$title = "WebPortalCSS"; +$title = "WebPortalSetup"; $wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; @@ -132,7 +100,7 @@ print load_fiche_titre($langs->trans($title), $linkback, 'title_setup'); // Configuration header $head = webportalAdminPrepareHead(); -print dol_get_fiche_head($head, 'css', $langs->trans($title), -1, "webportal@webportal"); +print dol_get_fiche_head($head, 'css', $langs->trans($title), -1, "webportal"); // Setup page goes here echo '' . $langs->trans("WebPortalCSS") . '

'; diff --git a/htdocs/webportal/admin/setup.php b/htdocs/webportal/admin/setup.php index 866c989d3b9..e7531e4d51b 100644 --- a/htdocs/webportal/admin/setup.php +++ b/htdocs/webportal/admin/setup.php @@ -23,42 +23,9 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"] . "/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; -$tmp2 = realpath(__FILE__); -$i = strlen($tmp) - 1; -$j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; - $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)) . "/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1)) . "/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - -global $conf, $db, $hookmanager, $langs, $user; - -// Libraries +require_once "../../main.inc.php"; require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; -dol_include_once('/webportal/lib/webportal.lib.php'); +require_once DOL_DOCUMENT_ROOT . "/webportal/lib/webportal.lib.php"; // Translations $langs->loadLangs(array("admin", "webportal")); @@ -66,11 +33,6 @@ $langs->loadLangs(array("admin", "webportal")); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('webportalsetup', 'globalsetup')); -// Access control -if (!$user->admin) { - accessforbidden(); -} - // Parameters $action = GETPOST('action', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); @@ -81,10 +43,14 @@ $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); $type = 'myobject'; - $error = 0; $setupnotempty = 0; +// Access control +if (!$user->admin) { + accessforbidden(); +} + // Set this to 1 to use the factory to manage constants. Warning, the generated module will be compatible with version v15+ only $useFormSetup = 1; @@ -100,15 +66,12 @@ $item->fieldAttr = array('placeholder' => 'https://'); $item->helpText = $langs->transnoentities('WebPortalRootUrlHelp'); require_once __DIR__ . '/../class/context.class.php'; $context = Context::getInstance(); -$item->fieldOutputOverride = ' '.Context::getRootConfigUrl().''; +$item->fieldOutputOverride = ''.img_picto('', 'globe', 'class="pictofixedwidth"').Context::getRootConfigUrl().''; $formSetup->newItem('WEBPORTAL_TITLE')->defaultFieldValue = getDolGlobalString('MAIN_INFO_SOCIETE_NOM'); - - - // Enable access for the membership record $access_list = array( 'hidden' => $langs->trans('WebPortalAccessHidden'), @@ -264,7 +227,7 @@ if ($action == 'updateMask') { $form = new Form($db); $help_url = ''; -$title = "Setup"; +$title = "WebPortalSetup"; llxHeader('', $langs->trans($title), $help_url); @@ -275,10 +238,10 @@ print load_fiche_titre($langs->trans($title), $linkback, 'title_setup'); // Configuration header $head = webportalAdminPrepareHead(); -print dol_get_fiche_head($head, 'settings', $langs->trans($title), -1, "webportal@webportal"); +print dol_get_fiche_head($head, 'settings', $langs->trans($title), -1, "webportal"); // Setup page goes here -echo '' . $langs->trans("SetupPage") . ' : ' . $langs->trans('UserAccountForWebPortalAreInThirdPartyTabHelp') .'.

'; +print info_admin($langs->trans("UserAccountForWebPortalAreInThirdPartyTabHelp")); if ($action == 'edit') { print $formSetup->generateOutput(true); diff --git a/htdocs/webportal/admin/setup_theme.php b/htdocs/webportal/admin/setup_theme.php index bc6854b99ab..66566c44420 100644 --- a/htdocs/webportal/admin/setup_theme.php +++ b/htdocs/webportal/admin/setup_theme.php @@ -23,42 +23,9 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"] . "/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; -$tmp2 = realpath(__FILE__); -$i = strlen($tmp) - 1; -$j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; - $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)) . "/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1)) . "/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - -global $conf, $db, $hookmanager, $langs, $user; - -// Libraries +require_once "../../main.inc.php"; require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; -dol_include_once('/webportal/lib/webportal.lib.php'); +require_once DOL_DOCUMENT_ROOT . "/webportal/lib/webportal.lib.php"; // Translations $langs->loadLangs(array("admin", "webportal")); @@ -66,11 +33,6 @@ $langs->loadLangs(array("admin", "webportal")); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('webportalthemesetup', 'globalsetup')); -// Access control -if (!$user->admin) { - accessforbidden(); -} - // Parameters $action = GETPOST('action', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); @@ -81,6 +43,10 @@ $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); $type = 'myobject'; +// Access control +if (!$user->admin) { + accessforbidden(); +} $error = 0; $setupnotempty = 0; @@ -143,7 +109,7 @@ include DOL_DOCUMENT_ROOT . '/core/actions_setmoduleoptions.inc.php'; $form = new Form($db); $help_url = ''; -$title = "Setup"; +$title = "WebPortalSetup"; llxHeader('', $langs->trans($title), $help_url); @@ -154,10 +120,10 @@ print load_fiche_titre($langs->trans($title), $linkback, 'title_setup'); // Configuration header $head = webportalAdminPrepareHead(); -print dol_get_fiche_head($head, 'themesettings', $langs->trans($title), -1, "webportal@webportal"); +print dol_get_fiche_head($head, 'themesettings', $langs->trans($title), -1, "webportal"); // Setup page goes here -echo '' . $langs->trans("SetupPage") . ' : ' . $langs->trans('UserAccountForWebPortalAreInThirdPartyTabHelp') .'.

'; +print info_admin($langs->trans("UserAccountForWebPortalAreInThirdPartyTabHelp")); if ($action == 'edit') { print $formSetup->generateOutput(true); diff --git a/htdocs/webportal/core/modules/modWebPortal.class.php b/htdocs/webportal/core/modules/modWebPortal.class.php index 4bcb779c04a..dd088dcd2e8 100644 --- a/htdocs/webportal/core/modules/modWebPortal.class.php +++ b/htdocs/webportal/core/modules/modWebPortal.class.php @@ -81,7 +81,7 @@ class modWebPortal extends DolibarrModules // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' // To use a supported fa-xxx css style of font awesome, use this->picto='xxx' - $this->picto = 'fa-door-open_fa_#6c6aa8'; + $this->picto = 'fa-door-open'; // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) $this->module_parts = array( diff --git a/htdocs/webportal/langs/en_US/webportal.lang b/htdocs/webportal/langs/en_US/webportal.lang index aabc2150476..13a19ba4731 100644 --- a/htdocs/webportal/langs/en_US/webportal.lang +++ b/htdocs/webportal/langs/en_US/webportal.lang @@ -27,6 +27,7 @@ WebPortalDescription = Public web portal module for membership and partnership # Admin page # WebPortalSetup = WebPortal setup +WebPortalCSS=Web portal CSS Settings = Settings WebPortalSetupPage = WebPortal setup page WEBPORTAL_ROOT_URL = Public access url From f9de28a9e926aeed0001cc642a5dcfdc58963ac9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Jan 2024 12:08:28 +0100 Subject: [PATCH 5/5] Qual: The color selector use the generic Dolibarr component. --- htdocs/core/class/html.formother.class.php | 4 ++-- htdocs/core/class/html.formsetup.class.php | 12 ++++++++++-- htdocs/webportal/admin/configcss.php | 4 ++++ htdocs/webportal/admin/setup.php | 8 ++++++++ htdocs/webportal/admin/setup_theme.php | 9 +++++---- 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 60b71ca95d9..5f4eb854b31 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -849,12 +849,12 @@ class FormOther * @param int $showcolorbox 1=Show color code and color box, 0=Show only color code * @param array $arrayofcolors Array of possible colors to choose in the selector. All colors are possible if empty. Example: array('29527A','5229A3','A32929','7A367A','B1365F','0D7813') * @param string $morecss Add css style into input field - * @param string $setpropertyonselect Set this property after selecting a color + * @param string $setpropertyonselect Set this CSS property after selecting a color * @param string $default Default color * @return string * @see showColor() */ - public static function selectColor($set_color = '', $prefix = 'f_color', $form_name = '', $showcolorbox = 1, $arrayofcolors = '', $morecss = '', $setpropertyonselect = '', $default = '') + public static function selectColor($set_color = '', $prefix = 'f_color', $form_name = '', $showcolorbox = 1, $arrayofcolors = array(), $morecss = '', $setpropertyonselect = '', $default = '') { // Deprecation warning if ($form_name) { diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index c97b5939aef..a33e095e116 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -1239,8 +1239,13 @@ class FormSetupItem */ public function generateOutputFieldColor() { + global $langs; $this->fieldAttr['disabled']=null; - return $this->generateInputField(); + $color = colorArrayToHex(colorStringToArray($this->fieldValue, array()), ''); + if ($color) { + return ''; + } + return $langs->trans("Default"); } /** * generateInputFieldColor @@ -1250,7 +1255,10 @@ class FormSetupItem public function generateInputFieldColor() { $this->fieldAttr['type']= 'color'; - return $this->generateInputFieldText(); + $default = $this->defaultFieldValue; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + $formother = new FormOther($this->db); + return $formother->selectColor(colorArrayToHex(colorStringToArray($this->fieldAttr['value'], array()), ''), $this->fieldAttr['name'], '', 1, array(), '', '', $default).' '; } /** diff --git a/htdocs/webportal/admin/configcss.php b/htdocs/webportal/admin/configcss.php index 5bc8effa778..4ea291a5c72 100644 --- a/htdocs/webportal/admin/configcss.php +++ b/htdocs/webportal/admin/configcss.php @@ -38,6 +38,10 @@ $hookmanager->initHooks(array('webportalsetup', 'globalsetup')); $action = GETPOST('action', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); +if (empty($action)) { + $action = 'edit'; +} + // Access control if (!$user->admin) { accessforbidden(); diff --git a/htdocs/webportal/admin/setup.php b/htdocs/webportal/admin/setup.php index e7531e4d51b..d0870bb54de 100644 --- a/htdocs/webportal/admin/setup.php +++ b/htdocs/webportal/admin/setup.php @@ -38,6 +38,10 @@ $action = GETPOST('action', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php +if (empty($action)) { + $action = 'edit'; +} + $value = GETPOST('value', 'alpha'); $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); @@ -219,6 +223,10 @@ if ($action == 'updateMask') { } } +// Force always edit mode +if (empty($action) || $action == 'update') { + $action = 'edit'; +} /* * View diff --git a/htdocs/webportal/admin/setup_theme.php b/htdocs/webportal/admin/setup_theme.php index 66566c44420..df6a3467a7d 100644 --- a/htdocs/webportal/admin/setup_theme.php +++ b/htdocs/webportal/admin/setup_theme.php @@ -41,7 +41,6 @@ $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleopti $value = GETPOST('value', 'alpha'); $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); -$type = 'myobject'; // Access control if (!$user->admin) { @@ -60,7 +59,6 @@ if (!class_exists('FormSetup')) { $formSetup = new FormSetup($db); - require_once __DIR__ . '/../class/webPortalTheme.class.php'; $webPortalTheme = new WebPortalTheme(); @@ -92,8 +90,6 @@ $item = $formSetup->newItem('WEBPORTAL_BANNER_BACKGROUND_IS_DARK')->setAsYesNo() $setupnotempty += count($formSetup->items); -$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - /* * Actions @@ -101,6 +97,11 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); include DOL_DOCUMENT_ROOT . '/core/actions_setmoduleoptions.inc.php'; +// Force always edit mode +if (empty($action) || $action == 'update') { + $action = 'edit'; +} + /* * View