7604 |
25 Feb 19 |
nicklas |
/* $Id $ |
7604 |
25 Feb 19 |
nicklas |
2 |
------------------------------------------------------------------ |
7604 |
25 Feb 19 |
nicklas |
Copyright (C) 2012 Nicklas Nordborg |
7604 |
25 Feb 19 |
nicklas |
4 |
|
7604 |
25 Feb 19 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
7604 |
25 Feb 19 |
nicklas |
Available at http://base.thep.lu.se/ |
7604 |
25 Feb 19 |
nicklas |
7 |
|
7604 |
25 Feb 19 |
nicklas |
BASE is free software; you can redistribute it and/or |
7604 |
25 Feb 19 |
nicklas |
modify it under the terms of the GNU General Public License |
7604 |
25 Feb 19 |
nicklas |
as published by the Free Software Foundation; either version 3 |
7604 |
25 Feb 19 |
nicklas |
of the License, or (at your option) any later version. |
7604 |
25 Feb 19 |
nicklas |
12 |
|
7604 |
25 Feb 19 |
nicklas |
BASE is distributed in the hope that it will be useful, |
7604 |
25 Feb 19 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
7604 |
25 Feb 19 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7604 |
25 Feb 19 |
nicklas |
GNU General Public License for more details. |
7604 |
25 Feb 19 |
nicklas |
17 |
|
7604 |
25 Feb 19 |
nicklas |
You should have received a copy of the GNU General Public License |
7604 |
25 Feb 19 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
7604 |
25 Feb 19 |
nicklas |
20 |
------------------------------------------------------------------ |
7604 |
25 Feb 19 |
nicklas |
21 |
|
7604 |
25 Feb 19 |
nicklas |
@author Nicklas |
7604 |
25 Feb 19 |
nicklas |
23 |
*/ |
7604 |
25 Feb 19 |
nicklas |
'use strict'; |
7604 |
25 Feb 19 |
nicklas |
25 |
|
7604 |
25 Feb 19 |
nicklas |
var Plugins = function() |
7604 |
25 Feb 19 |
nicklas |
27 |
{ |
7604 |
25 Feb 19 |
nicklas |
var plugins = {}; |
7604 |
25 Feb 19 |
nicklas |
29 |
|
7604 |
25 Feb 19 |
nicklas |
var Permission = {}; |
7604 |
25 Feb 19 |
nicklas |
31 |
|
7604 |
25 Feb 19 |
nicklas |
32 |
/** |
7604 |
25 Feb 19 |
nicklas |
Initialize the page. |
7604 |
25 Feb 19 |
nicklas |
34 |
*/ |
7604 |
25 Feb 19 |
nicklas |
plugins.initPage = function() |
7604 |
25 Feb 19 |
nicklas |
36 |
{ |
7604 |
25 Feb 19 |
nicklas |
var pageId = Doc.getPageId(); |
7604 |
25 Feb 19 |
nicklas |
if (pageId == 'edit-page') |
7604 |
25 Feb 19 |
nicklas |
39 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Save + Close buttons |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnSave', plugins.save); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
7604 |
25 Feb 19 |
nicklas |
43 |
|
7604 |
25 Feb 19 |
nicklas |
// Tab validation |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabValidator('settings.info', plugins.validatePlugin); |
7604 |
25 Feb 19 |
nicklas |
if (Doc.element('settings.annotations')) |
7604 |
25 Feb 19 |
nicklas |
47 |
{ |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('settings.annotations', Annotations.onSwitchToAnnotationsTab); |
7604 |
25 Feb 19 |
nicklas |
49 |
} |
7604 |
25 Feb 19 |
nicklas |
50 |
|
7604 |
25 Feb 19 |
nicklas |
// Job agents |
7604 |
25 Feb 19 |
nicklas |
plugins.agentSettings = Data.json('page-data', 'agent-settings'); |
7604 |
25 Feb 19 |
nicklas |
53 |
|
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('agents', 'click', plugins.agentsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('agents', 'base-selected', plugins.agentsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('btnRemoveAgents', 'click', plugins.hideAgentSettings); |
7604 |
25 Feb 19 |
nicklas |
57 |
|
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('agentMaxMemory', 'blur', plugins.maxMemoryOnBlur); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('useDefaultMaxMemory', 'click', plugins.useDefaultMaxMemoryOnClick) |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('agentTrustedDefault', 'click', plugins.trustedOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('agentTrustedYes', 'click', plugins.trustedOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('agentTrustedNo', 'click', plugins.trustedOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('agentPriorityBoost', 'keypress', Events.integerOnly); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('agentPriorityBoost', 'blur', plugins.priorityBoostOnBlur); |
7604 |
25 Feb 19 |
nicklas |
65 |
|
7604 |
25 Feb 19 |
nicklas |
var selectedAgent = Data.get('page-data', 'select-agent'); |
7604 |
25 Feb 19 |
nicklas |
if (selectedAgent) plugins.selectAgent(selectedAgent); |
7604 |
25 Feb 19 |
nicklas |
68 |
|
7604 |
25 Feb 19 |
nicklas |
// Permissions |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('permissionsYes', 'click', plugins.usePermissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('permissionsNo', 'click', plugins.usePermissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('permissionsAuto', 'click', plugins.usePermissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
73 |
|
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('itemTypes', 'click', plugins.itemTypesOnClick); |
7604 |
25 Feb 19 |
nicklas |
75 |
|
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('grant_create', 'click', plugins.permissionOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('grant_read', 'click', plugins.permissionOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('grant_use', 'click', plugins.permissionOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('grant_restricted_write', 'click', plugins.permissionOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('grant_write', 'click', plugins.permissionOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('grant_delete', 'click', plugins.permissionOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('grant_set_owner', 'click', plugins.permissionOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('grant_set_permission', 'click', plugins.permissionOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('deny_create', 'click', plugins.permissionOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('deny_read', 'click', plugins.permissionOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('deny_use', 'click', plugins.permissionOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('deny_restricted_write', 'click', plugins.permissionOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('deny_write', 'click', plugins.permissionOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('deny_delete', 'click', plugins.permissionOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('deny_set_owner', 'click', plugins.permissionOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('deny_set_permission', 'click', plugins.permissionOnClick); |
7604 |
25 Feb 19 |
nicklas |
92 |
|
7604 |
25 Feb 19 |
nicklas |
Permission.CREATE = Data.int('page-data', 'create'); |
7604 |
25 Feb 19 |
nicklas |
Permission.READ = Data.int('page-data', 'read'); |
7604 |
25 Feb 19 |
nicklas |
Permission.USE = Data.int('page-data', 'use'); |
7604 |
25 Feb 19 |
nicklas |
Permission.RESTRICTED_WRITE = Data.int('page-data', 'restricted-write'); |
7604 |
25 Feb 19 |
nicklas |
Permission.WRITE = Data.int('page-data', 'write'); |
7604 |
25 Feb 19 |
nicklas |
Permission.DELETE = Data.int('page-data', 'delete'); |
7604 |
25 Feb 19 |
nicklas |
Permission.SET_OWNER = Data.int('page-data', 'set-owner'); |
7604 |
25 Feb 19 |
nicklas |
Permission.SET_PERMISSION = Data.int('page-data', 'set-permission'); |
7604 |
25 Feb 19 |
nicklas |
101 |
|
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnSetRequestedPermissions', plugins.setRequestedPermissions); |
7604 |
25 Feb 19 |
nicklas |
103 |
|
7604 |
25 Feb 19 |
nicklas |
plugins.initPermissionLetters(); |
7604 |
25 Feb 19 |
nicklas |
105 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (pageId == 'view-page') |
7604 |
25 Feb 19 |
nicklas |
107 |
{ |
7604 |
25 Feb 19 |
nicklas |
var itemId = Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
var attributes = {'item-type': 'PLUGINDEFINITION', 'item-id': itemId}; |
7604 |
25 Feb 19 |
nicklas |
110 |
|
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnEdit', Buttons.editItem, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnDelete', Buttons.deleteItem, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnRestore', Buttons.restoreItem, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnUsingItems', Buttons.showUsingItems, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnDeletePermanently', Buttons.deleteItemPermanently, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnShare', Buttons.shareItem, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnSetOwner', Buttons.setOwner, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnExport', Buttons.runPlugin, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnImport', Buttons.runPlugin, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnRunPlugin', Buttons.runPlugin, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnNewConfiguration', plugins.newConfiguration, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnToggleDisabled', plugins.toggleDisabled); |
7604 |
25 Feb 19 |
nicklas |
123 |
|
7604 |
25 Feb 19 |
nicklas |
if (Doc.element('main.annotations')) |
7604 |
25 Feb 19 |
nicklas |
125 |
{ |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('main.annotations', AnnotationsList.loadOnce); |
7604 |
25 Feb 19 |
nicklas |
127 |
} |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('main.history', History.loadOnce); |
7604 |
25 Feb 19 |
nicklas |
129 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (pageId == 'list-page') |
7604 |
25 Feb 19 |
nicklas |
131 |
{ |
7604 |
25 Feb 19 |
nicklas |
var attributes = {'item-type': 'PLUGINDEFINITION'}; |
7604 |
25 Feb 19 |
nicklas |
var tableAttributes = {'table-id': 'plugins'}; |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnNewItem', Buttons.newItem, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnDeleteItems', Buttons.deleteItems, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnRestoreItems', Buttons.restoreItems, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnShareItems', Buttons.shareItems, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnSetOwner', Buttons.setOwnerOfItems, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnColumns', Buttons.configureColumns, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnExport', Buttons.runListPlugin, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnImport', Buttons.runListPlugin, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnRunPlugin', Buttons.runListPlugin, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
143 |
|
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnOk', Buttons.returnSelected, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
146 |
} |
7604 |
25 Feb 19 |
nicklas |
147 |
} |
7604 |
25 Feb 19 |
nicklas |
148 |
|
7604 |
25 Feb 19 |
nicklas |
149 |
|
7604 |
25 Feb 19 |
nicklas |
// Add event handlers to the 'configure' and copy icons |
7604 |
25 Feb 19 |
nicklas |
plugins.initElements = function(element, autoInit) |
7604 |
25 Feb 19 |
nicklas |
152 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (autoInit == 'new-config') |
7604 |
25 Feb 19 |
nicklas |
154 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler(element, plugins.newConfiguration); |
7604 |
25 Feb 19 |
nicklas |
156 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (autoInit == 'configure-plugin') |
7604 |
25 Feb 19 |
nicklas |
158 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler(element, plugins.configurePlugin); |
7604 |
25 Feb 19 |
nicklas |
160 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (autoInit == 'configure-agent') |
7604 |
25 Feb 19 |
nicklas |
162 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler(element, plugins.configureAgent); |
7604 |
25 Feb 19 |
nicklas |
164 |
} |
7604 |
25 Feb 19 |
nicklas |
165 |
} |
7604 |
25 Feb 19 |
nicklas |
166 |
|
7604 |
25 Feb 19 |
nicklas |
plugins.newConfiguration = function(event) |
7604 |
25 Feb 19 |
nicklas |
168 |
{ |
7604 |
25 Feb 19 |
nicklas |
var pluginId = Data.get(event.currentTarget, 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
Items.newItem('PLUGINCONFIGURATION', '&plugindefinition_id='+pluginId); |
7604 |
25 Feb 19 |
nicklas |
171 |
} |
7604 |
25 Feb 19 |
nicklas |
172 |
|
7604 |
25 Feb 19 |
nicklas |
173 |
/* |
7604 |
25 Feb 19 |
nicklas |
Run the plug-in configuration wizard |
7604 |
25 Feb 19 |
nicklas |
175 |
*/ |
7604 |
25 Feb 19 |
nicklas |
plugins.configurePlugin = function(event) |
7604 |
25 Feb 19 |
nicklas |
177 |
{ |
7604 |
25 Feb 19 |
nicklas |
var configId = Data.int(event.currentTarget, 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
var url = App.getRoot() + 'common/plugin/index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=ConfigurePlugin'; |
7604 |
25 Feb 19 |
nicklas |
url += '&pluginconfiguration_id='+configId; |
7604 |
25 Feb 19 |
nicklas |
Dialogs.openPopup(url, 'ConfigurePlugin', 750, 500); |
7604 |
25 Feb 19 |
nicklas |
183 |
} |
7604 |
25 Feb 19 |
nicklas |
184 |
|
7604 |
25 Feb 19 |
nicklas |
plugins.configureAgent = function(event) |
7604 |
25 Feb 19 |
nicklas |
186 |
{ |
7604 |
25 Feb 19 |
nicklas |
var pluginId = Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
var agentId = Data.get(event.currentTarget, 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
Items.editItem('PLUGINDEFINITION', pluginId, '&jobagent_id='+agentId); |
7604 |
25 Feb 19 |
nicklas |
190 |
} |
7604 |
25 Feb 19 |
nicklas |
191 |
|
7604 |
25 Feb 19 |
nicklas |
plugins.toggleDisabled = function(event) |
7604 |
25 Feb 19 |
nicklas |
193 |
{ |
7604 |
25 Feb 19 |
nicklas |
var enable = Data.int(event.currentTarget, 'enable'); |
7604 |
25 Feb 19 |
nicklas |
var tree = window.parent.frames['tree']; |
7604 |
25 Feb 19 |
nicklas |
if (tree && tree.Tree) |
7604 |
25 Feb 19 |
nicklas |
197 |
{ |
7604 |
25 Feb 19 |
nicklas |
var iconName = enable ? 'Plugin' : 'PluginDisabled'; |
7604 |
25 Feb 19 |
nicklas |
var className = Data.get(event.currentTarget, 'plugin-class'); |
7604 |
25 Feb 19 |
nicklas |
tree.Tree.setIcon(className, iconName); |
7604 |
25 Feb 19 |
nicklas |
201 |
} |
7604 |
25 Feb 19 |
nicklas |
var pluginId = Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
var iframe = Data.get('page-data', 'iframe'); |
7604 |
25 Feb 19 |
nicklas |
204 |
|
7604 |
25 Feb 19 |
nicklas |
var cmd = enable ? 'EnableItem' : 'DisableItem'; |
7604 |
25 Feb 19 |
nicklas |
var url = 'index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=' + (enable ? 'EnableItem' : 'DisableItem'); |
7604 |
25 Feb 19 |
nicklas |
url += '&item_id='+pluginId+'&iframe='+iframe; |
7604 |
25 Feb 19 |
nicklas |
location.replace(url); |
7604 |
25 Feb 19 |
nicklas |
210 |
} |
7604 |
25 Feb 19 |
nicklas |
211 |
|
7604 |
25 Feb 19 |
nicklas |
plugins.validatePlugin = function() |
7604 |
25 Feb 19 |
nicklas |
213 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['plugin']; |
7604 |
25 Feb 19 |
nicklas |
if (Strings.trim(frm.className.value) == '') |
7604 |
25 Feb 19 |
nicklas |
216 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.showNotification(frm.className, 'You must enter a class name'); |
7604 |
25 Feb 19 |
nicklas |
return false; |
7604 |
25 Feb 19 |
nicklas |
219 |
} |
7604 |
25 Feb 19 |
nicklas |
return true; |
7604 |
25 Feb 19 |
nicklas |
221 |
} |
7604 |
25 Feb 19 |
nicklas |
222 |
|
7604 |
25 Feb 19 |
nicklas |
plugins.save = function() |
7604 |
25 Feb 19 |
nicklas |
224 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['plugin']; |
7604 |
25 Feb 19 |
nicklas |
if (TabControl.validateActiveTab('settings')) |
7604 |
25 Feb 19 |
nicklas |
227 |
{ |
7604 |
25 Feb 19 |
nicklas |
Link.exportActions('agents'); |
7604 |
25 Feb 19 |
nicklas |
var agents = Link.getIdsInList(frm.agents, 'JOBAGENT'); |
7604 |
25 Feb 19 |
nicklas |
230 |
|
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < agents.length; i++) |
7604 |
25 Feb 19 |
nicklas |
232 |
{ |
7604 |
25 Feb 19 |
nicklas |
var agentId = agents[i]; |
7604 |
25 Feb 19 |
nicklas |
var settings = plugins.getAgentSettings(agentId); |
7604 |
25 Feb 19 |
nicklas |
if (settings) |
7604 |
25 Feb 19 |
nicklas |
236 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (settings.maxMemory) |
7604 |
25 Feb 19 |
nicklas |
238 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.addHidden(frm, 'maxMemory.'+agentId, settings.maxMemory); |
7604 |
25 Feb 19 |
nicklas |
240 |
} |
7604 |
25 Feb 19 |
nicklas |
Forms.addHidden(frm, 'trusted.'+agentId, settings.trusted); |
7604 |
25 Feb 19 |
nicklas |
Forms.addHidden(frm, 'priorityBoost.'+agentId, settings.priorityBoost); |
7604 |
25 Feb 19 |
nicklas |
243 |
} |
7604 |
25 Feb 19 |
nicklas |
244 |
} |
7604 |
25 Feb 19 |
nicklas |
Forms.addHidden(frm, 'allAgents', agents.join(',')); |
7604 |
25 Feb 19 |
nicklas |
if (window.Annotations) |
7604 |
25 Feb 19 |
nicklas |
247 |
{ |
7604 |
25 Feb 19 |
nicklas |
Annotations.saveModifiedAnnotationsToForm(frm); |
7604 |
25 Feb 19 |
nicklas |
249 |
} |
7604 |
25 Feb 19 |
nicklas |
frm.submit(); |
7604 |
25 Feb 19 |
nicklas |
251 |
} |
7604 |
25 Feb 19 |
nicklas |
252 |
} |
7604 |
25 Feb 19 |
nicklas |
253 |
|
7604 |
25 Feb 19 |
nicklas |
254 |
|
7604 |
25 Feb 19 |
nicklas |
plugins.getAgentSettings = function(agentId) |
7604 |
25 Feb 19 |
nicklas |
256 |
{ |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < plugins.agentSettings.length; i++) |
7604 |
25 Feb 19 |
nicklas |
258 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (plugins.agentSettings[i].agentId == agentId) |
7604 |
25 Feb 19 |
nicklas |
260 |
{ |
7604 |
25 Feb 19 |
nicklas |
return plugins.agentSettings[i]; |
7604 |
25 Feb 19 |
nicklas |
262 |
} |
7604 |
25 Feb 19 |
nicklas |
263 |
} |
7604 |
25 Feb 19 |
nicklas |
return null; |
7604 |
25 Feb 19 |
nicklas |
265 |
} |
7604 |
25 Feb 19 |
nicklas |
266 |
|
7604 |
25 Feb 19 |
nicklas |
plugins.selectAgent = function(agentId) |
7604 |
25 Feb 19 |
nicklas |
268 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['plugin']; |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < frm.agents.length; i++) |
7604 |
25 Feb 19 |
nicklas |
271 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (frm.agents[i].item.id == agentId) |
7604 |
25 Feb 19 |
nicklas |
273 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm.agents.selectedIndex = i; |
7604 |
25 Feb 19 |
nicklas |
plugins.agentsOnClick(); |
7604 |
25 Feb 19 |
nicklas |
return; |
7604 |
25 Feb 19 |
nicklas |
277 |
} |
7604 |
25 Feb 19 |
nicklas |
278 |
} |
7604 |
25 Feb 19 |
nicklas |
279 |
} |
7604 |
25 Feb 19 |
nicklas |
280 |
|
7604 |
25 Feb 19 |
nicklas |
plugins.maxMemoryOnBlur = function() |
7604 |
25 Feb 19 |
nicklas |
282 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['plugin']; |
7604 |
25 Feb 19 |
nicklas |
var agentId = frm.agents[frm.agents.selectedIndex].item.id; |
7604 |
25 Feb 19 |
nicklas |
var settings = plugins.getAgentSettings(agentId); |
7604 |
25 Feb 19 |
nicklas |
if (settings) |
7604 |
25 Feb 19 |
nicklas |
287 |
{ |
7604 |
25 Feb 19 |
nicklas |
settings.maxMemory = frm.agentMaxMemory.value; |
7604 |
25 Feb 19 |
nicklas |
289 |
} |
7604 |
25 Feb 19 |
nicklas |
290 |
} |
7604 |
25 Feb 19 |
nicklas |
291 |
|
7604 |
25 Feb 19 |
nicklas |
plugins.useDefaultMaxMemoryOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
293 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['plugin']; |
7604 |
25 Feb 19 |
nicklas |
var agentId = frm.agents[frm.agents.selectedIndex].item.id; |
7604 |
25 Feb 19 |
nicklas |
var settings = plugins.getAgentSettings(agentId); |
7604 |
25 Feb 19 |
nicklas |
if (settings) |
7604 |
25 Feb 19 |
nicklas |
298 |
{ |
7604 |
25 Feb 19 |
nicklas |
var useDefault = frm.useDefaultMaxMemory.checked; |
7604 |
25 Feb 19 |
nicklas |
300 |
|
7604 |
25 Feb 19 |
nicklas |
settings.maxMemory = useDefault ? null : frm.agentMaxMemory.value; |
7604 |
25 Feb 19 |
nicklas |
frm.agentMaxMemory.disabled = useDefault; |
7604 |
25 Feb 19 |
nicklas |
if (!frm.agentMaxMemory.disabled) frm.agentMaxMemory.focus(); |
7604 |
25 Feb 19 |
nicklas |
304 |
} |
7604 |
25 Feb 19 |
nicklas |
305 |
} |
7604 |
25 Feb 19 |
nicklas |
306 |
|
7604 |
25 Feb 19 |
nicklas |
307 |
|
7604 |
25 Feb 19 |
nicklas |
plugins.trustedOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
309 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['plugin']; |
7604 |
25 Feb 19 |
nicklas |
var agentId = frm.agents[frm.agents.selectedIndex].item.id; |
7604 |
25 Feb 19 |
nicklas |
var settings = plugins.getAgentSettings(agentId); |
7604 |
25 Feb 19 |
nicklas |
313 |
|
7604 |
25 Feb 19 |
nicklas |
if (settings) |
7604 |
25 Feb 19 |
nicklas |
315 |
{ |
7604 |
25 Feb 19 |
nicklas |
var selected = Forms.getCheckedRadio(frm.agentTrusted); |
7604 |
25 Feb 19 |
nicklas |
if (selected != null) |
7604 |
25 Feb 19 |
nicklas |
318 |
{ |
7604 |
25 Feb 19 |
nicklas |
settings.trusted = selected.value; |
7604 |
25 Feb 19 |
nicklas |
320 |
} |
7604 |
25 Feb 19 |
nicklas |
321 |
} |
7604 |
25 Feb 19 |
nicklas |
322 |
} |
7604 |
25 Feb 19 |
nicklas |
323 |
|
7604 |
25 Feb 19 |
nicklas |
324 |
|
7604 |
25 Feb 19 |
nicklas |
plugins.priorityBoostOnBlur = function() |
7604 |
25 Feb 19 |
nicklas |
326 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['plugin']; |
7604 |
25 Feb 19 |
nicklas |
var agentId = frm.agents[frm.agents.selectedIndex].item.id; |
7604 |
25 Feb 19 |
nicklas |
var settings = plugins.getAgentSettings(agentId); |
7604 |
25 Feb 19 |
nicklas |
if (settings) |
7604 |
25 Feb 19 |
nicklas |
331 |
{ |
7604 |
25 Feb 19 |
nicklas |
var priorityBoost = parseInt(frm.agentPriorityBoost.value); |
7604 |
25 Feb 19 |
nicklas |
if (priorityBoost < 0 || priorityBoost > 10) |
7604 |
25 Feb 19 |
nicklas |
334 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.showNotification(frm.agentPriorityBoost, 'The priority boost must be between 0 and 10'); |
7604 |
25 Feb 19 |
nicklas |
return; |
7604 |
25 Feb 19 |
nicklas |
337 |
} |
7604 |
25 Feb 19 |
nicklas |
settings.priorityBoost = priorityBoost; |
7604 |
25 Feb 19 |
nicklas |
339 |
} |
7604 |
25 Feb 19 |
nicklas |
340 |
} |
7604 |
25 Feb 19 |
nicklas |
341 |
|
7604 |
25 Feb 19 |
nicklas |
342 |
|
7604 |
25 Feb 19 |
nicklas |
plugins.agentsOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
344 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['plugin']; |
7604 |
25 Feb 19 |
nicklas |
var settings; |
7604 |
25 Feb 19 |
nicklas |
if (frm.agents.selectedIndex >= 0) |
7604 |
25 Feb 19 |
nicklas |
348 |
{ |
7604 |
25 Feb 19 |
nicklas |
var item = frm.agents[frm.agents.selectedIndex].item; |
7604 |
25 Feb 19 |
nicklas |
var agentId = item ? item.id : null; |
7604 |
25 Feb 19 |
nicklas |
settings = plugins.getAgentSettings(agentId); |
7604 |
25 Feb 19 |
nicklas |
352 |
} |
7604 |
25 Feb 19 |
nicklas |
353 |
|
7604 |
25 Feb 19 |
nicklas |
if (settings) |
7604 |
25 Feb 19 |
nicklas |
355 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.show('agentsettings'); |
7604 |
25 Feb 19 |
nicklas |
357 |
|
7604 |
25 Feb 19 |
nicklas |
// Set max memory |
7604 |
25 Feb 19 |
nicklas |
frm.useDefaultMaxMemory.checked = !settings.maxMemory; |
7604 |
25 Feb 19 |
nicklas |
frm.agentMaxMemory.value = settings.maxMemory || ''; |
7604 |
25 Feb 19 |
nicklas |
frm.agentMaxMemory.disabled = frm.useDefaultMaxMemory.checked; |
7604 |
25 Feb 19 |
nicklas |
362 |
|
7604 |
25 Feb 19 |
nicklas |
var defaultMaxMemory = Doc.element('defaultMaxMemory'); |
7604 |
25 Feb 19 |
nicklas |
defaultMaxMemory.innerHTML = settings.defaultMaxMemory || '<i>not specified</i>'; |
7604 |
25 Feb 19 |
nicklas |
365 |
|
7604 |
25 Feb 19 |
nicklas |
// Set trusted |
7604 |
25 Feb 19 |
nicklas |
Forms.checkRadio(frm.agentTrusted, settings.trusted); |
7604 |
25 Feb 19 |
nicklas |
var defaultTrusted = Doc.element('defaultTrusted'); |
7604 |
25 Feb 19 |
nicklas |
defaultTrusted.innerHTML = Forms.getCheckedRadio(frm.trusted).value == '0' ? 'no' : 'yes'; |
7604 |
25 Feb 19 |
nicklas |
370 |
|
7604 |
25 Feb 19 |
nicklas |
// Set priority boost |
7604 |
25 Feb 19 |
nicklas |
frm.agentPriorityBoost.value = settings.priorityBoost; |
7604 |
25 Feb 19 |
nicklas |
373 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
375 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.hide('agentsettings'); |
7604 |
25 Feb 19 |
nicklas |
377 |
} |
7604 |
25 Feb 19 |
nicklas |
378 |
|
7604 |
25 Feb 19 |
nicklas |
379 |
} |
7604 |
25 Feb 19 |
nicklas |
380 |
|
7604 |
25 Feb 19 |
nicklas |
381 |
|
7604 |
25 Feb 19 |
nicklas |
plugins.hideAgentSettings = function() |
7604 |
25 Feb 19 |
nicklas |
383 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.hide('agentsettings'); |
7604 |
25 Feb 19 |
nicklas |
385 |
} |
7604 |
25 Feb 19 |
nicklas |
386 |
|
7604 |
25 Feb 19 |
nicklas |
plugins.usePermissionsOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
388 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['plugin']; |
7604 |
25 Feb 19 |
nicklas |
var use = Forms.getCheckedRadio(frm.use_permissions).value == '1'; |
7604 |
25 Feb 19 |
nicklas |
frm.itemTypes.disabled = !use; |
7604 |
25 Feb 19 |
nicklas |
frm.grant_create.disabled = !use; |
7604 |
25 Feb 19 |
nicklas |
frm.grant_read.disabled = !use; |
7604 |
25 Feb 19 |
nicklas |
frm.grant_use.disabled = !use; |
7604 |
25 Feb 19 |
nicklas |
frm.grant_restricted_write.disabled = !use; |
7604 |
25 Feb 19 |
nicklas |
frm.grant_write.disabled = !use; |
7604 |
25 Feb 19 |
nicklas |
frm.grant_delete.disabled = !use; |
7604 |
25 Feb 19 |
nicklas |
frm.grant_set_owner.disabled = !use; |
7604 |
25 Feb 19 |
nicklas |
frm.grant_set_permission.disabled = !use; |
7604 |
25 Feb 19 |
nicklas |
frm.deny_create.disabled = !use; |
7604 |
25 Feb 19 |
nicklas |
frm.deny_read.disabled = !use; |
7604 |
25 Feb 19 |
nicklas |
frm.deny_use.disabled = !use; |
7604 |
25 Feb 19 |
nicklas |
frm.deny_restricted_write.disabled = !use; |
7604 |
25 Feb 19 |
nicklas |
frm.deny_write.disabled = !use; |
7604 |
25 Feb 19 |
nicklas |
frm.deny_delete.disabled = !use; |
7604 |
25 Feb 19 |
nicklas |
frm.deny_set_owner.disabled = !use; |
7604 |
25 Feb 19 |
nicklas |
frm.deny_set_permission.disabled = !use; |
7604 |
25 Feb 19 |
nicklas |
408 |
} |
7604 |
25 Feb 19 |
nicklas |
409 |
|
7604 |
25 Feb 19 |
nicklas |
plugins.initPermissionLetters = function() |
7604 |
25 Feb 19 |
nicklas |
411 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['plugin']; |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < frm.itemTypes.length; i++) |
7604 |
25 Feb 19 |
nicklas |
414 |
{ |
7604 |
25 Feb 19 |
nicklas |
plugins.updatePermissionLetters(frm.itemTypes[i]); |
7604 |
25 Feb 19 |
nicklas |
416 |
} |
7604 |
25 Feb 19 |
nicklas |
//usePermissionsOnClick(); |
7604 |
25 Feb 19 |
nicklas |
418 |
} |
7604 |
25 Feb 19 |
nicklas |
419 |
|
7604 |
25 Feb 19 |
nicklas |
// Show current permissions for the selected item |
7604 |
25 Feb 19 |
nicklas |
plugins.itemTypesOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
422 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['plugin']; |
7604 |
25 Feb 19 |
nicklas |
var itemType = frm.itemTypes.value; |
7604 |
25 Feb 19 |
nicklas |
if (itemType) |
7604 |
25 Feb 19 |
nicklas |
426 |
{ |
7604 |
25 Feb 19 |
nicklas |
var granted = parseInt(frm[itemType+'_granted'].value); |
7604 |
25 Feb 19 |
nicklas |
var denied = parseInt(frm[itemType+'_denied'].value); |
7604 |
25 Feb 19 |
nicklas |
var defined = parseInt(frm[itemType+'_defined'].value); |
7604 |
25 Feb 19 |
nicklas |
430 |
|
7604 |
25 Feb 19 |
nicklas |
plugins.updatePermissionCheckBoxes('create', Permission.CREATE, granted, denied, defined); |
7604 |
25 Feb 19 |
nicklas |
plugins.updatePermissionCheckBoxes('read', Permission.READ, granted, denied, defined); |
7604 |
25 Feb 19 |
nicklas |
plugins.updatePermissionCheckBoxes('use', Permission.USE, granted, denied, defined); |
7604 |
25 Feb 19 |
nicklas |
plugins.updatePermissionCheckBoxes('restricted_write', Permission.RESTRICTED_WRITE, granted, denied, defined); |
7604 |
25 Feb 19 |
nicklas |
plugins.updatePermissionCheckBoxes('write', Permission.WRITE, granted, denied, defined); |
7604 |
25 Feb 19 |
nicklas |
plugins.updatePermissionCheckBoxes('delete', Permission.DELETE, granted, denied, defined); |
7604 |
25 Feb 19 |
nicklas |
plugins.updatePermissionCheckBoxes('set_owner', Permission.SET_OWNER, granted, denied, defined); |
7604 |
25 Feb 19 |
nicklas |
plugins.updatePermissionCheckBoxes('set_permission', Permission.SET_PERMISSION, granted, denied, defined); |
7604 |
25 Feb 19 |
nicklas |
439 |
} |
7604 |
25 Feb 19 |
nicklas |
440 |
} |
7604 |
25 Feb 19 |
nicklas |
441 |
|
7604 |
25 Feb 19 |
nicklas |
442 |
/* |
7604 |
25 Feb 19 |
nicklas |
Check/uncheck and enable/disable checkboxes depending on given permissions |
7604 |
25 Feb 19 |
nicklas |
444 |
*/ |
7604 |
25 Feb 19 |
nicklas |
plugins.updatePermissionCheckBoxes = function(nameSuffix, permission, granted, denied, defined) |
7604 |
25 Feb 19 |
nicklas |
446 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['plugin']; |
7604 |
25 Feb 19 |
nicklas |
var isGranted = (permission & granted) > 0; |
7604 |
25 Feb 19 |
nicklas |
var isDenied = (permission & denied) > 0; |
7604 |
25 Feb 19 |
nicklas |
var isDefined = (permission & defined) > 0; |
7604 |
25 Feb 19 |
nicklas |
451 |
|
7604 |
25 Feb 19 |
nicklas |
frm['grant_'+nameSuffix].disabled = !isDefined; |
7604 |
25 Feb 19 |
nicklas |
frm['deny_'+nameSuffix].disabled = !isDefined || isGranted; |
7604 |
25 Feb 19 |
nicklas |
frm['grant_'+nameSuffix].checked = isGranted & isDefined; |
7604 |
25 Feb 19 |
nicklas |
frm['deny_'+nameSuffix].checked = isDenied & isDefined; |
7604 |
25 Feb 19 |
nicklas |
456 |
} |
7604 |
25 Feb 19 |
nicklas |
457 |
|
7604 |
25 Feb 19 |
nicklas |
458 |
|
7604 |
25 Feb 19 |
nicklas |
459 |
/* |
7604 |
25 Feb 19 |
nicklas |
Update the permission code string for the given list entry. |
7604 |
25 Feb 19 |
nicklas |
461 |
*/ |
7604 |
25 Feb 19 |
nicklas |
plugins.updatePermissionLetters = function(listOption) |
7604 |
25 Feb 19 |
nicklas |
463 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['plugin']; |
7604 |
25 Feb 19 |
nicklas |
listOption = Doc.element(listOption); |
7604 |
25 Feb 19 |
nicklas |
var itemType = listOption.value; |
7604 |
25 Feb 19 |
nicklas |
if (itemType) |
7604 |
25 Feb 19 |
nicklas |
468 |
{ |
7604 |
25 Feb 19 |
nicklas |
var granted = parseInt(frm[itemType+'_granted'].value); |
7604 |
25 Feb 19 |
nicklas |
var denied = parseInt(frm[itemType+'_denied'].value); |
7604 |
25 Feb 19 |
nicklas |
var defined = parseInt(frm[itemType+'_defined'].value); |
7604 |
25 Feb 19 |
nicklas |
472 |
|
7604 |
25 Feb 19 |
nicklas |
var s = ''; |
7604 |
25 Feb 19 |
nicklas |
s += plugins.getPermissionLetter('C', Permission.CREATE, granted, denied, defined); |
7604 |
25 Feb 19 |
nicklas |
s += plugins.getPermissionLetter('R', Permission.READ, granted, denied, defined); |
7604 |
25 Feb 19 |
nicklas |
s += plugins.getPermissionLetter('U', Permission.USE, granted, denied, defined); |
7604 |
25 Feb 19 |
nicklas |
s += plugins.getPermissionLetter('A', Permission.RESTRICTED_WRITE, granted, denied, defined); |
7604 |
25 Feb 19 |
nicklas |
s += plugins.getPermissionLetter('W', Permission.WRITE, granted, denied, defined); |
7604 |
25 Feb 19 |
nicklas |
s += plugins.getPermissionLetter('D', Permission.DELETE, granted, denied, defined); |
7604 |
25 Feb 19 |
nicklas |
s += plugins.getPermissionLetter('O', Permission.SET_OWNER, granted, denied, defined); |
7604 |
25 Feb 19 |
nicklas |
s += plugins.getPermissionLetter('P', Permission.SET_PERMISSION, granted, denied, defined); |
7604 |
25 Feb 19 |
nicklas |
482 |
|
7604 |
25 Feb 19 |
nicklas |
var text = listOption.text.replace(/\[.*\]/, '['+s+']'); |
7604 |
25 Feb 19 |
nicklas |
listOption.text = text; |
7604 |
25 Feb 19 |
nicklas |
485 |
} |
7604 |
25 Feb 19 |
nicklas |
486 |
} |
7604 |
25 Feb 19 |
nicklas |
487 |
|
7604 |
25 Feb 19 |
nicklas |
plugins.getPermissionLetter = function(permissionLetter, permission, granted, denied, defined) |
7604 |
25 Feb 19 |
nicklas |
489 |
{ |
7604 |
25 Feb 19 |
nicklas |
var letter = ''; |
7604 |
25 Feb 19 |
nicklas |
if ((defined & permission) > 0) |
7604 |
25 Feb 19 |
nicklas |
492 |
{ |
7604 |
25 Feb 19 |
nicklas |
if ((granted & permission) > 0) |
7604 |
25 Feb 19 |
nicklas |
494 |
{ |
7604 |
25 Feb 19 |
nicklas |
letter = permissionLetter.toUpperCase(); |
7604 |
25 Feb 19 |
nicklas |
496 |
} |
7604 |
25 Feb 19 |
nicklas |
else if ((denied & permission) > 0) |
7604 |
25 Feb 19 |
nicklas |
498 |
{ |
7604 |
25 Feb 19 |
nicklas |
letter = '-'; |
7604 |
25 Feb 19 |
nicklas |
500 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
502 |
{ |
7604 |
25 Feb 19 |
nicklas |
letter = permissionLetter.toLowerCase(); |
7604 |
25 Feb 19 |
nicklas |
504 |
} |
7604 |
25 Feb 19 |
nicklas |
505 |
} |
7604 |
25 Feb 19 |
nicklas |
return letter; |
7604 |
25 Feb 19 |
nicklas |
507 |
} |
7604 |
25 Feb 19 |
nicklas |
508 |
|
7604 |
25 Feb 19 |
nicklas |
// When a user clicks on one of the permission checkboxes |
7604 |
25 Feb 19 |
nicklas |
plugins.permissionOnClick = function(event) |
7604 |
25 Feb 19 |
nicklas |
511 |
{ |
7604 |
25 Feb 19 |
nicklas |
var checkbox = event.currentTarget; |
7604 |
25 Feb 19 |
nicklas |
513 |
|
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['plugin']; |
7604 |
25 Feb 19 |
nicklas |
// Make sure implied permissions are consistent |
7604 |
25 Feb 19 |
nicklas |
plugins.ensureImpliedPermissions(checkbox.checked); |
7604 |
25 Feb 19 |
nicklas |
// Calculate granted and denied permission values |
7604 |
25 Feb 19 |
nicklas |
var granted = plugins.getCheckedPermissions('grant_'); |
7604 |
25 Feb 19 |
nicklas |
var denied = plugins.getCheckedPermissions('deny_'); |
7604 |
25 Feb 19 |
nicklas |
// Apply to the selected items and update their text |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < frm.itemTypes.length; i++) |
7604 |
25 Feb 19 |
nicklas |
522 |
{ |
7604 |
25 Feb 19 |
nicklas |
var item = frm.itemTypes[i]; |
7604 |
25 Feb 19 |
nicklas |
var itemType = item.value; |
7604 |
25 Feb 19 |
nicklas |
if (item.selected && itemType) |
7604 |
25 Feb 19 |
nicklas |
526 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm[itemType+'_granted'].value = granted; |
7604 |
25 Feb 19 |
nicklas |
frm[itemType+'_denied'].value = denied; |
7604 |
25 Feb 19 |
nicklas |
plugins.updatePermissionLetters(item); |
7604 |
25 Feb 19 |
nicklas |
530 |
} |
7604 |
25 Feb 19 |
nicklas |
531 |
} |
7604 |
25 Feb 19 |
nicklas |
532 |
} |
7604 |
25 Feb 19 |
nicklas |
533 |
|
7604 |
25 Feb 19 |
nicklas |
534 |
/* |
7604 |
25 Feb 19 |
nicklas |
Get the permission for the checked checkboxes |
7604 |
25 Feb 19 |
nicklas |
prefix should be "grant_" or "deny_" |
7604 |
25 Feb 19 |
nicklas |
537 |
*/ |
7604 |
25 Feb 19 |
nicklas |
plugins.getCheckedPermissions = function(prefix) |
7604 |
25 Feb 19 |
nicklas |
539 |
{ |
7604 |
25 Feb 19 |
nicklas |
var permissionCode = 0; |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['plugin']; |
7604 |
25 Feb 19 |
nicklas |
permissionCode += frm[prefix+'create'].checked ? Permission.CREATE : 0; |
7604 |
25 Feb 19 |
nicklas |
permissionCode += frm[prefix+'read'].checked ? Permission.READ : 0; |
7604 |
25 Feb 19 |
nicklas |
permissionCode += frm[prefix+'use'].checked ? Permission.USE : 0; |
7604 |
25 Feb 19 |
nicklas |
permissionCode += frm[prefix+'restricted_write'].checked ? Permission.RESTRICTED_WRITE : 0; |
7604 |
25 Feb 19 |
nicklas |
permissionCode += frm[prefix+'write'].checked ? Permission.WRITE : 0; |
7604 |
25 Feb 19 |
nicklas |
permissionCode += frm[prefix+'delete'].checked ? Permission.DELETE : 0; |
7604 |
25 Feb 19 |
nicklas |
permissionCode += frm[prefix+'set_owner'].checked ? Permission.SET_OWNER : 0; |
7604 |
25 Feb 19 |
nicklas |
permissionCode += frm[prefix+'set_permission'].checked ? Permission.SET_PERMISSION : 0; |
7604 |
25 Feb 19 |
nicklas |
return permissionCode; |
7604 |
25 Feb 19 |
nicklas |
551 |
} |
7604 |
25 Feb 19 |
nicklas |
552 |
|
7604 |
25 Feb 19 |
nicklas |
553 |
|
7604 |
25 Feb 19 |
nicklas |
554 |
/* |
7604 |
25 Feb 19 |
nicklas |
Makes sure all checkboxes are in a consistent state with each other. |
7604 |
25 Feb 19 |
nicklas |
556 |
*/ |
7604 |
25 Feb 19 |
nicklas |
plugins.ensureImpliedPermissions = function(checked) |
7604 |
25 Feb 19 |
nicklas |
558 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['plugin']; |
7604 |
25 Feb 19 |
nicklas |
560 |
|
7604 |
25 Feb 19 |
nicklas |
// Grant permissions |
7604 |
25 Feb 19 |
nicklas |
if (checked) |
7604 |
25 Feb 19 |
nicklas |
563 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm['grant_write'].checked = (frm['grant_write'].checked || frm['grant_delete'].checked || frm['grant_set_owner'].checked || frm['grant_set_permission'].checked); |
7604 |
25 Feb 19 |
nicklas |
frm['grant_restricted_write'].checked = (frm['grant_restricted_write'].checked || frm['grant_write'].checked); |
7604 |
25 Feb 19 |
nicklas |
frm['grant_use'].checked = (frm['grant_use'].checked || frm['grant_write'].checked); |
7604 |
25 Feb 19 |
nicklas |
frm['grant_read'].checked = (frm['grant_read'].checked || frm['grant_use'].checked || frm['grant_restricted_write'].checked); |
7604 |
25 Feb 19 |
nicklas |
568 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
570 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm['grant_use'].checked = (frm['grant_use'].checked && frm['grant_read'].checked); |
7604 |
25 Feb 19 |
nicklas |
frm['grant_restricted_write'].checked = (frm['grant_restricted_write'].checked && frm['grant_read'].checked); |
7604 |
25 Feb 19 |
nicklas |
frm['grant_write'].checked = (frm['grant_write'].checked && frm['grant_use'].checked && frm['grant_restricted_write'].checked); |
7604 |
25 Feb 19 |
nicklas |
frm['grant_delete'].checked = (frm['grant_delete'].checked && frm['grant_write'].checked); |
7604 |
25 Feb 19 |
nicklas |
frm['grant_set_owner'].checked = (frm['grant_set_owner'].checked && frm['grant_write'].checked); |
7604 |
25 Feb 19 |
nicklas |
frm['grant_set_permission'].checked = (frm['grant_set_permission'].checked && frm['grant_write'].checked); |
7604 |
25 Feb 19 |
nicklas |
577 |
} |
7604 |
25 Feb 19 |
nicklas |
578 |
|
7604 |
25 Feb 19 |
nicklas |
// Deny permissions |
7604 |
25 Feb 19 |
nicklas |
frm['deny_create'].disabled = frm['grant_create'].disabled || frm['grant_create'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm['deny_read'].disabled =frm['grant_read'].disabled || frm['grant_read'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm['deny_use'].disabled = frm['grant_use'].disabled || frm['grant_use'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm['deny_restricted_write'].disabled = frm['grant_restricted_write'].disabled || frm['grant_restricted_write'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm['deny_write'].disabled = frm['grant_write'].disabled || frm['grant_write'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm['deny_delete'].disabled = frm['grant_delete'].disabled || frm['grant_delete'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm['deny_set_owner'].disabled = frm['grant_set_owner'].disabled || frm['grant_set_owner'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm['deny_set_permission'].disabled = frm['grant_set_permission'].disabled || frm['grant_set_permission'].checked; |
7604 |
25 Feb 19 |
nicklas |
if (checked) |
7604 |
25 Feb 19 |
nicklas |
589 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (!frm['deny_use'].disabled) frm['deny_use'].checked = frm['deny_use'].checked || frm['deny_read'].checked; |
7604 |
25 Feb 19 |
nicklas |
if (!frm['deny_restricted_write'].disabled) frm['deny_restricted_write'].checked = frm['deny_restricted_write'].checked || frm['deny_read'].checked; |
7604 |
25 Feb 19 |
nicklas |
if (!frm['deny_write'].disabled) frm['deny_write'].checked = frm['deny_write'].checked || frm['deny_use'].checked || frm['deny_restricted_write'].checked; |
7604 |
25 Feb 19 |
nicklas |
if (!frm['deny_delete'].disabled) frm['deny_delete'].checked = frm['deny_delete'].checked || frm['deny_write'].checked; |
7604 |
25 Feb 19 |
nicklas |
if (!frm['deny_set_owner'].disabled) frm['deny_set_owner'].checked = frm['deny_set_owner'].checked || frm['deny_write'].checked; |
7604 |
25 Feb 19 |
nicklas |
if (!frm['deny_set_permission'].disabled) frm['deny_set_permission'].checked = frm['deny_set_permission'].checked || frm['deny_write'].checked; |
7604 |
25 Feb 19 |
nicklas |
596 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
598 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (!frm['deny_write'].disabled) frm['deny_write'].checked = frm['deny_write'].checked && !((!frm['deny_delete'].checked && !frm['deny_delete'].disabled) || (!frm['deny_set_owner'].checked && !frm['deny_set_owner'].disabled) || (!frm['deny_set_permission'].checked && !frm['deny_set_permission'].disabled)); |
7604 |
25 Feb 19 |
nicklas |
if (!frm['deny_restricted_write'].disabled) frm['deny_restricted_write'].checked = frm['deny_restricted_write'].checked && frm['deny_write'].checked; |
7604 |
25 Feb 19 |
nicklas |
if (!frm['deny_use'].disabled) frm['deny_use'].checked = frm['deny_use'].checked && frm['deny_write'].checked; |
7604 |
25 Feb 19 |
nicklas |
if (!frm['deny_read'].disabled) frm['deny_read'].checked = frm['deny_read'].checked && frm['deny_use'].checked && frm['deny_restricted_write'].checked; |
7604 |
25 Feb 19 |
nicklas |
603 |
} |
7604 |
25 Feb 19 |
nicklas |
604 |
} |
7604 |
25 Feb 19 |
nicklas |
605 |
|
7604 |
25 Feb 19 |
nicklas |
plugins.setRequestedPermissions = function() |
7604 |
25 Feb 19 |
nicklas |
607 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['plugin']; |
7604 |
25 Feb 19 |
nicklas |
// Reset all existing permissions |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < frm.itemTypes.length; i++) |
7604 |
25 Feb 19 |
nicklas |
611 |
{ |
7604 |
25 Feb 19 |
nicklas |
var itemType = frm.itemTypes[i].value; |
7604 |
25 Feb 19 |
nicklas |
if (itemType) |
7604 |
25 Feb 19 |
nicklas |
614 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm[itemType+'_granted'].value = 0; |
7604 |
25 Feb 19 |
nicklas |
frm[itemType+'_denied'].value = 255; |
7604 |
25 Feb 19 |
nicklas |
617 |
} |
7604 |
25 Feb 19 |
nicklas |
618 |
} |
7604 |
25 Feb 19 |
nicklas |
619 |
|
7604 |
25 Feb 19 |
nicklas |
// Set requested permissions |
7604 |
25 Feb 19 |
nicklas |
var requested = Data.json('page-data', 'requested-permissions'); |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < requested.length; i++) |
7604 |
25 Feb 19 |
nicklas |
623 |
{ |
7604 |
25 Feb 19 |
nicklas |
var rp = requested[i]; |
7604 |
25 Feb 19 |
nicklas |
var itemType = rp.itemType; |
7604 |
25 Feb 19 |
nicklas |
frm[itemType+'_granted'].value = rp.granted; |
7604 |
25 Feb 19 |
nicklas |
frm[itemType+'_denied'].value = rp.denied; |
7604 |
25 Feb 19 |
nicklas |
628 |
} |
7604 |
25 Feb 19 |
nicklas |
629 |
|
7604 |
25 Feb 19 |
nicklas |
// Update the list |
7604 |
25 Feb 19 |
nicklas |
plugins.initPermissionLetters(); |
7604 |
25 Feb 19 |
nicklas |
632 |
} |
7604 |
25 Feb 19 |
nicklas |
633 |
|
7604 |
25 Feb 19 |
nicklas |
return plugins; |
7604 |
25 Feb 19 |
nicklas |
635 |
}(); |
7604 |
25 Feb 19 |
nicklas |
636 |
|
7604 |
25 Feb 19 |
nicklas |
Doc.addElementInitializer(Plugins.initElements); |
7604 |
25 Feb 19 |
nicklas |
Doc.onLoad(Plugins.initPage); |