From 7c41c9a3e4aedb97742ab505afe957281e9527e2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sat, 17 Jun 2017 11:43:00 +0200 Subject: [PATCH] Fix activation of dependency for a dedicated country. BlockedLog depends now on CashDesk only. --- htdocs/admin/modules.php | 8 +++-- htdocs/core/lib/admin.lib.php | 20 ++++++------ htdocs/core/modules/modBlockedLog.class.php | 6 ++-- htdocs/core/modules/modCashDesk.class.php | 6 ++-- htdocs/core/modules/modFacture.class.php | 31 +++++++++---------- htdocs/langs/en_US/admin.lang | 6 ++-- htdocs/langs/en_US/main.lang | 3 +- .../core/modules/modMyModule.class.php | 2 ++ htdocs/theme/md/style.css.php | 1 - 9 files changed, 45 insertions(+), 38 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 5d5886b5415..d3221f40505 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -80,7 +80,7 @@ $urldolibarrmodules='https://www.dolistore.com/'; * Actions */ -if (GETPOST('buttonreset')) +if (GETPOST('buttonreset','alpha')) { $search_keyword=''; $search_status=''; @@ -738,13 +738,17 @@ if ($mode == 'common') print '<!-- This module is an external module and it may have a warning to show (note: your country is '.$mysoc->country_code.') -->'."\n"; foreach ($arrayofwarningsext as $keymodule => $arrayofwarningsextbycountry) { - if (! empty($modules[$keymodule]->const_name)) // If module that request warning is on + $keymodulelowercase=strtolower(preg_replace('/^mod/','',$keymodule)); + if (in_array($keymodulelowercase, $conf->modules)) // If module that request warning is on { foreach ($arrayofwarningsextbycountry as $keycountry => $cursorwarningmessage) { if ($keycountry == 'always' || $keycountry == $mysoc->country_code) { $warningmessage .= ($warningmessage?"\n":"").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code, $modules[$keymodule]->getName()); + $warningmessage .= ($warningmessage?"\n":"").($warningmessage?"\n":"").$langs->trans("Module").' : '.$objMod->getName(); + if (! empty($objMod->editor_name)) $warningmessage .= ($warningmessage?"\n":"").$langs->trans("Publisher").' : '.$objMod->editor_name; + if (! empty($objMod->editor_name)) $warningmessage .= ($warningmessage?"\n":"").$langs->trans("ModuleTriggeringThisWarning").' : '.$modules[$keymodule]->getName(); } } } diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index ba5f099365c..e90f006ac7e 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -756,7 +756,7 @@ function purgeSessions($mysessionid) */ function activateModule($value,$withdeps=1) { - global $db, $modules, $langs, $conf; + global $db, $modules, $langs, $conf, $mysoc; // Check parameters if (empty($value)) { @@ -813,7 +813,7 @@ function activateModule($value,$withdeps=1) } $result=$objMod->init(); // Enable module - if ($result <= 0) + if ($result <= 0) { $ret['errors'][]=$objMod->error; } @@ -848,19 +848,19 @@ function activateModule($value,$withdeps=1) break; } } - + if ($activate) { $ret['nbmodules']+=$resarray['nbmodules']; $ret['nbperms']+=$resarray['nbperms']; } - else + else { $ret['errors'][] = $langs->trans('activateModuleDependNotSatisfied', $objMod->name, $modulestring); } } } - + if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && ! empty($objMod->conflictwith)) { // Desactivation des modules qui entrent en conflit @@ -879,12 +879,12 @@ function activateModule($value,$withdeps=1) } } - if (! count($ret['errors'])) + if (! count($ret['errors'])) { $ret['nbmodules']++; $ret['nbperms']+=count($objMod->rights); } - + return $ret; } @@ -1221,7 +1221,7 @@ function form_constantes($tableau, $strictw3c=0, $helptext='') if ($result) { $obj = $db->fetch_object($result); // Take first result of select - + // For avoid warning in strict mode if (empty($obj)) { @@ -1360,7 +1360,7 @@ function showModulesExludedForExternal($modules) //if (empty($conf->global->$moduleconst)) continue; if (! in_array($modulename,$listofmodules)) continue; //var_dump($modulename.'eee'.$langs->trans('Module'.$module->numero.'Name')); - + if ($i > 0) $text.=', '; else $text.=' '; $i++; @@ -1391,7 +1391,7 @@ function addDocumentModel($name, $type, $label='', $description='') $sql.= ($label?"'".$db->escape($label)."'":'null').", "; $sql.= (! empty($description)?"'".$db->escape($description)."'":"null"); $sql.= ")"; - + dol_syslog("admin.lib::addDocumentModel", LOG_DEBUG); $resql=$db->query($sql); if ($resql) diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index f3f3be971b5..3125627c007 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -65,9 +65,9 @@ class modBlockedLog extends DolibarrModules // Dependancies //------------- $this->hidden = false; // A condition to disable module - $this->depends = array('modFacture'); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->conflictwith = array(); // List of modules id this module is in conflict with + $this->depends = array('always'=>'modFacture'); // List of modules id that must be enabled if this module is enabled + $this->requiredby = array(); // List of modules id to disable if this one is disabled + $this->conflictwith = array(); // List of modules id this module is in conflict with $this->langfiles = array(); // Constants diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php index ec8764c9017..e5ba473c1c7 100644 --- a/htdocs/core/modules/modCashDesk.class.php +++ b/htdocs/core/modules/modCashDesk.class.php @@ -65,11 +65,13 @@ class modCashDesk extends DolibarrModules $this->config_page_url = array("cashdesk.php@cashdesk"); // Dependencies - $this->depends = array("modBanque","modFacture","modProduct"); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled + $this->depends = array('always'=>"modBanque", 'always'=>"modFacture", 'always'=>"modProduct", 'FR'=>'modBlockedLog'); // List of modules id that must be enabled if this module is enabled + $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->phpmin = array(4,1); // Minimum version of PHP required by module $this->need_dolibarr_version = array(2,4); // Minimum version of Dolibarr required by module $this->langfiles = array("cashdesk"); + $this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text') + $this->warnings_activation_ext = array('FR'=>'WarningInstallationMayBecomeNotCompliantWithLaw'); // Warning to show when we activate an external module. array('always'='text') or array('FR'='text') // Constants $this->const = array(); diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 3af85a1944d..40e2a03d161 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -64,14 +64,13 @@ class modFacture extends DolibarrModules $this->dirs = array("/facture/temp"); // Dependencies - $this->depends = array('always'=>"modSociete", 'FR'=>'modBlockedLog'); + $this->depends = array('always'=>"modSociete"); $this->requiredby = array("modComptabilite","modAccounting"); $this->conflictwith = array(); $this->langfiles = array("bills","companies","compta","products"); - $this->warnings_activation = array('FR'=>'WarningNoteModuleInvoiceForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text') - $this->warnings_activation = array(); - $this->warnings_activation_ext = array('FR'=>'WarningInstallationMayBecomeNotCompliantWithLaw'); // Warning to show when we activate an external module. array('always'='text') or array('FR'='text') - + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='text') + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='text') + // Config pages $this->config_page_url = array("facture.php"); @@ -99,7 +98,7 @@ class modFacture extends DolibarrModules $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; - + /*$this->const[$r][0] = "FACTURE_DRAFT_WATERMARK"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "__(Draft)__"; @@ -107,7 +106,7 @@ class modFacture extends DolibarrModules $this->const[$r][4] = 0; $r++;*/ - + // Boxes //$this->boxes = array(0=>array(1=>'box_factures_imp.php'),1=>array(1=>'box_factures.php')); $this->boxes = array( @@ -116,16 +115,16 @@ class modFacture extends DolibarrModules 2=>array('file'=>'box_graph_invoices_permonth.php','enabledbydefaulton'=>'Home') ); - // Cronjobs + // Cronjobs $this->cronjobs = array( - 0=>array('label'=>'RecurringInvoices', 'jobtype'=>'method', 'class'=>'compta/facture/class/facture-rec.class.php', 'objectname'=>'FactureRec', 'method'=>'createRecurringInvoices', 'parameters'=>'', 'comment'=>'Generate recurring invoices', 'frequency'=>1, 'unitfrequency'=>3600*24), + 0=>array('label'=>'RecurringInvoices', 'jobtype'=>'method', 'class'=>'compta/facture/class/facture-rec.class.php', 'objectname'=>'FactureRec', 'method'=>'createRecurringInvoices', 'parameters'=>'', 'comment'=>'Generate recurring invoices', 'frequency'=>1, 'unitfrequency'=>3600*24), // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>3600, 'unitfrequency'=>3600) - ); - // List of cron jobs entries to add - // Example: + ); + // List of cron jobs entries to add + // Example: // $this->cronjobs=array( - // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600), - // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600) + // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600) // ); // Permissions @@ -206,8 +205,8 @@ class modFacture extends DolibarrModules // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - + + // Exports //-------- $r=1; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 1aa79c2dced..0ba5ab270bc 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -104,7 +104,7 @@ MenuIdParent=Parent menu ID DetailMenuIdParent=ID of parent menu (empty for a top menu) DetailPosition=Sort number to define menu position AllMenus=All -NotConfigured=Module not configured +NotConfigured=Module/Application not configured Active=Active SetupShort=Setup OtherOptions=Other options @@ -114,7 +114,6 @@ CurrentValueSeparatorThousand=Thousand separator Destination=Destination IdModule=Module ID IdPermissions=Permissions ID -Modules=Modules LanguageBrowserParameter=Parameter %s LocalisationDolibarrParameters=Localisation parameters ClientTZ=Client Time Zone (user) @@ -1700,7 +1699,8 @@ UserHasNoPermissions=This user has no permission defined TypeCdr=Use "None" if the date of payment term is date of invoice plus a delta in days (delta is field "Nb of days")<br>Use "At end of month", if, after delta, the date must be increased to reach the end of month (+ an optional "Offset" in days)<br>Use "Current/Next" to have payment term date being the first Nth of the month (N is stored into field "Nb of days") BaseCurrency=Reference currency of the company (go into setup of company to change this) WarningNoteModuleInvoiceForFrenchLaw=This module %s is compliant with french laws (Loi Finance 2016). -WarningInstallationMayBecomeNotCompliantWithLaw=You try to install the module %s that is an external module. Activating an external module means you trust the editor of the module and you are sure that this module does not alterate negatively the behavior of your application and is compliant with laws of your country (%s). If the module bring a non legal feature, you become responsible for the use of a non legal software. +WarningNoteModulePOSForFrenchLaw=This module %s is compliant with french laws (Loi Finance 2016) because module Non Reversible Logs is automatically activated. +WarningInstallationMayBecomeNotCompliantWithLaw=You try to install the module %s that is an external module. Activating an external module means you trust the publisher of the module and you are sure that this module does not alterate negatively the behavior of your application and is compliant with laws of your country (%s). If the module bring a non legal feature, you become responsible for the use of a non legal software. ##### Resource #### ResourceSetup=Configuration du module Resource UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 8ea14fdb305..a35342f2af9 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -366,7 +366,8 @@ VATRate=Tax Rate Average=Average Sum=Sum Delta=Delta -Module=Module +Module=Module/Application +Modules=Modules/Applications Option=Option List=List FullList=Full list diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index dc98c327cb3..60889bdf279 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -114,6 +114,8 @@ class modMyModule extends DolibarrModules $this->phpmin = array(5,0); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module $this->langfiles = array("mymodule@mymodule"); + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) // Constants // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 5fbd8455919..e96fa032538 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2528,7 +2528,6 @@ div.pagination li.noborder a:hover { div.pagination li a, div.pagination li span { background-color: #fff; - border: 1px solid #ddd; } div.pagination li:first-child a, div.pagination li:first-child span { -- GitLab