{$mod_strings['LBL_MODULE_NAME']}"; $params[] = $mod_strings['LBL_CAMPAIGN_DIAGNOSTICS']; echo getClassicModuleTitle('Campaigns', $params, true); } global $theme; global $currentModule; if(isset($_REQUEST['inline']) && $_REQUEST['inline'] == 'inline'){ { } }else{ //use html if not inline $ss = new Sugar_Smarty(); $ss->assign("MOD", $mod_strings); $ss->assign("APP", $app_strings); if (isset($_REQUEST['return_module'])) $ss->assign("RETURN_MODULE", $_REQUEST['return_module']); if (isset($_REQUEST['return_action'])) $ss->assign("RETURN_ACTION", $_REQUEST['return_action']); if (isset($_REQUEST['return_id'])) $ss->assign("RETURN_ID", $_REQUEST['return_id']); // handle Create $module then Cancel if (empty($_REQUEST['return_id'])) { $ss->assign("RETURN_ACTION", 'index'); } } /************ EMAIL COMPONENTS *************/ //monitored mailbox section $focus = new Administration(); $focus->retrieveSettings(); //retrieve all admin settings. //run query for mail boxes of type 'bounce' $email_health = 0; $email_components = 2; $mbox_qry = "select * from inbound_email where deleted ='0' and mailbox_type = 'bounce'"; $mbox_res = $focus->db->query($mbox_qry); $mboxTable = ""; //put all rows returned into an array $mbox = array(); while ($mbox_row = $focus->db->fetchByAssoc($mbox_res)){$mbox[] = $mbox_row;} $mbox_msg = ' '; //if the array is not empty, then set "good" message if(isset($mbox) && count($mbox)>0){ $mboxTable .= ""; $mboxTable .= "" . " " . " " . " " . " "; foreach($mbox as $details){ $mboxTable .= ""; $mboxTable .= ""; $mboxTable .= ""; $mboxTable .= ""; $mboxTable .= ""; } }else{ //if array is empty, then set "bad" message and increment health counter $mboxTable .= ""; $email_health =$email_health +1; } $mboxTable.= '
" .count($mbox) ." ". $mod_strings['LBL_MAILBOX_CHECK1_GOOD']." .
".$mod_strings['LBL_MAILBOX_NAME']."".$mod_strings['LBL_LOGIN']."".$mod_strings['LBL_MAILBOX']."".$mod_strings['LBL_SERVER_URL']."".$mod_strings['LBL_LIST_STATUS']."
".$details['name']."".$details['email_user']."".$details['mailbox']."".$details['server_url']."".$details['status']."
". $mod_strings['LBL_MAILBOX_CHECK1_BAD']."
' ; $ss->assign("MAILBOXES_DETECTED_MESSAGE", $mboxTable); //email settings configured $conf_msg=""; if (strstr($focus->settings['notify_fromaddress'], 'example.com')){ //if from address is the default, then set "bad" message and increment health counter $conf_msg .= ""; $email_health =$email_health +1; }else{ $conf_msg .= ""; $conf_msg .= "" . " " . " "; if($focus->settings['mail_sendtype']=='SMTP'){ $conf_msg .= " " . " "; }else{$conf_msg .= "";} $conf_msg .= ""; $conf_msg .= ""; $conf_msg .= ""; if($focus->settings['mail_sendtype']=='SMTP'){ $conf_msg .= ""; $conf_msg .= ""; }else{$conf_msg .= "";} } $conf_msg .= '
".$mod_strings['LBL_MAILBOX_CHECK2_BAD']."
".$mod_strings['LBL_MAILBOX_CHECK2_GOOD']."
".$mod_strings['LBL_WIZ_FROM_NAME']."".$mod_strings['LBL_WIZ_FROM_ADDRESS']."".$mod_strings['LBL_MAIL_SENDTYPE']."".$mod_strings['LBL_MAIL_SMTPSERVER']."".$mod_strings['LBL_MAIL_SMTPUSER']."
".$focus->settings['notify_fromname']."".$focus->settings['notify_fromaddress']."".$focus->settings['mail_sendtype']."".$focus->settings['mail_smtpserver']."".$focus->settings['mail_smtpuser']."
'; $ss->assign("EMAIL_SETTINGS_CONFIGURED_MESSAGE", $conf_msg); $email_setup_wiz_link=''; if ($email_health>0){ if (is_admin($current_user)){ $email_setup_wiz_link="".$mod_strings['LBL_EMAIL_SETUP_WIZ'].""; }else{ $email_setup_wiz_link=$mod_strings['LBL_NON_ADMIN_ERROR_MSG']; } } $ss->assign("EMAIL_SETUP_WIZ_LINK", $email_setup_wiz_link); $ss->assign( 'EMAIL_IMAGE', define_image($email_health, 2)); $ss->assign( 'EMAIL_COMPONENTS', $mod_strings['LBL_EMAIL_COMPONENTS']); $ss->assign( 'SCHEDULER_COMPONENTS', $mod_strings['LBL_SCHEDULER_COMPONENTS']); $ss->assign( 'RECHECK_BTN', $mod_strings['LBL_RECHECK_BTN']); /************* SCHEDULER COMPONENTS ************/ //create and run the scheduler queries $sched_qry = "select job, name, status from schedulers where deleted = 0 and status = 'Active'"; $sched_res = $focus->db->query($sched_qry); $sched_health = 0; $sched = array(); $check_sched1 = 'function::runMassEmailCampaign'; $check_sched2 = 'function::pollMonitoredInboxesForBouncedCampaignEmails'; $sched_mes = ''; $sched_mes_body = ''; $scheds = array(); //build the table rows for scheduler display while ($sched_row = $focus->db->fetchByAssoc($sched_res)){$scheds[] = $sched_row;} foreach ($scheds as $funct){ if( ($funct['job']==$check_sched1) || ($funct['job']==$check_sched2)){ $sched_mes = 'use'; $sched_mes_body .= "".$funct['name'].""; $sched_mes_body .= "".$funct['status'].""; if($funct['job']==$check_sched1){ $check_sched1 ="found"; }else{ $check_sched2 ="found"; } } } //determine which table header to use, based on whether or not schedulers were found $show_admin_link = false; if($sched_mes == 'use'){ $sched_mes = "
".$mod_strings['LBL_SCHEDULER_CHECK_GOOD']."

"; $sched_mes .= "" . " "; }else{ $sched_mes = "
".$mod_strings['LBL_SCHEDULER_NAME']."".$mod_strings['LBL_SCHEDULER_STATUS']."
"; $sched_mes .= ""; $show_admin_link = true; } //determine if error messages need to be displayed for schedulers if($check_sched2 != 'found'){ $sched_health =$sched_health +1; $sched_mes_body .= ""; } if($check_sched1 != 'found'){ $sched_health =$sched_health +1; $sched_mes_body .= ""; } $admin_sched_link=''; if ($sched_health>0){ if (is_admin($current_user)){ $admin_sched_link="".$mod_strings['LBL_SCHEDULER_LINK'].""; }else{ $admin_sched_link=$mod_strings['LBL_NON_ADMIN_ERROR_MSG']; } } //put table html together and display $final_sched_msg = $sched_mes . $sched_mes_body . '
".$mod_strings['LBL_SCHEDULER_CHECK_BAD']."
".$mod_strings['LBL_SCHEDULER_CHECK1_BAD']."
".$mod_strings['LBL_SCHEDULER_CHECK2_BAD']."
' . $admin_sched_link; $ss->assign("SCHEDULER_EMAILS_MESSAGE", $final_sched_msg); $ss->assign( 'SCHEDULE_IMAGE', define_image($sched_health, 2)); /********** FINAL END OF PAGE UI Stuff ********/ if(!isset($_REQUEST['inline']) || $_REQUEST['inline'] != 'inline'){ $ss->display('modules/Campaigns/CampaignDiagnostic.html'); } /** * This function takes in 3 parameters and determines the appropriate image source. * * @param int $num parameter is the "health" parameter being tracked whenever there is something wrong. (higher number =bad) * @param int $total Parameter is the total number things being checked. * @return string HTML img tag */ function define_image($num, $total) { global $mod_strings; //if health number is equal to total number then all checks failed, set red image if($num == $total){ //red return SugarThemeRegistry::current()->getImage('red_camp', "align='absmiddle'", null, null, ".gif", $mod_strings['LBL_INVALID']); }elseif($num == 0){ //if health number is zero, then all checks passed, set green image //green return SugarThemeRegistry::current()->getImage('green_camp', "align='absmiddle'", null, null, ".gif", $mod_strings['LBL_VALID']); }else{ //if health number is between total and num params, then some checks failed but not all, set yellow image //yellow return SugarThemeRegistry::current()->getImage('yellow_camp', "align='absmiddle'", null, null, ".gif", $mod_strings['LBL_ALERT']); } } ?>