Esempio n. 1
0
        $res = Support::getListDetails($item);
        $tpl->assign('emails', $res);
        $tpl->assign('attached_emails', @implode(',', $item));
        if (CRM::hasCustomerIntegration($prj_id)) {
            $crm = CRM::getInstance($prj_id);
            // also need to guess the contact_id from any attached emails
            try {
                $info = $crm->getCustomerInfoFromEmails($prj_id, $item);
                $tpl->assign(array('customer_id' => $info['customer_id'], 'customer_name' => $info['customer_name'], 'contact_id' => $info['contact_id'], 'contact_name' => $info['contact_name'], 'contacts' => $info['contacts']));
            } catch (CRMException $e) {
            }
        }
        // if we are dealing with just one message, use the subject line as the
        // summary for the issue, and the body as the description
        if (count($item) == 1) {
            $email_details = Support::getEmailDetails(Email_Account::getAccountByEmail($item[0]), $item[0]);
            $tpl->assign(array('issue_summary' => $email_details['sup_subject'], 'issue_description' => $email_details['seb_body']));
            // also auto pre-fill the customer contact text fields
            if (CRM::hasCustomerIntegration($prj_id)) {
                $sender_email = Mail_Helper::getEmailAddress($email_details['sup_from']);
                try {
                    $contact = $crm->getContactByEmail($sender_email);
                    $tpl->assign('contact_details', $contact->getDetails());
                } catch (CRMException $e) {
                }
            }
        }
    }
}
$tpl->assign(array('cats' => Category::getAssocList($prj_id), 'priorities' => Priority::getAssocList($prj_id), 'severities' => Severity::getList($prj_id), 'users' => Project::getUserAssocList($prj_id, 'active', User::getRoleID('Customer')), 'releases' => Release::getAssocList($prj_id), 'custom_fields' => Custom_Field::getListByProject($prj_id, 'report_form'), 'max_attachment_size' => Attachment::getMaxAttachmentSize(), 'max_attachment_bytes' => Attachment::getMaxAttachmentSize(true), 'field_display_settings' => Project::getFieldDisplaySettings($prj_id), 'groups' => Group::getAssocList($prj_id), 'products' => Product::getList(false)));
$prefs = Prefs::get($usr_id);
Esempio n. 2
0
// enter the time tracking entry about this new email
if ($cat == 'save_draft' || $cat == 'update_draft') {
    if (!empty($_POST['time_spent'])) {
        $date = (array) $_POST['date'];
        $ttc_id = Time_Tracking::getCategoryId($prj_id, 'Email Discussion');
        $time_spent = (int) $_POST['time_spent'];
        $summary = 'Time entry inserted when saving an email draft.';
        Time_Tracking::addTimeEntry($issue_id, $ttc_id, $time_spent, $date, $summary);
    }
}
if ($cat == 'view_draft') {
    $draft = Draft::getDetails($_GET['id']);
    $email = array('sup_subject' => $draft['emd_subject'], 'seb_body' => $draft['emd_body'], 'sup_from' => $draft['to'], 'cc' => implode('; ', $draft['cc']));
    // try to guess the correct email account to be associated with this email
    if (!empty($draft['emd_sup_id'])) {
        $_GET['ema_id'] = Email_Account::getAccountByEmail($draft['emd_sup_id']);
    } else {
        // if we are not replying to an existing message, just get the first email account you can find...
        $_GET['ema_id'] = Email_Account::getEmailAccount();
    }
    $tpl->assign(array('draft_id' => $_GET['id'], 'email' => $email, 'parent_email_id' => $draft['emd_sup_id'], 'draft_status' => $draft['emd_status']));
    if ($draft['emd_status'] != 'pending') {
        $tpl->assign('read_only', 1);
    }
} elseif ($cat == 'create_draft') {
    $tpl->assign('hide_email_buttons', 'yes');
} else {
    if (!empty($_GET['id'])) {
        $email = Support::getEmailDetails($_GET['ema_id'], $_GET['id']);
        $header = Misc::formatReplyPreamble($email['timestamp'], $email['sup_from']);
        $email['seb_body'] = $header . Misc::formatReply($email['seb_body']);
Esempio n. 3
0
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
            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);
Esempio n. 4
0
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
            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);
Esempio n. 5
0
    }
}
if (@$HTTP_GET_VARS["cat"] == "associate") {
    if (@count($HTTP_GET_VARS["item"]) > 0) {
        $res = Support::getListDetails($HTTP_GET_VARS["item"]);
        $tpl->assign("emails", $res);
        $tpl->assign("attached_emails", @implode(",", $HTTP_GET_VARS["item"]));
        if (Customer::hasCustomerIntegration($prj_id)) {
            // also need to guess the contact_id from any attached emails
            $info = Customer::getCustomerInfoFromEmails($prj_id, $HTTP_GET_VARS["item"]);
            $tpl->assign(array("customer_id" => $info['customer_id'], 'customer_name' => $info['customer_name'], "contact_id" => $info['contact_id'], 'contact_name' => $info['contact_name'], 'contacts' => $info['contacts']));
        }
        // if we are dealing with just one message, use the subject line as the
        // summary for the issue, and the body as the description
        if (count($HTTP_GET_VARS["item"]) == 1) {
            $email_details = Support::getEmailDetails(Email_Account::getAccountByEmail($HTTP_GET_VARS["item"][0]), $HTTP_GET_VARS["item"][0]);
            $tpl->assign(array('issue_summary' => $email_details['sup_subject'], 'issue_description' => $email_details['message']));
            // also auto pre-fill the customer contact text fields
            if (Customer::hasCustomerIntegration($prj_id)) {
                $sender_email = Mail_API::getEmailAddress($email_details['sup_from']);
                list(, $contact_id) = Customer::getCustomerIDByEmails($prj_id, array($sender_email));
                if (!empty($contact_id)) {
                    $tpl->assign("contact_details", Customer::getContactDetails($prj_id, $contact_id));
                }
            }
        }
    }
}
$tpl->assign(array("cats" => Category::getAssocList($prj_id), "priorities" => Priority::getAssocList($prj_id), "users" => Project::getUserAssocList($prj_id, 'active', User::getRoleID('Customer')), "releases" => Release::getAssocList($prj_id), "custom_fields" => Custom_Field::getListByProject($prj_id, 'report_form'), "max_attachment_size" => Attachment::getMaxAttachmentSize(), "field_display_settings" => Project::getFieldDisplaySettings($prj_id), "groups" => Group::getAssocList($prj_id)));
$setup = Setup::load();
$tpl->assign("allow_unassigned_issues", @$setup["allow_unassigned_issues"]);
 /**
  * Method used to send an email notification to the sender of a
  * set of email messages that were manually converted into an
  * issue.
  *
  * @param   integer $prj_id The project ID
  * @param   integer $issue_id The issue ID
  * @param   array $sup_ids The email IDs
  * @param bool|int $customer_id The customer ID
  * @return  array The list of recipient emails
  */
 public static function notifyEmailConvertedIntoIssue($prj_id, $issue_id, $sup_ids, $customer_id = false)
 {
     if (CRM::hasCustomerIntegration($prj_id)) {
         $crm = CRM::getInstance($prj_id);
         return $crm->notifyEmailConvertedIntoIssue($issue_id, $sup_ids, $customer_id);
     } else {
         // build the list of recipients
         $recipients = array();
         $recipient_emails = array();
         foreach ($sup_ids as $sup_id) {
             $senders = Support::getSender(array($sup_id));
             if (count($senders) > 0) {
                 $sender_email = Mail_Helper::getEmailAddress($senders[0]);
                 $recipients[$sup_id] = $senders[0];
                 $recipient_emails[] = $sender_email;
             }
         }
         if (!$recipients) {
             return false;
         }
         $data = Issue::getDetails($issue_id);
         foreach ($recipients as $sup_id => $recipient) {
             $recipient_usr_id = User::getUserIDByEmail(Mail_Helper::getEmailAddress($recipient));
             // open text template
             $tpl = new Template_Helper();
             $tpl->setTemplate('notifications/new_auto_created_issue.tpl.text');
             $tpl->assign(array('data' => $data, 'sender_name' => Mail_Helper::getName($recipient), 'app_title' => Misc::getToolCaption(), 'recipient_name' => Mail_Helper::getName($recipient)));
             $email_details = Support::getEmailDetails(Email_Account::getAccountByEmail($sup_id), $sup_id);
             $tpl->assign(array('email' => array('date' => $email_details['sup_date'], 'from' => $email_details['sup_from'], 'subject' => $email_details['sup_subject'])));
             // change the current locale
             if (!empty($recipient_usr_id)) {
                 Language::set(User::getLang($recipient_usr_id));
             } else {
                 Language::set(APP_DEFAULT_LOCALE);
             }
             $text_message = $tpl->getTemplateContents();
             // send email (use PEAR's classes)
             $mail = new Mail_Helper();
             $mail->setTextBody($text_message);
             $setup = $mail->getSMTPSettings();
             $from = self::getFixedFromHeader($issue_id, $setup['from'], 'issue');
             $mail->setHeaders(Mail_Helper::getBaseThreadingHeaders($issue_id));
             // TRANSLATORS: %1 - issue_id, %2 - iss_summary
             $subject = ev_gettext('[#%1$s] Issue Created: %2$s', $issue_id, $data['iss_summary']);
             $mail->send($from, $recipient, $subject, 1, $issue_id, 'email_converted_to_issue');
         }
         Language::restore();
         return $recipient_emails;
     }
 }
Esempio n. 7
0
}
// enter the time tracking entry about this new email
if (@$HTTP_POST_VARS["cat"] == "save_draft" || @$HTTP_POST_VARS["cat"] == "update_draft") {
    if (!empty($HTTP_POST_VARS['time_spent'])) {
        $HTTP_POST_VARS['issue_id'] = $issue_id;
        $HTTP_POST_VARS['category'] = Time_Tracking::getCategoryID('Email Discussion');
        $HTTP_POST_VARS['summary'] = 'Time entry inserted when saving an email draft.';
        Time_Tracking::insertEntry();
    }
}
if (@$HTTP_GET_VARS['cat'] == 'view_draft') {
    $draft = Draft::getDetails($HTTP_GET_VARS['id']);
    $email = array('sup_subject' => $draft['emd_subject'], 'seb_body' => $draft['emd_body'], 'sup_from' => $draft['to'], 'cc' => implode('; ', $draft['cc']));
    // try to guess the correct email account to be associated with this email
    if (!empty($draft['emd_sup_id'])) {
        $HTTP_GET_VARS['ema_id'] = Email_Account::getAccountByEmail($draft['emd_sup_id']);
    } else {
        // if we are not replying to an existing message, just get the first email account you can find...
        $HTTP_GET_VARS['ema_id'] = Email_Account::getEmailAccount();
    }
    $tpl->bulkAssign(array("draft_id" => $HTTP_GET_VARS['id'], "email" => $email, "parent_email_id" => $draft['emd_sup_id'], "draft_status" => $draft['emd_status']));
    if ($draft['emd_status'] != 'pending') {
        $tpl->assign("read_only", 1);
    }
} elseif (@$HTTP_GET_VARS['cat'] == 'create_draft') {
    $tpl->assign("hide_email_buttons", "yes");
} else {
    if (!@empty($HTTP_GET_VARS["id"])) {
        $email = Support::getEmailDetails($HTTP_GET_VARS["ema_id"], $HTTP_GET_VARS["id"]);
        $date = Misc::formatReplyDate($email["timestamp"]);
        $header = "To " . $email["sup_from"] . ",\n\n\nThank you, \n" . Auth::getCurrentProjectName() . "\n\nOn {$date}, " . $email["sup_from"] . " wrote:\n>\n";
 /**
  * Method used to send an email notification to the sender of a
  * set of email messages that were manually converted into an
  * issue.
  *
  * @access  public
  * @param   integer $prj_id The project ID
  * @param   integer $issue_id The issue ID
  * @param   array $sup_ids The email IDs
  * @param   integer $customer_id The customer ID
  * @return  array The list of recipient emails
  */
 function notifyEmailConvertedIntoIssue($prj_id, $issue_id, $sup_ids, $customer_id = FALSE)
 {
     if (Customer::hasCustomerIntegration($prj_id)) {
         return Customer::notifyEmailConvertedIntoIssue($prj_id, $issue_id, $sup_ids, $customer_id);
     } else {
         // build the list of recipients
         $recipients = array();
         $recipient_emails = array();
         for ($i = 0; $i < count($sup_ids); $i++) {
             $senders = Support::getSender(array($sup_ids[$i]));
             if (count($senders) > 0) {
                 $sender_email = Mail_API::getEmailAddress($senders[0]);
                 $recipients[$sup_ids[$i]] = $senders[0];
                 $recipient_emails[] = $sender_email;
             }
         }
         if (count($recipients) == 0) {
             return false;
         }
         $data = Issue::getDetails($issue_id);
         foreach ($recipients as $sup_id => $recipient) {
             // open text template
             $tpl = new Template_API();
             $tpl->setTemplate('notifications/new_auto_created_issue.tpl.text');
             $tpl->bulkAssign(array("data" => $data, "sender_name" => Mail_API::getName($recipient)));
             $email_details = Support::getEmailDetails(Email_Account::getAccountByEmail($sup_id), $sup_id);
             $tpl->assign(array('email' => array('date' => $email_details['sup_date'], 'from' => $email_details['sup_from'], 'subject' => $email_details['sup_subject'])));
             $text_message = $tpl->getTemplateContents();
             // send email (use PEAR's classes)
             $mail = new Mail_API();
             $mail->setTextBody($text_message);
             $setup = $mail->getSMTPSettings();
             $from = Notification::getFixedFromHeader($issue_id, $setup["from"], 'issue');
             $mail->setHeaders(Mail_API::getBaseThreadingHeaders($issue_id));
             $mail->send($from, $recipient, 'New Issue Created', 1, $issue_id, 'email_converted_to_issue');
         }
         return $recipient_emails;
     }
 }