Merge branch 'develop' into fixprecommit

This commit is contained in:
Frédéric FRANCE
2024-01-28 18:22:33 +01:00
committed by GitHub
12 changed files with 50 additions and 33 deletions

View File

@@ -476,12 +476,12 @@ if (getDolGlobalInt('TICKET_ENABLE_PUBLIC_INTERFACE')) {
// Url public interface
$url_interface = getDolGlobalString("TICKET_URL_PUBLIC_INTERFACE");
print '<tr><td>'.$langs->trans("TicketUrlPublicInterfaceLabelAdmin").'</label>';
print '<tr><td>'.$langs->trans("UrlPublicInterfaceLabelAdmin").'</label>';
print '</td><td>';
print '<input type="text" class="minwidth500" name="TICKET_URL_PUBLIC_INTERFACE" value="'.$url_interface.'"></td>';
print '<input type="text" class="minwidth500" name="TICKET_URL_PUBLIC_INTERFACE" value="'.$url_interface.'" placeholder="https://..."></td>';
print '</td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help');
print $form->textwithpicto('', $langs->trans("UrlPublicInterfaceHelpAdmin"), 1, 'help');
print '</td></tr>';
print '</table>';

View File

@@ -280,6 +280,7 @@ class modWebPortal extends DolibarrModules
$this->menu = array();
$r = 0;
// Add here entries to declare new menus
/*
$this->menu[$r++] = array(
'fk_menu' => '', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type' => 'top', // This is a Top menu entry
@@ -295,6 +296,7 @@ class modWebPortal extends DolibarrModules
'target' => '',
'user' => 2, // 0=Menu for internal users, 1=external users, 2=both
);
*/
/*$this->menu[$r++]=array(
'fk_menu'=>'fk_mainmenu=webportal', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'left', // This is a Left menu entry

View File

@@ -2437,3 +2437,5 @@ ParametersForTestEnvironment=Parameters for test environment
TryToKeepOnly=Try to keep only %s
RecommendedForProduction=Recommended for Production
RecommendedForDebug=Recommended for Debug
UrlPublicInterfaceLabelAdmin=Alternative URL for public interface
UrlPublicInterfaceHelpAdmin=It is possible to define an alias to the web server and thus make available the public interface with another URL (the virtual host server must act as a proxy on the standard URL)

View File

@@ -107,8 +107,6 @@ TicketsShowProgressionHelp=Enable this option to hide the progress of the ticket
TicketCreateThirdPartyWithContactIfNotExist=Ask name and company name for unknown emails.
TicketCreateThirdPartyWithContactIfNotExistHelp=Check if a third party or a contact exists for the email entered. If not, ask a name and a company name to create a third party with contact.
PublicInterface=Public interface
TicketUrlPublicInterfaceLabelAdmin=Alternative URL for public interface
TicketUrlPublicInterfaceHelpAdmin=It is possible to define an alias to the web server and thus make available the public interface with another URL (the server must act as a proxy on this new URL)
TicketPublicInterfaceTextHomeLabelAdmin=Welcome text of the public interface
TicketPublicInterfaceTextHome=You can create a support ticket or view existing from its identifier tracking ticket.
TicketPublicInterfaceTextHomeHelpAdmin=The text defined here will appear on the home page of the public interface.

View File

@@ -174,8 +174,6 @@ WebPortalSetup = WebPortal setup
WebPortalCSS=Web portal CSS
Settings = Settings
WebPortalSetupPage = WebPortal setup page
WEBPORTAL_ROOT_URL = Alternative virtual host URL
WebPortalRootUrlHelp = Public access url (http or https) if you have a virtual host or keep empty
WEBPORTAL_TITLE = Brand name on header of public page
UserAccountForWebPortalAreInThirdPartyTabHelp = Users accounts for WebPortal can be set on each third party card in Website accounts tab
WebPortalAccessHidden = Hidden
@@ -234,3 +232,4 @@ WebPortalErrorFetchLoggedUser = Error when loading user (Id : %s)
WebPortalErrorFetchLoggedThirdParty = Error when loading third-party (Id : %s)
WebPortalErrorFetchLoggedMember = Error when loading member (Id : %s)
WebPortalErrorFetchLoggedPartnership = Error when loading partnership (Third-party Id : %s, Member Id : %s)
ExportIntoGIT=Export into sources

View File

@@ -2440,3 +2440,4 @@ ParametersForTestEnvironment=Paramètres pour l'environnement de test
TryToKeepOnly=Essayez de ne conserver que %s
RecommendedForProduction=Recommandé pour la production
RecommendedForDebug=Recommandé pour le débogage
UrlPublicInterfaceHelpAdmin=Il est possible de définir un alias vers le serveur et de rendre ainsi l'interface publique accessible avec une autre URL (le serveur doit agir comme un proxy sur cette nouvelle URL)

View File

@@ -108,7 +108,6 @@ TicketCreateThirdPartyWithContactIfNotExist=Demandez le nom et le nom de l'entre
TicketCreateThirdPartyWithContactIfNotExistHelp=Vérifiez s'il existe un tiers ou un contact pour l'e-mail saisi. Sinon, demandez un nom et un nom société pour créer un tiers avec contact.
PublicInterface=Interface publique
TicketUrlPublicInterfaceLabelAdmin=URL alternative pour l'interface publique
TicketUrlPublicInterfaceHelpAdmin=Il est possible de définir un alias vers le serveur et de rendre ainsi l'interface publique accessible avec une autre URL (le serveur doit agir comme un proxy sur cette nouvelle URL)
TicketPublicInterfaceTextHomeLabelAdmin=Texte de bienvenue dans l'interface publique
TicketPublicInterfaceTextHome=Vous pouvez créer un ticket ou consulter à partir d'un ID de ticket existant.
TicketPublicInterfaceTextHomeHelpAdmin=Le texte défini ici apparaîtra sur la page d'accueil de l'interface publique.

View File

@@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
require_once DOL_DOCUMENT_ROOT . "/webportal/lib/webportal.lib.php";
// Translations
$langs->loadLangs(array("admin", "hrm", "other"));
$langs->loadLangs(array("admin", "hrm", "other", "website"));
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('webportalsetup', 'globalsetup'));

View File

@@ -57,15 +57,15 @@ $useFormSetup = 1;
if (!class_exists('FormSetup')) {
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formsetup.class.php';
}
$formSetup = new FormSetup($db);
// root url
$item = $formSetup->newItem('WEBPORTAL_ROOT_URL')->setAsString();
$item->nameText = $langs->transnoentities('UrlPublicInterfaceLabelAdmin');
$item->fieldAttr = array('placeholder' => 'https://');
$item->helpText = $langs->transnoentities('WebPortalRootUrlHelp');
$item->helpText = $langs->transnoentities('UrlPublicInterfaceHelpAdmin');
require_once __DIR__ . '/../class/context.class.php';
$context = Context::getInstance();
//$context = Context::getInstance();
//$item->fieldOutputOverride = '<a target="_blank" href="'.Context::getRootConfigUrl().'" >'.img_picto('', 'globe', 'class="pictofixedwidth"').Context::getRootConfigUrl().'</a>';
@@ -270,7 +270,7 @@ print ajax_autoselect('publicurlmember');
// Setup page goes here
print info_admin($langs->trans("UserAccountForWebPortalAreInThirdPartyTabHelp"));
print '<br>';
print '<br><br>';
if ($action == 'edit') {
print $formSetup->generateOutput(true);

View File

@@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
require_once DOL_DOCUMENT_ROOT . "/webportal/lib/webportal.lib.php";
// Translations
$langs->loadLangs(array("admin", "webportal"));
$langs->loadLangs(array("admin", "webportal", "website"));
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('webportalthemesetup', 'globalsetup'));

View File

@@ -1608,8 +1608,9 @@ class Website extends CommonObject
}
/**
* Overite template by copy and past all files
* @return void
* Overite template by copying all files
*
* @return int <0 if KO, >0 if OK
*/
public function overwriteTemplate()
{
@@ -1618,21 +1619,28 @@ class Website extends CommonObject
$website = $this;
if (empty($website->id) || empty($website->ref)) {
setEventMessages("Website id or ref is not defined", null, 'errors');
return false;
return -1;
}
if (empty($website->name_template)) {
setEventMessages("To export the website template into the GIT sources directory, the name of the directory/template must be know. For this website, the variable 'name_template' is unknown, so export in GIT sources is not possible.", null, 'errors');
return -1;
}
if (!is_writable($conf->website->dir_temp)) {
setEventMessages("Temporary dir ".$conf->website->dir_temp." is not writable", null, 'errors');
return '';
return -1;
}
$sourcedir = $conf->website->dir_output."/".$website->ref;
$fichierEtat = $sourcedir . '/etat_fichiers.txt';
$fichierEtat = $sourcedir . '/filelist-lastwrite-doctemplates.txt';
// Get array with hash of files
$etatPrecedent = $this->checkPreviousState($fichierEtat);
// Get list of all source files of the website
$arraySourcedir = dol_dir_list($sourcedir);
// Get list of modified files
$modifications = [];
foreach ($arraySourcedir as $file) {
if (substr($file['name'], -4) === '.old') {
@@ -1645,12 +1653,12 @@ class Website extends CommonObject
$modifications[] = $file;
}
$etatPrecedent[$file['name']] = $hashActuel;
$etatPrecedent[$file['name']] = $hashActuel; // we store he new hash to record it later on disk.
}
// listed modified files
$destdir = DOL_DOCUMENT_ROOT . '/install/doctemplates/websites/'.$website->name_template;
// Replace modified files into the doctemplates directory.
$destdirrel = 'install/doctemplates/websites/'.$website->name_template;
$destdir = DOL_DOCUMENT_ROOT.'/'.$destdirrel;
$arraydestdir = dol_dir_list($destdir, "all", 1);
$differences = [];
$names = array_column($arraydestdir, 'name');
@@ -1717,6 +1725,7 @@ class Website extends CommonObject
}
}
}
// Find the corresponding file in the destination folder
if (in_array($nomFichierModifie, $namesSource)) {
foreach ($arraydestdir as $destFile) {
@@ -1730,7 +1739,7 @@ class Website extends CommonObject
$result = $this->replaceLineUsingNum($destFile['fullname'], $differences[$nomFichierModifie]);
if ($result !== false) {
if ($result == -2) {
setEventMessages("No permissions to write in file <b>".$nomFichierModifie."</b> from template <b>".$website->name_template."</b>", null, 'errors');
setEventMessages("No permissions to write into file <b>".$destdirrel.'/'.$nomFichierModifie."</b> from the current website <b>".$website->name_template."</b>", null, 'errors');
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website->ref);
exit();
}
@@ -1747,7 +1756,7 @@ class Website extends CommonObject
$result = $this->replaceLineUsingNum($differences[$nomFichierModifie]['file_destination']['fullname'], $differences[$nomFichierModifie]);
if ($result !== false) {
if ($result == -2) {
setEventMessages("No permissions to write in file <b>".$differences[$nomFichierModifie]['file_destination']['name']."</b> from template <b>".$website->name_template."</b>", null, 'errors');
setEventMessages("No permissions to write into file <b>".$destdirrel.'/'.$differences[$nomFichierModifie]['file_destination']['name']."</b> from the current website <b>".$website->name_template."</b>", null, 'errors');
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website->ref);
exit();
}
@@ -1758,8 +1767,8 @@ class Website extends CommonObject
}
}
}
if ($success>0) {
// save state file
if ($success > 0) {
// Save the state file filelist.txt
$this->saveState($etatPrecedent, $fichierEtat);
setEventMessages("file <b>".$differences[$nomFichierModifie]['file_destination']['name']."</b> was modified in template <b>".$website->name_template."</b>", null, 'warnings');
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website->ref);
@@ -1768,8 +1777,10 @@ class Website extends CommonObject
} else {
setEventMessages("No file has been modified", null, 'errors');
}
// save state file
$this->saveState($etatPrecedent, $fichierEtat);
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website->ref);
exit();
}
@@ -1844,7 +1855,7 @@ class Website extends CommonObject
*/
public function initFilesStatus($sourcedir)
{
$fichierEtat = $sourcedir . '/etat_fichiers.txt';
$fichierEtat = $sourcedir . '/filelist-lastwrite-doctemplates.txt';
$etatPrecedent = $this->checkPreviousState($fichierEtat);

View File

@@ -2417,9 +2417,11 @@ if ($action == 'exportsite' && $user->hasRight('website', 'export')) {
}
}
// Overite site
if ($action == 'overwitesite' && $user->hasRight('website', 'export')) {
$fileofzip = $object->overwriteTemplate();
// Overwrite site
if ($action == 'overwritesite' && $user->hasRight('website', 'export')) {
if (getDolGlobalString('WEBSITE_ALLOW_OVERWRITE_GIT_SOURCE')) {
$fileofzip = $object->overwriteTemplate();
}
}
// Regenerate site
if ($action == 'regeneratesite' && $usercanedit) {
@@ -3020,6 +3022,11 @@ if (!GETPOST('hide_websitemenu')) {
// Export web site
print '<input type="submit" class="button bordertransp"'.$disabledexport.' value="'.dol_escape_htmltag($exportlabel).'" name="exportsite">';
if (getDolGlobalString('WEBSITE_ALLOW_OVERWRITE_GIT_SOURCE')) {
// Overwrite template in sources
print '<a href="'.$_SERVER["PHP_SELF"].'?action=overwritesite&website='.urlencode($website->ref).'" class="button bordertransp">'.dol_escape_htmltag($langs->trans("ExportIntoGIT")).'</a>';
}
// Clone web site
print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("CloneSite")).'" name="createfromclone">';
@@ -3065,8 +3072,6 @@ if (!GETPOST('hide_websitemenu')) {
print '</span>';
}
// overite template
print '<a href="'.$_SERVER["PHP_SELF"].'?action=overwitesite&website='.urlencode($website->ref).'" class="button bordertransp"> <i class="fa fa-bolt" aria-hidden="true"></i> '.dol_escape_htmltag($langs->trans("Overwrite")).'</a>';
} else {
print '<input type="hidden" name="website" id="website" value="'.$websitekey.'">';
}