Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 $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 {
         if (count($uids) > 1) {
             $all_uids += $uids;
         }
     }
 }
 // Next try a hash lookup
 if ($hash) {