]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - jssource/src_files/modules/Administration/javascript/Administration.js
Release 6.5.0
[Github/sugarcrm.git] / jssource / src_files / modules / Administration / javascript / Administration.js
1 /*********************************************************************************
2  * SugarCRM Community Edition is a customer relationship management program developed by
3  * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
4  * 
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.
11  * 
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
15  * details.
16  * 
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
20  * 02110-1301 USA.
21  * 
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.
24  * 
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.
28  * 
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  ********************************************************************************/
35
36 // defense
37 if(typeof(SUGAR) == 'undefined') {
38         var SUGAR = {};
39 }
40
41 SUGAR.Administration = {
42         /**
43          * calls modules/Administration/Async.php with JSON objects
44          */
45         Async : {
46         },
47
48         /**
49          * Utility functions for RepairXSS screen
50          * @param HTMLSelectObject select dropdown
51          */
52         RepairXSS : {
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
56                 repairedCount : 0,
57                 numberToFix: 25, // how many IDs to send at once from client
58
59                 /**
60                  * Calculates how many rows to iterate through
61                  */
62                 refreshEstimate : function(select) {
63                         this.toRepair = new Object();
64                         this.repairedCount = 0;
65
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');
72
73                         if(selected != "0") {
74                                 button.style.display = 'inline';
75                                 repairedCounter.value = 0;
76                                 AjaxObject.startRequest(callbackRepairXssRefreshEstimate, "&adminAction=refreshEstimate&bean=" + selected);
77                         } else {
78                                 button.style.display = 'none';
79                                 totalDisplay.style.display = 'none';
80                                 repaired.style.display = 'none';
81                                 counter.value = 0;
82                                 repaired.value= 0;
83                         }
84                 },
85
86                 /**
87                  * Takes selection and executes repair function
88                  */
89                 executeRepair : function() {
90                         if(this.toRepair) {
91                                 // if queue is empty load next
92                                 if(this.currentRepairIds.length < 1) {
93                                         if(!this.loadRepairQueue()) {
94                                                 alert(done);
95                                                 return; // we're done
96                                         }
97                                 }
98
99                                 var beanIds = new Array();
100
101                                 for(var i=0; i<this.numberToFix; i++) {
102                                         if(this.currentRepairIds.length > 0) {
103                                                 beanIds.push(this.currentRepairIds.pop());
104                                         }
105                                 }
106
107                                 var beanId = YAHOO.lang.JSON.stringify(beanIds);
108                                 AjaxObject.startRequest(callbackRepairXssExecute, "&adminAction=repairXssExecute&bean=" + this.currentRepairObject + "&id=" + beanId);
109                         }
110                 },
111
112                 /**
113                  * Loads the bean name and array of bean ids for repair
114                  * @return bool False if load did not occur
115                  */
116                 loadRepairQueue : function() {
117                         var loaded = false;
118
119                         this.currentRepairObject = '';
120                         this.currentRepairIds = new Array();
121
122                         for(var bean in this.toRepair) {
123                                 if(this.toRepair[bean].length > 0) {
124                                         this.currentRepairObject = bean;
125                                         this.currentRepairIds = this.toRepair[bean];
126                                         loaded = true;
127                                 }
128                         }
129
130                         // 'unset' the IDs array so we don't iterate over it again
131                         this.toRepair[this.currentRepairObject] = new Array();
132
133                         return loaded;
134                 }
135         }
136 }