function send_comment($commentID, $emailRecipients, $email_receive = false, $files = array()) { $comment = new comment(); $comment->set_id($commentID); $comment->select(); $token = new token(); if ($comment->get_value("commentType") == "comment" && $comment->get_value("commentLinkID")) { $c = new comment(); $c->set_id($comment->get_value("commentLinkID")); $c->select(); $is_a_reply_comment = true; if ($token->select_token_by_entity_and_action("comment", $c->get_id(), "add_comment_from_email")) { $hash = $token->get_value("tokenHash"); } } if (!$hash) { if ($token->select_token_by_entity_and_action("comment", $comment->get_id(), "add_comment_from_email")) { $hash = $token->get_value("tokenHash"); } else { $hash = $comment->make_token_add_comment_from_email(); } } $rtn = $comment->send_emails($emailRecipients, $email_receive, $hash, $is_a_reply_comment, $files); if (is_array($rtn)) { $email_sent = true; list($successful_recipients, $messageid) = $rtn; } // Append success to end of the comment if ($successful_recipients) { $append_comment_text = "Email sent to: " . $successful_recipients; $message_good .= $append_comment_text; //$comment->set_value("commentEmailMessageID",$messageid); that's the outbound message-id :-( $comment->set_value("commentEmailRecipients", $successful_recipients); } $comment->skip_modified_fields = true; $comment->updateSearchIndexLater = true; $comment->save(); return $email_sent; }
$recipient_keys = $_POST["reminder_recipient"]; // make 24 hour with 12am = 0 -> 11am = 11 -> 12pm = 12 -> 11pm = 23 if ($_POST["reminder_hour"] == 12) { $_POST["reminder_hour"] = 0; } if ($_POST["reminder_meridian"] == "pm") { $_POST["reminder_hour"] += 12; } $reminder = new reminder(); if (isset($_POST["reminder_update"])) { $reminder->set_id($_POST["reminder_id"]); $reminder->select(); if ($reminder->get_value("reminderHash")) { $token = new token(); $token->set_hash($reminder->get_value("reminderHash"), false); if ($token->get_value("tokenActionID") == 3) { $reminder->set_value("reminderTime", ""); $no = true; } } } $reminder->set_value('reminderType', $parentType); $reminder->set_value('reminderLinkID', $parentID); $reminder->set_value('reminderModifiedUser', $current_user->get_id()); $reminder->set_modified_time(); $no or $reminder->set_value('reminderTime', $_POST["reminder_date"] . " " . $_POST["reminder_hour"] . ":" . $_POST["reminder_minute"] . ":00"); $reminder->set_value('reminderHash', $_POST["reminderHash"]); if (!$_POST["reminder_recuring_value"]) { $reminder->set_value('reminderRecuringInterval', 'No'); $reminder->set_value('reminderRecuringValue', '0'); } else {
$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 { if (count($uids) > 1) { $all_uids += $uids; } } } // Next try a hash lookup if ($hash) { $str = sprintf('TEXT "%s"', $hash);
function archive($mailbox = null) { $keys = $this->get_hashes(); $token = new token(); if ($keys && is_array($keys) && $token->set_hash($keys[0])) { if ($token->get_value("tokenEntity") == "comment") { $db = new db_alloc(); $row = $db->qr("SELECT commentMaster,commentMasterID \n FROM comment\n WHERE commentID = %d", $token->get_value("tokenEntityID")); $m = $row["commentMaster"]; $mID = $row["commentMasterID"]; $mailbox = "INBOX/" . $m . $mID; } else { $m = $token->get_value("tokenEntity"); $mID = $token->get_value("tokenEntityID"); $mailbox = "INBOX/" . $m . $mID; } } $mailbox or $mailbox = "INBOX"; // Some IMAP servers like dot-separated mail folders, some like slash-separated if ($mailbox) { $this->create_mailbox($mailbox); if ($this->msg_uid) { $this->move_mail($this->msg_uid, $mailbox); } else { if ($this->msg_text) { $this->append($mailbox, $this->msg_text); } } } }
function add_comment_via_email($commands, $email_receive) { // If there's Key in the email, then add a comment with the contents of the email. $token = new token(); if ($commands["key"] && $token->set_hash($commands["key"])) { $db = new db_alloc(); $comment = $token->get_value("tokenEntity"); $commentID = $token->get_value("tokenEntityID"); list($entity, $method) = $token->execute(); if (is_object($entity) && $method == "add_comment_from_email") { $c = comment::add_comment_from_email($email_receive, $entity); if (is_object($c) && $c->get_id()) { $quiet = interestedParty::adjust_by_email_subject($email_receive, $entity); if ($commands["ip"]) { $rtn = interestedParty::add_remove_ips($commands["ip"], $entity->classname, $entity->get_id(), $entity->get_project_id()); } if (!$quiet) { comment::send_comment($c->get_id(), array("interested"), $email_receive); } } } // Bad or missing key, then error } else { if ($email_receive) { alloc_error("Bad or missing key. Unable to process email."); } } return array($status, $message); }