diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 9979760bc4f..ef86062bbd0 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -1,2 +1,4 @@ # Dolibarr language file - Source file is en_US - loan -ModuleBuilderDesc=This tools give you utilites to build your own module. Your modules will be generated into the first alternative directory: %s. +ModuleBuilderDesc=This tools give you utilites to build your own module. +ModuleBuilderDesc2=Path were modules are generated (first alternative directory defined into %s): %s. +They are detected when the file %s exists in root of module directory. diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 182268a5f06..38339d643c1 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -29,9 +29,43 @@ $langs->load("admin"); $langs->load("modulebuilder"); $langs->load("other"); +$action=GETPOST('action','alpha'); +$confirm=GETPOST('confirm','alpha'); + // Security check if (! $user->admin && empty($conf->global->MODULEBUILDER_FOREVERYONE)) accessforbidden('ModuleBuilderNotAllowed'); +$modulename=dol_sanitizeFileName(GETPOST('modulename','alpha')); + +// Dir for custom dirs +$tmp=explode(',', $dolibarr_main_document_root_alt); +$dircustom = $tmp[0]; + + + +/* + * Actions + */ + +if ($dircustom && $action == 'initmodule' && $modulename) +{ + $srcfile = DOL_DOCUMENT_ROOT.'/modulebuilder/skeletons'; + $destfile = $dircustom.'/'.$modulename; + //$result = dolCopyDir($srcfile, $destfile, 0, 0); + + dol_mkdir($destfile); + + fopen($destfile, $mode) + + if ($result > 0) + { + setEventMessages('ModuleInitialized', null); + } + else + { + setEventMessages($langs->trans("ErrorFailedToCopyDir"), null, 'errors'); + } +} /* @@ -48,14 +82,24 @@ $text=$langs->trans("ModuleBuilder"); print load_fiche_titre($text, '', 'title_setup'); -$tmp=explode(',', $dolibarr_main_document_root_alt); -$dircustom = $tmp[0]; - // Show description of content -print $langs->trans("ModuleBuilderDesc", $dircustom).'

'; +print $langs->trans("ModuleBuilderDesc").'
'; +print $langs->trans("ModuleBuilderDesc2", 'conf/conf.php', $dircustom).'
'; +print '
'; +// New module +print '
'; +print '
'; +print ''; +print ''; +print ''; +print ''; +print '
'; +print '
'; + +$listofmodules=array(); /* if (!empty($conf->modulebuilder->enabled) && $mainmenu == 'modulebuilder') // Entry for Module builder { @@ -73,7 +117,7 @@ if (!empty($conf->modulebuilder->enabled) && $mainmenu == 'modulebuilder') // En $fullname = $dircustom['fullname']; if (dol_is_file($fullname.'/modulebuilder.txt')) { - print '
'.$module.'
'; + $listofmodules[$module]=$fullname; } } } @@ -84,7 +128,11 @@ if (!empty($conf->modulebuilder->enabled) && $mainmenu == 'modulebuilder') // En $newmenu->add('', 'NoGeneratedModuleFound', 0, 0); }*/ - +foreach($listofmodules as $modules => $fullname) +{ + print '