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-2013 SugarCRM Inc. |
6
|
|
|
|
7
|
|
|
* SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd. |
8
|
|
|
* Copyright (C) 2011 - 2014 Salesagility Ltd. |
9
|
|
|
* |
10
|
|
|
* This program is free software; you can redistribute it and/or modify it under |
11
|
|
|
* the terms of the GNU Affero General Public License version 3 as published by the |
12
|
|
|
* Free Software Foundation with the addition of the following permission added |
13
|
|
|
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK |
14
|
|
|
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY |
15
|
|
|
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. |
16
|
|
|
* |
17
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT |
18
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
19
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
20
|
|
|
* details. |
21
|
|
|
* |
22
|
|
|
* You should have received a copy of the GNU Affero General Public License along with |
23
|
|
|
* this program; if not, see http://www.gnu.org/licenses or write to the Free |
24
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
25
|
|
|
* 02110-1301 USA. |
26
|
|
|
* |
27
|
|
|
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, |
28
|
|
|
* SW2-130, Cupertino, CA 95014, USA. or at email address [email protected]. |
29
|
|
|
* |
30
|
|
|
* The interactive user interfaces in modified source and object code versions |
31
|
|
|
* of this program must display Appropriate Legal Notices, as required under |
32
|
|
|
* Section 5 of the GNU Affero General Public License version 3. |
33
|
|
|
* |
34
|
|
|
* In accordance with Section 7(b) of the GNU Affero General Public License version 3, |
35
|
|
|
* these Appropriate Legal Notices must retain the display of the "Powered by |
36
|
|
|
* SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not |
37
|
|
|
* reasonably feasible for technical reasons, the Appropriate Legal Notices must |
38
|
|
|
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
39
|
|
|
********************************************************************************/ |
40
|
|
|
|
41
|
|
|
/********************************************************************************* |
42
|
|
|
|
43
|
|
|
* Description: Contains a variety of utility functions specific to this module. |
44
|
|
|
********************************************************************************/ |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Create javascript to validate the data entered into a record. |
48
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
49
|
|
|
* All Rights Reserved. |
50
|
|
|
* Contributor(s): ______________________________________.. |
51
|
|
|
*/ |
52
|
|
|
function get_validate_record_js () { |
|
|
|
|
53
|
|
|
global $mod_strings; |
54
|
|
|
global $app_strings; |
55
|
|
|
|
56
|
|
|
$lbl_email_per_run = $mod_strings['LBL_EMAILS_PER_RUN']; |
57
|
|
|
$lbl_location = $mod_strings['LBL_LOCATION_ONLY']; |
58
|
|
|
$err_int_only=$mod_strings['ERR_INT_ONLY_EMAIL_PER_RUN']; |
59
|
|
|
$err_missing_required_fields = $app_strings['ERR_MISSING_REQUIRED_FIELDS']; |
60
|
|
|
$err_from_name = $mod_strings['LBL_LIST_FROM_NAME']; |
61
|
|
|
$err_from_addr = $app_strings['LBL_EMAIL_SETTINGS_FROM_ADDR']; |
62
|
|
|
$err_smtpport = $mod_strings['LBL_MAIL_SMTPPORT']; |
63
|
|
|
$err_mailserver = $mod_strings['LBL_MAIL_SMTPSERVER']; |
64
|
|
|
$err_smtpuser = $mod_strings['LBL_MAIL_SMTPUSER']; |
65
|
|
|
$err_smtppass = $mod_strings['LBL_MAIL_SMTPPASS']; |
66
|
|
|
|
67
|
|
|
$the_script = <<<EOQ |
68
|
|
|
|
69
|
|
|
<script type="text/javascript" language="Javascript"> |
70
|
|
|
<!-- to hide script contents from old browsers |
71
|
|
|
|
72
|
|
|
function verify_data(button) { |
73
|
|
|
var isError = false; |
74
|
|
|
var errorMessage = ""; |
75
|
|
|
if (typeof button.form['campaign_emails_per_run'] != 'undefined' && trim(button.form['campaign_emails_per_run'].value) == "") { |
76
|
|
|
isError = true; |
77
|
|
|
errorMessage += "\\n$lbl_email_per_run"; |
78
|
|
|
} else { |
79
|
|
|
//make sure emails per run is an integer. |
80
|
|
|
if (typeof button.form['campaign_emails_per_run'] != 'undefined' && isInteger(trim(button.form['campaign_emails_per_run'].value)) == false) { |
81
|
|
|
isError = true; |
82
|
|
|
errorMessage += "\\n$err_int_only"; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
if (typeof button.form['tracking_entities_location_type'] != 'undefined' && button.form['tracking_entities_location_type'][1].checked == true) { |
86
|
|
|
if (typeof button.form['tracking_entities_location'] != 'undefined' && trim(button.form['tracking_entities_location'].value) == "") { |
87
|
|
|
isError = true; |
88
|
|
|
errorMessage += "\\n$lbl_location"; |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
if (typeof document.forms['ConfigureSettings'] != 'undefined') { |
92
|
|
|
var fromname = document.getElementById('notify_fromname').value; |
93
|
|
|
var fromAddress = document.getElementById('notify_fromaddress').value; |
94
|
|
|
var sendType = document.getElementById('mail_sendtype').value; |
95
|
|
|
var smtpPort = document.getElementById('mail_smtpport').value; |
96
|
|
|
var smtpserver = document.getElementById('mail_smtpserver').value; |
97
|
|
|
var mailsmtpauthreq = document.getElementById('mail_smtpauth_req'); |
98
|
|
|
|
99
|
|
|
if(trim(fromname) == "") { |
100
|
|
|
isError = true; |
101
|
|
|
errorMessage += "\\n$err_from_name"; |
102
|
|
|
} |
103
|
|
|
if(trim(fromAddress) == "") { |
104
|
|
|
isError = true; |
105
|
|
|
errorMessage += "\\n$err_from_addr"; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
if (sendType == 'SMTP') { |
109
|
|
|
if(trim(smtpserver) == "") { |
110
|
|
|
isError = true; |
111
|
|
|
errorMessage += "\\n$err_mailserver"; |
112
|
|
|
} |
113
|
|
|
if(trim(smtpPort) == "") { |
114
|
|
|
isError = true; |
115
|
|
|
errorMessage += "\\n$err_smtpport"; |
116
|
|
|
} |
117
|
|
|
if (mailsmtpauthreq.checked) { |
118
|
|
|
if(trim(document.getElementById('mail_smtpuser').value) == "") { |
119
|
|
|
isError = true; |
120
|
|
|
errorMessage += "\\n$err_smtpuser"; |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
} // if |
125
|
|
|
} // if |
126
|
|
|
|
127
|
|
|
// Here we decide whether to submit the form. |
128
|
|
|
if (isError == true) { |
129
|
|
|
alert("$err_missing_required_fields" + errorMessage); |
130
|
|
|
return false; |
131
|
|
|
} |
132
|
|
|
return true; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
function add_checks(f) { |
136
|
|
|
removeFromValidate('ConfigureSettings', 'mail_smtpserver'); |
137
|
|
|
removeFromValidate('ConfigureSettings', 'mail_smtpport'); |
138
|
|
|
removeFromValidate('ConfigureSettings', 'mail_smtpuser'); |
139
|
|
|
removeFromValidate('ConfigureSettings', 'mail_smtppass'); |
140
|
|
|
|
141
|
|
|
if (f.mail_sendtype.value == "SMTP") { |
142
|
|
|
addToValidate('ConfigureSettings', 'mail_smtpserver', 'varchar', 'true', '{$mod_strings['LBL_MAIL_SMTPSERVER']}'); |
143
|
|
|
addToValidate('ConfigureSettings', 'mail_smtpport', 'int', 'true', '{$mod_strings['LBL_MAIL_SMTPPORT']}'); |
144
|
|
|
if (f.mail_smtpauth_req.checked) { |
145
|
|
|
addToValidate('ConfigureSettings', 'mail_smtpuser', 'varchar', 'true', '{$mod_strings['LBL_MAIL_SMTPUSER']}'); |
146
|
|
|
addToValidate('ConfigureSettings', 'mail_smtppass', 'varchar', 'true', '{$mod_strings['LBL_MAIL_SMTPPASS']}'); |
147
|
|
|
} |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
return true; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
// end hiding contents from old browsers --> |
154
|
|
|
</script> |
155
|
|
|
EOQ; |
156
|
|
|
return $the_script; |
157
|
|
|
} |
158
|
|
|
?> |
This check looks for functions that have already been defined in other files.
Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the
@ignore
annotation.See also the PhpDoc documentation for @ignore.