/**
 *	\file			htdocs/core/actions_sendmails.inc.php
 *  \brief			Code for actions on sending mails from object page
 */
// TODO Include this include file into all class objects
// $id must be defined
// $actiontypecode must be defined
/*
 * Add file in email form
 */
if (GETPOST('addfile')) {
    require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
    // Set tmp user directory
    $vardir = $conf->user->dir_output . "/" . $user->id;
    $upload_dir_tmp = $vardir . '/temp';
    dol_add_file_process($upload_dir_tmp, 0, 0);
    $action = 'presend';
}
/*
 * Remove file in email form
 */
if (!empty($_POST['removedfile'])) {
    require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
    // Set tmp user directory
    $vardir = $conf->user->dir_output . "/" . $user->id;
    $upload_dir_tmp = $vardir . '/temp';
    // TODO Delete only files that was uploaded from email form
    dol_remove_file_process($_POST['removedfile'], 0);
    $action = 'presend';
}
/*
Beispiel #2
0
$pagenext = $page + 1;
if (!$sortorder) {
    $sortorder = "ASC";
}
if (!$sortfield) {
    $sortfield = "name";
}
$object = new Locataire($db);
$object->fetch($id);
$upload_dir = $conf->immobilier->dir_output . '/locataire/' . dol_sanitizeFileName($object->id);
$modulepart = 'immobilier';
/*
 * Actions
 */
if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC)) {
    dol_add_file_process($upload_dir, 0, 1, 'userfile');
}
if ($action == 'delete') {
    $file = $upload_dir . '/' . GETPOST("urlfile");
    // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
    $ret = dol_delete_file($file);
    if ($ret) {
        setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
    } else {
        setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
    }
}
/*
 * View
 */
llxheader('', $langs->trans("adddocument"), '');
 * or see http://www.gnu.org/
 */
// Variable $upload_dir must be defined when entering here
// Send file/link
if (GETPOST('sendit') && !empty($conf->global->MAIN_UPLOAD_DOC)) {
    if ($object->id) {
        dol_add_file_process($upload_dir, 0, 1, 'userfile');
    }
} elseif (GETPOST('linkit') && !empty($conf->global->MAIN_UPLOAD_DOC)) {
    if ($object->id) {
        $link = GETPOST('link', 'alpha');
        if ($link) {
            if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://') {
                $link = 'http://' . $link;
            }
            dol_add_file_process($upload_dir, 0, 1, 'userfile', null, $link);
        }
    }
}
// Delete file/link
if ($action == 'confirm_deletefile' && $confirm == 'yes') {
    if ($object->id) {
        $urlfile = GETPOST('urlfile', 'alpha');
        // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
        if (GETPOST('section')) {
            $file = $upload_dir . "/" . $urlfile;
        } else {
            $urlfile = basename($urlfile);
            $file = $upload_dir . "/" . $urlfile;
        }
        $linkid = GETPOST('linkid', 'int');
Beispiel #4
0
            Header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id);
            exit;
        }
        $mesg = $object->error;
    }
    $mesg = '<div class="error">' . $mesg . '</div>';
    $action = "";
}
/*
 * Add file in email form
 */
if (!empty($_POST['addfile'])) {
    $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id, 2, 0, 1);
    require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
    // Set tmp user directory
    $mesg = dol_add_file_process($upload_dir, 0, 0);
    $action = "edit";
}
// Action remove file
if (!empty($_POST["removedfile"])) {
    $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id, 2, 0, 1);
    require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
    $mesg = dol_remove_file_process($_POST['removedfile'], 0);
    $action = "edit";
}
// Action update emailing
if ($action == 'update' && empty($_POST["removedfile"]) && empty($_POST["cancel"])) {
    require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
    $isupload = 0;
    if (!$isupload) {
        $object->sujet = trim($_POST["sujet"]);