Skip to content

Commit

Permalink
FIX Selection of addmaindocfile is lost on error
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Oct 29, 2018
1 parent dbb2168 commit 770f8c3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
8 changes: 6 additions & 2 deletions htdocs/core/class/html.formmail.class.php
Expand Up @@ -881,8 +881,12 @@ function get_form($addfileaction='addfile', $removefileaction='removefile')

$out.= '<td>';

if (GETPOSTISSET('sendmail'))
{
$this->withmaindocfile = (GETPOST('addmaindocfile', 'alpha') ? -1 : 1);
}
// If a template was selected, we use setup of template to define if join file checkbox is selected or not.
if (is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
elseif (is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
{
$this->withmaindocfile = ($arraydefaultmessage->joinfiles ? -1 : 1);
}
Expand All @@ -895,7 +899,7 @@ function get_form($addfileaction='addfile', $removefileaction='removefile')
}
if ($this->withmaindocfile == -1)
{
$out.='<input type="checkbox" name="addmaindocfile" checked="checked" />';
$out.='<input type="checkbox" name="addmaindocfile" value="1" checked="checked" />';
}
$out.=' '.$langs->trans("JoinMainDoc").'.<br>';
}
Expand Down
11 changes: 6 additions & 5 deletions htdocs/core/tpl/massactions_pre.tpl.php
Expand Up @@ -41,11 +41,12 @@
{
$langs->load("mails");

$listofselectedid = array();
$listofselectedthirdparties = array();
$listofselectedref = array();

if (! GETPOST('cancel', 'alpha'))
{
$listofselectedid = array();
$listofselectedthirdparties = array();
$listofselectedref = array();
foreach ($arrayofselected as $toselectid)
{
$result = $objecttmp->fetch($toselectid);
Expand Down Expand Up @@ -110,8 +111,8 @@
} else {
$formmail->withtoreadonly = 1;
}

$formmail->withoptiononeemailperrecipient = empty($liste)?0:((GETPOST('oneemailperrecipient')=='on')?1:-1);
$formmail->withoptiononeemailperrecipient = (count($listofselectedref) == 1 || empty($liste))? 0 : ((GETPOST('oneemailperrecipient')=='on')?1:-1);
$formmail->withto = empty($liste)?(GETPOST('sendto','alpha')?GETPOST('sendto','alpha'):array()):$liste;
$formmail->withtofree = empty($liste)?1:0;
$formmail->withtocc = 1;
Expand Down

0 comments on commit 770f8c3

Please sign in to comment.