2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM Community Edition 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 ********************************************************************************/
39 require_once('include/DetailView/DetailView.php');
41 require_once('include/SugarFolders/SugarFolders.php');
50 /* start standard DetailView layout process */
51 $GLOBALS['log']->info("InboundEmails DetailView");
52 $focus = new InboundEmail();
53 $focus->retrieve($_REQUEST['record']);
54 if (empty($focus->id)) {
55 sugar_die($app_strings['ERROR_NO_RECORD']);
58 $detailView = new DetailView();
63 /* end standard DetailView layout process */
64 $exServ = explode('::',$focus->service);
65 if($focus->delete_seen == 1) {
66 $delete_seen = $mod_strings['LBL_MARK_READ_NO'];
68 $delete_seen = $mod_strings['LBL_MARK_READ_YES'];
72 //$r = $focus->db->query("SELECT id, name FROM queues WHERE owner_id = '".$focus->id."'");
73 //$a = $focus->db->fetchByAssoc($r);
74 //$queue = '<a href="index.php?module=Queues&action=EditView&record='.$a['id'].'">'.$a['name'].'</a>';
76 if($focus->group_id) {
78 //$group = new Group();
79 //$group->retrieve($focus->group_id);
80 //$groupName = $group->user_name;
83 if($focus->template_id) {
85 $et = new EmailTemplate();
86 $et->retrieve($focus->template_id);
87 $emailTemplate = $et->name;
89 $emailTemplate = $mod_strings['LBL_NONE'];
91 $ssl = $app_list_strings['dom_email_bool']['bool_false'];
92 $allow_outbound_group_usage = $app_list_strings['dom_email_bool']['bool_false'];
93 $tls = $app_list_strings['dom_email_bool']['bool_false'];
94 $ca = $app_list_strings['dom_email_bool']['bool_false'];
95 if(!empty($focus->service)) {
96 // will always have 2 values: /tls || /notls and /validate-cert || /novalidate-cert
97 $exServ = explode('::', $focus->service);
98 if($exServ[0] == 'tls') {
99 $tls = $app_list_strings['dom_email_bool']['bool_true'];
101 if($exServ[1] == 'validate-cert') {
102 $cert = $app_list_strings['dom_email_bool']['bool_true'];
104 if(isset($exServ[2]) && !empty($exServ[2]) && $exServ[2] == 'ssl') {
105 $ssl = $app_list_strings['dom_email_bool']['bool_true'];
109 // FROM NAME FROM ADDRESS STRINGS
110 $email = new Email();
111 $from = $email->getSystemDefaultEmail();
112 $default_from_name = $from['name'];
113 $default_from_addr = $from['email'];
122 $distributionMethod = '';
123 $create_case_email_template='';
124 $create_case_email_template_name = $mod_strings['LBL_NONE'];
125 $leaveMessagesOnMailServer = $app_strings['LBL_EMAIL_NO'];
127 //$fromNameAddr = $fromName.' <'.$from['email'].'> <br><em>('.$mod_strings['LBL_SYSTEM_DEFAULT'].')</em>';
128 //$replyNameAddr = $mod_strings['LBL_SAME_AS_ABOVE'];
129 $onlySince = $mod_strings['LBL_ONLY_SINCE_NO'];
131 if(!empty($focus->stored_options)) {
132 // FROM NAME and Address
133 $storedOptions = unserialize(base64_decode($focus->stored_options));
135 $from_name = (isset($storedOptions['from_name']) ? $storedOptions['from_name'] : "");
136 $from_addr = (isset($storedOptions['from_addr']) ? $storedOptions['from_addr'] : "");
138 $reply_to_name = (isset($storedOptions['reply_to_name'])) ? $storedOptions['reply_to_name'] : "";
139 $reply_to_addr = (isset($storedOptions['reply_to_addr'])) ? $storedOptions['reply_to_addr'] : "";
141 if($storedOptions['only_since']) {
142 $onlySince = $mod_strings['LBL_ONLY_SINCE_YES'];
144 $onlySince = $mod_strings['LBL_ONLY_SINCE_NO'];
147 if(isset($storedOptions['filter_domain']) && !empty($storedOptions['filter_domain'])) {
148 $filterDomain = $storedOptions['filter_domain'];
150 $filterDomain = $app_strings['NTC_NO_ITEMS_DISPLAY'];
153 if(isset($storedOptions['trashFolder']) && !empty($storedOptions['trashFolder'])) {
154 $trashFolder = $storedOptions['trashFolder'];
156 $trashFolder = $mod_strings['LBL_NONE'];
159 if(isset($storedOptions['sentFolder']) && !empty($storedOptions['sentFolder'])) {
160 $sentFolder = $storedOptions['sentFolder'];
162 $sentFolder = $mod_strings['LBL_NONE'];
165 if(!isset($storedOptions['leaveMessagesOnMailServer']) || $storedOptions['leaveMessagesOnMailServer'] == 1) {
166 $leaveMessagesOnMailServer = $app_strings['LBL_EMAIL_YES'];
168 $leaveMessagesOnMailServer = $app_strings['LBL_EMAIL_NO'];
170 if(!isset($storedOptions['leaveMessagesOnMailServer']) || $storedOptions['leaveMessagesOnMailServer'] == 1) {
171 $leaveMessagesOnMailServer = $app_strings['LBL_EMAIL_YES'];
173 $leaveMessagesOnMailServer = $app_strings['LBL_EMAIL_NO'];
175 $distrib_method = (isset($storedOptions['distrib_method'])) ? $storedOptions['distrib_method'] : "";
176 $create_case_email_template = (isset($storedOptions['create_case_email_template'])) ? $storedOptions['create_case_email_template'] : "";
177 $email_num_autoreplies_24_hours = (isset($storedOptions['email_num_autoreplies_24_hours'])) ? $storedOptions['email_num_autoreplies_24_hours'] : $focus->defaultEmailNumAutoreplies24Hours;
179 if( isset($storedOptions['allow_outbound_group_usage']) && $storedOptions['allow_outbound_group_usage'] == 1)
180 $allow_outbound_group_usage = $app_list_strings['dom_email_bool']['bool_true'];
184 if(!empty($create_case_email_template)) {
186 $et = new EmailTemplate();
187 $et->retrieve($create_case_email_template);
188 $create_case_email_template_name = $et->name;
190 if (!empty($distrib_method)) {
191 $distributionMethod = $app_list_strings['dom_email_distribution_for_auto_create'][$distrib_method];
193 $xtpl = new XTemplate('modules/InboundEmail/DetailView.html');
194 //// ERRORS from Save
195 if(isset($_REQUEST['error'])) {
196 $xtpl->assign('ERROR', "<div class='error'>".$mod_strings['ERR_NO_OPTS_SAVED']."</div>");
198 //cma, June 24,2008 - Fix bug 21670. User status and group/personal statements are not localized.
199 $userStatus = $mod_strings['LBL_STATUS_ACTIVE'];
200 if('Inactive' == $focus->status) {
201 $userStatus = $mod_strings['LBL_STATUS_INACTIVE'];
204 $xtpl->assign('MODULE_TITLE', getClassicModuleTitle($mod_strings['LBL_MODULE_TITLE'], array($mod_strings['LBL_MODULE_NAME'],$focus->name), true));
205 $xtpl->assign('MOD', $mod_strings);
206 $xtpl->assign('APP', $app_strings);
207 $xtpl->assign('CREATED_BY', $focus->created_by_name);
208 $xtpl->assign('MODIFIED_BY', $focus->modified_by_name);
209 $xtpl->assign('GRIDLINE', $gridline);
210 $xtpl->assign('PRINT_URL', 'index.php?'.$GLOBALS['request_string']);
211 $xtpl->assign('ID', $focus->id);
212 $xtpl->assign('STATUS', $userStatus);
213 $xtpl->assign('SERVER_URL', $focus->server_url);
214 $xtpl->assign('USER', $focus->email_user);
215 $xtpl->assign('NAME', $focus->name);
216 $xtpl->assign('MAILBOX', $focus->mailbox);
217 $xtpl->assign('TRASHFOLDER', $trashFolder);
218 $xtpl->assign('SENTFOLDER', $sentFolder);
220 $protocol = filterInboundEmailPopSelection($app_list_strings['dom_email_server_type']);
221 $xtpl->assign('SERVER_TYPE', $protocol[$focus->protocol]);
222 $xtpl->assign('SSL', $ssl);
223 $xtpl->assign('TLS', $tls);
224 $xtpl->assign('CERT', $ca);
225 $xtpl->assign('MARK_READ', $delete_seen);
226 $xtpl->assign('ALLOW_OUTBOUND_GROUP_USAGE', $allow_outbound_group_usage);
229 //$xtpl->assign('QUEUE', $queue);
230 $createCaseRowStyle = "display:none";
231 $leaveMessagesOnMailServerStyle = "display:none";
232 if ($focus->is_personal) {
233 $xtpl->assign('EDIT_GROUP_FOLDER_STYLE', "display:none");
235 $is_auto_import = $app_list_strings['checkbox_dom']['2'];
237 if (!empty($focus->groupfolder_id)) {
238 $is_auto_import = $app_list_strings['checkbox_dom']['1'];
239 $leaveMessagesOnMailServerStyle = "display:''";
241 $xtpl->assign('IS_AUTO_IMPORT_ENABLED', $is_auto_import);
242 $xtpl->assign('EDIT_GROUP_FOLDER_STYLE', "display:''");
243 if ($focus->isMailBoxTypeCreateCase()) {
244 $createCaseRowStyle = "display:''";
248 $xtpl->assign('LEAVEMESSAGESONMAILSERVER_STYLE', $leaveMessagesOnMailServerStyle);
249 $xtpl->assign('LEAVEMESSAGESONMAILSERVER', $leaveMessagesOnMailServer);
250 $xtpl->assign('CREATE_CASE_ROW_STYLE', $createCaseRowStyle);
251 $xtpl->assign('DISTRIBUTION_METHOD', $distributionMethod);
252 $xtpl->assign('CREATE_CASE_EMAIL_TEMPLATE', $create_case_email_template_name);
253 if ($focus->isPop3Protocol()) {
254 $xtpl->assign('TRASH_SENT_FOLDER_STYLE', "display:none");
256 $xtpl->assign('TRASH_SENT_FOLDER_STYLE', "display:''");
259 $possibleAction = "pick";
260 if (!isset($app_list_strings['dom_mailbox_type'][$focus->mailbox_type])) {
261 $possibleAction = $app_list_strings['dom_mailbox_type']['pick'];
263 $possibleAction = $app_list_strings['dom_mailbox_type'][$focus->mailbox_type];
266 if($focus->mailbox_type == 'createcase')
267 $is_create_case = $app_list_strings['checkbox_dom']['1'];
269 $is_create_case = $app_list_strings['checkbox_dom']['2'];
272 $xtpl->assign('GROUP_NAME', $groupName);
273 $xtpl->assign('IS_CREATE_CASE', $is_create_case);
274 $xtpl->assign('EMAIL_TEMPLATE', $emailTemplate);
275 $xtpl->assign('FROM_NAME', $from_name);
276 $xtpl->assign('FROM_ADDR', $from_addr);
277 $xtpl->assign('DEFAULT_FROM_NAME', $default_from_name);
278 $xtpl->assign('DEFAULT_FROM_ADDR', $default_from_addr);
279 $xtpl->assign('REPLY_TO_NAME', $reply_to_name);
280 $xtpl->assign('REPLY_TO_ADDR', $reply_to_addr);
281 $xtpl->assign('ONLY_SINCE', $onlySince);
282 $xtpl->assign('FILTER_DOMAIN', $filterDomain);
283 $xtpl->assign('EMAIL_NUM_AUTOREPLIES_24_HOURS', $email_num_autoreplies_24_hours);
284 if(!empty($focus->port)) {
285 $xtpl->assign('PORT', $focus->port);
287 if($focus->handleIsPersonal()) {
288 $xtpl->assign('LBL_GROUP_QUEUE', $mod_strings['LBL_ASSIGN_TO_USER']);
290 $xtpl->assign('LBL_GROUP_QUEUE', $mod_strings['LBL_GROUP_QUEUE']);
293 //Overrides for bounce mailbox accounts
294 if ($focus->mailbox_type == 'bounce')
296 $xtpl->assign('MODULE_TITLE', getClassicModuleTitle($mod_strings['LBL_MODULE_TITLE'], array($mod_strings['LBL_BOUNCE_MODULE_NAME'],$focus->name), true));
298 else if( $focus->is_personal == '1')
299 $xtpl->assign('MODULE_TITLE', getClassicModuleTitle($mod_strings['LBL_MODULE_TITLE'], array($mod_strings['LBL_PERSONAL_MODULE_NAME'],$focus->name), true));
301 $xtpl->parse('main');