diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 745b5229340..036e6100449 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -7,7 +7,8 @@ * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Raphaël Doursenaud - * + * Copyright (C) 2018 Nicolas ZABOURI + * * 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 * the Free Software Foundation; either version 3 of the License, or @@ -670,6 +671,17 @@ if ($mode == 'common') // Version print ''; print $versiontrans; + if(!empty($conf->global->CHECKLASTVERSION_EXTERNALMODULE)){ + require_once(DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'); + if (!empty($objMod->url_last_version)) { + $newversion = getURLContent($objMod->url_last_version); + if(isset($newversion['content'])){ + if (version_compare($newversion['content'], $versiontrans) > 0) { + print " ".$newversion['content'].""; + } + } + } + } print "\n"; // Activate/Disable and Setup (2 columns) diff --git a/htdocs/core/modules/modModuleBuilder.class.php b/htdocs/core/modules/modModuleBuilder.class.php index b6ba08a84a5..875820c9b6b 100644 --- a/htdocs/core/modules/modModuleBuilder.class.php +++ b/htdocs/core/modules/modModuleBuilder.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2018 Nicolas ZABOURI * * 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 @@ -59,7 +60,7 @@ class modModuleBuilder extends DolibarrModules // Config pages //------------- - $this->config_page_url = array(); + $this->config_page_url = array('setup@modulebuilder'); // Dependancies //------------- diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 6638e1fa674..ed3a872d3c6 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -94,4 +94,7 @@ YouCanUseTranslationKey=You can use here a key that is the translation key found DropTableIfEmpty=(Delete table if empty) TableDoesNotExists=The table %s does not exists TableDropped=Table %s deleted -InitStructureFromExistingTable=Build the structure array string of an existing table \ No newline at end of file +InitStructureFromExistingTable=Build the structure array string of an existing table +UseAboutPage=Disallow the about page +UseDocFolder=Disallow the documentation folder +UseSpecificReadme=Use a specific ReadMe \ No newline at end of file diff --git a/htdocs/modulebuilder/admin/setup.php b/htdocs/modulebuilder/admin/setup.php new file mode 100644 index 00000000000..5bc1fb7c206 --- /dev/null +++ b/htdocs/modulebuilder/admin/setup.php @@ -0,0 +1,159 @@ + + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/modulebuilder/admin/setup.php + * \ingroup modulebuilder + * \brief Page setup for modulebuilder module + */ +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; + +global $conf,$langs,$user, $db; +$langs->loadLangs(array("admin", "other", "modulebuilder")); + +if (!$user->admin || empty($conf->modulebuilder->enabled)) + accessforbidden(); + +$action = GETPOST('action', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); + +/* + * Actions + */ +if($action=="update"){ + $res1=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_README', GETPOST('MODULEBUILDER_SPECIFIC_README'), 'chaine', 0, '', $conf->entity); + if ($res1 < 0) + { + setEventMessages('ErrorFailedToSaveDate', null, 'errors'); + $db->rollback(); + } + else + { + setEventMessages('RecordModifiedSuccessfully', null, 'mesgs'); + $db->commit(); + } +} + +if (preg_match('/set_(.*)/', $action, $reg)) { + $code = $reg[1]; + $values = GETPOST($code); + if (is_array($values)) + $values = implode(',', $values); + + if (dolibarr_set_const($db, $code, $values, 'chaine', 0, '', $conf->entity) > 0) { + header("Location: " . $_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } +} + +if (preg_match('/del_(.*)/', $action, $reg)) { + $code = $reg[1]; + if (dolibarr_del_const($db, $code, 0) > 0) { + Header("Location: " . $_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } +} + + +/* + * View + */ + +$form = new Form($db); + +llxHeader('', $langs->trans("ModulebuilderSetup")); + +$linkback = ''; +if (GETPOST('withtab', 'alpha')) { + $linkback = '' . $langs->trans("BackToModuleList") . ''; +} + +print load_fiche_titre($langs->trans("ModuleSetup") . ' ' . $langs->trans('Modulebuilder'), $linkback); + +if (GETPOST('withtab', 'alpha')) { + dol_fiche_head($head, 'modulebuilder', '', -1); +} + + +print '' . $langs->trans("ModuleBuilderDesc") . "
\n"; + +print '
'; + +print ''; +print ''; +print ''; +print ''; +print "\n"; + +print ''; +print ''; +print ''; + + + +print ''; +print ''; +print ''; + +print ''; +print ''; +print ''; + +print ''; +print ''; +print ''; +print ''; +print ''; +print '
' . $langs->trans("Key") . '' . $langs->trans("Value") . '
' . $langs->trans("UseAboutPage") . ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MODULEBUILDER_USE_ABOUT'); +} else { + if (empty($conf->global->MODULEBUILDER_USE_ABOUT)) { + print '' . img_picto($langs->trans("Disabled"), 'off') . ''; + } else { + print '' . img_picto($langs->trans("Enabled"), 'on') . ''; + } +} +print '
' . $langs->trans("UseDocFolder") . ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MODULEBUILDER_USE_DOCFOLDER'); +} else { + if (empty($conf->global->MODULEBUILDER_USE_DOCFOLDER)) { + print '' . img_picto($langs->trans("Disabled"), 'off') . ''; + } else { + print '' . img_picto($langs->trans("Enabled"), 'on') . ''; + } +} +print '
' . $langs->trans("UseSpecificReadme") . ''; +print ''; +print '
'; +print ''; +print '
'; + +if (GETPOST('withtab', 'alpha')) { + dol_fiche_end(); +} + +print '

'; + +llxFooter(); +$db->close(); diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index e844793b601..1d0c7960fda 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -120,6 +120,13 @@ if ($dirins && $action == 'initmodule' && $modulename) setEventMessages($langs->trans("AllFilesDidAlreadyExist", $srcdir, $destdir), null, 'warnings'); } } + + if(!empty($conf->global->MODULEBUILDER_USE_ABOUT)){ + dol_delete_file($destdir.'/admin/about.php'); + } + if(!empty($conf->global->MODULEBUILDER_USE_DOCFOLDER)){ + dol_delete_dir($destdir.'/doc/'); + } // Delete some files dol_delete_file($destdir.'/myobject_card.php'); @@ -165,6 +172,11 @@ if ($dirins && $action == 'initmodule' && $modulename) setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors'); } } + + if(!empty($conf->global->MODULEBUILDER_SPECIFIC_README)){ + dol_delete_file($destdir.'/README.md'); + file_put_contents($destdir.'/README.md', $conf->global->MODULEBUILDER_SPECIFIC_README); + } } if (! $error) diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index d30e944260a..675271a2947 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software; you can redistribute it and/or modify @@ -73,6 +74,9 @@ class modMyModule extends DolibarrModules // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' $this->version = '1.0'; + + //Url to the file with your last numberversion of this module + $this->url_last_version = 'http://www.example.com/versionmodule.txt'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Name of image file used for this module.