Fix sort order of email templates

This commit is contained in:
Laurent Destailleur 2018-05-01 16:24:40 +02:00
parent 3cad7c6998
commit c3b5664fb5

View File

@ -169,10 +169,6 @@ if ($conf->adherent->enabled) $elementList['member']=$langs->trans('Mai
if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract');
if ($conf->projet->enabled) $elementList['project']=$langs->trans('MailToProject');
$elementList['user']=$langs->trans('MailToUser');
sort($elementList);
// Add all and none after the sort
$elementList['all'] ='-- '.$langs->trans("All").' -- ('.$langs->trans('VisibleEverywhere').')';
$elementList['none']='-- '.$langs->trans("None").' -- ('.$langs->trans('VisibleNowhere').')';
$parameters=array('elementList'=>$elementList);
$reshook=$hookmanager->executeHooks('emailElementlist',$parameters); // Note that $action and $object may have been modified by some hooks
@ -182,6 +178,12 @@ if ($reshook == 0) {
}
}
// Add all and none after the sort
$elementList['all'] ='-- '.$langs->trans("All").' -- ('.$langs->trans('VisibleEverywhere').')';
$elementList['none']='-- '.$langs->trans("None").' -- ('.$langs->trans('VisibleNowhere').')';
asort($elementList);
$id = 25;
@ -211,7 +213,7 @@ if (empty($reshook))
}
// Actions add or modify an entry into a dictionary
if (GETPOST('actionadd') || GETPOST('actionmodify'))
if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha'))
{
$listfield=explode(',', str_replace(' ', '',$tabfield[$id]));
$listfieldinsert=explode(',',$tabfieldinsert[$id]);
@ -227,7 +229,7 @@ if (empty($reshook))
if ($value == 'content') continue;
if ($value == 'content_lines') continue;
if (GETPOST('actionmodify') && $value == 'topic') $_POST['topic']=$_POST['topic-'.$rowid];
if (GETPOST('actionmodify','alpha') && $value == 'topic') $_POST['topic']=$_POST['topic-'.$rowid];
if ((! isset($_POST[$value]) || $_POST[$value]=='' || $_POST[$value]=='-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position')
{
@ -269,8 +271,8 @@ if (empty($reshook))
if ($value == 'fk_user' && ! ($_POST[$keycode] > 0)) $_POST[$keycode]='';
if ($value == 'private' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='0';
if ($value == 'position' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='1';
if ($_POST[$keycode] == '' && $keycode != 'langcode') $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work
elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql.="null";
if ($_POST[$keycode] == '' && $keycode != 'langcode') $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work
elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql.="''"; // lang must be '' if not defined so the unique key that include lang will work
else $sql.="'".$db->escape($_POST[$keycode])."'";
$i++;
}
@ -316,12 +318,16 @@ if (empty($reshook))
if ($field == 'entity') $_POST[$keycode] = $conf->entity;
if ($i) $sql.=",";
$sql.= $field."=";
if ($_POST[$keycode] == '' || ($keycode == 'langcode' && empty($_POST[$keycode]))) $sql.="null"; // For vat, we want/accept code = ''
// print $keycode.' - '.$_POST[$keycode].'<br>';
if ($_POST[$keycode] == '' || ($keycode != 'langcode' && $keycode != 'private' && empty($_POST[$keycode]))) $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work
elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql.="''"; // lang must be '' if not defined so the unique key that include lang will work
elseif ($keycode == 'private') $sql.=((int) $_POST[$keycode]); // private must be 0 or 1
else $sql.="'".$db->escape($_POST[$keycode])."'";
$i++;
}
$sql.= " WHERE ".$rowidcol." = '".$rowid."'";
//print $sql;exit;
dol_syslog("actionmodify", LOG_DEBUG);
//print $sql;
$resql = $db->query($sql);