if (!empty($_SESSION["listofnames"])) { $listofnames = explode(';', $_SESSION["listofnames"]); } if (!empty($_SESSION["listofmimes"])) { $listofmimes = explode(';', $_SESSION["listofmimes"]); } include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); foreach ($listofpaths as $key => $value) { $pathtodelete = $value; $filetodelete = $listofnames[$key]; $result = dol_delete_file($pathtodelete, 1); // Delete uploded Files $langs->load("other"); setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs'); $formmail->remove_attached_files($key); // Update Session } } /* * Send mail */ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST['removAll'] && !$_POST['removedfile'] && !$_POST['cancel'] && !$_POST['modelselected']) { if ($conf->dolimail->enabled) { $langs->load("dolimail@dolimail"); } $langs->load('mails'); $subject = ''; $actionmsg = ''; $actionmsg2 = ''; $result = $object->fetch($id);
/** * Remove an uploaded file (for example after submitting a new file a mail form). * All information used are in db, conf, langs, user and _FILES. * * @param int $filenb File nb to delete * @param int $donotupdatesession 1=Do not edit _SESSION variable * @param int $donotdeletefile 1=Do not delete physically file * @return void */ function dol_remove_file_process($filenb, $donotupdatesession = 0, $donotdeletefile = 1) { global $db, $user, $conf, $langs, $_FILES; $keytodelete = $filenb; $keytodelete--; $listofpaths = array(); $listofnames = array(); $listofmimes = array(); if (!empty($_SESSION["listofpaths"])) { $listofpaths = explode(';', $_SESSION["listofpaths"]); } if (!empty($_SESSION["listofnames"])) { $listofnames = explode(';', $_SESSION["listofnames"]); } if (!empty($_SESSION["listofmimes"])) { $listofmimes = explode(';', $_SESSION["listofmimes"]); } if ($keytodelete >= 0) { $pathtodelete = $listofpaths[$keytodelete]; $filetodelete = $listofnames[$keytodelete]; if (empty($donotdeletefile)) { $result = dol_delete_file($pathtodelete, 1); } else { $result = 0; } if ($result >= 0) { if (empty($donotdeletefile)) { $langs->load("other"); setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs'); } if (empty($donotupdatesession)) { include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $formmail->remove_attached_files($keytodelete); } } } }
} if (!empty($_SESSION["listofnames"])) { $listofnames = explode(';', $_SESSION["listofnames"]); } if (!empty($_SESSION["listofmimes"])) { $listofmimes = explode(';', $_SESSION["listofmimes"]); } if ($keytodelete >= 0) { $pathtodelete = $listofpaths[$keytodelete]; $filetodelete = $listofnames[$keytodelete]; $result = dol_delete_file($pathtodelete, 1); if ($result) { setEventMessage($langs->trans("FileWasRemoved"), $filetodelete); include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $formmail->remove_attached_files($keytodelete); } } if ($_POST['removedfile'] || ($action = 'send')) { $action = 'test'; } if ($_POST['removedfilehtml'] || ($action = 'sendhtml')) { $action = 'testhtml'; } } /* * Send mail */ if (($action == 'send' || $action == 'sendhtml') && !GETPOST('addfile') && !GETPOST('addfilehtml') && !GETPOST('removedfile') && !GETPOST('cancel')) { $error = 0; $email_from = '';
/** * Remove an uploaded file (for example after submitting a new file a mail form). * All information used are in db, conf, langs, user and _FILES. * @param filenb File nb to delete * @param donotupdatesession 1=Do not edit _SESSION variable * @param donotdeletefile 1=Do not delete physically file * @return string Message with result of upload and store. */ function dol_remove_file_process($filenb,$donotupdatesession=0,$donotdeletefile=0) { global $db,$user,$conf,$langs,$_FILES; $mesg=''; $keytodelete=$filenb; $keytodelete--; $listofpaths=array(); $listofnames=array(); $listofmimes=array(); if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]); if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]); if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]); if ($keytodelete >= 0) { $pathtodelete=$listofpaths[$keytodelete]; $filetodelete=$listofnames[$keytodelete]; if (empty($donotdeletefile)) $result = dol_delete_file($pathtodelete,1); else $result=0; if ($result >= 0) { if (empty($donotdeletefile)) { $langs->load("other"); $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",$filetodelete).'</div>'; //print_r($_FILES); } if (empty($donotupdatesession)) { include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'); $formmail = new FormMail($db); $formmail->remove_attached_files($keytodelete); } } } return $mesg; }