commit
342fed350c
@ -33,8 +33,7 @@
|
||||
/*
|
||||
* Add file in email form
|
||||
*/
|
||||
if (GETPOST('addfile', 'alpha'))
|
||||
{
|
||||
if (GETPOST('addfile', 'alpha')) {
|
||||
$trackid = GETPOST('trackid', 'aZ09');
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
@ -50,8 +49,7 @@ if (GETPOST('addfile', 'alpha'))
|
||||
/*
|
||||
* Remove file in email form
|
||||
*/
|
||||
if (!empty($_POST['removedfile']) && empty($_POST['removAll']))
|
||||
{
|
||||
if (!empty($_POST['removedfile']) && empty($_POST['removAll'])) {
|
||||
$trackid = GETPOST('trackid', 'aZ09');
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
@ -69,24 +67,28 @@ if (!empty($_POST['removedfile']) && empty($_POST['removAll']))
|
||||
/*
|
||||
* Remove all files in email form
|
||||
*/
|
||||
if (GETPOST('removAll', 'alpha'))
|
||||
{
|
||||
if (GETPOST('removAll', 'alpha')) {
|
||||
$trackid = GETPOST('trackid', 'aZ09');
|
||||
|
||||
$listofpaths = array();
|
||||
$listofnames = array();
|
||||
$listofmimes = array();
|
||||
$keytoavoidconflict = empty($trackid) ? '' : '-'.$trackid;
|
||||
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
|
||||
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
|
||||
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
|
||||
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) {
|
||||
$listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
|
||||
}
|
||||
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) {
|
||||
$listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
|
||||
}
|
||||
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) {
|
||||
$listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
|
||||
}
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
$formmail = new FormMail($db);
|
||||
$formmail->trackid = $trackid;
|
||||
|
||||
foreach ($listofpaths as $key => $value)
|
||||
{
|
||||
foreach ($listofpaths as $key => $value) {
|
||||
$pathtodelete = $value;
|
||||
$filetodelete = $listofnames[$key];
|
||||
$result = dol_delete_file($pathtodelete, 1); // Delete uploded Files
|
||||
@ -101,50 +103,56 @@ if (GETPOST('removAll', 'alpha'))
|
||||
/*
|
||||
* Send mail
|
||||
*/
|
||||
if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST['removAll'] && !$_POST['removedfile'] && !$_POST['cancel'] && !$_POST['modelselected'])
|
||||
{
|
||||
if (empty($trackid)) $trackid = GETPOST('trackid', 'aZ09');
|
||||
if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST['removAll'] && !$_POST['removedfile'] && !$_POST['cancel'] && !$_POST['modelselected']) {
|
||||
if (empty($trackid)) {
|
||||
$trackid = GETPOST('trackid', 'aZ09');
|
||||
}
|
||||
|
||||
$subject = ''; $actionmsg = ''; $actionmsg2 = '';
|
||||
|
||||
$langs->load('mails');
|
||||
|
||||
if (is_object($object))
|
||||
{
|
||||
if (is_object($object)) {
|
||||
$result = $object->fetch($id);
|
||||
|
||||
$sendtosocid = 0; // Id of related thirdparty
|
||||
if (method_exists($object, "fetch_thirdparty") && !in_array($object->element, array('member', 'user', 'expensereport', 'societe', 'contact')))
|
||||
{
|
||||
if (method_exists($object, "fetch_thirdparty") && !in_array($object->element, array('member', 'user', 'expensereport', 'societe', 'contact'))) {
|
||||
$resultthirdparty = $object->fetch_thirdparty();
|
||||
$thirdparty = $object->thirdparty;
|
||||
if (is_object($thirdparty)) $sendtosocid = $thirdparty->id;
|
||||
} elseif ($object->element == 'member' || $object->element == 'user')
|
||||
{
|
||||
if (is_object($thirdparty)) {
|
||||
$sendtosocid = $thirdparty->id;
|
||||
}
|
||||
} elseif ($object->element == 'member' || $object->element == 'user') {
|
||||
$thirdparty = $object;
|
||||
if ($object->socid > 0) $sendtosocid = $object->socid;
|
||||
} elseif ($object->element == 'expensereport')
|
||||
{
|
||||
if ($object->socid > 0) {
|
||||
$sendtosocid = $object->socid;
|
||||
}
|
||||
} elseif ($object->element == 'expensereport') {
|
||||
$tmpuser = new User($db);
|
||||
$tmpuser->fetch($object->fk_user_author);
|
||||
$thirdparty = $tmpuser;
|
||||
if ($object->socid > 0) $sendtosocid = $object->socid;
|
||||
} elseif ($object->element == 'societe')
|
||||
{
|
||||
if ($object->socid > 0) {
|
||||
$sendtosocid = $object->socid;
|
||||
}
|
||||
} elseif ($object->element == 'societe') {
|
||||
$thirdparty = $object;
|
||||
if (is_object($thirdparty) && $thirdparty->id > 0) $sendtosocid = $thirdparty->id;
|
||||
} elseif ($object->element == 'contact')
|
||||
{
|
||||
if (is_object($thirdparty) && $thirdparty->id > 0) {
|
||||
$sendtosocid = $thirdparty->id;
|
||||
}
|
||||
} elseif ($object->element == 'contact') {
|
||||
$contact = $object;
|
||||
if ($contact->id > 0) {
|
||||
$contact->fetch_thirdparty();
|
||||
$thirdparty = $contact->thirdparty;
|
||||
if (is_object($thirdparty) && $thirdparty->id > 0) $sendtosocid = $thirdparty->id;
|
||||
if (is_object($thirdparty) && $thirdparty->id > 0) {
|
||||
$sendtosocid = $thirdparty->id;
|
||||
}
|
||||
}
|
||||
} else dol_print_error('', "Use actions_sendmails.in.php for an element/object '".$object->element."' that is not supported");
|
||||
} else {
|
||||
dol_print_error('', "Use actions_sendmails.in.php for an element/object '".$object->element."' that is not supported");
|
||||
}
|
||||
|
||||
if (is_object($hookmanager))
|
||||
{
|
||||
if (is_object($hookmanager)) {
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('initSendToSocid', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
}
|
||||
@ -152,8 +160,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
|
||||
$thirdparty = $mysoc;
|
||||
}
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
$sendto = '';
|
||||
$sendtocc = '';
|
||||
$sendtobcc = '';
|
||||
@ -163,48 +170,40 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
|
||||
|
||||
// Define $sendto
|
||||
$receiver = $_POST['receiver'];
|
||||
if (!is_array($receiver))
|
||||
{
|
||||
if ($receiver == '-1') $receiver = array();
|
||||
else $receiver = array($receiver);
|
||||
if (!is_array($receiver)) {
|
||||
if ($receiver == '-1') {
|
||||
$receiver = array();
|
||||
} else {
|
||||
$receiver = array($receiver);
|
||||
}
|
||||
}
|
||||
|
||||
$tmparray = array();
|
||||
if (trim($_POST['sendto']))
|
||||
{
|
||||
if (trim($_POST['sendto'])) {
|
||||
// Recipients are provided into free text
|
||||
$tmparray[] = trim($_POST['sendto']);
|
||||
}
|
||||
|
||||
if (count($receiver) > 0)
|
||||
{
|
||||
if (count($receiver) > 0) {
|
||||
// Recipient was provided from combo list
|
||||
foreach ($receiver as $key=>$val)
|
||||
{
|
||||
if ($val == 'thirdparty') // Key selected means current third party ('thirdparty' may be used for current member or current user too)
|
||||
{
|
||||
foreach ($receiver as $key => $val) {
|
||||
if ($val == 'thirdparty') { // Key selected means current third party ('thirdparty' may be used for current member or current user too)
|
||||
$tmparray[] = dol_string_nospecial($thirdparty->getFullName($langs), ' ', array(",")).' <'.$thirdparty->email.'>';
|
||||
}
|
||||
elseif ($val == 'contact') // Key selected means current contact
|
||||
{
|
||||
} elseif ($val == 'contact') { // Key selected means current contact
|
||||
$tmparray[] = dol_string_nospecial($contact->getFullName($langs), ' ', array(",")).' <'.$contact->email.'>';
|
||||
$sendtoid[] = $contact->id;
|
||||
} elseif ($val) // $val is the Id of a contact
|
||||
{
|
||||
} elseif ($val) { // $val is the Id of a contact
|
||||
$tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
|
||||
$sendtoid[] = ((int) $val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
|
||||
$receiveruser = $_POST['receiveruser'];
|
||||
if (is_array($receiveruser) && count($receiveruser) > 0)
|
||||
{
|
||||
if (is_array($receiveruser) && count($receiveruser) > 0) {
|
||||
$fuserdest = new User($db);
|
||||
foreach ($receiveruser as $key=>$val)
|
||||
{
|
||||
foreach ($receiveruser as $key => $val) {
|
||||
$tmparray[] = $fuserdest->user_get_property($val, 'email');
|
||||
$sendtouserid[] = $val;
|
||||
}
|
||||
@ -215,32 +214,27 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
|
||||
|
||||
// Define $sendtocc
|
||||
$receivercc = $_POST['receivercc'];
|
||||
if (!is_array($receivercc))
|
||||
{
|
||||
if ($receivercc == '-1') $receivercc = array();
|
||||
else $receivercc = array($receivercc);
|
||||
if (!is_array($receivercc)) {
|
||||
if ($receivercc == '-1') {
|
||||
$receivercc = array();
|
||||
} else {
|
||||
$receivercc = array($receivercc);
|
||||
}
|
||||
}
|
||||
$tmparray = array();
|
||||
if (trim($_POST['sendtocc']))
|
||||
{
|
||||
if (trim($_POST['sendtocc'])) {
|
||||
$tmparray[] = trim($_POST['sendtocc']);
|
||||
}
|
||||
if (count($receivercc) > 0)
|
||||
{
|
||||
foreach ($receivercc as $key=>$val)
|
||||
{
|
||||
// Recipient was provided from combo list
|
||||
if ($val == 'thirdparty') // Key selected means currentthird party (may be usd for current member or current user too)
|
||||
{
|
||||
if (count($receivercc) > 0) {
|
||||
foreach ($receivercc as $key => $val) {
|
||||
if ($val == 'thirdparty') { // Key selected means currentthird party (may be usd for current member or current user too)
|
||||
// Recipient was provided from combo list
|
||||
$tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>';
|
||||
}
|
||||
// Recipient was provided from combo list
|
||||
elseif ($val == 'contact') // Key selected means current contact
|
||||
{
|
||||
} elseif ($val == 'contact') { // Key selected means current contact
|
||||
// Recipient was provided from combo list
|
||||
$tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>';
|
||||
//$sendtoid[] = $contact->id; TODO Add also id of contact in CC ?
|
||||
} elseif ($val) // $val is the Id of a contact
|
||||
{
|
||||
} elseif ($val) { // $val is the Id of a contact
|
||||
$tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
|
||||
//$sendtoid[] = ((int) $val); TODO Add also id of contact in CC ?
|
||||
}
|
||||
@ -249,11 +243,9 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
|
||||
if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
|
||||
$receiverccuser = $_POST['receiverccuser'];
|
||||
|
||||
if (is_array($receiverccuser) && count($receiverccuser) > 0)
|
||||
{
|
||||
if (is_array($receiverccuser) && count($receiverccuser) > 0) {
|
||||
$fuserdest = new User($db);
|
||||
foreach ($receiverccuser as $key=>$val)
|
||||
{
|
||||
foreach ($receiverccuser as $key => $val) {
|
||||
$tmparray[] = $fuserdest->user_get_property($val, 'email');
|
||||
$sendtoccuserid[] = $val;
|
||||
}
|
||||
@ -261,8 +253,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
|
||||
}
|
||||
$sendtocc = implode(',', $tmparray);
|
||||
|
||||
if (dol_strlen($sendto))
|
||||
{
|
||||
if (dol_strlen($sendto)) {
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
|
||||
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
@ -291,8 +282,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
|
||||
$sql .= ' WHERE rowid = '.(int) $reg[1];
|
||||
$resql = $db->query($sql);
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj)
|
||||
{
|
||||
if ($obj) {
|
||||
$from = dol_string_nospecial($obj->label, ' ', array(",")).' <'.$obj->email.'>';
|
||||
}
|
||||
} else {
|
||||
@ -312,21 +302,20 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
|
||||
$sendtobcc = GETPOST('sendtoccc');
|
||||
// Autocomplete the $sendtobcc
|
||||
// $autocopy can be MAIN_MAIL_AUTOCOPY_PROPOSAL_TO, MAIN_MAIL_AUTOCOPY_ORDER_TO, MAIN_MAIL_AUTOCOPY_INVOICE_TO, MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO...
|
||||
if (!empty($autocopy))
|
||||
{
|
||||
if (!empty($autocopy)) {
|
||||
$sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc ? ", " : "").$conf->global->$autocopy));
|
||||
}
|
||||
|
||||
$deliveryreceipt = $_POST['deliveryreceipt'];
|
||||
|
||||
if ($action == 'send' || $action == 'relance')
|
||||
{
|
||||
if ($action == 'send' || $action == 'relance') {
|
||||
$actionmsg2 = $langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from, 4, 0, 1).' '.$langs->transnoentities('at').' '.CMailFile::getValidAddress($sendto, 4, 0, 1);
|
||||
if ($message)
|
||||
{
|
||||
if ($message) {
|
||||
$actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
|
||||
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
|
||||
if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc));
|
||||
if ($sendtocc) {
|
||||
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc));
|
||||
}
|
||||
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject);
|
||||
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":");
|
||||
$actionmsg = dol_concatdesc($actionmsg, $message);
|
||||
@ -343,50 +332,6 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
|
||||
$filename = $attachedfiles['names'];
|
||||
$mimetype = $attachedfiles['mimes'];
|
||||
|
||||
// Feature to push mail sent into Sent folder
|
||||
/* This code must be now included into the hook mail, method sendMailAfter
|
||||
if (! empty($conf->dolimail->enabled))
|
||||
{
|
||||
$mailfromid = explode("#", $_POST['frommail'],3); // $_POST['frommail'] = 'aaa#Sent# <aaa@aaa.com>' // TODO Use a better way to define Sent dir.
|
||||
if (count($mailfromid)==0) $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>';
|
||||
else
|
||||
{
|
||||
$mbid = $mailfromid[1];
|
||||
|
||||
// IMAP Postbox
|
||||
$mailboxconfig = new IMAP($db);
|
||||
$mailboxconfig->fetch($mbid);
|
||||
if ($mailboxconfig->mailbox_imap_host) $ref=$mailboxconfig->get_ref();
|
||||
|
||||
$mailboxconfig->folder_id=$mailboxconfig->mailbox_imap_outbox;
|
||||
$mailboxconfig->userfolder_fetch();
|
||||
|
||||
if ($mailboxconfig->mailbox_save_sent_mails == 1)
|
||||
{
|
||||
|
||||
$folder=str_replace($ref, '', $mailboxconfig->folder_cache_key);
|
||||
if (!$folder) $folder = "Sent"; // Default Sent folder
|
||||
|
||||
$mailboxconfig->mbox = imap_open($mailboxconfig->get_connector_url().$folder, $mailboxconfig->mailbox_imap_login, $mailboxconfig->mailbox_imap_password);
|
||||
if (false === $mailboxconfig->mbox)
|
||||
{
|
||||
$info = false;
|
||||
$err = $langs->trans('Error3_Imap_Connection_Error');
|
||||
setEventMessages($err,$mailboxconfig->element, null, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
$mailboxconfig->mailboxid=$_POST['frommail'];
|
||||
$mailboxconfig->foldername=$folder;
|
||||
$from = $mailfromid[0] . $mailfromid[2];
|
||||
$imap=1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Make substitution in email content
|
||||
$substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object);
|
||||
$substitutionarray['__EMAIL__'] = $sendto;
|
||||
@ -398,38 +343,38 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
|
||||
$subject = make_substitutions($subject, $substitutionarray);
|
||||
$message = make_substitutions($message, $substitutionarray);
|
||||
|
||||
if (method_exists($object, 'makeSubstitution'))
|
||||
{
|
||||
if (method_exists($object, 'makeSubstitution')) {
|
||||
$subject = $object->makeSubstitution($subject);
|
||||
$message = $object->makeSubstitution($message);
|
||||
}
|
||||
|
||||
// Send mail (substitutionarray must be done just before this)
|
||||
if (empty($sendcontext)) $sendcontext = 'standard';
|
||||
if (empty($sendcontext)) {
|
||||
$sendcontext = 'standard';
|
||||
}
|
||||
$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext);
|
||||
|
||||
if ($mailfile->error)
|
||||
{
|
||||
if ($mailfile->error) {
|
||||
setEventMessages($mailfile->error, $mailfile->errors, 'errors');
|
||||
$action = 'presend';
|
||||
} else {
|
||||
$result = $mailfile->sendfile();
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
// Initialisation of datas of object to call trigger
|
||||
if (is_object($object))
|
||||
{
|
||||
if (empty($actiontypecode)) $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically
|
||||
if (is_object($object)) {
|
||||
if (empty($actiontypecode)) {
|
||||
$actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically
|
||||
}
|
||||
|
||||
$object->socid = $sendtosocid; // To link to a company
|
||||
$object->sendtoid = $sendtoid; // To link to contact-addresses. This is an array.
|
||||
$object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
|
||||
$object->actionmsg = $actionmsg; // Long text (@todo Replace this with $message, we already have details of email in dedicated properties)
|
||||
$object->actionmsg2 = $actionmsg2; // Short text ($langs->transnoentities('MailSentBy')...);
|
||||
$object->actionmsg2 = $actionmsg2; // Short text ($langs->transnoentities('MailSentBy')...);
|
||||
|
||||
$object->trackid = $trackid;
|
||||
$object->fk_element = $object->id;
|
||||
$object->elementtype = $object->element;
|
||||
$object->fk_element = $object->id;
|
||||
$object->elementtype = $object->element;
|
||||
if (is_array($attachedfiles) && count($attachedfiles) > 0) {
|
||||
$object->attachedfiles = $attachedfiles;
|
||||
}
|
||||
@ -447,11 +392,12 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
|
||||
$object->email_msgid = $mailfile->msgid;
|
||||
|
||||
// Call of triggers (you should have set $triggersendname to execute trigger. $trigger_name is deprecated)
|
||||
if (!empty($triggersendname) || !empty($trigger_name))
|
||||
{
|
||||
if (!empty($triggersendname) || !empty($trigger_name)) {
|
||||
// Call trigger
|
||||
$result = $object->call_trigger(empty($triggersendname) ? $trigger_name : $triggersendname, $user);
|
||||
if ($result < 0) $error++;
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
|
||||
if ($error) {
|
||||
@ -466,10 +412,12 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
|
||||
$mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2));
|
||||
setEventMessages($mesg, null, 'mesgs');
|
||||
|
||||
$moreparam = '';
|
||||
if (isset($paramname2) || isset($paramval2)) $moreparam .= '&'.($paramname2 ? $paramname2 : 'mid').'='.$paramval2;
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname ? $paramname : 'id').'='.(is_object($object) ? $object->id : '').$moreparam);
|
||||
exit;
|
||||
$moreparam = '';
|
||||
if (isset($paramname2) || isset($paramval2)) {
|
||||
$moreparam .= '&'.($paramname2 ? $paramname2 : 'mid').'='.$paramval2;
|
||||
}
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname ? $paramname : 'id').'='.(is_object($object) ? $object->id : '').$moreparam);
|
||||
exit;
|
||||
} else {
|
||||
$langs->load("other");
|
||||
$mesg = '<div class="error">';
|
||||
|
||||
@ -6668,8 +6668,7 @@ class Form
|
||||
});
|
||||
</script>';
|
||||
|
||||
if ($acceptdelayedhtml)
|
||||
{
|
||||
if ($acceptdelayedhtml) {
|
||||
$delayedhtmlcontent .= $outdelayed;
|
||||
} else {
|
||||
$out .= $outdelayed;
|
||||
@ -6707,24 +6706,20 @@ class Form
|
||||
}
|
||||
|
||||
// Add code for jquery to use multiselect
|
||||
if (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT'))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) {
|
||||
$out .= "\n".'<!-- JS CODE TO ENABLE select for id '.$htmlname.' -->
|
||||
<script>'."\n";
|
||||
if ($addjscombo == 1)
|
||||
{
|
||||
if ($addjscombo == 1) {
|
||||
$tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
|
||||
$out .= 'function formatResult(record) {'."\n";
|
||||
if ($elemtype == 'category')
|
||||
{
|
||||
if ($elemtype == 'category') {
|
||||
$out .= 'return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png"> \'+record.text+\'</span>\';';
|
||||
} else {
|
||||
$out .= 'return record.text;';
|
||||
}
|
||||
$out .= '};'."\n";
|
||||
$out .= 'function formatSelection(record) {'."\n";
|
||||
if ($elemtype == 'category')
|
||||
{
|
||||
if ($elemtype == 'category') {
|
||||
$out .= 'return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png"> \'+record.text+\'</span>\';';
|
||||
} else {
|
||||
$out .= 'return record.text;';
|
||||
@ -6741,8 +6736,7 @@ class Form
|
||||
templateSelection: formatSelection /* For 4.0 */
|
||||
});
|
||||
});'."\n";
|
||||
} elseif ($addjscombo == 2 && !defined('DISABLE_MULTISELECT'))
|
||||
{
|
||||
} elseif ($addjscombo == 2 && !defined('DISABLE_MULTISELECT')) {
|
||||
// Add other js lib
|
||||
// TODO external lib multiselect/jquery.multi-select.js must have been loaded to use this multiselect plugin
|
||||
// ...
|
||||
@ -6763,20 +6757,18 @@ class Form
|
||||
|
||||
// Try also magic suggest
|
||||
$out .= '<select id="'.$htmlname.'" class="multiselect'.($morecss ? ' '.$morecss : '').'" multiple name="'.$htmlname.'[]"'.($moreattrib ? ' '.$moreattrib : '').($width ? ' style="width: '.(preg_match('/%/', $width) ? $width : $width.'px').'"' : '').'>'."\n";
|
||||
if (is_array($array) && !empty($array))
|
||||
{
|
||||
if ($value_as_key) $array = array_combine($array, $array);
|
||||
if (is_array($array) && !empty($array)) {
|
||||
if ($value_as_key) {
|
||||
$array = array_combine($array, $array);
|
||||
}
|
||||
|
||||
if (!empty($array))
|
||||
{
|
||||
foreach ($array as $key => $value)
|
||||
{
|
||||
if (!empty($array)) {
|
||||
foreach ($array as $key => $value) {
|
||||
$newval = ($translate ? $langs->trans($value) : $value);
|
||||
$newval = ($key_in_label ? $key.' - '.$newval : $newval);
|
||||
|
||||
$out .= '<option value="'.$key.'"';
|
||||
if (is_array($selected) && !empty($selected) && in_array((string) $key, $selected) && ((string) $key != ''))
|
||||
{
|
||||
if (is_array($selected) && !empty($selected) && in_array((string) $key, $selected) && ((string) $key != '')) {
|
||||
$out .= ' selected';
|
||||
}
|
||||
$out .= ' data-html="'.dol_escape_htmltag($newval).'"';
|
||||
@ -6805,36 +6797,36 @@ class Form
|
||||
{
|
||||
global $conf, $langs, $user, $extrafields;
|
||||
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) return '';
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$tmpvar = "MAIN_SELECTEDFIELDS_".$varpage; // To get list of saved seleteced properties
|
||||
if (!empty($user->conf->$tmpvar))
|
||||
{
|
||||
if (!empty($user->conf->$tmpvar)) {
|
||||
$tmparray = explode(',', $user->conf->$tmpvar);
|
||||
foreach ($array as $key => $val)
|
||||
{
|
||||
foreach ($array as $key => $val) {
|
||||
//var_dump($key);
|
||||
//var_dump($tmparray);
|
||||
if (in_array($key, $tmparray)) $array[$key]['checked'] = 1;
|
||||
else $array[$key]['checked'] = 0;
|
||||
if (in_array($key, $tmparray)) {
|
||||
$array[$key]['checked'] = 1;
|
||||
} else {
|
||||
$array[$key]['checked'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$lis = '';
|
||||
$listcheckedstring = '';
|
||||
|
||||
foreach ($array as $key => $val)
|
||||
{
|
||||
foreach ($array as $key => $val) {
|
||||
/* var_dump($val);
|
||||
var_dump(array_key_exists('enabled', $val));
|
||||
var_dump(!$val['enabled']);*/
|
||||
if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled'])
|
||||
{
|
||||
if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled']) {
|
||||
unset($array[$key]); // We don't want this field
|
||||
continue;
|
||||
}
|
||||
if ($val['label'])
|
||||
{
|
||||
if ($val['label']) {
|
||||
if (!empty($val['langfile']) && is_object($langs)) {
|
||||
$langs->load($val['langfile']);
|
||||
}
|
||||
|
||||
@ -120,8 +120,16 @@ class FormMail extends Form
|
||||
public $withtocc;
|
||||
public $withtoccc;
|
||||
public $withtopic;
|
||||
public $withfile; // 0=No attaches files, 1=Show attached files, 2=Can add new attached files
|
||||
public $withmaindocfile; // 1=Add a checkbox "Attach also main document" for mass actions (checked by default), -1=Add checkbox (not checked by default)
|
||||
|
||||
/**
|
||||
* @var int 0=No attaches files, 1=Show attached files, 2=Can add new attached files
|
||||
*/
|
||||
public $withfile;
|
||||
|
||||
/**
|
||||
* @var int 1=Add a checkbox "Attach also main document" for mass actions (checked by default), -1=Add checkbox (not checked by default)
|
||||
*/
|
||||
public $withmaindocfile;
|
||||
public $withbody;
|
||||
|
||||
public $withfromreadonly;
|
||||
@ -195,7 +203,9 @@ class FormMail extends Form
|
||||
// Set tmp user directory
|
||||
$vardir = $conf->user->dir_output."/".$user->id;
|
||||
$upload_dir = $vardir.'/temp/'; // TODO Add $keytoavoidconflict in upload_dir path
|
||||
if (is_dir($upload_dir)) dol_delete_dir_recursive($upload_dir);
|
||||
if (is_dir($upload_dir)) {
|
||||
dol_delete_dir_recursive($upload_dir);
|
||||
}
|
||||
|
||||
$keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined
|
||||
unset($_SESSION["listofpaths".$keytoavoidconflict]);
|
||||
@ -219,15 +229,24 @@ class FormMail extends Form
|
||||
$listofnames = array();
|
||||
$listofmimes = array();
|
||||
|
||||
if (empty($file)) $file = basename($path);
|
||||
if (empty($type)) $type = dol_mimetype($file);
|
||||
if (empty($file)) {
|
||||
$file = basename($path);
|
||||
}
|
||||
if (empty($type)) {
|
||||
$type = dol_mimetype($file);
|
||||
}
|
||||
|
||||
$keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined
|
||||
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
|
||||
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
|
||||
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
|
||||
if (!in_array($file, $listofnames))
|
||||
{
|
||||
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) {
|
||||
$listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
|
||||
}
|
||||
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) {
|
||||
$listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
|
||||
}
|
||||
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) {
|
||||
$listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
|
||||
}
|
||||
if (!in_array($file, $listofnames)) {
|
||||
$listofpaths[] = $path;
|
||||
$listofnames[] = $file;
|
||||
$listofmimes[] = $type;
|
||||
@ -252,11 +271,16 @@ class FormMail extends Form
|
||||
$listofmimes = array();
|
||||
|
||||
$keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined
|
||||
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
|
||||
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
|
||||
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
|
||||
if ($keytodelete >= 0)
|
||||
{
|
||||
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) {
|
||||
$listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
|
||||
}
|
||||
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) {
|
||||
$listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
|
||||
}
|
||||
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) {
|
||||
$listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
|
||||
}
|
||||
if ($keytodelete >= 0) {
|
||||
unset($listofpaths[$keytodelete]);
|
||||
unset($listofnames[$keytodelete]);
|
||||
unset($listofmimes[$keytodelete]);
|
||||
@ -281,9 +305,15 @@ class FormMail extends Form
|
||||
$listofmimes = array();
|
||||
|
||||
$keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined
|
||||
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
|
||||
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
|
||||
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
|
||||
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) {
|
||||
$listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
|
||||
}
|
||||
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) {
|
||||
$listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
|
||||
}
|
||||
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) {
|
||||
$listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
|
||||
}
|
||||
return array('paths'=>$listofpaths, 'names'=>$listofnames, 'mimes'=>$listofmimes);
|
||||
}
|
||||
|
||||
|
||||
@ -92,7 +92,7 @@ MailingModuleDescEmailsFromUser=Emails input by user
|
||||
MailingModuleDescDolibarrUsers=Users with Emails
|
||||
MailingModuleDescThirdPartiesByCategories=Third parties (by categories)
|
||||
SendingFromWebInterfaceIsNotAllowed=Sending from web interface is not allowed.
|
||||
EmailCollectorFilterDesc=All filters must match to have an email being collected
|
||||
EmailCollectorFilterDesc=All filters must match to have an email being collected
|
||||
|
||||
# Libelle des modules de liste de destinataires mailing
|
||||
LineInFile=Line %s in file
|
||||
@ -174,4 +174,4 @@ Unanswered=Unanswered
|
||||
Answered=Answered
|
||||
IsNotAnAnswer=Is not answer (initial email)
|
||||
IsAnAnswer=Is an answer of an initial email
|
||||
RecordCreatedByEmailCollector=Record created by the Email Collector %s from email %s
|
||||
RecordCreatedByEmailCollector=Record created by the Email Collector %s from email %s
|
||||
|
||||
Loading…
Reference in New Issue
Block a user