} } //$lockfile = ATTACHMENTS_DIR."mail.lock.person_".$current_user->get_id(); $info["host"] = config::get_config_item("allocEmailHost"); $info["port"] = config::get_config_item("allocEmailPort"); $info["username"] = config::get_config_item("allocEmailUsername"); $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
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; }
function comment_stats() { // date from which a comment is counted as being new. if monday then date back to friday, else the previous day $days = date("w") == 1 ? 3 : 1; $date = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - $days, date("Y"))); $query = "SELECT * FROM comment"; $db = new db_alloc(); $db->query($query); while ($db->next_record()) { $comment = new comment(); $comment->read_db_record($db); $this->comments["total"][$comment->get_value("commentModifiedUser")]++; $this->comments["total"]["total"]++; if ($comment->get_value("commentModifiedTime") != "") { if (!isset($this->comments["all"][$comment->get_value("commentModifiedUser")])) { $this->comments["all"][$comment->get_value("commentModifiedUser")] = array(); } $this->comments["all"][$comment->get_value("commentModifiedUser")][date("Y-m-d", strtotime($comment->get_value("commentModifiedTime")))]++; $this->comments["all"][$comment->get_value("commentModifiedUser")]["total"]++; $this->comments["all"]["total"][date("Y-m-d", strtotime($comment->get_value("commentModifiedTime")))]++; if (strcmp($date, $comment->get_value("commentModifiedTime")) <= 0) { if (!isset($this->comments["new"][$comment->get_value("commentModifiedUser")])) { $this->comments["new"][$comment->get_value("commentModifiedUser")] = array(); } $this->comments["new"][$comment->get_value("commentModifiedUser")][date("Y-m-d", strtotime($comment->get_value("commentModifiedTime")))]++; $this->comments["new"][$comment->get_value("commentModifiedUser")]["total"]++; $this->comments["new"]["total"][date("Y-m-d", strtotime($comment->get_value("commentModifiedTime")))]++; } } } return $this->comments; }