$tpl->assign('associate_result', $res); } else { foreach ($_POST['item'] as $item) { $email = Support::getEmailDetails(Email_Account::getAccountByEmail($item), $item); // add the message body as a note $_POST['full_message'] = $email['seb_full_email']; $_POST['title'] = $email['sup_subject']; $_POST['note'] = $email['seb_body']; // XXX: probably broken to use the current logged in user as the 'owner' of // XXX: this new note, but that's how it was already $res = Note::insertFromPost(Auth::getUserID(), $_POST['issue_id'], false, true, false, true, true); // remove the associated email if ($res) { list($_POST['from']) = Support::getSender(array($item)); Workflow::handleBlockedEmail(Issue::getProjectID($_POST['issue_id']), $_POST['issue_id'], $_POST, 'associated'); Support::removeEmail($item); } } $tpl->assign('associate_result', $res); } @$tpl->assign('total_emails', count($_POST['item'])); } else { @$tpl->assign('emails', $_GET['item']); @$tpl->assign('total_emails', count($_GET['item'])); $prj_id = Issue::getProjectID($_GET['issue_id']); if (CRM::hasCustomerIntegration($prj_id)) { // check if the selected emails all have sender email addresses that are associated with the issue' customer $crm = CRM::getInstance($prj_id); $senders = Support::getSender($_GET['item']); $sender_emails = array(); foreach ($senders as $sender) {
$tpl->assign("associate_result", $res); } else { for ($i = 0; $i < count($HTTP_POST_VARS['item']); $i++) { $email = Support::getEmailDetails(Email_Account::getAccountByEmail($HTTP_POST_VARS['item'][$i]), $HTTP_POST_VARS['item'][$i]); // add the message body as a note $HTTP_POST_VARS['blocked_msg'] = $email['seb_full_email']; $HTTP_POST_VARS['title'] = $email['sup_subject']; $HTTP_POST_VARS['note'] = $email['seb_body']; // XXX: probably broken to use the current logged in user as the 'owner' of // XXX: this new note, but that's how it was already $res = Note::insert(Auth::getUserID(), $HTTP_POST_VARS['issue']); // remove the associated email if ($res) { list($HTTP_POST_VARS["from"]) = Support::getSender(array($HTTP_POST_VARS['item'][$i])); Workflow::handleBlockedEmail(Issue::getProjectID($HTTP_POST_VARS['issue']), $HTTP_POST_VARS['issue'], $HTTP_POST_VARS, 'associated'); Support::removeEmail($HTTP_POST_VARS['item'][$i]); } } $tpl->assign("associate_result", $res); } @$tpl->assign('total_emails', count($HTTP_POST_VARS['item'])); } else { @$tpl->assign('emails', $HTTP_GET_VARS['item']); @$tpl->assign('total_emails', count($HTTP_GET_VARS['item'])); $prj_id = Issue::getProjectID($HTTP_GET_VARS['issue']); if (Customer::hasCustomerIntegration($prj_id)) { // check if the selected emails all have sender email addresses that are associated with the issue' customer $senders = Support::getSender($HTTP_GET_VARS['item']); $sender_emails = array(); for ($i = 0; $i < count($senders); $i++) { $email = Mail_API::getEmailAddress($senders[$i]);
/** * Permanently removes the given support emails from the associated email * server. * * @access public * @param array $sup_ids The list of support emails * @return integer 1 if the removal worked, -1 otherwise */ function expungeEmails($sup_ids) { $accounts = array(); $stmt = "SELECT\n sup_id,\n sup_message_id,\n sup_ema_id\n FROM\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email\n WHERE\n sup_id IN (" . implode(', ', Misc::escapeInteger($sup_ids)) . ")"; $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC); if (PEAR::isError($res)) { Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); return -1; } else { for ($i = 0; $i < count($res); $i++) { // don't remove emails from the imap/pop3 server if the email // account is set to leave a copy of the messages on the server $account_details = Email_Account::getDetails($res[$i]['sup_ema_id']); if (!$account_details['leave_copy']) { // try to re-use an open connection to the imap server if (!in_array($res[$i]['sup_ema_id'], array_keys($accounts))) { $accounts[$res[$i]['sup_ema_id']] = Support::connectEmailServer(Email_Account::getDetails($res[$i]['sup_ema_id'])); } $mbox = $accounts[$res[$i]['sup_ema_id']]; if ($mbox !== FALSE) { // now try to find the UID of the current message-id $matches = @imap_search($mbox, 'TEXT "' . $res[$i]['sup_message_id'] . '"'); if (count($matches) > 0) { for ($y = 0; $y < count($matches); $y++) { $headers = imap_headerinfo($mbox, $matches[$y]); // if the current message also matches the message-id header, then remove it! if ($headers->message_id == $res[$i]['sup_message_id']) { @imap_delete($mbox, $matches[$y]); @imap_expunge($mbox); break; } } } } } // remove the email record from the table Support::removeEmail($res[$i]['sup_id']); } return 1; } }