NEW custom dir is enabled dy default on first install.

Fix modulebuilder when custom dir not defined.
This commit is contained in:
Laurent Destailleur 2017-06-10 23:50:02 +02:00
parent a74d008ff2
commit 542a72c684
5 changed files with 150 additions and 116 deletions

View File

@ -829,7 +829,7 @@ if ($mode == 'deploy')
{ {
if (! in_array('/custom',explode(',',$dolibarr_main_url_root_alt))) if (! in_array('/custom',explode(',',$dolibarr_main_url_root_alt)))
{ {
$message=info_admin($langs->trans("ConfFileMuseContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT)); $message=info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT));
$allowfromweb=-1; $allowfromweb=-1;
} }
else else

View File

@ -57,14 +57,14 @@ $db_user=GETPOST('db_user','alpha');
$db_pass=GETPOST('db_pass'); $db_pass=GETPOST('db_pass');
$db_port=GETPOST('db_port','int'); $db_port=GETPOST('db_port','int');
$db_prefix=GETPOST('db_prefix','alpha'); $db_prefix=GETPOST('db_prefix','alpha');
$db_create_database = GETPOST('db_create_database'); $db_create_database = GETPOST('db_create_database','none');
$db_create_user = GETPOST('db_create_user'); $db_create_user = GETPOST('db_create_user','none');
// Force https // Force https
$main_force_https = ((GETPOST("main_force_https") && (GETPOST("main_force_https") == "on" || GETPOST("main_force_https") == 1)) ? '1' : '0'); $main_force_https = ((GETPOST("main_force_https",'alpha') && (GETPOST("main_force_https",'alpha') == "on" || GETPOST("main_force_https",'alpha') == 1)) ? '1' : '0');
// Use alternative directory // Use alternative directory
$main_use_alt_dir = ((GETPOST("main_use_alt_dir") && (GETPOST("main_use_alt_dir") == "on" || GETPOST("main_use_alt_dir") == 1)) ? '' : '//'); $main_use_alt_dir = ((GETPOST("main_use_alt_dir",'alpha') == '' || (GETPOST("main_use_alt_dir",'alpha') == "on" || GETPOST("main_use_alt_dir",'alpha') == 1)) ? '' : '//');
// Alternative root directory name // Alternative root directory name
$main_alt_dir_name = ((GETPOST("main_alt_dir_name") && GETPOST("main_alt_dir_name") != '') ? GETPOST("main_alt_dir_name") : 'custom'); $main_alt_dir_name = ((GETPOST("main_alt_dir_name",'alpha') && GETPOST("main_alt_dir_name",'alpha') != '') ? GETPOST("main_alt_dir_name",'alpha') : 'custom');
session_start(); // To be able to keep info into session (used for not losing password during navigation. The password must not transit through parameters) session_start(); // To be able to keep info into session (used for not losing password during navigation. The password must not transit through parameters)

View File

@ -1619,7 +1619,7 @@ BackupDumpWizard=Wizard to build database backup dump file
SomethingMakeInstallFromWebNotPossible=Installation of external module is not possible from the web interface for the following reason: SomethingMakeInstallFromWebNotPossible=Installation of external module is not possible from the web interface for the following reason:
SomethingMakeInstallFromWebNotPossible2=For this reason, process to upgrade described here is only manual steps a privileged user can do. SomethingMakeInstallFromWebNotPossible2=For this reason, process to upgrade described here is only manual steps a privileged user can do.
InstallModuleFromWebHasBeenDisabledByFile=Install of external module from application has been disabled by your administrator. You must ask him to remove the file <strong>%s</strong> to allow this feature. InstallModuleFromWebHasBeenDisabledByFile=Install of external module from application has been disabled by your administrator. You must ask him to remove the file <strong>%s</strong> to allow this feature.
ConfFileMuseContainCustom=Installing an external module from application need to save the module files into directory <strong>%s</strong>. To have this directory processed by Dolibarr, you must setup your <strong>conf/conf.php</strong> to add the 2 directive lines:<br><strong>$dolibarr_main_url_root_alt='/custom';</strong><br><strong>$dolibarr_main_document_root_alt='%s/custom';</strong> ConfFileMustContainCustom=Installing or building an external module from application need to save the module files into directory <strong>%s</strong>. To have this directory processed by Dolibarr, you must setup your <strong>conf/conf.php</strong> to add the 2 directive lines:<br><strong>$dolibarr_main_url_root_alt='/custom';</strong><br><strong>$dolibarr_main_document_root_alt='%s/custom';</strong>
HighlightLinesOnMouseHover=Highlight table lines when mouse move passes over HighlightLinesOnMouseHover=Highlight table lines when mouse move passes over
HighlightLinesColor=Highlight color of the line when the mouse passes over (keep empty for no highlight) HighlightLinesColor=Highlight color of the line when the mouse passes over (keep empty for no highlight)
TextTitleColor=Color of page title TextTitleColor=Color of page title

View File

@ -9,26 +9,26 @@ If you're not a module developer you have no use for this.
Documentation Documentation
------------- -------------
[Module tutorial](http://wiki.dolibarr.org/index.php/Module_development) [Module tutorial](https://wiki.dolibarr.org/index.php/Module_development)
[Dolibarr development](http://wiki.dolibarr.org/index.php/Developer_documentation) [Dolibarr development](https://wiki.dolibarr.org/index.php/Developer_documentation)
### Translations ### Translations
Dolibarr uses [Transifex](http://transifex.com) to manage it's translations. Dolibarr uses [Transifex](https://transifex.com) to manage it's translations.
This template also contains a sample configuration for Transifex managed translations under the hidden [.tx](.tx) directory. This template also contains a sample configuration for Transifex managed translations under the hidden [.tx](.tx) directory.
For more informations, see the [translator's documentation](http://wiki.dolibarr.org/index.php/Translator_documentation). For more informations, see the [translator's documentation](http://wiki.dolibarr.org/index.php/Translator_documentation).
There is a [Transifex project](http://transifex.com/projects/p/dolibarr-module-template) for this module. There is a [Transifex project](https://transifex.com/projects/p/dolibarr-module-template) for this module.
Install Install
------- -------
### Manually ### Manually
- Make sure Dolibarr (>= 3.3.x) is already installed and configured on your workstation or development server. - Make sure Dolibarr is already installed and configured on your workstation or development server.
- In your Dolibarr installation directory, edit the ```htdocs/conf/conf.php``` file - In your Dolibarr installation directory, edit the ```htdocs/conf/conf.php``` file
@ -60,8 +60,6 @@ Install
For more information about the ```conf.php``` file take a look at the conf.php.example file. For more information about the ```conf.php``` file take a look at the conf.php.example file.
*Note that for Dolibarr versions before 3.5, the ```$dolibarr_main_url_root_alt``` has to be an absolute path*
- Clone the repository in ```$dolibarr_main_document_root_alt/mymodule``` - Clone the repository in ```$dolibarr_main_document_root_alt/mymodule```
*(You may have to create the ```htdocs/custom``` directory first if it doesn't exist yet.)* *(You may have to create the ```htdocs/custom``` directory first if it doesn't exist yet.)*
@ -187,10 +185,6 @@ The de-facto standard for publishing and marketing modules for Dolibarr is the [
Templates for required images and texts are [provided](dev/dolistore). Templates for required images and texts are [provided](dev/dolistore).
Check the dedicated [README](dev/dolistore/README.md) for more informations. Check the dedicated [README](dev/dolistore/README.md) for more informations.
Contributions
-------------
Feel free to contribute and report defects on our [issue tracker](http://github.com/Dolibarr/dolibarr-module-template/issues).
Licenses Licenses
-------- --------

View File

@ -45,7 +45,7 @@ if (! $user->admin && empty($conf->global->MODULEBUILDER_FOREVERYONE)) accessfor
// Dir for custom dirs // Dir for custom dirs
$tmp=explode(',', $dolibarr_main_document_root_alt); $tmp=explode(',', $dolibarr_main_document_root_alt);
$dircustom = $tmp[0]; $dirins = $tmp[0];
$FILEFLAG='modulebuilder.txt'; $FILEFLAG='modulebuilder.txt';
@ -54,10 +54,10 @@ $FILEFLAG='modulebuilder.txt';
* Actions * Actions
*/ */
if ($dircustom && $action == 'initmodule' && $modulename) if ($dirins && $action == 'initmodule' && $modulename)
{ {
$srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template';
$destdir = $dircustom.'/'.strtolower($modulename); $destdir = $dirins.'/'.strtolower($modulename);
$arrayreplacement=array( $arrayreplacement=array(
'mymodule'=>strtolower($modulename), 'mymodule'=>strtolower($modulename),
@ -113,12 +113,12 @@ if ($dircustom && $action == 'initmodule' && $modulename)
} }
} }
if ($dircustom && $action == 'generatepackage') if ($dirins && $action == 'generatepackage')
{ {
$modulelowercase=strtolower($module); $modulelowercase=strtolower($module);
// Dir for module // Dir for module
$dir = $dircustom.'/'.$modulelowercase; $dir = $dirins.'/'.$modulelowercase;
// Zip file to build // Zip file to build
$FILENAMEZIP=''; $FILENAMEZIP='';
@ -176,6 +176,14 @@ if ($dircustom && $action == 'generatepackage')
* View * View
*/ */
// Set dir where external modules are installed
if (! dol_is_dir($dirins))
{
dol_mkdir($dirins);
}
$dirins_ok=(dol_is_dir($dirins));
llxHeader("",$langs->trans("ModuleBuilder"),""); llxHeader("",$langs->trans("ModuleBuilder"),"");
@ -193,7 +201,7 @@ if (!empty($conf->modulebuilder->enabled) && $mainmenu == 'modulebuilder') // En
{ {
foreach ($dolibarr_main_document_root_alt as $diralt) foreach ($dolibarr_main_document_root_alt as $diralt)
{*/ {*/
$dirsincustom=dol_dir_list($dircustom, 'directories'); $dirsincustom=dol_dir_list($dirins, 'directories');
if (is_array($dirsincustom) && count($dirsincustom) > 0) if (is_array($dirsincustom) && count($dirsincustom) > 0)
{ {
@ -224,8 +232,40 @@ if (!empty($conf->modulebuilder->enabled) && $mainmenu == 'modulebuilder') // En
// Show description of content // Show description of content
$newdircustom=$dirins;
if (empty($newdircustom)) $newdircustom=img_warning();
print $langs->trans("ModuleBuilderDesc").'<br>'; print $langs->trans("ModuleBuilderDesc").'<br>';
print $langs->trans("ModuleBuilderDesc2", 'conf/conf.php', $dircustom).'<br>'; print $langs->trans("ModuleBuilderDesc2", 'conf/conf.php', $newdircustom).'<br>';
$message='';
if (! $dirins)
{
$message=info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT));
$allowfromweb=-1;
}
else
{
if ($dirins_ok)
{
if (! is_writable(dol_osencode($dirins)))
{
$langs->load("errors");
$message=info_admin($langs->trans("ErrorFailedToWriteInDir",$dirins));
$allowfromweb=0;
}
}
else
{
$message=info_admin($langs->trans("NotExistsDirect",$dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample"));
$allowfromweb=0;
}
}
if ($message)
{
print $message;
}
print $langs->trans("ModuleBuilderDesc3", count($listofmodules), $FILEFLAG).'<br>'; print $langs->trans("ModuleBuilderDesc3", count($listofmodules), $FILEFLAG).'<br>';
//print '<br>'; //print '<br>';
@ -296,7 +336,7 @@ if ($module == 'initmodule')
print $langs->trans("EnterNameOfModuleDesc").'<br><br>'; print $langs->trans("EnterNameOfModuleDesc").'<br><br>';
print '<input type="text" name="modulename" value="'.dol_escape_htmltag($modulename).'" placeholder="'.dol_escape_htmltag($langs->trans("ModuleKey")).'">'; print '<input type="text" name="modulename" value="'.dol_escape_htmltag($modulename).'" placeholder="'.dol_escape_htmltag($langs->trans("ModuleKey")).'">';
print '<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans("Create")).'">'; print '<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans("Create")).'"'.($dirins?'':' disabled="disabled"').'>';
print '</form>'; print '</form>';
} }
elseif (! empty($module)) elseif (! empty($module))
@ -422,7 +462,7 @@ elseif (! empty($module))
print '<input type="hidden" name="action" value="confirm_delete">'; print '<input type="hidden" name="action" value="confirm_delete">';
print '<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).'">'; print '<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).'">';
print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">'; print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">';
print '<input type="submit" class="buttonDelete" value="'.$langs->trans("Delete").'">'; print '<input type="submit" class="buttonDelete" value="'.$langs->trans("Delete").'"'.($dirins?'':' disabled="disabled"').'>';
print '</form>'; print '</form>';
} }