]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/EmailMan/Forms.php
Release 6.1.5
[Github/sugarcrm.git] / modules / EmailMan / Forms.php
1 <?php
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.
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:  Contains a variety of utility functions specific to this module.
41  ********************************************************************************/
42
43 /**
44  * Create javascript to validate the data entered into a record.
45  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
46  * All Rights Reserved.
47  * Contributor(s): ______________________________________..
48  */
49 function get_validate_record_js () {
50 global $mod_strings;
51 global $app_strings;
52
53 $lbl_email_per_run = $mod_strings['LBL_EMAILS_PER_RUN'];
54 $lbl_location = $mod_strings['LBL_LOCATION_ONLY'];
55 $err_int_only=$mod_strings['ERR_INT_ONLY_EMAIL_PER_RUN'];
56 $err_missing_required_fields = $app_strings['ERR_MISSING_REQUIRED_FIELDS'];
57 $err_from_name = $mod_strings['LBL_LIST_FROM_NAME'];
58 $err_from_addr = $app_strings['LBL_EMAIL_SETTINGS_FROM_ADDR'];
59 $err_smtpport = $mod_strings['LBL_MAIL_SMTPPORT'];
60 $err_mailserver = $mod_strings['LBL_MAIL_SMTPSERVER'];
61 $err_smtpuser = $mod_strings['LBL_MAIL_SMTPUSER'];
62 $err_smtppass = $mod_strings['LBL_MAIL_SMTPPASS'];
63
64 $the_script  = <<<EOQ
65
66 <script type="text/javascript" language="Javascript">
67 <!--  to hide script contents from old browsers
68
69 function verify_data(button) {
70         var isError = false;
71         var errorMessage = "";
72         if (typeof button.form['campaign_emails_per_run'] != 'undefined' && trim(button.form['campaign_emails_per_run'].value) == "") {
73                 isError = true;
74                 errorMessage += "\\n$lbl_email_per_run";
75         } else {
76                  //make sure emails per run  is an integer.
77                 if (typeof button.form['campaign_emails_per_run'] != 'undefined' && isInteger(trim(button.form['campaign_emails_per_run'].value)) == false) {
78                         isError = true;
79                         errorMessage += "\\n$err_int_only";
80                 }
81         }
82         if (typeof button.form['tracking_entities_location_type'] != 'undefined' && button.form['tracking_entities_location_type'][1].checked == true) {
83                 if (typeof button.form['tracking_entities_location'] != 'undefined' && trim(button.form['tracking_entities_location'].value) == "") {
84                         isError = true;
85                         errorMessage += "\\n$lbl_location";
86                 }
87         }
88         if (typeof document.forms['ConfigureSettings'] != 'undefined') {
89         var fromname = document.getElementById('notify_fromname').value;
90         var fromAddress = document.getElementById('notify_fromaddress').value;
91         var sendType = document.getElementById('mail_sendtype').value;
92         var smtpPort = document.getElementById('mail_smtpport').value;
93         var smtpserver = document.getElementById('mail_smtpserver').value;
94         var mailsmtpauthreq = document.getElementById('mail_smtpauth_req');
95
96         if(trim(fromname) == "") {
97                         isError = true;
98                         errorMessage += "\\n$err_from_name";
99         }
100         if(trim(fromAddress) == "") {
101                         isError = true;
102                         errorMessage += "\\n$err_from_addr";
103         }
104
105         if (sendType == 'SMTP') {
106                 if(trim(smtpserver) == "") {
107                                 isError = true;
108                                 errorMessage += "\\n$err_mailserver";
109                 }
110                 if(trim(smtpPort) == "") {
111                                 isError = true;
112                                 errorMessage += "\\n$err_smtpport";
113                 }
114                 if (mailsmtpauthreq.checked) {
115                         if(trim(document.getElementById('mail_smtpuser').value) == "") {
116                                         isError = true;
117                                         errorMessage += "\\n$err_smtpuser";
118                         }
119                 }
120
121         } // if
122         } // if
123
124         // Here we decide whether to submit the form.
125         if (isError == true) {
126                 alert("$err_missing_required_fields" + errorMessage);
127                 return false;
128         }
129         return true;
130 }
131
132 function add_checks(f) {
133         removeFromValidate('ConfigureSettings', 'mail_smtpserver');
134         removeFromValidate('ConfigureSettings', 'mail_smtpport');
135         removeFromValidate('ConfigureSettings', 'mail_smtpuser');
136         removeFromValidate('ConfigureSettings', 'mail_smtppass');
137
138         if (f.mail_sendtype.value == "SMTP") {
139                 addToValidate('ConfigureSettings', 'mail_smtpserver', 'varchar', 'true', '{$mod_strings['LBL_MAIL_SMTPSERVER']}');
140                 addToValidate('ConfigureSettings', 'mail_smtpport', 'int', 'true', '{$mod_strings['LBL_MAIL_SMTPPORT']}');
141                 if (f.mail_smtpauth_req.checked) {
142                         addToValidate('ConfigureSettings', 'mail_smtpuser', 'varchar', 'true', '{$mod_strings['LBL_MAIL_SMTPUSER']}');
143                         addToValidate('ConfigureSettings', 'mail_smtppass', 'varchar', 'true', '{$mod_strings['LBL_MAIL_SMTPPASS']}');
144                 }
145         }
146
147         return true;
148 }
149
150 // end hiding contents from old browsers  -->
151 </script>
152 EOQ;
153 return $the_script;
154 }
155 ?>