~eventum-developers/eventum/trunk

« back to all changes in this revision

Viewing changes to lib/eventum/class.routing.php

  • Committer: Bryan Alsdorf
  • Date: 2013-08-23 03:50:34 UTC
  • mto: (4033.1.168 eventum-skysql)
  • mto: This revision was merged to the branch mainline in revision 4660.
  • Revision ID: bryan@montyprogram.com-20130823035034-7f5r3pt1xg0xnnhk
Initial commit of CRM migration

Show diffs side-by-side

added added

removed removed

Lines of Context:
171
171
            'headers'        => @$structure->headers
172
172
        );
173
173
        // automatically associate this incoming email with a customer
174
 
        if (Customer::hasCustomerIntegration($prj_id)) {
 
174
        if (CRM::hasCustomerIntegration($prj_id)) {
 
175
            $crm = CRM::getInstance($prj_id);
175
176
            if (!empty($structure->headers['from'])) {
176
 
                list($customer_id,) = Customer::getCustomerIDByEmails($prj_id, array($sender_email));
177
 
                if (!empty($customer_id)) {
178
 
                    $t['customer_id'] = $customer_id;
179
 
                }
 
177
                try {
 
178
                    $contact = $crm->getContactByEmail($sender_email);
 
179
                    $issue_contract = $crm->getContract(Issue::getContractID($issue_id));
 
180
                    if ($contact->canAccessContract($issue_contract)) {
 
181
                        $t['customer_id'] = $issue_contract->getCustomerID();
 
182
                    }
 
183
                } catch (CRMException $e) {}
180
184
            }
181
185
        }
182
186
        if (empty($t['customer_id'])) {