示例#1
0
    mkdir($dir, 0777);
}
// Write out all of the attachments and generated files to the local filesystem
foreach ((array) $files as $k => $f) {
    $fullpath = $dir . DIRECTORY_SEPARATOR . $f["name"];
    if ($f["blob"]) {
        file_put_contents($fullpath, $f["blob"]);
    } else {
        if ($f["tmp_name"]) {
            rename($f["tmp_name"], $fullpath);
        }
    }
    $files[$k]["fullpath"] = $fullpath;
}
if ($files) {
    comment::update_mime_parts($commentID, $files);
}
// Re-email the comment out, including any attachments
if (!comment::send_comment($commentID, $emailRecipients, false, $files)) {
    alloc_error("Email failed to send.");
}
foreach ((array) $files as $k => $f) {
    if (file_exists($f["fullpath"])) {
        unlink($f["fullpath"]);
    }
}
rmdir_if_empty($dir);
// Re-direct browser back home
$TPL["message_good"][] = $message_good;
$extra .= "&sbs_link=comments";
alloc_redirect($TPL["url_alloc_" . $_REQUEST["commentMaster"]] . $_REQUEST["commentMaster"] . "ID=" . $_REQUEST["commentMasterID"] . $extra);
示例#2
0
 function rename_email_attachment_dir($dir)
 {
     if ($dir && is_dir($dir)) {
         $b = basename($dir);
         $newdir = dirname($dir) . DIRECTORY_SEPARATOR . $this->get_id();
         rename($dir, $newdir);
         rmdir_if_empty($newdir);
     }
 }
示例#3
0
 function convert_email_to_new_task($email_receive, $change_user = false)
 {
     global $TPL;
     $current_user =& singleton("current_user");
     $orig_current_user =& $current_user;
     if ($change_user) {
         inbox::change_current_user($email_receive->mail_headers["from"]);
         $current_user =& singleton("current_user");
         if (is_object($current_user) && method_exists($current_user, "get_id") && $current_user->get_id()) {
             $personID = $current_user->get_id();
         }
     }
     $email_receive->save_email();
     // Subject line is name, email body is body
     $task = new task();
     $task->set_value("taskName", $email_receive->mail_headers["subject"]);
     $task->set_value("taskDescription", $email_receive->mail_text);
     $task->set_value("priority", "3");
     $task->set_value("taskTypeID", "Task");
     $task->save();
     if (!$TPL["message"] && $task->get_id()) {
         $dir = ATTACHMENTS_DIR . DIRECTORY_SEPARATOR . "task" . DIRECTORY_SEPARATOR . $task->get_id();
         if (!is_dir($dir)) {
             mkdir($dir);
             foreach ((array) $email_receive->mimebits as $file) {
                 $fh = fopen($dir . DIRECTORY_SEPARATOR . $file["name"], "wb");
                 fputs($fh, $file["blob"]);
                 fclose($fh);
             }
         }
         rmdir_if_empty(ATTACHMENTS_DIR . DIRECTORY_SEPARATOR . "task" . DIRECTORY_SEPARATOR . $task->get_id());
         $msg = "Created task " . $task->get_task_link(array("prefixTaskID" => true)) . " and moved the email to the task's mail folder.";
         $mailbox = "INBOX/task" . $task->get_id();
         $email_receive->create_mailbox($mailbox) and $msg .= "\nCreated mailbox: " . $mailbox;
         $email_receive->archive($mailbox) and $msg .= "\nMoved email to " . $mailbox;
         $msg and $TPL["message_good_no_esc"][] = $msg;
         list($from_address, $from_name) = parse_email_address($email_receive->mail_headers["from"]);
         $ip["emailAddress"] = $from_address;
         $ip["name"] = $from_name;
         $ip["personID"] = $personID;
         $ip["entity"] = "task";
         $ip["entityID"] = $task->get_id();
         interestedParty::add_interested_party($ip);
     }
     // Put current_user back to normal
     $current_user =& $orig_current_user;
     singleton("current_user", $current_user);
 }