1 /*********************************************************************************
2 * SugarCRM Community Edition is a customer relationship management program developed by
3 * SugarCRM, Inc. Copyright (C) 2004-2012 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 ********************************************************************************/
37 if(typeof(SUGAR) == 'undefined') {
41 SUGAR.Administration = {
43 * calls modules/Administration/Async.php with JSON objects
49 * Utility functions for RepairXSS screen
50 * @param HTMLSelectObject select dropdown
53 toRepair : new Object, // assoc array of items to be cleaned
54 currentRepairObject : "", // bean currently worked on
55 currentRepairIds : new Array(), // array of ids for above bean
57 numberToFix: 25, // how many IDs to send at once from client
60 * Calculates how many rows to iterate through
62 refreshEstimate : function(select) {
63 this.toRepair = new Object();
64 this.repairedCount = 0;
66 var button = document.getElementById('repairXssButton');
67 var selected = select.value;
68 var totalDisplay = document.getElementById('repairXssDisplay');
69 var counter = document.getElementById('repairXssCount');
70 var repaired = document.getElementById('repairXssResults');
71 var repairedCounter = document.getElementById('repairXssResultCount');
74 button.style.display = 'inline';
75 repairedCounter.value = 0;
76 AjaxObject.startRequest(callbackRepairXssRefreshEstimate, "&adminAction=refreshEstimate&bean=" + selected);
78 button.style.display = 'none';
79 totalDisplay.style.display = 'none';
80 repaired.style.display = 'none';
87 * Takes selection and executes repair function
89 executeRepair : function() {
91 // if queue is empty load next
92 if(this.currentRepairIds.length < 1) {
93 if(!this.loadRepairQueue()) {
99 var beanIds = new Array();
101 for(var i=0; i<this.numberToFix; i++) {
102 if(this.currentRepairIds.length > 0) {
103 beanIds.push(this.currentRepairIds.pop());
107 var beanId = YAHOO.lang.JSON.stringify(beanIds);
108 AjaxObject.startRequest(callbackRepairXssExecute, "&adminAction=repairXssExecute&bean=" + this.currentRepairObject + "&id=" + beanId);
113 * Loads the bean name and array of bean ids for repair
114 * @return bool False if load did not occur
116 loadRepairQueue : function() {
119 this.currentRepairObject = '';
120 this.currentRepairIds = new Array();
122 for(var bean in this.toRepair) {
123 if(this.toRepair[bean].length > 0) {
124 this.currentRepairObject = bean;
125 this.currentRepairIds = this.toRepair[bean];
130 // 'unset' the IDs array so we don't iterate over it again
131 this.toRepair[this.currentRepairObject] = new Array();