// +----------------------------------------------------------------------+ // | Authors: João Prado Maia <*****@*****.**> | // +----------------------------------------------------------------------+ require_once dirname(__FILE__) . '/../init.php'; $tpl = new Template_Helper(); $tpl->setTemplate('associate.tpl.html'); Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true); if (@$_POST['cat'] == 'associate') { if ($_POST['target'] == 'email') { $res = Support::associate(Auth::getUserID(), $_POST['issue_id'], $_POST['item']); if ($res == 1) { Workflow::handleManualEmailAssociation(Issue::getProjectID($_POST['issue_id']), $_POST['issue_id']); } $tpl->assign('associate_result', $res); } elseif ($_POST['target'] == 'reference') { $res = Support::associateEmail(Auth::getUserID(), $_POST['issue_id'], $_POST['item']); if ($res == 1) { Workflow::handleManualEmailAssociation(Issue::getProjectID($_POST['issue_id']), $_POST['issue_id']); } $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
include_once APP_INC_PATH . "class.issue.php"; include_once APP_INC_PATH . "class.note.php"; include_once APP_INC_PATH . "class.support.php"; include_once APP_INC_PATH . "class.mail.php"; $tpl = new Template_API(); $tpl->setTemplate("associate.tpl.html"); Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true); if (@$HTTP_POST_VARS['cat'] == 'associate') { if ($HTTP_POST_VARS['target'] == 'email') { $res = Support::associate(Auth::getUserID(), $HTTP_POST_VARS['issue'], $HTTP_POST_VARS['item']); if ($res == 1) { Workflow::handleManualEmailAssociation(Issue::getProjectID($HTTP_POST_VARS['issue']), $HTTP_POST_VARS['issue']); } $tpl->assign("associate_result", $res); } elseif ($HTTP_POST_VARS['target'] == 'reference') { $res = Support::associateEmail(Auth::getUserID(), $HTTP_POST_VARS['issue'], $HTTP_POST_VARS['item']); if ($res == 1) { Workflow::handleManualEmailAssociation(Issue::getProjectID($HTTP_POST_VARS['issue']), $HTTP_POST_VARS['issue']); } $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
/** * Method used to associate a support email with an existing * issue. * * @access public * @param integer $usr_id The user ID of the person performing this change * @param integer $issue_id The issue ID * @param array $items The list of email IDs to associate * @param boolean $authorize If the senders should be added the authorized repliers list * @return integer 1 if it worked, -1 otherwise */ function associate($usr_id, $issue_id, $items, $authorize = false) { $res = Support::associateEmail($usr_id, $issue_id, $items); if ($res == 1) { $stmt = "SELECT\n sup_id,\n seb_full_email\n FROM\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email,\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email_body\n WHERE\n sup_id=seb_sup_id AND\n sup_id IN (" . @implode(", ", Misc::escapeInteger($items)) . ")"; $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC); for ($i = 0; $i < count($res); $i++) { // since downloading email should make the emails 'public', send 'false' below as the 'internal_only' flag $structure = Mime_Helper::decode($res[$i]['seb_full_email'], true, false); if (Mime_Helper::hasAttachments($res[$i]['seb_full_email'])) { $has_attachments = 1; } else { $has_attachments = 0; } $t = array('issue_id' => $issue_id, 'message_id' => @$structure->headers['message-id'], 'from' => @$structure->headers['from'], 'to' => @$structure->headers['to'], 'cc' => @$structure->headers['cc'], 'subject' => @$structure->headers['subject'], 'body' => Mime_Helper::getMessageBody($structure), 'full_email' => $res[$i]['seb_full_email'], 'has_attachment' => $has_attachments, 'headers' => @$structure->headers); Notification::notifyNewEmail($usr_id, $issue_id, $t, false, false, '', $res[$i]['sup_id']); if ($authorize) { Authorized_Replier::manualInsert($issue_id, Mail_API::getEmailAddress(@$structure->headers['from']), false); } } return 1; } else { return -1; } }