Example #1
0
function move_attachment($entity, $id = false)
{
    global $TPL;
    $id = sprintf("%d", $id);
    $files = rejig_files_array($_FILES);
    if (is_array($files) && count($files)) {
        foreach ($files as $file) {
            if (is_uploaded_file($file["tmp_name"])) {
                $dir = ATTACHMENTS_DIR . $entity . DIRECTORY_SEPARATOR . $id;
                if (!is_dir($dir)) {
                    mkdir($dir, 0777);
                }
                $newname = basename($file["name"]);
                if (!move_uploaded_file($file["tmp_name"], $dir . DIRECTORY_SEPARATOR . $newname)) {
                    alloc_error("Could not move attachment to: " . $dir . DIRECTORY_SEPARATOR . $newname);
                } else {
                    chmod($dir . DIRECTORY_SEPARATOR . $newname, 0777);
                }
            } else {
                switch ($file['error']) {
                    case 0:
                        alloc_error("There was a problem with your upload.");
                        break;
                    case 1:
                        // upload_max_filesize in php.ini
                        alloc_error("The file you are trying to upload is too big(1).");
                        break;
                    case 2:
                        // MAX_FILE_SIZE
                        alloc_error("The file you are trying to upload is too big(2).");
                        break;
                    case 3:
                        alloc_error("The file you are trying upload was only partially uploaded.");
                        break;
                    case 4:
                        alloc_error("You must select a file for upload.");
                        break;
                    default:
                        alloc_error("There was a problem with your upload.");
                        break;
                }
            }
        }
    }
}
Example #2
0
// add a comment
$commentID = comment::add_comment($_REQUEST["entity"], $_REQUEST["entityID"], $_REQUEST["comment"], $_REQUEST["commentMaster"], $_REQUEST["commentMasterID"]);
if (!$commentID) {
    alloc_error("Could not create comment.", 1);
}
// add additional interested parties
if ($_REQUEST["eo_email"]) {
    $other_parties[$_REQUEST["eo_email"]] = array("name" => $_REQUEST["eo_name"], "addIP" => $_REQUEST["eo_add_interested_party"], "addContact" => $_REQUEST["eo_add_client_contact"], "clientID" => $_REQUEST["eo_client_id"]);
}
// add all interested parties
$emailRecipients = comment::add_interested_parties($commentID, $_REQUEST["commentEmailRecipients"], $other_parties);
// We're going to store all the attachments and generated pdf files in this array
$files = array();
// If someone uploads attachments
if ($_FILES) {
    $files = rejig_files_array($_FILES);
}
// Attach any alloc generated timesheet pdf
if ($_REQUEST["attach_timeSheet"]) {
    $files[] = comment::attach_timeSheet($commentID, $_REQUEST["commentMasterID"], $_REQUEST["attach_timeSheet"]);
}
// Attach any alloc generated invoice pdf
if ($_REQUEST["attach_invoice"]) {
    $_REQUEST["attach_invoice"] == $_REQUEST["generate_pdf_verbose"] and $verbose = true;
    // select
    $_REQUEST["generate_pdf_verbose"] and $verbose = true;
    // link
    $files[] = comment::attach_invoice($commentID, $_REQUEST["commentMasterID"], $verbose);
}
// Attach any alloc generated tasks pdf
if ($_REQUEST["attach_tasks"]) {