function save($check_notify = false)
 {
     global $current_user, $sugar_config;
     parent::save($check_notify);
     $email_template = new EmailTemplate();
     if ($_REQUEST['module'] == 'Import') {
         //Don't send email on import
         return;
     }
     $signature = array();
     $addDelimiter = true;
     $aop_config = $sugar_config['aop'];
     if (!empty($this->contact_id)) {
         $emails = $this->getEmailForUser();
         if ($aop_config['user_email_template_id']) {
             $email_template->retrieve($aop_config['user_email_template_id']);
         }
         $addDelimiter = false;
     } elseif ($this->assigned_user_id && !$this->internal) {
         $emails = $this->getEmailForContact();
         if ($aop_config['contact_email_template_id']) {
             $email_template->retrieve($aop_config['contact_email_template_id']);
             $signature = $current_user->getDefaultSignature();
         }
     }
     if ($emails && $email_template) {
         $GLOBALS['log']->info("AOPCaseUpdates: Calling send email");
         $res = $this->sendEmail($emails, $email_template, $signature, $this->case_id, $addDelimiter);
     }
 }
 function save($check_notify = false)
 {
     $this->name = SugarCleaner::cleanHtml($this->name);
     $this->description = SugarCleaner::cleanHtml($this->description);
     global $current_user, $sugar_config;
     parent::save($check_notify);
     $email_template = new EmailTemplate();
     if ($_REQUEST['module'] == 'Import') {
         //Don't send email on import
         return;
     }
     if (!isAOPEnabled()) {
         return;
     }
     if ($this->internal) {
         return;
     }
     $signature = array();
     $addDelimiter = true;
     $aop_config = $sugar_config['aop'];
     if ($this->assigned_user_id) {
         if ($aop_config['contact_email_template_id']) {
             $email_template = $email_template->retrieve($aop_config['contact_email_template_id']);
             $signature = $current_user->getDefaultSignature();
         }
         if ($email_template) {
             foreach ($this->getContacts() as $contact) {
                 $GLOBALS['log']->info("AOPCaseUpdates: Calling send email");
                 $emails = array();
                 $emails[] = $contact->emailAddress->getPrimaryAddress($contact);
                 $res = $this->sendEmail($emails, $email_template, $signature, $this->case_id, $addDelimiter, $contact->id);
             }
         }
     } else {
         $emails = $this->getEmailForUser();
         if ($aop_config['user_email_template_id']) {
             $email_template = $email_template->retrieve($aop_config['user_email_template_id']);
         }
         $addDelimiter = false;
         if ($emails && $email_template) {
             $GLOBALS['log']->info("AOPCaseUpdates: Calling send email");
             $res = $this->sendEmail($emails, $email_template, $signature, $this->case_id, $addDelimiter, $this->contact_id);
         }
     }
     if ($emails && $email_template) {
         $GLOBALS['log']->info("AOPCaseUpdates: Calling send email");
         $res = $this->sendEmail($emails, $email_template, $signature, $this->case_id, $addDelimiter);
     }
 }
 function save($check_notify = false)
 {
     $this->name = SugarCleaner::cleanHtml($this->name);
     $this->description = SugarCleaner::cleanHtml($this->description);
     parent::save($check_notify);
     if (file_exists('custom/modules/AOP_Case_Updates/CaseUpdatesHook.php')) {
         require_once 'custom/modules/AOP_Case_Updates/CaseUpdatesHook.php';
     } else {
         require_once 'modules/AOP_Case_Updates/CaseUpdatesHook.php';
     }
     if (class_exists('CustomCaseUpdatesHook')) {
         $hook = new CustomCaseUpdatesHook();
     } else {
         $hook = new CaseUpdatesHook();
     }
     $hook->sendCaseUpdate($this);
 }