]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/EmailMan/controller.php
Release 6.5.0
[Github/sugarcrm.git] / modules / EmailMan / controller.php
1 <?php
2 /*********************************************************************************
3  * SugarCRM Community Edition is a customer relationship management program developed by
4  * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
5  * 
6  * This program is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  * 
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
16  * details.
17  * 
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  * 
23  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
24  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
25  * 
26  * The interactive user interfaces in modified source and object code versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  * 
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the "Powered by
32  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
33  * technical reasons, the Appropriate Legal Notices must display the words
34  * "Powered by SugarCRM".
35  ********************************************************************************/
36
37
38 class EmailManController extends SugarController
39 {
40         function action_Save(){
41
42         
43         require_once('include/OutboundEmail/OutboundEmail.php');
44         require_once('modules/Configurator/Configurator.php');
45
46         $configurator = new Configurator();
47         global $sugar_config;
48         global $current_user;
49         if ( !is_admin($current_user)
50                 && !is_admin_for_module($GLOBALS['current_user'],'Emails')
51                 && !is_admin_for_module($GLOBALS['current_user'],'Campaigns') ){
52         sugar_die("Unauthorized access to administration.");
53         }
54
55         //Do not allow users to spoof for sendmail if the config flag is not set.
56         if( !isset($sugar_config['allow_sendmail_outbound']) || !$sugar_config['allow_sendmail_outbound'])
57             $_REQUEST['mail_sendtype'] = "SMTP";
58
59         // save Outbound settings  #Bug 20033 Ensure data for Outbound email exists before trying to update the system mailer.
60         if(isset($_REQUEST['mail_sendtype']) && empty($_REQUEST['campaignConfig'])) {
61             $oe = new OutboundEmail();
62             $oe->populateFromPost();
63             $oe->saveSystem();
64         }
65
66
67
68         $focus = new Administration();
69
70         if(isset($_POST['tracking_entities_location_type'])) {
71             if ($_POST['tracking_entities_location_type'] != '2') {
72                 unset($_POST['tracking_entities_location']);
73                 unset($_POST['tracking_entities_location_type']);
74             }
75         }
76         // cn: handle mail_smtpauth_req checkbox on/off (removing double reference in the form itself
77         if( !isset($_POST['mail_smtpauth_req']) )
78         {
79             $_POST['mail_smtpauth_req'] = 0;
80                 if (empty($_POST['campaignConfig'])) {
81                         $_POST['notify_allow_default_outbound'] = 0; // If smtp auth is disabled ensure outbound is disabled.
82                 }
83         }
84
85         if( !empty($_POST['notify_allow_default_outbound']) )
86         {
87             $oe = new OutboundEmail();
88             if( !$oe->isAllowUserAccessToSystemDefaultOutbound() )
89                 $oe->removeUserOverrideAccounts();
90         }
91
92         $focus->saveConfig();
93
94         // save User defaults for emails
95         $configurator->config['email_default_delete_attachments'] = (isset($_REQUEST['email_default_delete_attachments'])) ? true : false;
96
97         ///////////////////////////////////////////////////////////////////////////////
98         ////    SECURITY
99         $security = array();
100         if(isset($_REQUEST['applet'])) $security['applet'] = 'applet';
101         if(isset($_REQUEST['base'])) $security['base'] = 'base';
102         if(isset($_REQUEST['embed'])) $security['embed'] = 'embed';
103         if(isset($_REQUEST['form'])) $security['form'] = 'form';
104         if(isset($_REQUEST['frame'])) $security['frame'] = 'frame';
105         if(isset($_REQUEST['frameset'])) $security['frameset'] = 'frameset';
106         if(isset($_REQUEST['iframe'])) $security['iframe'] = 'iframe';
107         if(isset($_REQUEST['import'])) $security['import'] = '\?import';
108         if(isset($_REQUEST['layer'])) $security['layer'] = 'layer';
109         if(isset($_REQUEST['link'])) $security['link'] = 'link';
110         if(isset($_REQUEST['object'])) $security['object'] = 'object';
111         if(isset($_REQUEST['style'])) $security['style'] = 'style';
112         if(isset($_REQUEST['xmp'])) $security['xmp'] = 'xmp';
113         $security['script'] = 'script';
114
115         $configurator->config['email_xss'] = base64_encode(serialize($security));
116
117         ////    SECURITY
118         ///////////////////////////////////////////////////////////////////////////////
119
120         ksort($sugar_config);
121
122         $configurator->handleOverride();
123
124
125     }
126
127 }
128 ?>