2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
38 /*********************************************************************************
40 * Description: TODO: To be written.
41 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
42 * All Rights Reserved.
43 * Contributor(s): ______________________________________..
44 ********************************************************************************/
46 /************** general UI Stuff *************/
52 global $app_list_strings;
56 //if (!is_admin($current_user)) sugar_die("Unauthorized access to administration.");
57 //account for use within wizards
58 if(!isset($_REQUEST['inline']) || $_REQUEST['inline'] != 'inline'){
60 $params[] = "<a href='index.php?module=Campaigns&action=index'>{$mod_strings['LBL_MODULE_NAME']}</a>";
61 $params[] = $mod_strings['LBL_CAMPAIGN_DIAGNOSTICS'];
63 echo getClassicModuleTitle('Campaigns', $params, true);
64 //echo "<h2>".get_module_title($mod_strings['LBL_MODULE_NAME'],$mod_strings['LBL_CAMPAIGN_DIAGNOSTICS'],true)."</h2>";
68 global $currentModule;
73 if(isset($_REQUEST['inline']) && $_REQUEST['inline'] == 'inline'){
78 //use html if not inline
79 $ss = new Sugar_Smarty();
80 $ss->assign("MOD", $mod_strings);
81 $ss->assign("APP", $app_strings);
82 if (isset($_REQUEST['return_module'])) $ss->assign("RETURN_MODULE", $_REQUEST['return_module']);
83 if (isset($_REQUEST['return_action'])) $ss->assign("RETURN_ACTION", $_REQUEST['return_action']);
84 if (isset($_REQUEST['return_id'])) $ss->assign("RETURN_ID", $_REQUEST['return_id']);
85 // handle Create $module then Cancel
86 if (empty($_REQUEST['return_id'])) {
87 $ss->assign("RETURN_ACTION", 'index');
91 /************ EMAIL COMPONENTS *************/
92 //monitored mailbox section
93 $focus = new Administration();
94 $focus->retrieveSettings(); //retrieve all admin settings.
97 //run query for mail boxes of type 'bounce'
99 $email_components = 2;
100 $mbox_qry = "select * from inbound_email where deleted ='0' and mailbox_type = 'bounce'";
101 $mbox_res = $focus->db->query($mbox_qry);
102 $mboxTable = "<table border ='0' width='100%' class='detail view' cellpadding='0' cellspacing='0'>";
103 //put all rows returned into an array
105 while ($mbox_row = $focus->db->fetchByAssoc($mbox_res)){$mbox[] = $mbox_row;}
107 //if the array is not empty, then set "good" message
108 if(isset($mbox) && count($mbox)>0){
109 $mboxTable .= "<tr><td colspan='5' style='text-align: left;'><b>" .count($mbox) ." ". $mod_strings['LBL_MAILBOX_CHECK1_GOOD']." </b>.</td></tr>";
110 $mboxTable .= "<tr><td width='20%'><b>".$mod_strings['LBL_MAILBOX_NAME']."</b></td>"
111 . " <td width='20%'><b>".$mod_strings['LBL_LOGIN']."</b></td>"
112 . " <td width='20%'><b>".$mod_strings['LBL_MAILBOX']."</b></td>"
113 . " <td width='20%'><b>".$mod_strings['LBL_SERVER_URL']."</b></td>"
114 . " <td width='20%'><b>".$mod_strings['LBL_LIST_STATUS']."</b></td></tr>";
116 foreach($mbox as $details){
117 $mboxTable .= "<tr><td>".$details['name']."</td>";
118 $mboxTable .= "<td scope='row'>".$details['email_user']."</td>";
119 $mboxTable .= "<td scope='row'>".$details['mailbox']."</td>";
120 $mboxTable .= "<td scope='row'>".$details['server_url']."</td>";
121 $mboxTable .= "<td scope='row'>".$details['status']."</td></tr>";
125 //if array is empty, then set "bad" message and increment health counter
126 $mboxTable .= "<tr><td colspan='5'><b class='error'>". $mod_strings['LBL_MAILBOX_CHECK1_BAD']."</b></td></tr>";
127 $email_health =$email_health +1;
130 $mboxTable.= '</table>' ;
134 $ss->assign("MAILBOXES_DETECTED_MESSAGE", $mboxTable);
136 //email settings configured
137 $conf_msg="<table border='0' width='100%' class='detail view' cellpadding='0' cellspacing='0'>";
138 if (strstr($focus->settings['notify_fromaddress'], 'example.com')){
139 //if from address is the default, then set "bad" message and increment health counter
140 $conf_msg .= "<tr><td colspan = '5'><b class='error'> ".$mod_strings['LBL_MAILBOX_CHECK2_BAD']." </b></td></td>";
141 $email_health =$email_health +1;
143 $conf_msg .= "<tr><td colspan = '5'><b> ".$mod_strings['LBL_MAILBOX_CHECK2_GOOD']."</b></td></tr>";
144 $conf_msg .= "<tr><td width='20%'><b>".$mod_strings['LBL_WIZ_FROM_NAME']."</b></td>"
145 . " <td width='20%'><b>".$mod_strings['LBL_WIZ_FROM_ADDRESS']."</b></td>"
146 . " <td width='20%'><b>".$mod_strings['LBL_MAIL_SENDTYPE']."</b></td>";
147 if($focus->settings['mail_sendtype']=='SMTP'){
148 $conf_msg .= " <td width='20%'><b>".$mod_strings['LBL_MAIL_SMTPSERVER']."</b></td>"
149 . " <td width='20%'><b>".$mod_strings['LBL_MAIL_SMTPUSER']."</b></td></tr>";
151 }else{$conf_msg .= "</tr>";}
155 $conf_msg .= "<tr scope='row'><td>".$focus->settings['notify_fromname']."</td>";
156 $conf_msg .= "<td>".$focus->settings['notify_fromaddress']."</td>";
157 $conf_msg .= "<td>".$focus->settings['mail_sendtype']."</td>";
158 if($focus->settings['mail_sendtype']=='SMTP'){
159 $conf_msg .= "<td>".$focus->settings['mail_smtpserver']."</td>";
160 $conf_msg .= "<td>".$focus->settings['mail_smtpuser']."</td></tr>";
162 }else{$conf_msg .= "</tr>";}
166 $conf_msg .= '</table>';
167 $ss->assign("EMAIL_SETTINGS_CONFIGURED_MESSAGE", $conf_msg);
168 $email_setup_wiz_link='';
169 if ($email_health>0){
170 if (is_admin($current_user)){
171 $email_setup_wiz_link="<a href='index.php?module=Campaigns&action=WizardEmailSetup'>".$mod_strings['LBL_EMAIL_SETUP_WIZ']."</a>";
173 $email_setup_wiz_link=$mod_strings['LBL_NON_ADMIN_ERROR_MSG'];
177 $ss->assign("EMAIL_SETUP_WIZ_LINK", $email_setup_wiz_link);
178 $ss->assign( 'EMAIL_IMAGE', define_image($email_health, 2));
179 $ss->assign( 'EMAIL_COMPONENTS', $mod_strings['LBL_EMAIL_COMPONENTS']);
180 $ss->assign( 'SCHEDULER_COMPONENTS', $mod_strings['LBL_SCHEDULER_COMPONENTS']);
181 $ss->assign( 'RECHECK_BTN', $mod_strings['LBL_RECHECK_BTN']);
183 /************* SCHEDULER COMPONENTS ************/
185 //create and run the scheduler queries
186 $sched_qry = "select job, name, status from schedulers where deleted = 0 and status = 'Active'";
187 $sched_res = $focus->db->query($sched_qry);
190 $check_sched1 = 'function::runMassEmailCampaign';
191 $check_sched2 = 'function::pollMonitoredInboxesForBouncedCampaignEmails';
193 $sched_mes_body = '';
196 //build the table rows for scheduler display
197 while ($sched_row = $focus->db->fetchByAssoc($sched_res)){$scheds[] = $sched_row;}
198 foreach ($scheds as $funct){
199 if( ($funct['job']==$check_sched1) || ($funct['job']==$check_sched2)){
201 $sched_mes_body .= "<tr><td scope='row' style='text-align: left;'>".$funct['name']."</td>";
202 $sched_mes_body .= "<td scope='row' style='text-align: left;'>".$funct['status']."</td></tr>";
203 if($funct['job']==$check_sched1){
204 $check_sched1 ="found";
206 $check_sched2 ="found";
212 //determine which table header to use, based on whether or not schedulers were found
213 $show_admin_link = false;
214 if($sched_mes == 'use'){
215 $sched_mes = "<h5>".$mod_strings['LBL_SCHEDULER_CHECK_GOOD']."</h5><br><table class='other view' cellspacing='1'>";
216 $sched_mes .= "<tr><td width='40%'><b>".$mod_strings['LBL_SCHEDULER_NAME']."</b></td>"
217 . " <td width='60%'><b>".$mod_strings['LBL_SCHEDULER_STATUS']."</b></td></tr>";
220 $sched_mes = "<table class='other view' cellspacing='1'>";
221 $sched_mes .= "<tr><td colspan ='3'><font color='red'><b> ".$mod_strings['LBL_SCHEDULER_CHECK_BAD']."</b></font></td></tr>";
222 $show_admin_link = true;
225 //determine if error messages need to be displayed for schedulers
226 if($check_sched2 != 'found'){
227 $sched_health =$sched_health +1;
228 $sched_mes_body .= "<tr><td colspan ='3'><font color='red'> ".$mod_strings['LBL_SCHEDULER_CHECK1_BAD']."</font></td></tr>";
230 if($check_sched1 != 'found'){
231 $sched_health =$sched_health +1;
232 $sched_mes_body .= "<tr><td colspan ='3' scope='row'><font color='red'>".$mod_strings['LBL_SCHEDULER_CHECK2_BAD']."</font></td></tr>";
234 $admin_sched_link='';
235 if ($sched_health>0){
236 if (is_admin($current_user)){
237 $admin_sched_link="<a href='index.php?module=Schedulers&action=index'>".$mod_strings['LBL_SCHEDULER_LINK']."</a>";
239 $admin_sched_link=$mod_strings['LBL_NON_ADMIN_ERROR_MSG'];
243 //put table html together and display
244 $final_sched_msg = $sched_mes . $sched_mes_body . '</table>' . $admin_sched_link;
245 $ss->assign("SCHEDULER_EMAILS_MESSAGE", $final_sched_msg);
246 $ss->assign( 'SCHEDULE_IMAGE', define_image($sched_health, 2));
249 /********** FINAL END OF PAGE UI Stuff ********/
250 if(!isset($_REQUEST['inline']) || $_REQUEST['inline'] != 'inline'){
252 $ss->display('modules/Campaigns/CampaignDiagnostic.html');
256 * This function takes in 3 parameters and determines the appropriate image source.
258 * @param int $num parameter is the "health" parameter being tracked whenever there is something wrong. (higher number =bad)
259 * @param int $total Parameter is the total number things being checked.
260 * @return string HTML img tag
262 function define_image($num, $total)
264 //if health number is equal to total number then all checks failed, set red image
267 return "<img src='".SugarThemeRegistry::current()->getImageURL("red_camp.gif")."' align='absmiddle'> ";
269 //if health number is zero, then all checks passed, set green image
271 return "<img src='".SugarThemeRegistry::current()->getImageURL("green_camp.gif")."' align='absmiddle' > ";
273 //if health number is between total and num params, then some checks failed but not all, set yellow image
275 return "<img src='".SugarThemeRegistry::current()->getImageURL("yellow_camp.gif")."' align='absmiddle' > ";