diff --git a/htdocs/bookcal/availabilities_agenda.php b/htdocs/bookcal/availabilities_agenda.php index 743eb5cb3b7..44cc15c3fdb 100644 --- a/htdocs/bookcal/availabilities_agenda.php +++ b/htdocs/bookcal/availabilities_agenda.php @@ -17,7 +17,7 @@ */ /** - * \file availabilities_agenda.php + * \file htdocs/bookcal/availabilities_agenda.php * \ingroup bookcal * \brief Tab of events on Availabilities */ diff --git a/htdocs/bookcal/availabilities_card.php b/htdocs/bookcal/availabilities_card.php index f1ebb871af7..dc62fa0f2e0 100644 --- a/htdocs/bookcal/availabilities_card.php +++ b/htdocs/bookcal/availabilities_card.php @@ -17,9 +17,9 @@ */ /** - * \file availabilities_card.php - * \ingroup bookcal - * \brief Page to create/edit/view availabilities + * \file htdocs/bookcal/availabilities_card.php + * \ingroup bookcal + * \brief Page to create/edit/view availabilities */ // Load Dolibarr environment @@ -36,7 +36,7 @@ $langs->loadLangs(array("agenda", "other")); // Get parameters $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$lineid = GETPOST('lineid', 'int'); +$lineid = GETPOST('lineid', 'int'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); diff --git a/htdocs/bookcal/availabilities_contact.php b/htdocs/bookcal/availabilities_contact.php index cef8bd0367c..4b24db76ad4 100644 --- a/htdocs/bookcal/availabilities_contact.php +++ b/htdocs/bookcal/availabilities_contact.php @@ -17,9 +17,9 @@ */ /** - * \file availabilities_contact.php - * \ingroup bookcal - * \brief Tab for contacts linked to Availabilities + * \file htdocs/bookcal/availabilities_contact.php + * \ingroup bookcal + * \brief Tab for contacts linked to Availabilities */ // Load Dolibarr environment diff --git a/htdocs/bookcal/availabilities_document.php b/htdocs/bookcal/availabilities_document.php index 301ccdc2eae..830813d5fcb 100644 --- a/htdocs/bookcal/availabilities_document.php +++ b/htdocs/bookcal/availabilities_document.php @@ -17,9 +17,9 @@ */ /** - * \file availabilities_document.php - * \ingroup bookcal - * \brief Tab for documents linked to Availabilities + * \file htdocs/bookcal/availabilities_document.php + * \ingroup bookcal + * \brief Tab for documents linked to Availabilities */ // Load Dolibarr environment diff --git a/htdocs/bookcal/availabilities_list.php b/htdocs/bookcal/availabilities_list.php index c53ff3bd17d..cf79f93e96e 100644 --- a/htdocs/bookcal/availabilities_list.php +++ b/htdocs/bookcal/availabilities_list.php @@ -17,9 +17,9 @@ */ /** - * \file availabilities_list.php - * \ingroup bookcal - * \brief List page for availabilities + * \file htdocs/bookcal/availabilities_list.php + * \ingroup bookcal + * \brief List page for availabilities */ // Load Dolibarr environment diff --git a/htdocs/bookcal/availabilities_note.php b/htdocs/bookcal/availabilities_note.php index dea5fee7625..7dd390d1fa2 100644 --- a/htdocs/bookcal/availabilities_note.php +++ b/htdocs/bookcal/availabilities_note.php @@ -17,9 +17,9 @@ */ /** - * \file availabilities_note.php - * \ingroup bookcal - * \brief Tab for notes on Availabilities + * \file htdocs/bookcal/availabilities_note.php + * \ingroup bookcal + * \brief Tab for notes on Availabilities */ // Load Dolibarr environment diff --git a/htdocs/bookcal/booking_agenda.php b/htdocs/bookcal/booking_agenda.php index af078bff0e1..62346d66721 100644 --- a/htdocs/bookcal/booking_agenda.php +++ b/htdocs/bookcal/booking_agenda.php @@ -17,9 +17,9 @@ */ /** - * \file booking_agenda.php - * \ingroup bookcal - * \brief Tab of events on Booking + * \file htdocs/bookcal/booking_agenda.php + * \ingroup bookcal + * \brief Tab of events on Booking */ // Load Dolibarr environment diff --git a/htdocs/bookcal/booking_card.php b/htdocs/bookcal/booking_card.php index fd8ddbc4614..f85331cc801 100644 --- a/htdocs/bookcal/booking_card.php +++ b/htdocs/bookcal/booking_card.php @@ -17,9 +17,9 @@ */ /** - * \file booking_card.php - * \ingroup bookcal - * \brief Page to create/edit/view booking + * \file htdocs/bookcal/booking_card.php + * \ingroup bookcal + * \brief Page to create/edit/view booking */ // Load Dolibarr environment diff --git a/htdocs/bookcal/booking_contact.php b/htdocs/bookcal/booking_contact.php index e1954ce07a3..938e3287c70 100644 --- a/htdocs/bookcal/booking_contact.php +++ b/htdocs/bookcal/booking_contact.php @@ -17,9 +17,9 @@ */ /** - * \file booking_contact.php - * \ingroup bookcal - * \brief Tab for contacts linked to Booking + * \file htdocs/bookcal/booking_contact.php + * \ingroup bookcal + * \brief Tab for contacts linked to Booking */ // Load Dolibarr environment diff --git a/htdocs/bookcal/booking_document.php b/htdocs/bookcal/booking_document.php index 83031edec2b..d04258d54d2 100644 --- a/htdocs/bookcal/booking_document.php +++ b/htdocs/bookcal/booking_document.php @@ -17,9 +17,9 @@ */ /** - * \file booking_document.php - * \ingroup bookcal - * \brief Tab for documents linked to Booking + * \file htdocs/bookcal/booking_document.php + * \ingroup bookcal + * \brief Tab for documents linked to Booking */ // Load Dolibarr environment diff --git a/htdocs/bookcal/booking_list.php b/htdocs/bookcal/booking_list.php index d8c333a8f61..a141f33a909 100644 --- a/htdocs/bookcal/booking_list.php +++ b/htdocs/bookcal/booking_list.php @@ -17,9 +17,9 @@ */ /** - * \file booking_list.php - * \ingroup bookcal - * \brief List page for booking + * \file htdocs/bookcal/booking_list.php + * \ingroup bookcal + * \brief List page for booking */ // Load Dolibarr environment diff --git a/htdocs/bookcal/booking_note.php b/htdocs/bookcal/booking_note.php index a194d084fe1..b72c0fbe6d1 100644 --- a/htdocs/bookcal/booking_note.php +++ b/htdocs/bookcal/booking_note.php @@ -17,9 +17,9 @@ */ /** - * \file booking_note.php - * \ingroup bookcal - * \brief Tab for notes on Booking + * \file htdocs/bookcal/booking_note.php + * \ingroup bookcal + * \brief Tab for notes on Booking */ // Load Dolibarr environment @@ -31,9 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_booking.lib.php'; $langs->loadLangs(array("agenda", "companies")); // Get parameters -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index de26ad0462d..1d930013c1c 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -1020,3 +1020,116 @@ function reWriteAllMenus($file, $menus, $menuWantTo, $key, $action) return 1; }return -1; } + +/** + * Creates a new dictionary table. + * + * for creating a new dictionary table in Dolibarr. It generates the necessary SQL code to define the table structure, + * including columns such as 'rowid', 'code', 'label', 'position', 'use_default', 'active', etc. The table name is constructed based on the provided $namedic parameter. + * + * @param string $modulename The lowercase name of the module for which the dictionary table is being created. + * @param string $file The file path to the Dolibarr module builder file where the dictionaries are defined. + * @param string $namedic The name of the dictionary, which will also be used as the base for the table name. + * @param array|null $dictionnaires An optional array containing pre-existing dictionary data, including 'tabname', 'tablib', 'tabsql', etc. + * @return void + */ +function createNewDictionnary($modulename, $file, $namedic, $dictionnaires = null) +{ + global $db, $langs; + + if (empty($namedic)) { + setEventMessages($langs->trans("ErrorEmptyNameDic"), null, 'errors'); + return; + } + if (!file_exists($file)) { + return -1; + } + $modulename = strtolower($modulename); + + if (empty($dictionnaires)) { + $dictionnaires = array('tabname' => array(), 'tablib' => array(), 'tabsql' => array(), 'tabsqlsort' => array(), 'tabfield' => array(), 'tabfieldvalue' => array(), 'tabfieldinsert' => array(), 'tabrowid' => array(), 'tabcond' => array(), 'tabhelp' => array()); + } + + $columns = array( + 'rowid' => array('type' => 'integer(11)'), + 'code' => array('type' => 'varchar(255) NOT NULL'), + 'label' => array('type' => 'varchar(255) NOT NULL'), + 'position' => array('type' => 'integer(11) NULL'), + 'use_default' => array('type' => 'varchar(255) DEFAULT 1'), + 'active' => array('type' => 'integer') + ); + + + $primaryKey = 'rowid'; + foreach ($columns as $key => $value) { + if ($key === 'rowid') { + $primaryKey = 'rowid'; + break; + } + if (!array_key_exists('rowid', $columns)) { + $primaryKey = array_key_first($columns); + break; + } + } + // check if tablename exist in Database + $query = "SHOW TABLES LIKE '" . MAIN_DB_PREFIX.strtolower($namedic) . "'"; + $checkTable = $db->query($query); + if ($checkTable && $db->num_rows($checkTable) > 0) { + setEventMessages($langs->trans("ErrorTableExist", $namedic), null, 'errors'); + return; + } else { + $_results = $db->DDLCreateTable(MAIN_DB_PREFIX.strtolower($namedic), $columns, $primaryKey, "InnoDB"); + if ($_results < 0) { + dol_print_error($db); + $langs->load("errors"); + setEventMessages($langs->trans("ErrorTableNotFound", $namedic), null, 'errors'); + } + } + + // rewrite dictionnary if + $dictionnaires['tabname'][] = $namedic; + $dictionnaires['tablib'][] = ucfirst(substr($namedic, 2)); + $dictionnaires['tabsql'][] = 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.strtolower($namedic).' as f'; + $dictionnaires['tabsqlsort'][] = (array_key_exists('label', $columns) ? 'label ASC' : ''); + $dictionnaires['tabfield'][] = (array_key_exists('code', $columns) && array_key_exists('label', $columns) ? 'code,label' : ''); + $dictionnaires['tabfieldvalue'][] = (array_key_exists('code', $columns) && array_key_exists('label', $columns) ? 'code,label' : ''); + $dictionnaires['tabfieldinsert'][] = (array_key_exists('code', $columns) && array_key_exists('label', $columns) ? 'code,label' : ''); + $dictionnaires['tabrowid'][] = $primaryKey; + $dictionnaires['tabcond'][] = isModEnabled('$modulename'); + $dictionnaires['tabhelp'][] = (array_key_exists('code', $columns) ? array('code'=>$langs->trans('CodeTooltipHelp'), 'field2' => 'field2tooltip') : ''); + + // Build the dictionary string + $dicData = "\t\t\$this->dictionaries=array(\n"; + + foreach ($dictionnaires as $key => $value) { + $dicData .= "\t\t\t'$key'=>"; + + if ($key === 'tabcond') { + $conditions = array_map(function ($val) use ($modulename) { + return ($val === true || $val === false) ? "isModEnabled('$modulename')" : $val; + }, $value); + $dicData .= "array(" . implode(",", $conditions) . ")"; + } elseif ($key === 'tabhelp') { + $helpItems = array(); + foreach ($value as $helpValue) { + $helpItems[] = "array('code'=>\$langs->trans('".$helpValue['code']."'), 'field2' => 'field2tooltip')"; + } + $dicData .= "array(" . implode(",", $helpItems) . ")"; + } else { + if (is_array($value)) { + $dicData .= "array(" . implode(",", array_map(function ($val) { + return "'$val'"; + }, $value)) . ")"; + } else { + $dicData .= "'$value'"; + } + } + $dicData .= ",\n"; + } + $dicData .= "\t\t);"; + $stringDic = getFromFile($file, '/* BEGIN MODULEBUILDER DICTIONARIES */', '/* END MODULEBUILDER DICTIONARIES */'); + $writeInfile = dolReplaceInFile($file, array($stringDic => $dicData."\n")); + if ($writeInfile > 0) { + setEventMessages($langs->trans("DictionariesCreated", ucfirst(substr($namedic, 2))), null); + } +} diff --git a/htdocs/core/triggers/interface_20_all_Logevents.class.php b/htdocs/core/triggers/interface_20_all_Logevents.class.php index 3b9d59778e9..acf250f9faa 100644 --- a/htdocs/core/triggers/interface_20_all_Logevents.class.php +++ b/htdocs/core/triggers/interface_20_all_Logevents.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2009 Laurent Destailleur * Copyright (C) 2009-2017 Regis Houssin * Copyright (C) 2014 Marcos García + * Copyright (C) 2023 Udo Tamm * * 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 @@ -20,7 +21,7 @@ /** * \file htdocs/core/triggers/interface_20_all_Logevents.class.php * \ingroup core - * \brief Trigger file for + * \brief Trigger file for log events */ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; @@ -40,12 +41,11 @@ class InterfaceLogevents extends DolibarrTriggers { $this->db = $db; - $this->name = preg_replace('/^Interface/i', '', get_class($this)); - $this->family = "core"; - $this->description = "Triggers of this module allows to add security event records inside Dolibarr."; - // 'development', 'experimental', 'dolibarr' or version - $this->version = self::VERSION_DOLIBARR; - $this->picto = 'technic'; + $this->name = preg_replace('/^Interface/i', '', get_class($this)); + $this->family = "core"; + $this->description = "Triggers of this module allows to add security event records inside Dolibarr."; + $this->version = self::VERSION_DOLIBARR; // VERSION_ 'DEVELOPMENT' or 'EXPERMENTAL' or 'DOLIBARR' + $this->picto = 'technic'; } /** @@ -77,54 +77,59 @@ class InterfaceLogevents extends DolibarrTriggers $date = dol_now(); - // Actions + /* Actions */ + + $txt = $action; + $langs->load("users"); + + // USER_LOGIN if ($action == 'USER_LOGIN') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - - $langs->load("users"); - // Initialisation donnees (date,duree,texte,desc) + // Initialize data (date,duree,text,desc) $text = "(UserLogged,".$object->login.")"; $text .= (empty($object->trigger_mesg) ? '' : ' - '.$object->trigger_mesg); $desc = "(UserLogged,".$object->login.")"; $desc .= (empty($object->trigger_mesg) ? '' : ' - '.$object->trigger_mesg); + + // USER_LOGIN_FAILED } elseif ($action == 'USER_LOGIN_FAILED') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - - // Initialisation donnees (date,duree,texte,desc) + // Initialize data (date,duree,text,desc) $text = $object->trigger_mesg; // Message direct $desc = $object->trigger_mesg; // Message direct + + // USER_LOGOUT } elseif ($action == 'USER_LOGOUT') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - - $langs->load("users"); - // Initialisation donnees (date,duree,texte,desc) + // Initialize data (date,duree,text,desc) $text = "(UserLogoff,".$object->login.")"; $desc = "(UserLogoff,".$object->login.")"; + + // USER_CREATE } elseif ($action == 'USER_CREATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - $langs->load("users"); - - // Initialisation donnees (date,duree,texte,desc) + // Initialize data (date,duree,text,desc) $text = $langs->transnoentities("NewUserCreated", $object->login); $desc = $langs->transnoentities("NewUserCreated", $object->login); + + // USER_MODIFY } elseif ($action == 'USER_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - $langs->load("users"); - - // Initialisation donnees (date,duree,texte,desc) + // Initialize data (date,duree,text,desc) $text = $langs->transnoentities("EventUserModified", $object->login); $desc = $langs->transnoentities("EventUserModified", $object->login); + + // USER_NEW_PASSWORD } elseif ($action == 'USER_NEW_PASSWORD') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - $langs->load("users"); - - // Initialisation donnees (date,duree,texte,desc) + // Initialize data (date,duree,text,desc) $text = $langs->transnoentities("NewUserPassword", $object->login); $desc = $langs->transnoentities("NewUserPassword", $object->login); + + // USER ENABLED/DISABLED } elseif ($action == 'USER_ENABLEDISABLE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - $langs->load("users"); - // Initialisation donnees (date,duree,texte,desc) + // Initialize data (date,duree,text,desc) if ($object->statut == 0) { $text = $langs->transnoentities("UserEnabled", $object->login); $desc = $langs->transnoentities("UserEnabled", $object->login); @@ -133,42 +138,36 @@ class InterfaceLogevents extends DolibarrTriggers $text = $langs->transnoentities("UserDisabled", $object->login); $desc = $langs->transnoentities("UserDisabled", $object->login); } + + // USER_DELETE } elseif ($action == 'USER_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - $langs->load("users"); - // Initialisation donnees (date,duree,texte,desc) + // Initialize data (date,duree,text,desc) $text = $langs->transnoentities("UserDeleted", $object->login); $desc = $langs->transnoentities("UserDeleted", $object->login); + + // USERGROUP_CREATE } elseif ($action == 'USERGROUP_CREATE') { - // Groups dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - $langs->load("users"); - // Initialisation donnees (date,duree,texte,desc) + // Initialize data (date,duree,text,desc) $text = $langs->transnoentities("NewGroupCreated", $object->name); $desc = $langs->transnoentities("NewGroupCreated", $object->name); + + // USERGROUP_MODIFY } elseif ($action == 'USERGROUP_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - $langs->load("users"); - // Initialisation donnees (date,duree,texte,desc) + // Initialize data (date,duree,text,desc) $text = $langs->transnoentities("GroupModified", $object->name); $desc = $langs->transnoentities("GroupModified", $object->name); + + // USERGROUP_DELETE } elseif ($action == 'USERGROUP_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - $langs->load("users"); - // Initialisation donnees (date,duree,texte,desc) + // Initialize data (date,duree,text,desc) $text = $langs->transnoentities("GroupDeleted", $object->name); $desc = $langs->transnoentities("GroupDeleted", $object->name); } - // If not found - /* - else - { - dol_syslog("Trigger '".$this->name."' for action '$action' was ran by ".__FILE__." but no handler found for this action."); - return 0; - } - */ - // Add more information into desc from the context property if (!empty($desc) && !empty($object->context['audit'])) { $desc .= ' - '.$object->context['audit']; diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 17d8e51dc60..247a03563c6 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -912,7 +912,7 @@ if (!empty($id) && $action != 'edit') { if ($object->statut == $object::STATUS_CANCELED || $object->statut == $object::STATUS_DRAFT) { print '"; } else { - print '"; + print '"; } } else { print '"; diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 571802e6d5f..01e944c4051 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -318,7 +318,7 @@ ErrorTheUrlOfYourDolInstanceDoesNotMatchURLIntoOAuthSetup=Error: The URL of you ErrorMenuExistValue=A Menu already exist with this Title or URL ErrorSVGFilesNotAllowedAsLinksWithout=SVG files are not allowed as external links without the option %s ErrorTypeMenu=Impossible to add another menu for the same module on the navbar, not handle yet - +ErrorTableExist=Table %s already exist # Warnings WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup. WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user. diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 02fb5b5d6a9..4bd66be5d57 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -176,4 +176,5 @@ MenuUpdatedSuccessfuly=Menu has been successfully updated ApiObjectDeleted=API for object %s has been successfully deleted CRUDRead=Read CRUDCreateWrite=Create or Update -FailedToAddCodeIntoDescriptor=Failed to add code into descriptor. Check that the string comment "%s" is still present into the file. \ No newline at end of file +FailedToAddCodeIntoDescriptor=Failed to add code into descriptor. Check that the string comment "%s" is still present into the file. +DictionariesCreated=Dictionary %s created successfully \ No newline at end of file diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang index d81be42b602..22d141795b0 100644 --- a/htdocs/langs/fr_FR/errors.lang +++ b/htdocs/langs/fr_FR/errors.lang @@ -317,6 +317,7 @@ ErrorTheUrlOfYourDolInstanceDoesNotMatchURLIntoOAuthSetup=Erreur : L'URL de vot ErrorMenuExistValue=Un menu existe déjà avec ce titre ou cette URL ErrorSVGFilesNotAllowedAsLinksWithout=Les fichiers SVG ne sont pas autorisés en tant que liens externes sans l'option %s ErrorTypeMenu=Impossible d'ajouter un autre menu pour le même module sur la barre de navigation, pas encore géré +ErrorTableExist=La table %s existe déja # Warnings WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Votre paramètre PHP upload_max_filesize (%s) est supérieur au paramètre PHP post_max_size (%s). Ceci n'est pas une configuration cohérente. diff --git a/htdocs/langs/fr_FR/modulebuilder.lang b/htdocs/langs/fr_FR/modulebuilder.lang index 5fa2c474900..f5aefbc4e38 100644 --- a/htdocs/langs/fr_FR/modulebuilder.lang +++ b/htdocs/langs/fr_FR/modulebuilder.lang @@ -177,3 +177,4 @@ ApiObjectDeleted=L'API pour l'objet %s a été supprimée avec succès CRUDRead=Lire CRUDCreateWrite=Créer ou mettre à jour FailedToAddCodeIntoDescriptor=Échec de l'ajout de code dans le descripteur. Vérifiez que le commentaire de chaîne "%s" est toujours présent dans le fichier. +DictionariesCreated = Le dictionnaire %s a été créé avec succès \ No newline at end of file diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index edead052752..680e61730f3 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1553,15 +1553,39 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { // Add a dictionary if ($dirins && $action == 'initdic' && $module && $dicname) { + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; + $destdir = $dirins.'/'.strtolower($module); + $moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; + if (!$error) { $newdicname = $dicname; if (!preg_match('/^c_/', $newdicname)) { $newdicname = 'c_'.$dicname; } + dol_include_once($pathtofile); + $class = 'mod'.$module; - // TODO - - setEventMessages($langs->trans("FeatureNotYetAvailable"), null, 'errors'); + if (class_exists($class)) { + try { + $moduleobj = new $class($db); + } catch (Exception $e) { + $error++; + dol_print_error($db, $e->getMessage()); + } + } else { + $error++; + $langs->load("errors"); + dol_print_error($db, $langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module)); + exit; + } + $dictionaries = $moduleobj->dictionaries; + createNewDictionnary($module, $moduledescriptorfile, $newdicname, $dictionaries); + if (function_exists('opcache_invalidate')) { + opcache_reset(); // remove the include cache hell ! + } + clearstatcache(true); + header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ? '@'.$dirread : '')); + exit; } } @@ -4088,6 +4112,7 @@ if ($module == 'initmodule') { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $dicts = $moduleobj->dictionaries; + //var_dump($dicts);exit; if ($action != 'editfile' || empty($file)) { print ''; @@ -4217,11 +4242,11 @@ if ($module == 'initmodule') { print $dicts['tabfieldinsert'][$i]; print ''; - print ''; + print ''; print $dicts['tabrowid'][$i]; print ''; - print ''; + print ''; print $dicts['tabcond'][$i]; print ''; @@ -4250,8 +4275,8 @@ if ($module == 'initmodule') { print ''.$langs->trans("EnterNameOfDictionaryDesc").'

'; print '
'; - //print '
'; - //print '
'; + // print '
'; + // print '
'; print ''; /*print '
'; print '
'; diff --git a/htdocs/projet/comment.php b/htdocs/projet/comment.php index 7103916cdb4..fa71bc2aa72 100644 --- a/htdocs/projet/comment.php +++ b/htdocs/projet/comment.php @@ -18,9 +18,9 @@ */ /** - * \file htdocs/projet/tasks/task.php + * \file htdocs/projet/comment.php * \ingroup project - * \brief Page of a project task + * \brief Page of a project */ // Load Dolibarr environment diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 0669ba9f61b..bca52b73045 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -37,71 +37,72 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -if (isModEnabled('stock')) { - require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; + +if (isModEnabled('agenda')) { + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; } -if (isModEnabled("propal")) { - require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (isModEnabled('banque')) { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; +} +if (isModEnabled('categorie')) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +} +if (isModEnabled('commande')) { + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +} +if (isModEnabled('contrat')) { + require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; +} +if (isModEnabled('deplacement')) { + require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; +} +if (isModEnabled('don')) { + require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; +} +if (isModEnabled('expedition')) { + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; +} +if (isModEnabled('expensereport')) { + require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; } if (isModEnabled('facture')) { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; } -if (isModEnabled('commande')) { - require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -} -if (isModEnabled('supplier_proposal')) { - require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; -} -if (isModEnabled("supplier_invoice")) { - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -} -if (isModEnabled("supplier_order")) { - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -} -if (isModEnabled('contrat')) { - require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; -} if (isModEnabled('ficheinter')) { require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; } -if (isModEnabled("expedition")) { - require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; -} -if (isModEnabled('deplacement')) { - require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; -} -if (isModEnabled('expensereport')) { - require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; -} -if (isModEnabled('agenda')) { - require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; -} -if (isModEnabled('don')) { - require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; -} if (isModEnabled('loan')) { require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; } -if (isModEnabled('stock')) { - require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; +if (isModEnabled('mrp')) { + require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; } -if (isModEnabled('tax')) { - require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; -} -if (isModEnabled("banque")) { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; +if (isModEnabled('propal')) { + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; } if (isModEnabled('salaries')) { require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php'; } -if (isModEnabled('categorie')) { - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +if (isModEnabled('stock')) { + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; } -if (isModEnabled('mrp')) { - require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; +if (isModEnabled('supplier_invoice')) { + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; } +if (isModEnabled('supplier_order')) { + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +} +if (isModEnabled('supplier_proposal')) { + require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; +} +if (isModEnabled('tax')) { + require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; +} + + // Load translation files required by the page $langs->loadLangs(array('projects', 'companies', 'suppliers', 'compta')); diff --git a/htdocs/projet/tasks/comment.php b/htdocs/projet/tasks/comment.php index 4540112f4c3..5199c026b93 100644 --- a/htdocs/projet/tasks/comment.php +++ b/htdocs/projet/tasks/comment.php @@ -18,9 +18,9 @@ */ /** - * \file htdocs/projet/tasks/task.php + * \file htdocs/projet/tasks/comment.php * \ingroup project - * \brief Page of a project task + * \brief Page of a project task comment */ require "../../main.inc.php";