Fix clone web site

This commit is contained in:
Laurent Destailleur 2020-06-08 23:37:49 +02:00
parent ff9312c96a
commit 738fa35471
2 changed files with 5 additions and 1 deletions

View File

@ -621,7 +621,7 @@ class Website extends CommonObject
*/
public function createFromClone($user, $fromid, $newref, $newlang = '')
{
global $conf;
global $conf, $langs;
global $dolibarr_main_data_root;
$now = dol_now();
@ -663,12 +663,15 @@ class Website extends CommonObject
$object->virtualhost = '';
$object->date_creation = $now;
$object->fk_user_creat = $user->id;
$object->position = $object->position + 1;
if (empty($object->lang)) $object->lang = substr($langs->defaultlang, 0, 2); // Should not happen. Protection for corrupted site with no languages
// Create clone
$object->context['createfromclone'] = 'createfromclone';
$result = $object->create($user);
if ($result < 0) {
$error++;
$this->error = $object->error;
$this->errors = $object->errors;
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
}

View File

@ -1774,6 +1774,7 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf
$objectnew = new Website($db);
$result = $objectnew->createFromClone($user, GETPOST('id', 'int'), GETPOST('siteref', 'aZ09'), (GETPOST('newlang', 'aZ09') ?GETPOST('newlang', 'aZ09') : ''));
if ($result < 0)
{
$error++;