Beispiel #1
0
while ($row = $db->row($qid)) {
    // For each comment, ascertain the taskID
    $entity = $row["commentMaster"];
    $entityID = $row["commentMasterID"];
    // Use the taskID to query the mbox.taskID for all its emails
    $mail = new email_receive($info);
    $mail->open_mailbox("INBOX");
    $created = $mail->create_mailbox("INBOX/" . $entity . $entityID);
    $created or $created = $mail->create_mailbox("INBOX." . $entity . $entityID);
    $opened = $mail->open_mailbox("INBOX/" . $entity . $entityID);
    $uids = $mail->get_all_email_msg_uids();
    //e("Entity: ".$entity.$entityID." comment: ".$row["commentID"]." uids: ".print_r($uids,1));
    $found = false;
    foreach ((array) $uids as $uid) {
        // If there's one that looks like the current one, forgeddaboutit
        list($header, $body) = $mail->get_raw_email_by_msg_uid($uid);
        similar_text(preg_replace("/\\s+/", "", trim($row["comment"])), preg_replace("/\\s+/", "", trim($body)), $percent);
        if ($percent > 97) {
            $found = true;
            #e("percent: ".$percent);
            #e("1-------------------");
            #e($row["comment"]);
            #e("2-------------------");
            #e($body);
            #e("E-------------------");
        }
    }
    // If not found, append the comment to the mailbox
    if (!$found) {
        e("Appending this comment: " . $row["comment"]);
        $people_cache =& get_cached_table("person");
Beispiel #2
0
$info["password"] = config::get_config_item("allocEmailPassword");
$info["protocol"] = config::get_config_item("allocEmailProtocol");
if (!$info["host"]) {
    alloc_error("Email mailbox host not defined, assuming email fetch function is inactive.", true);
}
if ($_REQUEST["commentID"]) {
    $c = new comment();
    $c->set_id($_REQUEST["commentID"]);
    $c->select();
    $entity = $c->get_value("commentMaster");
    $entityID = $c->get_value("commentMasterID");
    $mail = new email_receive($info);
    $mail->open_mailbox(config::get_config_item("allocEmailFolder") . "/" . $entity . $entityID);
    if ($_REQUEST["uid"]) {
        header('Content-Type: text/plain; charset=utf-8');
        list($h, $b) = $mail->get_raw_email_by_msg_uid($_REQUEST["uid"]);
        $mail->close();
        echo $h . $b;
        exit;
    }
    //$uids = $mail->get_all_email_msg_uids();
    $t = new token();
    $t->select_token_by_entity_and_action($c->get_value("commentType"), $c->get_value("commentLinkID"), "add_comment_from_email");
    $hash = $t->get_value("tokenHash");
    // First try a messageID search
    if ($c->get_value("commentEmailMessageID")) {
        $str = sprintf('TEXT "%s"', $c->get_value("commentEmailMessageID"));
        $uids = $mail->get_emails_UIDs_search($str);
        if (count($uids) == 1) {
            alloc_redirect($TPL["url_alloc_downloadEmail"] . "commentID=" . $_REQUEST["commentID"] . "&uid=" . $uids[0]);
        } else {
Beispiel #3
0
}
// Tests
if (basename($_SERVER["PHP_SELF"]) == "email_receive.inc.php") {
    define("NO_AUTH", 1);
    require_once "alloc.php";
    //require_once("emailsettings.php");
    $num = 30;
    $e = new email_receive($info);
    $e->open_mailbox("INBOX");
    echo "\nNum emails: " . $e->get_num_emails();
    echo "\nNew emails: " . $e->get_num_new_emails();
    echo "\ncheck_mail(): " . str_replace("\n", " ", print_r($e->mail_info, 1));
    echo "\nget_new_email_msg_uids(): " . str_replace("\n", " ", print_r($e->get_new_email_msg_uids(), 1));
    echo "\nget_all_email_msg_uids(): " . str_replace("\n", " ", print_r($e->get_all_email_msg_uids(), 1));
    //exit();
    echo "\nget_emails_UIDs_search(): " . str_replace("\n", " ", print_r($e->get_emails_UIDs_search("SUBJECT alloc"), 1));
    //echo "\nget_msg_header(): ".str_replace("\n"," ",print_r($e->get_msg_header($num),1));
    echo "\n";
    $e->set_msg($num);
    $e->load_structure();
    echo "\nload_structure(): " . str_replace(" ", " ", print_r($e->mail_structure, 1));
    echo "\nget_charset(): " . $e->get_charset();
    //exit();
    list($h, $b) = $e->get_raw_email_by_msg_uid($num);
    //echo "\nget_raw_email_by_msg_uid(): "."HEADER: ".$h."\nBODY: ".$b;
    echo "\nsave_email(): " . $e->save_email();
    //echo "\nload_parts(): ".print_r($e->mail_parts,1);
    echo "\nmail_text (plaintext version): " . $e->mail_text;
    echo "\nget_commands(): " . print_r($e->get_commands(task::get_exposed_fields()), 1);
    echo "\n";
}
Beispiel #4
0
 /**
  * Get a single email, add an mbox date header line
  * @param integer $emailUID the IMAP UID of an email
  * @return string a single email in mbox format
  */
 public function get_email($emailUID)
 {
     $current_user =& singleton("current_user");
     //$lockfile = ATTACHMENTS_DIR."mail.lock.person_".$current_user->get_id();
     if ($emailUID) {
         $info = $this->init_email_info();
         $mail = new email_receive($info);
         $mail->open_mailbox(config::get_config_item("allocEmailFolder"), OP_READONLY);
         list($header, $body) = $mail->get_raw_email_by_msg_uid($emailUID);
         $mail->close();
         $m = new email_send();
         $m->set_headers($header);
         $timestamp = $m->get_header('Date');
         $str = "From allocPSA " . date('D M  j G:i:s Y', strtotime($timestamp)) . "\r\n" . $header . $body;
         return utf8_encode(str_replace("\r\n", "\n", $str));
     }
 }