]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Campaigns/WizardEmailSetupSave.php
Release 6.5.0
[Github/sugarcrm.git] / modules / Campaigns / WizardEmailSetupSave.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
40  * Description:  TODO: To be written.
41  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
42  * All Rights Reserved.
43  * Contributor(s): ______________________________________..
44  ********************************************************************************/
45 require_once('include/formbase.php');
46
47
48 global $mod_strings;
49
50
51 //get new administration bean for setup
52 $focus = new Administration();
53 $camp_steps[] = 'wiz_step_';
54 $camp_steps[] = 'wiz_step1_';
55 $camp_steps[] = 'wiz_step2_';
56
57     //name is used as key in post, it is also used in creation of summary page for wizard,
58     //so let's clean up the posting so we can reuse the save functionality for inbound emails and
59     //from existing save.php's  
60     foreach($camp_steps as $step){
61         clean_up_post($step);
62     }
63 /**************************** Save general Email Setup  *****************************/
64
65 //we do not need to track location if location type is not set
66 if(isset($_POST['tracking_entities_location_type'])) {
67     if ($_POST['tracking_entities_location_type'] != '2') {
68         unset($_POST['tracking_entities_location']);
69         unset($_POST['tracking_entities_location_type']);
70     }
71 }
72 //if the check box is empty, then set it to 0
73 if(!isset($_POST['mail_smtpauth_req'])) { $_POST['mail_smtpauth_req'] = 0; }
74 //default ssl use to false
75 if(!isset($_POST['mail_smtpssl'])) { $_POST['mail_smtpssl'] = 0; }
76 //reuse existing saveconfig functionality
77 $focus->saveConfig();
78
79
80
81 /**************************** Add New Monitored Box  *****************************/
82 //perform this if the option to create new mail box has been checked
83 if(isset($_REQUEST['wiz_new_mbox']) && ($_REQUEST['wiz_new_mbox']=='1')){
84     
85    //Populate the Request variables that inboundemail expects
86     $_REQUEST['mark_read'] = 1;
87     $_REQUEST['only_since'] = 1;
88     $_REQUEST['mailbox_type'] = 'bounce';
89     $_REQUEST['from_name'] = $_REQUEST['name'];
90     $_REQUEST['group_id'] = 'new';
91 //    $_REQUEST['from_addr'] = $_REQUEST['wiz_step1_notify_fromaddress'];
92     //reuse save functionality for inbound email
93     require_once('modules/InboundEmail/Save.php');    
94
95 }
96 //set navigation details
97 header("Location: index.php?action=index&module=Campaigns");
98
99
100 /*
101  * This function will re-add the post variables that exist with the specified prefix.  
102  * It will add them minus the specified prefix.  This is needed in order to reuse the save functionality,
103  * which does not expect the prefix, and still use the generic create summary functionality in wizard, which
104  * does expect the prefix.  
105  */
106 function clean_up_post($prefix){
107
108     foreach ($_REQUEST as $key => $val) {
109               if((strstr($key, $prefix )) && (strpos($key, $prefix )== 0)){
110               $newkey  =substr($key, strlen($prefix)) ;
111               $_REQUEST[$newkey] = $val;
112          }               
113     }
114
115     foreach ($_POST as $key => $val) {
116               if((strstr($key, $prefix )) && (strpos($key, $prefix )== 0)){
117               $newkey  =substr($key, strlen($prefix)) ;
118               $_POST[$newkey] = $val;
119               
120          }               
121     }
122 }
123
124 ?>