diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 38b241fba84..2d53f9a8100 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -144,7 +144,7 @@ class Website extends CommonObject */ public function create(User $user, $notrigger = false) { - global $conf; + global $conf, $langs; dol_syslog(__METHOD__, LOG_DEBUG); @@ -184,6 +184,10 @@ class Website extends CommonObject if (empty($this->entity)) { $this->entity = $conf->entity; } + if (empty($this->lang)) { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MainLanguage")); + return -1; + } // Insert request $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'('; @@ -444,7 +448,7 @@ class Website extends CommonObject */ public function update(User $user, $notrigger = false) { - global $conf; + global $conf, $langs; $error = 0; @@ -474,6 +478,10 @@ class Website extends CommonObject } $this->otherlang = join(',', $tmparray); } + if (empty($this->lang)) { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MainLanguage")); + return -1; + } // Check parameters // Put here code to add a control on parameters values diff --git a/htdocs/website/index.php b/htdocs/website/index.php index d6cc3608869..4aff7b1d8a7 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2692,14 +2692,14 @@ if ($action == 'editcss') print ''; // Website - print ''; // Main language - print ''; + print ''; + print ''; - print ''; - print '
'; + print '
'; print $langs->trans('WebSite'); print ''; print $websitekey; print '
'; + print '
'; $htmltext=''; print $form->textwithpicto($langs->trans('MainLanguage'), $htmltext, 1, 'help', '', 0, 2, 'WEBSITE_LANG'); print ''; @@ -2853,18 +2853,19 @@ if ($action == 'createsite') print ''; print '
'; + print $langs->trans('MainLanguage'); + print ''; + $shortlangcode = preg_replace('/[_-].*$/', '', trim($langs->defaultlang)); + print $formadmin->select_language((GETPOSTISSET('WEBSITE_LANG') ? GETPOST('WEBSITE_LANG', 'aZ09comma') : $shortlangcode), 'WEBSITE_LANG', 0, null, 1, 0, 0, 'minwidth300', 2, 0, 0, array(), 1); + print '
'; print $langs->trans('Description'); print ''; print ''; print '
'; - print $langs->trans('MainLanguage'); - print ''; - print $formadmin->select_language((GETPOSTISSET('WEBSITE_LANG') ? GETPOST('WEBSITE_LANG', 'aZ09comma') : '0'), 'WEBSITE_LANG', 0, null, 1, 0, 0, 'minwidth300', 2, 0, 0, array(), 1); - print '
'; print $langs->trans('OtherLanguages'); print '';