diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 02eef8a00d3..1b5f8353f12 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -56,7 +56,7 @@ if (isModEnabled('eventorganization')) { $langs->loadLangs($langsArray); $toselect = GETPOST('toselect', 'array'); -$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; +$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; $massaction = GETPOST('massaction', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation $mode = GETPOST('mode', 'aZ09'); @@ -350,7 +350,7 @@ if (empty($reshook)) { } setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); - $action = 'add'; + $action = 'create'; } } @@ -424,7 +424,7 @@ if (empty($reshook)) { } else { dol_print_error($db); } - $action = 'add'; + $action = 'create'; } } @@ -654,7 +654,7 @@ $linkback = ''; $titlepicto = 'title_setup'; -$url = DOL_URL_ROOT.'/admin/mails_templates.php?action=add&token='.newToken(); +$url = DOL_URL_ROOT.'/admin/mails_templates.php?action=create'; $newcardbutton = dolGetButtonTitle($langs->trans('NewEMailTemplate'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd); @@ -685,10 +685,11 @@ if ($action == 'delete') { $fieldlist = explode(',', $tabfield[$id]); -if ($action == 'add') { +if ($action == 'create') { // Form to add a new line print '
'; print ''; + print ''; print ''; print '
'; @@ -739,7 +740,6 @@ if ($action == 'add') { if ($fieldlist[$field] == 'content_lines') { $valuetoshow = ''; } - if ($valuetoshow != '') { print ''; if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) { @@ -820,16 +820,15 @@ if ($action == 'add') { // Input field if ($tmpfieldlist == 'topic') { - print ''; + print ''; } elseif ($tmpfieldlist == 'joinfiles') { - print ''; + print $form->selectyesno($tmpfieldlist, (isset($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : '0'), 1, false, 0, 1); } else { - // print ''; $okforextended = true; if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { $okforextended = false; } - $doleditor = new DolEditor($tmpfieldlist, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 180, 'dolibarr_mailings', 'In', 0, true, $okforextended, ROWS_4, '90%'); + $doleditor = new DolEditor($tmpfieldlist, (!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : ''), '', 180, 'dolibarr_mailings', 'In', 0, true, $okforextended, ROWS_4, '90%'); print $doleditor->Create(1); } print ''; @@ -917,7 +916,7 @@ foreach ($fieldlist as $field => $value) { print ''; } elseif ($value == 'fk_user') { print ''; - print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'maxwidth150'); + print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'maxwidth150', 1); print ''; } elseif ($value == 'topic') { print ''; @@ -1024,7 +1023,7 @@ if ($num) { $reshook = $hookmanager->executeHooks('editEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error = $hookmanager->error; $errors = $hookmanager->errors; - // Show fields + // Show main fields if (empty($reshook)) { fieldList($fieldlist, $obj, $tabname[$id], 'edit'); } @@ -1045,7 +1044,7 @@ if ($num) { foreach ($fieldsforcontent as $tmpfieldlist) { $showfield = 1; $align = "left"; - $valuetoshow = $obj->{$tmpfieldlist}; + $valuetoshow = $obj->$tmpfieldlist; $class = 'tddict'; // Show value for field @@ -1059,7 +1058,7 @@ if ($num) { } if ($tmpfieldlist == 'joinfiles') { print ''.$form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; - print ''; + print $form->selectyesno($tmpfieldlist.'-'.$rowid, (isset($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : '0'), 1, false, 0, 1); } // If $acceptlocallinktomedia is true, we can add link media files int email templates (we already can do this into HTML editor of an email). @@ -1204,7 +1203,7 @@ if ($num) { if ($value == 'joinfiles') { $align = "center"; if ($valuetoshow) { - $valuetoshow = 1; + $valuetoshow = yn(1); } else { $valuetoshow = ''; } @@ -1311,7 +1310,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') if ($value == 'fk_user') { print ''; if ($user->admin) { - print $form->select_dolusers(empty($obj->{$value}) ? '' : $obj->{$value}, 'fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'minwidth150 maxwidth300'); + print $form->select_dolusers(empty($obj->{$value}) ? '' : $obj->{$value}, 'fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'minwidth150 maxwidth200'); } else { if ($context == 'add') { // I am not admin and we show the add form print $user->getNomUrl(1); // Me @@ -1335,29 +1334,29 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') if (getDolGlobalInt('MAIN_MULTILANGS')) { $selectedlang = GETPOSTISSET('langcode') ?GETPOST('langcode', 'aZ09') : $langs->defaultlang; if ($context == 'edit') { - $selectedlang = $obj->{$value}; + $selectedlang = $obj->lang; } print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1, 0, 0, 'maxwidth150'); } else { - if (!empty($obj->{$value})) { - print $obj->{$value}.' - '.$langs->trans('Language_'.$obj->{$value}); + if (!empty($obj->lang)) { + print $obj->lang.' - '.$langs->trans('Language_'.$obj->lang); } $keyname = $value; if ($keyname == 'lang') { $keyname = 'langcode'; // Avoid conflict with lang param } - print ''; + print ''; } print ''; } elseif ($value == 'type_template') { // Le type de template print ''; - if ($context == 'edit' && !empty($obj->{$value}) && !in_array($obj->{$value}, array_keys($elementList))) { + if ($context == 'edit' && !empty($obj->type_template) && !in_array($obj->type_template, array_keys($elementList))) { // Current template type is an unknown type, so we must keep it as it is. - print ''; - print $obj->{$value}; + print ''; + print $obj->type_template; } else { - print $form->selectarray('type_template', $elementList, (!empty($obj->{$value}) ? $obj->{$value}:''), 1, 0, 0, '', 0, 0, 0, '', 'minwidth150', 1, '', 0, 1); + print $form->selectarray('type_template', $elementList, (!empty($obj->type_template) ? $obj->type_template:''), 1, 0, 0, '', 0, 0, 0, '', 'minwidth150', 1, '', 0, 1); } print ''; } elseif ($context == 'add' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) { @@ -1378,7 +1377,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') $class = 'maxwidth50'; $classtd = 'center'; } if ($value == 'position') { - $class = 'maxwidth50'; $classtd = 'center'; + $class = 'maxwidth50 center'; $classtd = 'center'; } if ($value == 'libelle') { $class = 'quatrevingtpercent'; @@ -1395,7 +1394,6 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') if (empty($user->admin)) { print $form->selectyesno($value, '1', 1); } else { - //print ''; print $form->selectyesno($value, (isset($obj->{$value}) ? $obj->{$value}:''), 1); } } else { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 6c7f60fc98f..dc7d8439cad 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1929,14 +1929,14 @@ class Form * @param integer $show_every 0=default list, 1=add also a value "Everybody" at beginning of list * @param string $enableonlytext If option $enableonlytext is set, we use this text to explain into label why record is disabled. Not used if enableonly is empty. * @param string $morecss More css - * @param int $noactive Show only active users (this will also happened whatever is this option if USER_HIDE_INACTIVE_IN_COMBOBOX is on). + * @param int $notdisabled Show only active users (this will also happened whatever is this option if USER_HIDE_INACTIVE_IN_COMBOBOX is on). * @param int $outputmode 0=HTML select string, 1=Array * @param bool $multiple add [] in the name of element and add 'multiple' attribut * @param int $forcecombo Force the component to be a simple combo box without ajax * @return string HTML select string * @see select_dolgroups() */ - public function select_dolusers($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $show_every = 0, $enableonlytext = '', $morecss = '', $noactive = 0, $outputmode = 0, $multiple = false, $forcecombo = 0) + public function select_dolusers($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $show_every = 0, $enableonlytext = '', $morecss = '', $notdisabled = 0, $outputmode = 0, $multiple = false, $forcecombo = 0) { // phpcs:enable global $conf, $user, $langs, $hookmanager; @@ -2005,7 +2005,7 @@ class Form if ($includeUsers) { $sql .= " AND u.rowid IN (".$this->db->sanitize($includeUsers).")"; } - if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive) { + if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $notdisabled) { $sql .= " AND u.statut <> 0"; } if (!empty($morefilter)) { @@ -2065,7 +2065,7 @@ class Form $disableline = ($enableonlytext ? $enableonlytext : '1'); } - $labeltoshow = ''; + $labeltoshow = ''; $labeltoshowhtml = ''; // $fullNameMode is 0=Lastname+Firstname (MAIN_FIRSTNAME_NAME_POSITION=1), 1=Firstname+Lastname (MAIN_FIRSTNAME_NAME_POSITION=0) $fullNameMode = 0; @@ -2073,37 +2073,50 @@ class Form $fullNameMode = 1; //Firstname+lastname } $labeltoshow .= $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength); + $labeltoshowhtml .= $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength); if (empty($obj->firstname) && empty($obj->lastname)) { $labeltoshow .= $obj->login; + $labeltoshowhtml .= $obj->login; } - // Complete name with more info - $moreinfo = ''; + // Complete name with a more info string like: ' (info1 - info2 - ...)' + $moreinfo = ''; $moreinfohtml = ''; if (!empty($conf->global->MAIN_SHOW_LOGIN)) { - $moreinfo .= ($moreinfo ? ' - ' : ' (').$obj->login; + $moreinfo .= ($moreinfo ? ' - ' : ' ('); + $moreinfohtml .= ($moreinfohtml ? ' - ' : ' ('); + $moreinfo .= $obj->login; + $moreinfohtml .= $obj->login; } if ($showstatus >= 0) { if ($obj->status == 1 && $showstatus == 1) { $moreinfo .= ($moreinfo ? ' - ' : ' (').$langs->trans('Enabled'); + $moreinfohtml .= ($moreinfohtml ? ' - ' : ' (').$langs->trans('Enabled'); } if ($obj->status == 0 && $showstatus == 1) { $moreinfo .= ($moreinfo ? ' - ' : ' (').$langs->trans('Disabled'); + $moreinfohtml .= ($moreinfohtml ? ' - ' : ' (').$langs->trans('Disabled'); } } if (isModEnabled('multicompany') && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) { if (!$obj->entity) { $moreinfo .= ($moreinfo ? ' - ' : ' (').$langs->trans("AllEntities"); + $moreinfohtml .= ($moreinfohtml ? ' - ' : ' (').$langs->trans("AllEntities"); } else { if ($obj->entity != $conf->entity) { $moreinfo .= ($moreinfo ? ' - ' : ' (').($obj->label ? $obj->label : $langs->trans("EntityNameNotDefined")); + $moreinfohtml .= ($moreinfohtml ? ' - ' : ' (').($obj->label ? $obj->label : $langs->trans("EntityNameNotDefined")); } } } $moreinfo .= ($moreinfo ? ')' : ''); + $moreinfohtml .= ($moreinfohtml ? ')' : ''); if ($disableline && $disableline != '1') { - $moreinfo .= ' - '.$disableline; // This is text from $enableonlytext parameter + // Add text from $enableonlytext parameter + $moreinfo .= ' - '.$disableline; + $moreinfohtml .= ' - '.$disableline; } $labeltoshow .= $moreinfo; + $labeltoshowhtml .= $moreinfohtml; $out .= '