1 /*********************************************************************************
2 * SugarCRM is a customer relationship management program developed by
3 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Affero General Public License version 3 as published by the
7 * Free Software Foundation with the addition of the following permission added
8 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
9 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
10 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
17 * You should have received a copy of the GNU Affero General Public License along with
18 * this program; if not, see http://www.gnu.org/licenses or write to the Free
19 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
23 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
25 * The interactive user interfaces in modified source and object code versions
26 * of this program must display Appropriate Legal Notices, as required under
27 * Section 5 of the GNU Affero General Public License version 3.
29 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
30 * these Appropriate Legal Notices must retain the display of the "Powered by
31 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
32 * technical reasons, the Appropriate Legal Notices must display the words
33 * "Powered by SugarCRM".
34 ********************************************************************************/
39 function send_back_selected(module, form, field, error_message, field_to_name_array)
41 // cn: bug 12274 - stripping false-positive security envelope
42 var temp_request_data = request_data;
43 if(temp_request_data.jsonObject) {
44 request_data = temp_request_data.jsonObject;
46 request_data = temp_request_data; // passed data that is NOT incorrectly encoded via JSON.encode();
48 // cn: end bug 12274 fix
50 var passthru_data = Object();
51 if(typeof(request_data.passthru_data) != 'undefined')
53 passthru_data = request_data.passthru_data;
55 var form_name = request_data.form_name;
56 var field_to_name_array = request_data.field_to_name_array;
57 var call_back_function = eval("window.opener." + request_data.call_back_function);
59 var array_contents = Array();
61 for (i = 0; i < form.elements.length; i++){
62 if(form.elements[i].name == field) {
63 if (form.elements[i].checked == true) {
65 var id = form.elements[i].value;
66 array_contents_row = Array();
67 for(var the_key in field_to_name_array)
69 if(the_key != 'toJSON')
71 var the_name = field_to_name_array[the_key];
74 if(/*module != '' && */id != '')
76 the_value = associated_javascript_data[id][the_key.toUpperCase()];
79 array_contents_row.push('"' + the_name + '":"' + the_value + '"');
82 eval("array_contents.push({" + array_contents_row.join(",") + "})");
87 var result_data = {"form_name":form_name,"name_to_value_array":array_contents};
89 if (array_contents.length ==0 ) {
90 window.alert(error_message);
94 call_back_function(result_data);
95 var close_popup = window.opener.get_close_popup();
103 function send_back(module, id)
105 var associated_row_data = associated_javascript_data[id];
107 // cn: bug 12274 - stripping false-positive security envelope
108 eval("var temp_request_data = " + window.document.forms['popup_query_form'].request_data.value);
109 if(temp_request_data.jsonObject) {
110 var request_data = temp_request_data.jsonObject;
112 var request_data = temp_request_data; // passed data that is NOT incorrectly encoded via JSON.encode();
114 // cn: end bug 12274 fix
116 var passthru_data = Object();
117 if(typeof(request_data.passthru_data) != 'undefined')
119 passthru_data = request_data.passthru_data;
121 var form_name = request_data.form_name;
122 var field_to_name_array = request_data.field_to_name_array;
123 var call_back_function = eval("window.opener." + request_data.call_back_function);
124 var array_contents = Array();
126 // constructs the array of values associated to the bean that the user clicked
127 for(var the_key in field_to_name_array)
129 if(the_key != 'toJSON')
131 var the_name = field_to_name_array[the_key];
134 if(module != '' && id != '')
136 the_value = associated_row_data[the_key.toUpperCase()];
139 array_contents.push('"' + the_name + '":"' + the_value + '"');
143 eval("var name_to_value_array = {'0' : {" + array_contents.join(",") + "}}");
145 var result_data = {"form_name":form_name,"name_to_value_array":name_to_value_array,"passthru_data":passthru_data};
146 var close_popup = window.opener.get_close_popup();
148 call_back_function(result_data);