Main language of a web site is now mandatory

This commit is contained in:
Laurent Destailleur 2020-02-21 16:37:07 +01:00
parent d3f8c7af1e
commit df1851838e
2 changed files with 19 additions and 10 deletions

View File

@ -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

View File

@ -2692,14 +2692,14 @@ if ($action == 'editcss')
print '<table class="border centpercent">';
// Website
print '<tr><td class="titlefieldcreate">';
print '<tr><td class="titlefieldcreate fieldrequired">';
print $langs->trans('WebSite');
print '</td><td>';
print $websitekey;
print '</td></tr>';
// Main language
print '<tr><td class="tdtop">';
print '<tr><td class="tdtop fieldrequired">';
$htmltext='';
print $form->textwithpicto($langs->trans('MainLanguage'), $htmltext, 1, 'help', '', 0, 2, 'WEBSITE_LANG');
print '</td><td>';
@ -2853,18 +2853,19 @@ if ($action == 'createsite')
print '<input type="text" class="flat maxwidth300" name="WEBSITE_REF" value="'.dol_escape_htmltag($siteref).'" autofocus>';
print '</td></tr>';
print '<tr><td class="fieldrequired">';
print $langs->trans('MainLanguage');
print '</td><td>';
$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 '</td></tr>';
print '<tr><td>';
print $langs->trans('Description');
print '</td><td>';
print '<input type="text" class="flat minwidth500" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($sitedesc).'">';
print '</td></tr>';
print '<tr><td>';
print $langs->trans('MainLanguage');
print '</td><td>';
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 '</td></tr>';
print '<tr><td>';
print $langs->trans('OtherLanguages');
print '</td><td>';