]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/InboundEmail/DetailView.php
Release 6.5.0
[Github/sugarcrm.git] / modules / InboundEmail / DetailView.php
1 <?php
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-2012 SugarCRM Inc.
6  * 
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.
13  * 
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
17  * details.
18  * 
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
22  * 02110-1301 USA.
23  * 
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.
26  * 
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.
30  * 
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  ********************************************************************************/
37
38
39 require_once('include/DetailView/DetailView.php');
40
41 require_once('include/SugarFolders/SugarFolders.php');
42
43
44 global $mod_strings;
45 global $app_strings;
46 global $sugar_config;
47 global $timedate;
48 global $theme;
49
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']);
56 } // if
57 $focus->checkImap();
58 $detailView = new DetailView();
59 $offset=0;
60
61
62
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'];
67 } else {
68         $delete_seen = $mod_strings['LBL_MARK_READ_YES'];
69 }
70
71 // deferred
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>';
75 $groupName = '';
76 if($focus->group_id) {
77         
78         //$group = new Group();
79         //$group->retrieve($focus->group_id);
80         //$groupName = $group->user_name;
81 }
82
83 if($focus->template_id) {
84         
85         $et = new EmailTemplate();
86         $et->retrieve($focus->template_id);
87         $emailTemplate = $et->name;
88 } else {
89         $emailTemplate = $mod_strings['LBL_NONE'];
90 }
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'];
100         }
101         if($exServ[1] == 'validate-cert') {
102                 $cert = $app_list_strings['dom_email_bool']['bool_true'];
103         }
104         if(isset($exServ[2]) && !empty($exServ[2]) && $exServ[2] == 'ssl') {
105                 $ssl = $app_list_strings['dom_email_bool']['bool_true'];
106         }
107 }
108
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'];
114 $from_name = '';
115 $from_addr = '';
116 $reply_to_name = '';
117 $reply_to_addr = '';
118 $distrib_method ='';
119 $filterDomain = '';
120 $trashFolder = '';
121 $sentFolder = '';
122 $distributionMethod = '';
123 $create_case_email_template='';
124 $create_case_email_template_name = $mod_strings['LBL_NONE'];
125 $leaveMessagesOnMailServer = $app_strings['LBL_EMAIL_NO'];
126
127 //$fromNameAddr = $fromName.' &lt;'.$from['email'].'&gt; <br><em>('.$mod_strings['LBL_SYSTEM_DEFAULT'].')</em>';
128 //$replyNameAddr = $mod_strings['LBL_SAME_AS_ABOVE'];
129 $onlySince = $mod_strings['LBL_ONLY_SINCE_NO'];
130
131 if(!empty($focus->stored_options)) {
132         // FROM NAME and Address
133         $storedOptions = unserialize(base64_decode($focus->stored_options));
134
135         $from_name = (isset($storedOptions['from_name']) ? $storedOptions['from_name'] : "");
136         $from_addr = (isset($storedOptions['from_addr']) ? $storedOptions['from_addr'] : "");
137
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'] : "";
140                 // only-since option
141         if($storedOptions['only_since']) {
142                 $onlySince = $mod_strings['LBL_ONLY_SINCE_YES'];
143         } else {
144                 $onlySince = $mod_strings['LBL_ONLY_SINCE_NO'];
145         }
146         // filter-domain
147         if(isset($storedOptions['filter_domain']) && !empty($storedOptions['filter_domain'])) {
148                 $filterDomain = $storedOptions['filter_domain'];
149         } else {
150                 $filterDomain = $app_strings['NTC_NO_ITEMS_DISPLAY'];
151         }
152         // Trash Folder
153         if(isset($storedOptions['trashFolder']) && !empty($storedOptions['trashFolder'])) {
154                 $trashFolder = $storedOptions['trashFolder'];
155         } else {
156                 $trashFolder = $mod_strings['LBL_NONE'];
157         }
158         // Sent Folder
159         if(isset($storedOptions['sentFolder']) && !empty($storedOptions['sentFolder'])) {
160                 $sentFolder = $storedOptions['sentFolder'];
161         } else {
162                 $sentFolder = $mod_strings['LBL_NONE'];
163         }
164
165         if(!isset($storedOptions['leaveMessagesOnMailServer']) || $storedOptions['leaveMessagesOnMailServer'] == 1) {
166                 $leaveMessagesOnMailServer = $app_strings['LBL_EMAIL_YES'];
167         } else {
168                 $leaveMessagesOnMailServer = $app_strings['LBL_EMAIL_NO'];
169         } // else
170         if(!isset($storedOptions['leaveMessagesOnMailServer']) || $storedOptions['leaveMessagesOnMailServer'] == 1) {
171                 $leaveMessagesOnMailServer = $app_strings['LBL_EMAIL_YES'];
172         } else {
173                 $leaveMessagesOnMailServer = $app_strings['LBL_EMAIL_NO'];
174         } // else
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;
178     
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'];
181         
182 }
183
184 if(!empty($create_case_email_template)) {
185         
186         $et = new EmailTemplate();
187         $et->retrieve($create_case_email_template);
188         $create_case_email_template_name = $et->name;
189 }
190 if (!empty($distrib_method)) {
191         $distributionMethod = $app_list_strings['dom_email_distribution_for_auto_create'][$distrib_method];
192 } // if
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>");
197 }
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'];
202 }
203
204 $xtpl->assign('MODULE_TITLE', getClassicModuleTitle('InboundEmail', 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);
219
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);
227
228 // deferred
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");
234 } else {
235         $is_auto_import = $app_list_strings['checkbox_dom']['2'];
236         
237         if (!empty($focus->groupfolder_id)) {
238                 $is_auto_import = $app_list_strings['checkbox_dom']['1'];
239                 $leaveMessagesOnMailServerStyle = "display:''";
240         } // if
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:''";
245         }
246
247 }
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");
255 } else {
256         $xtpl->assign('TRASH_SENT_FOLDER_STYLE', "display:''");
257 } // else
258
259 $possibleAction = "pick";
260 if (!isset($app_list_strings['dom_mailbox_type'][$focus->mailbox_type])) {
261         $possibleAction = $app_list_strings['dom_mailbox_type']['pick'];
262 } else {
263         $possibleAction = $app_list_strings['dom_mailbox_type'][$focus->mailbox_type];
264 }
265
266 if($focus->mailbox_type == 'createcase')
267     $is_create_case = $app_list_strings['checkbox_dom']['1'];
268 else 
269     $is_create_case = $app_list_strings['checkbox_dom']['2'];
270
271
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);
286 }
287 if($focus->handleIsPersonal()) {
288         $xtpl->assign('LBL_GROUP_QUEUE', $mod_strings['LBL_ASSIGN_TO_USER']);
289 } else {
290         $xtpl->assign('LBL_GROUP_QUEUE', $mod_strings['LBL_GROUP_QUEUE']);
291 }
292
293 //Overrides for bounce mailbox accounts
294 if ($focus->mailbox_type == 'bounce')
295 {
296     $xtpl->assign('MODULE_TITLE', getClassicModuleTitle('InboundEmail', array($mod_strings['LBL_BOUNCE_MODULE_NAME'],$focus->name), true));
297 }
298 else if( $focus->is_personal == '1')
299      $xtpl->assign('MODULE_TITLE', getClassicModuleTitle('InboundEmail', array($mod_strings['LBL_PERSONAL_MODULE_NAME'],$focus->name), true));
300
301 $xtpl->parse('main');
302 $xtpl->out('main');
303 ?>