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.
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.
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
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
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.
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.
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 ********************************************************************************/
38 /*********************************************************************************
40 * Description: Contains a variety of utility functions specific to this module.
41 ********************************************************************************/
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): ______________________________________..
49 function get_validate_record_js () {
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'];
66 <script type="text/javascript" language="Javascript">
67 <!-- to hide script contents from old browsers
69 function verify_data(button) {
71 var errorMessage = "";
72 if (typeof button.form['campaign_emails_per_run'] != 'undefined' && trim(button.form['campaign_emails_per_run'].value) == "") {
74 errorMessage += "\\n$lbl_email_per_run";
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) {
79 errorMessage += "\\n$err_int_only";
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) == "") {
85 errorMessage += "\\n$lbl_location";
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');
96 if(trim(fromname) == "") {
98 errorMessage += "\\n$err_from_name";
100 if(trim(fromAddress) == "") {
102 errorMessage += "\\n$err_from_addr";
105 if (sendType == 'SMTP') {
106 if(trim(smtpserver) == "") {
108 errorMessage += "\\n$err_mailserver";
110 if(trim(smtpPort) == "") {
112 errorMessage += "\\n$err_smtpport";
114 if (mailsmtpauthreq.checked) {
115 if(trim(document.getElementById('mail_smtpuser').value) == "") {
117 errorMessage += "\\n$err_smtpuser";
124 // Here we decide whether to submit the form.
125 if (isError == true) {
126 alert("$err_missing_required_fields" + errorMessage);
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');
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']}');
150 // end hiding contents from old browsers -->