~eventum-developers/eventum/trunk

« back to all changes in this revision

Viewing changes to lib/eventum/class.note.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:
565
565
     *
566
566
     * @access  public
567
567
     * @param   $note_id The id of the note
568
 
     * @param   $target What the not should be converted too
569
 
     * @param   $authorize_sender If the sender should be added to authorized senders list.
 
568
     * @param   $target What the note should be converted too
 
569
     * @param bool|If $authorize_sender If the sender should be added to authorized senders list.
 
570
     * @return int
570
571
     */
571
572
    function convertNote($note_id, $target, $authorize_sender = false)
572
573
    {
603
604
            if (!empty($structure->headers['from'])) {
604
605
                $details = Email_Account::getDetails($email_account_id);
605
606
                // check from the associated project if we need to lookup any customers by this email address
606
 
                if (Customer::hasCustomerIntegration($details['ema_prj_id'])) {
 
607
                if (CRM::hasCustomerIntegration($details['ema_prj_id'])) {
 
608
                    $crm = CRM::getInstance($details['ema_prj_id']);
607
609
                    // check for any customer contact association
608
 
                    list($customer_id,) = Customer::getCustomerIDByEmails($details['ema_prj_id'], array($sender_email));
609
 
                    if (!empty($customer_id)) {
610
 
                        $t['customer_id'] = $customer_id;
611
 
                    }
 
610
                    try {
 
611
                        $contact = $crm->getContactByEmail($sender_email);
 
612
                        $issue_contract = $crm->getContract(Issue::getContractID($issue_id));
 
613
                        if ($contact->canAccessContract($issue_contract)) {
 
614
                            $t['customer_id'] = $issue_contract->getCustomerID();
 
615
                        }
 
616
                    } catch (CRMException $e) {}
612
617
                }
613
618
            }
614
619
            if (empty($t['customer_id'])) {