Example #1
0
$issue_id = isset($_GET['issue_id']) ? (int) $_GET['issue_id'] : (isset($_POST['issue_id']) ? (int) $_POST['issue_id'] : null);
$cat = isset($_POST['cat']) ? (string) $_POST['cat'] : (isset($_GET['cat']) ? (string) $_GET['cat'] : null);
$tpl->assign('issue_id', $issue_id);
if (!Issue::canAccess($issue_id, $usr_id)) {
    $tpl->setTemplate('permission_denied.tpl.html');
    $tpl->displayTemplate();
    exit;
}
Workflow::prePage($prj_id, 'send_email');
// since emails associated with issues are sent to the notification list, not the to: field, set the to field to be blank
// this field should already be blank, but may also be unset.
if ($issue_id) {
    $_POST['to'] = '';
}
if ($cat == 'send_email') {
    $res = Support::sendEmailFromPost($_POST['parent_id']);
    $tpl->assign('send_result', $res);
    if (Access::canChangeStatus($issue_id, $usr_id) && isset($_POST['new_status']) && !empty($_POST['new_status'])) {
        $res = Issue::setStatus($issue_id, $_POST['new_status']);
        if ($res != -1) {
            $new_status = Status::getStatusTitle($_POST['new_status']);
            History::add($issue_id, $usr_id, 'status_changed', "Status changed to '{status}' by {user} when sending an email", array('status' => $new_status, 'user' => User::getFullName($usr_id)));
        }
    }
    // remove the existing email draft, if appropriate
    if (!empty($_POST['draft_id'])) {
        Draft::remove($_POST['draft_id']);
    }
    // enter the time tracking entry about this new email
    if (!empty($_POST['time_spent'])) {
        $date = (array) $_POST['date'];
Example #2
0
 /**
  * Converts an email to a draft and sends it.
  *
  * @param   integer $draft_id The id of the draft to send.
  * @return int
  */
 public static function send($draft_id)
 {
     $draft = self::getDetails($draft_id);
     $_POST['issue_id'] = $draft['emd_iss_id'];
     $_POST['subject'] = $draft['emd_subject'];
     $_POST['from'] = User::getFromHeader(Auth::getUserID());
     $_POST['to'] = $draft['to'];
     $_POST['cc'] = @implode(';', $draft['cc']);
     $_POST['message'] = $draft['emd_body'];
     $_POST['ema_id'] = Email_Account::getEmailAccount();
     $res = Support::sendEmailFromPost();
     if ($res == 1) {
         self::remove($draft_id);
     }
     return $res;
 }