/** * Presaves one attachment for new email 2.0 spec * DOES NOT CREATE A NOTE * @return string ID of note associated with the attachment */ public function email2saveAttachment() { $email_uploads = "modules/Emails/{$GLOBALS['current_user']->id}"; $upload = new UploadFile('email_attachment'); if (!$upload->confirm_upload()) { $err = $upload->get_upload_error(); if ($err) { $GLOBALS['log']->error("Email Attachment could not be attached due to error: {$err}"); } return array(); } $guid = create_guid(); $fileName = $upload->create_stored_filename(); $GLOBALS['log']->debug("Email Attachment [{$fileName}]"); if ($upload->final_move($guid)) { copy("upload://{$guid}", sugar_cached("{$email_uploads}/{$guid}")); return array('guid' => $guid, 'name' => $GLOBALS['db']->quote($fileName), 'nameForDisplay' => $fileName); } else { $GLOBALS['log']->debug("Email Attachment [{$fileName}] could not be moved to upload dir"); return array(); } }
$note = new Note(); $note->name = $focus->name; if ($zuckerreports_config["debug"] == "yes") { $note->description = $focus->report_output; } $note->filename = $focus->report_result_name; if ($_REQUEST['parent_module'] == 'Contacts') { $note->contact_id = $_REQUEST['parent_id']; } else { $note->parent_type = $_REQUEST['parent_module']; $note->parent_id = $_REQUEST['parent_id']; } $note->save(); $uf = new UploadFile("upload"); $uf->set_for_soap($focus->report_result_name, file_get_contents($focus->report_result)); $uf->stored_file_name = $uf->create_stored_filename(); $uf->final_move($note->id); $note_url = "index.php?action=DetailView&module=Notes&record=" . $note->id . "&return_module=ZuckerReports&return_action=ReportOnDemand"; } if (!empty($_REQUEST['send_email'])) { $mail = new SugarPHPMailer(); $emails = split(",", $_REQUEST['send_email']); foreach ($emails as $email) { $mail->AddAddress($email); } $admin = new Administration(); $admin->retrieveSettings(); if ($admin->settings['mail_sendtype'] == "SMTP") { $mail->Mailer = "smtp"; $mail->Host = $admin->settings['mail_smtpserver']; $mail->Port = $admin->settings['mail_smtpport'];