diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php
index 751cbce81e9..62533ced467 100644
--- a/htdocs/admin/fichinter.php
+++ b/htdocs/admin/fichinter.php
@@ -495,7 +495,6 @@ print "
";
/*
* Other options
- *
*/
print load_fiche_titre($langs->trans("OtherOptions"),'','');
diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php
index 1d4b5cee8d4..36b0d4d0df1 100644
--- a/htdocs/admin/limits.php
+++ b/htdocs/admin/limits.php
@@ -101,25 +101,24 @@ if ($action == 'edit')
print '';
clearstatcache();
- $var=true;
print '
';
print '| '.$langs->trans("Parameter").' | '.$langs->trans("Value").' |
';
-
+
print '| ';
print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_UNIT"),$langs->trans("ParameterActiveForNextInputOnly"));
print ' | |
';
-
+
print '| ';
print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_TOT"),$langs->trans("ParameterActiveForNextInputOnly"));
print ' | |
';
-
+
print '| '.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").' | |
';
-
+
print '| ';
print $form->textwithpicto($langs->trans("MAIN_ROUNDING_RULE_TOT"),$langs->trans("ParameterActiveForNextInputOnly"));
print ' | |
';
@@ -135,25 +134,23 @@ if ($action == 'edit')
}
else
{
- $var=true;
-
print '';
print '| '.$langs->trans("Parameter").' | '.$langs->trans("Value").' |
';
-
+
print '| ';
print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_UNIT"),$langs->trans("ParameterActiveForNextInputOnly"));
print ' | '.$conf->global->MAIN_MAX_DECIMALS_UNIT.' |
';
-
+
print '| ';
print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_TOT"),$langs->trans("ParameterActiveForNextInputOnly"));
print ' | '.$conf->global->MAIN_MAX_DECIMALS_TOT.' |
';
-
+
print '| '.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").' | '.$conf->global->MAIN_MAX_DECIMALS_SHOWN.' |
';
-
+
print '| ';
print $form->textwithpicto($langs->trans("MAIN_ROUNDING_RULE_TOT"),$langs->trans("ParameterActiveForNextInputOnly"));
print ' | '.$conf->global->MAIN_ROUNDING_RULE_TOT.' |
';
diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php
index b8ae96cb920..eadce1dc74c 100644
--- a/htdocs/core/actions_setmoduleoptions.inc.php
+++ b/htdocs/core/actions_setmoduleoptions.inc.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2014-2017 Laurent Destailleur
*
* 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
@@ -17,15 +17,43 @@
*/
/**
- * \file htdocs/core/actions_setnotes.inc.php
+ * \file htdocs/core/actions_setmoduleoptions.inc.php
* \brief Code for actions on setting notes of object page
*/
// $action must be defined
-// $_FILES may be defined
+// $arrayofparameters must be set for action 'update'
+// $nomessageinupdate can be set to 1
// $nomessageinsetmoduleoptions can be set to 1
+if ($action == 'update' && is_array($arrayofparameters))
+{
+ $db->begin();
+
+ $ok=True;
+ foreach($arrayofparameters as $key => $val)
+ {
+ $result=dolibarr_set_const($db,$key,GETPOST($key, 'alpha'),'chaine',0,'',$conf->entity);
+ if ($result < 0)
+ {
+ $ok=False;
+ break;
+ }
+ }
+
+ if (! $error)
+ {
+ $db->commit();
+ if (empty($nomessageinupdate)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+ }
+ else
+ {
+ $db->rollback();
+ if (empty($nomessageinupdate)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors');
+ }
+}
+
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
if ($action == 'setModuleOptions')
{
diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php
index 3fe6d5887f4..8643e951fd4 100644
--- a/htdocs/core/lib/files.lib.php
+++ b/htdocs/core/lib/files.lib.php
@@ -1929,7 +1929,7 @@ function dol_most_recent_file($dir,$regexfilter='',$excludefilter=array('(\.meta
function dol_check_secure_access_document($modulepart, $original_file, $entity, $fuser='', $refname='', $mode='read')
{
global $user, $conf, $db;
- global $dolibarr_main_data_root;
+ global $dolibarr_main_data_root, $dolibarr_main_document_root_alt;
if (! is_object($fuser)) $fuser=$user;
@@ -1965,6 +1965,16 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
$accessallowed=($user->admin && basename($original_file) == $original_file && preg_match('/^dolibarr.*\.log$/', basename($original_file)));
$original_file=$dolibarr_main_data_root.'/'.$original_file;
}
+ // Wrapping for *.zip files, like when used with url http://.../document.php?modulepart=packages&file=module_myfile.zip
+ elseif ($modulepart == 'packages' && !empty($dolibarr_main_data_root))
+ {
+ // Dir for custom dirs
+ $tmp=explode(',', $dolibarr_main_document_root_alt);
+ $dirins = $tmp[0];
+
+ $accessallowed=($user->admin && preg_match('/^module_.*\.zip$/', basename($original_file)));
+ $original_file=$dirins.'/'.$original_file;
+ }
// Wrapping for some images
elseif (($modulepart == 'mycompany' || $modulepart == 'companylogo') && !empty($conf->mycompany->dir_output))
{
diff --git a/htdocs/langs/en_US/cron.lang b/htdocs/langs/en_US/cron.lang
index 0113b2669c5..7f3385bef12 100644
--- a/htdocs/langs/en_US/cron.lang
+++ b/htdocs/langs/en_US/cron.lang
@@ -55,7 +55,7 @@ CronSaveSucess=Save successfully
CronNote=Comment
CronFieldMandatory=Fields %s is mandatory
CronErrEndDateStartDt=End date cannot be before start date
-StatusAtInstall=Status at installation
+StatusAtInstall=Status at module installation
CronStatusActiveBtn=Enable
CronStatusInactiveBtn=Disable
CronTaskInactive=This job is disabled
diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang
index 7f986e036c1..034deb7c800 100644
--- a/htdocs/langs/en_US/modulebuilder.lang
+++ b/htdocs/langs/en_US/modulebuilder.lang
@@ -58,4 +58,6 @@ SqlFileKey=Sql file for keys
AnObjectAlreadyExistWithThisNameAndDiffCase=An object already exists with this name and a different case
UseAsciiDocFormat=You can use Markdown format, but it is recommanded to use Asciidoc format (Comparison between .md and .asciidoc: http://asciidoctor.org/docs/user-manual/#compared-to-markdown)
IsAMeasure=Is a measure
-DirScanned=Directory scanned
\ No newline at end of file
+DirScanned=Directory scanned
+NoTrigger=No trigger
+NoWidget=No widget
\ No newline at end of file
diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php
index 4ef05cb6e2b..d0da95b6947 100644
--- a/htdocs/modulebuilder/index.php
+++ b/htdocs/modulebuilder/index.php
@@ -149,7 +149,7 @@ if ($dirins && $action == 'initmodule' && $modulename)
'my module'=>$modulename,
'Mon module'=>$modulename,
'mon module'=>$modulename,
- 'htdocs/modulebuilder/template/'=>strtolower($modulename),
+ 'htdocs/modulebuilder/template'=>strtolower($modulename),
'---Put here your own copyright and developer email---'=>dol_print_date($now,'%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'')
);
@@ -508,11 +508,11 @@ if ($dirins && $action == 'generatepackage')
$FILENAMEZIP="module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2]?".".$arrayversion[2]:"").".zip";
$dirofmodule = dol_buildpath($modulelowercase, 0).'/bin';
- $outputfile = $dirofmodule.'/'.$FILENAMEZIP;
+ $outputfilezip = $dirofmodule.'/'.$FILENAMEZIP;
if ($dirofmodule)
{
if (! dol_is_dir($dirofmodule)) dol_mkdir($dirofmodule);
- $result = dol_compress_dir($dir, $outputfile, 'zip');
+ $result = dol_compress_dir($dir, $outputfilezip, 'zip');
}
else
{
@@ -521,13 +521,13 @@ if ($dirins && $action == 'generatepackage')
if ($result > 0)
{
- setEventMessages($langs->trans("ZipFileGeneratedInto", $outputfile), null);
+ setEventMessages($langs->trans("ZipFileGeneratedInto", $outputfilezip), null);
}
else
{
$error++;
$langs->load("errors");
- setEventMessages($langs->trans("ErrorFailToGenerateFile", $outputfile), null, 'errors');
+ setEventMessages($langs->trans("ErrorFailToGenerateFile", $outputfilezip), null, 'errors');
}
}
else
@@ -576,7 +576,7 @@ if ($dirins && $action == 'generatedoc')
$FILENAMEDOC=$modulelowercase.'.html';
$dirofmodule = dol_buildpath($modulelowercase, 0).'/doc';
- $outputfile = $dirofmodule.'/'.$FILENAMEDOC;
+ $outputfiledoc = $dirofmodule.'/'.$FILENAMEDOC;
if ($dirofmodule)
{
if (! dol_is_dir($dirofmodule)) dol_mkdir($dirofmodule);
@@ -591,13 +591,13 @@ if ($dirins && $action == 'generatedoc')
if ($result > 0)
{
- setEventMessages($langs->trans("DocFileGeneratedInto", $outputfile), null);
+ setEventMessages($langs->trans("DocFileGeneratedInto", $outputfiledoc), null);
}
else
{
$error++;
$langs->load("errors");
- setEventMessages($langs->trans("ErrorFailToGenerateFile", $outputfile), null, 'errors');
+ setEventMessages($langs->trans("ErrorFailToGenerateFile", $outputfiledoc), null, 'errors');
}
}
else
@@ -1578,14 +1578,21 @@ elseif (! empty($module))
if ($action != 'editfile' || empty($file))
{
- foreach ($triggers as $trigger)
- {
- $pathtofile = $trigger['relpath'];
+ if (! empty($triggers))
+ {
+ foreach ($triggers as $trigger)
+ {
+ $pathtofile = $trigger['relpath'];
- print ' '.$langs->trans("TriggersFile").' : '.$pathtofile.'';
- print ' '.img_picto($langs->trans("Edit"), 'edit').'';
- print '
';
- }
+ print ' '.$langs->trans("TriggersFile").' : '.$pathtofile.'';
+ print ' '.img_picto($langs->trans("Edit"), 'edit').'';
+ print '
';
+ }
+ }
+ else
+ {
+ print $langs->trans("NoTrigger");
+ }
}
else
{
@@ -1622,13 +1629,20 @@ elseif (! empty($module))
if ($action != 'editfile' || empty($file))
{
- foreach ($widgets as $widget)
- {
- $pathtofile = $widget['relpath'];
+ if (! empty($widget))
+ {
+ foreach ($widgets as $widget)
+ {
+ $pathtofile = $widget['relpath'];
- print ' '.$langs->trans("WidgetFile").' : '.$pathtofile.'';
- print ' '.img_picto($langs->trans("Edit"), 'edit').'';
- print '
';
+ print ' '.$langs->trans("WidgetFile").' : '.$pathtofile.'';
+ print ' '.img_picto($langs->trans("Edit"), 'edit').'';
+ print '
';
+ }
+ }
+ else
+ {
+ print $langs->trans("NoWidget");
}
}
else
@@ -1811,7 +1825,7 @@ elseif (! empty($module))
if (count($arrayversion))
{
$FILENAMEZIP="module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2]?".".$arrayversion[2]:"").".zip";
- $outputfile = dol_buildpath($modulelowercase, 0).'/bin/'.$FILENAMEZIP;
+ $outputfilezip = dol_buildpath($modulelowercase, 0).'/bin/'.$FILENAMEZIP;
$FILENAMEDOC=$modulelowercase.'.html';
$outputfiledoc = dol_buildpath($modulelowercase, 0).'/doc/'.$FILENAMEDOC;
@@ -1820,10 +1834,11 @@ elseif (! empty($module))
print '
';
print ' '. $langs->trans("PathToModulePackage") . ' : ';
- if (! dol_is_file($outputfile)) print ''.$langs->trans("FileNotYetGenerated").'';
+ if (! dol_is_file($outputfilezip)) print ''.$langs->trans("FileNotYetGenerated").'';
else {
- print ''.$outputfile.'';
- print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfile), 'dayhour').')';
+ $relativepath = $modulelowercase.'/bin/'.$FILENAMEZIP;
+ print ''.$outputfilezip.'';
+ print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfilezip), 'dayhour').')';
}
print '
';
diff --git a/htdocs/modulebuilder/template/admin/about.php b/htdocs/modulebuilder/template/admin/about.php
index ac21d2810e0..d492f72da79 100644
--- a/htdocs/modulebuilder/template/admin/about.php
+++ b/htdocs/modulebuilder/template/admin/about.php
@@ -81,16 +81,11 @@ $head = mymoduleAdminPrepareHead();
dol_fiche_head(
$head,
'about',
- $langs->trans("MyModuleName"),
+ $langs->trans("ModuleMyModuleName"),
0,
'mymodule@mymodule'
);
-// About page goes here
-echo $langs->trans("MyModuleAboutPage");
-
-echo '
';
-
dol_include_once('/mymodule/core/modules/modMyModule.class.php');
$tmpmodule = new modMyModule($db);
print $tmpmodule->getDescLong();
diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php
index d32bd0a1723..46b608efa8e 100644
--- a/htdocs/modulebuilder/template/admin/setup.php
+++ b/htdocs/modulebuilder/template/admin/setup.php
@@ -42,8 +42,9 @@ global $langs, $user;
require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
require_once '../lib/mymodule.lib.php';
//require_once "../class/myclass.class.php";
+
// Translations
-$langs->load("mymodule@mymodule");
+$langs->loadLangs(array("admin", "mymodule@mymodule"));
// Access control
if (! $user->admin) accessforbidden();
@@ -51,6 +52,8 @@ if (! $user->admin) accessforbidden();
// Parameters
$action = GETPOST('action', 'alpha');
+$arrayofparameters=array('MYMODULE_MYPARAM1'=>'1', 'MYMODULE_MYPARAM2'=>'2');
+
/*
* Actions
@@ -76,14 +79,62 @@ $head = mymoduleAdminPrepareHead();
dol_fiche_head(
$head,
'settings',
- $langs->trans("Module500000Name"),
- 0,
+ $langs->trans("ModuleMyModuleName"),
+ -1,
"mymodule@mymodule"
);
// Setup page goes here
echo $langs->trans("MyModuleSetupPage");
+
+if ($action == 'edit')
+{
+ print '';
+ print '
';
+}
+else
+{
+ print '';
+ print '| '.$langs->trans("Parameter").' | '.$langs->trans("Value").' |
';
+
+ foreach($arrayofparameters as $key => $val)
+ {
+ print '| ';
+ print $form->textwithpicto($langs->trans($key),$langs->trans($key.'Tooltip'));
+ print ' | ' . $conf->global->$key . ' |
';
+ }
+
+ print '
';
+
+ print '';
+}
+
+
// Page end
dol_fiche_end();
+
llxFooter();
+$db->close();
diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php
index a26f7148142..77f860ba92c 100644
--- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php
+++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php
@@ -311,10 +311,11 @@ class modMyModule extends DolibarrModules
include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
- //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty');
- //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'string', 1, 10, 'project');
- //$param=array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3'));
- //$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'select', 1, 3, 'thirdparty', 0, 1, '', $param, 1);
+ $result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty');
+ //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project');
+ //$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account');
+ //$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1);
+ //$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user');
$sql = array();
diff --git a/htdocs/modulebuilder/template/langs/en_US/mymodule.lang b/htdocs/modulebuilder/template/langs/en_US/mymodule.lang
index e09e396dce0..a37d8e0c241 100644
--- a/htdocs/modulebuilder/template/langs/en_US/mymodule.lang
+++ b/htdocs/modulebuilder/template/langs/en_US/mymodule.lang
@@ -28,6 +28,11 @@ ModuleMyModuleDesc = My module description
MyModuleSetup = My module setup
Settings = Settings
MyModuleSetupPage = My module setup page
+MYMODULE_MYPARAM1 = My param 1
+MYMODULE_MYPARAM1Tooltip = My param 1 tooltip
+MYMODULE_MYPARAM2=My param 2
+MYMODULE_MYPARAM2Tooltip=My param 2 tooltip
+
#
# About page