Hi Harold,
I am trying to implement your logic hook into my sugar installation. I have a few questions that I think are pretty straight forward. First I am simply trying to use your script as is except for changing the campaign_id to my own campaign id. That I kinda figured was a gimme.
Second, I am unsure where to load this code. I am guessing this goes into the logic_hooks.php under the custom/modules/Leads directory. I guess this is the first questions, is this the right file?
Third, I noticed some other code in the default logic_hooks.php and was wondering does this need to be triggered before the $hook_array['after_ui_frame'] = Array(); ?
This is what my logic_hooks.php looks like at current.
PHP Code:
<?php
// Do not store anything in this file that is not part of the array or the hook version. This file will
// be automatically rebuilt in the future.
$hook_version = 1;
$hook_array = Array();
// position, file, function
$hook_array['before_save'] = Array();
$hook_array['before_save'][] = Array(1, 'Leads push feed', 'modules/Leads/SugarFeeds/LeadFeed.php','LeadFeed', 'pushFeed');
$hook_array['after_ui_frame'] = Array();
$hook_array['after_ui_frame'][] = Array(1, 'Leads InsideView frame', 'modules/Connectors/connectors/sources/ext/rest/insideview/InsideViewLogicHook.php','InsideViewLogicHook', 'showFrame');
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
if($event=="before_save"){
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
if (($focus->campaign_id == "28d22d4b-688e-3fa7-5eb4-4e9cbcc419a9") &&
($focus->status == "new") &&
($focus->new_with_id == "1"))
{
$mailsubj = "Thank you for Newsletter Registration";
$mailbody = "
bla bla
bla bla
bla bla
";
require_once('include/SugarPHPMailer.php');
require_once("modules/Administration/Administration.php");
$mail = new SugarPHPMailer();
$admin = new Administration();
$admin->retrieveSettings();
if ($admin->settings['mail_sendtype'] == "SMTP") {
$mail->Host = $admin->settings['mail_smtpserver'];
$mail->Port = $admin->settings['mail_smtpport'];
if ($admin->settings['mail_smtpauth_req']) {
$mail->SMTPAuth = TRUE;
$mail->Username = $admin->settings['mail_smtpuser'];
$mail->Password = $admin->settings['mail_smtppass'];
}
$mail->Mailer = "smtp";
$mail->SMTPKeepAlive = true;
}
else {
$mail->mailer = 'sendmail';
}
$mail->From = $admin->settings['notify_fromaddress'];
$mail->FromName = $admin->settings['notify_fromname'];
$mail->ContentType = "text/plain"; //"text/html"
$mail->Subject = $mailsubj;
$mail->Body = $mailbody;
$mail->AddAddress($focus->email1, $focus->email1);
if (!$mail->send()) {
$GLOBALS['log']->fatal("Mailer error: " . $mail->ErrorInfo);
}
}
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
} // end if logic hook is beforesave
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
?>
Bookmarks