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 Share = function() |
7604 |
25 Feb 19 |
nicklas |
27 |
{ |
7604 |
25 Feb 19 |
nicklas |
var EVERYONE_ID; |
7604 |
25 Feb 19 |
nicklas |
var SHARE_TO_EVERYONE; |
7604 |
25 Feb 19 |
nicklas |
var USE_RESTRICTED_WRITE; |
7604 |
25 Feb 19 |
nicklas |
var Permission = {}; |
7604 |
25 Feb 19 |
nicklas |
32 |
|
7604 |
25 Feb 19 |
nicklas |
var share = {}; |
7604 |
25 Feb 19 |
nicklas |
34 |
|
7604 |
25 Feb 19 |
nicklas |
share.initPage = function() |
7604 |
25 Feb 19 |
nicklas |
36 |
{ |
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 |
44 |
|
7604 |
25 Feb 19 |
nicklas |
// Dialog buttons |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnSave', share.save); |
7604 |
25 Feb 19 |
nicklas |
48 |
|
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnAddUsers', share.addUsers); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('btnAddUsers', 'base-selected', share.addUserCallback); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnAddGroups', share.addGroups); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('btnAddGroups', 'base-selected', share.addGroupCallback); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnAddProjects', share.addProjects); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('btnAddProjects', 'base-selected', share.addProjectCallback); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnAddPermissionTemplates', share.addPermissionTemplates); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('btnAddPermissionTemplates', 'base-selected', share.addPermissionTemplateCallback); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('members', 'base-removed', share.itemRemoved); |
7604 |
25 Feb 19 |
nicklas |
58 |
|
7604 |
25 Feb 19 |
nicklas |
// Permission checkboxes |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('read', 'click', share.permissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('use', 'click', share.permissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('restricted_write', 'click', share.permissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('write', 'click', share.permissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('delete', 'click', share.permissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('setOwner', 'click', share.permissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('setPermission', 'click', share.permissionsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('members', 'change', share.membersOnChange); |
7604 |
25 Feb 19 |
nicklas |
68 |
|
7604 |
25 Feb 19 |
nicklas |
EVERYONE_ID = Data.int('page-data', 'everyone-id'); |
7604 |
25 Feb 19 |
nicklas |
SHARE_TO_EVERYONE = Data.int('page-data', 'share-to-everyone'); |
7604 |
25 Feb 19 |
nicklas |
USE_RESTRICTED_WRITE = Data.int('page-data', 'use-restricted-write'); |
7604 |
25 Feb 19 |
nicklas |
72 |
} |
7604 |
25 Feb 19 |
nicklas |
73 |
|
7604 |
25 Feb 19 |
nicklas |
74 |
/** |
7604 |
25 Feb 19 |
nicklas |
Event handler that update the permission checkboxes depending |
7604 |
25 Feb 19 |
nicklas |
on the currently selected item in the list. |
7604 |
25 Feb 19 |
nicklas |
77 |
*/ |
7604 |
25 Feb 19 |
nicklas |
share.membersOnChange = function() |
7604 |
25 Feb 19 |
nicklas |
79 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['share']; |
7604 |
25 Feb 19 |
nicklas |
var item = frm.members[frm.members.selectedIndex].item; |
7604 |
25 Feb 19 |
nicklas |
if (item && item.id) |
7604 |
25 Feb 19 |
nicklas |
83 |
{ |
7604 |
25 Feb 19 |
nicklas |
var isTemplate = item.type == 'PERMISSIONTEMPLATE'; |
7604 |
25 Feb 19 |
nicklas |
var isEveryone = item.id == EVERYONE_ID && item.type == 'GROUP'; |
7604 |
25 Feb 19 |
nicklas |
share.checkPermissions(item.value, isEveryone, isTemplate); |
7604 |
25 Feb 19 |
nicklas |
87 |
} |
7604 |
25 Feb 19 |
nicklas |
88 |
} |
7604 |
25 Feb 19 |
nicklas |
89 |
|
7604 |
25 Feb 19 |
nicklas |
90 |
/** |
7604 |
25 Feb 19 |
nicklas |
Event handler for the permission checkboxes that modify the permissions |
7604 |
25 Feb 19 |
nicklas |
on all selected users/groups/projects in the list |
7604 |
25 Feb 19 |
nicklas |
93 |
*/ |
7604 |
25 Feb 19 |
nicklas |
share.permissionsOnClick = function(event) |
7604 |
25 Feb 19 |
nicklas |
95 |
{ |
7604 |
25 Feb 19 |
nicklas |
var target = event.currentTarget; |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['share']; |
7604 |
25 Feb 19 |
nicklas |
98 |
|
7604 |
25 Feb 19 |
nicklas |
share.correctPermissions(target.checked); |
7604 |
25 Feb 19 |
nicklas |
var permissionCode = share.getPermissionCode(); |
7604 |
25 Feb 19 |
nicklas |
var permissionText = share.getPermissionText(permissionCode) |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < frm.members.length; i++) |
7604 |
25 Feb 19 |
nicklas |
103 |
{ |
7604 |
25 Feb 19 |
nicklas |
var option = frm.members[i]; |
7604 |
25 Feb 19 |
nicklas |
if (option.selected && option.item && option.item.id) |
7604 |
25 Feb 19 |
nicklas |
106 |
{ |
7604 |
25 Feb 19 |
nicklas |
var item = option.item; |
7604 |
25 Feb 19 |
nicklas |
var disabled = item.type == 'PERMISSIONTEMPLATE' || (item.id == EVERYONE_ID && item.type == 'GROUP' && !SHARE_TO_EVERYONE); |
7604 |
25 Feb 19 |
nicklas |
if (!disabled) |
7604 |
25 Feb 19 |
nicklas |
110 |
{ |
7604 |
25 Feb 19 |
nicklas |
option.item.value = permissionCode; |
7604 |
25 Feb 19 |
nicklas |
var text = option.text.replace(/\[.*\]/, '['+permissionText+']'); |
7604 |
25 Feb 19 |
nicklas |
option.text = text; |
7604 |
25 Feb 19 |
nicklas |
114 |
} |
7604 |
25 Feb 19 |
nicklas |
115 |
} |
7604 |
25 Feb 19 |
nicklas |
116 |
} |
7604 |
25 Feb 19 |
nicklas |
117 |
} |
7604 |
25 Feb 19 |
nicklas |
118 |
|
7604 |
25 Feb 19 |
nicklas |
119 |
/** |
7604 |
25 Feb 19 |
nicklas |
Collected the modified permissions and submit the form. |
7604 |
25 Feb 19 |
nicklas |
121 |
*/ |
7604 |
25 Feb 19 |
nicklas |
share.save = function() |
7604 |
25 Feb 19 |
nicklas |
123 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['share']; |
7604 |
25 Feb 19 |
nicklas |
Link.exportActions('members', '!'); |
7604 |
25 Feb 19 |
nicklas |
frm.submit(); |
7604 |
25 Feb 19 |
nicklas |
127 |
} |
7604 |
25 Feb 19 |
nicklas |
128 |
|
7604 |
25 Feb 19 |
nicklas |
129 |
/** |
7604 |
25 Feb 19 |
nicklas |
Open a popup dialog for selecting users. |
7604 |
25 Feb 19 |
nicklas |
131 |
*/ |
7604 |
25 Feb 19 |
nicklas |
share.addUsers = function(event) |
7604 |
25 Feb 19 |
nicklas |
133 |
{ |
7604 |
25 Feb 19 |
nicklas |
var users = Link.getIdsInList('members', 'USER'); |
7604 |
25 Feb 19 |
nicklas |
var url = '&exclude='+users.join(','); |
7604 |
25 Feb 19 |
nicklas |
url += '&permission=READ'; |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('USER', event.currentTarget.id, 1, url); |
7604 |
25 Feb 19 |
nicklas |
138 |
} |
7604 |
25 Feb 19 |
nicklas |
139 |
|
7604 |
25 Feb 19 |
nicklas |
140 |
/** |
7604 |
25 Feb 19 |
nicklas |
Callback that add more users to the list. |
7604 |
25 Feb 19 |
nicklas |
142 |
*/ |
7604 |
25 Feb 19 |
nicklas |
share.addUserCallback = function(event) |
7604 |
25 Feb 19 |
nicklas |
144 |
{ |
7604 |
25 Feb 19 |
nicklas |
var permissionCode = share.getPermissionCode(); |
7604 |
25 Feb 19 |
nicklas |
var permissionString = share.getPermissionText(permissionCode); |
7604 |
25 Feb 19 |
nicklas |
147 |
|
7604 |
25 Feb 19 |
nicklas |
event.detail.name += ' ['+permissionString+']'; |
7604 |
25 Feb 19 |
nicklas |
event.detail.value = permissionCode; |
7604 |
25 Feb 19 |
nicklas |
event.detail.originalValue = 0; |
7604 |
25 Feb 19 |
nicklas |
151 |
|
7604 |
25 Feb 19 |
nicklas |
Link.addItem('members', 'USER', event.detail); |
7604 |
25 Feb 19 |
nicklas |
if (event.detail.remaining == 0) |
7604 |
25 Feb 19 |
nicklas |
154 |
{ |
7604 |
25 Feb 19 |
nicklas |
share.membersOnChange(); |
7604 |
25 Feb 19 |
nicklas |
156 |
} |
7604 |
25 Feb 19 |
nicklas |
157 |
} |
7604 |
25 Feb 19 |
nicklas |
158 |
|
7604 |
25 Feb 19 |
nicklas |
159 |
/** |
7604 |
25 Feb 19 |
nicklas |
Open a popup dialog for selecting groups. |
7604 |
25 Feb 19 |
nicklas |
161 |
*/ |
7604 |
25 Feb 19 |
nicklas |
share.addGroups = function(event) |
7604 |
25 Feb 19 |
nicklas |
163 |
{ |
7604 |
25 Feb 19 |
nicklas |
var groups = Link.getIdsInList('members', 'GROUP'); |
7604 |
25 Feb 19 |
nicklas |
if (!SHARE_TO_EVERYONE) |
7604 |
25 Feb 19 |
nicklas |
166 |
{ |
7604 |
25 Feb 19 |
nicklas |
groups[groups.length] = EVERYONE_ID; |
7604 |
25 Feb 19 |
nicklas |
168 |
} |
7604 |
25 Feb 19 |
nicklas |
var url = '&exclude='+groups.join(','); |
7604 |
25 Feb 19 |
nicklas |
url += '&permission=READ'; |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('GROUP', event.currentTarget.id, 1, url); |
7604 |
25 Feb 19 |
nicklas |
172 |
} |
7604 |
25 Feb 19 |
nicklas |
173 |
|
7604 |
25 Feb 19 |
nicklas |
174 |
/** |
7604 |
25 Feb 19 |
nicklas |
Callback that add more groups to the list. |
7604 |
25 Feb 19 |
nicklas |
176 |
*/ |
7604 |
25 Feb 19 |
nicklas |
share.addGroupCallback = function(event) |
7604 |
25 Feb 19 |
nicklas |
178 |
{ |
7604 |
25 Feb 19 |
nicklas |
var permissionCode = share.getPermissionCode(); |
7604 |
25 Feb 19 |
nicklas |
var permissionString = share.getPermissionText(permissionCode); |
7604 |
25 Feb 19 |
nicklas |
181 |
|
7604 |
25 Feb 19 |
nicklas |
event.detail.name += ' ['+permissionString+']'; |
7604 |
25 Feb 19 |
nicklas |
event.detail.value = permissionCode; |
7604 |
25 Feb 19 |
nicklas |
event.detail.originalValue = 0; |
7604 |
25 Feb 19 |
nicklas |
185 |
|
7604 |
25 Feb 19 |
nicklas |
Link.addItem('members', 'GROUP', event.detail); |
7604 |
25 Feb 19 |
nicklas |
if (event.detail.remaining == 0) |
7604 |
25 Feb 19 |
nicklas |
188 |
{ |
7604 |
25 Feb 19 |
nicklas |
share.membersOnChange(); |
7604 |
25 Feb 19 |
nicklas |
190 |
} |
7604 |
25 Feb 19 |
nicklas |
191 |
} |
7604 |
25 Feb 19 |
nicklas |
192 |
|
7604 |
25 Feb 19 |
nicklas |
193 |
/** |
7604 |
25 Feb 19 |
nicklas |
Open a popup dialog for selecting projects. |
7604 |
25 Feb 19 |
nicklas |
195 |
*/ |
7604 |
25 Feb 19 |
nicklas |
share.addProjects = function(event) |
7604 |
25 Feb 19 |
nicklas |
197 |
{ |
7604 |
25 Feb 19 |
nicklas |
var projects = Link.getIdsInList('members', 'PROJECT'); |
7604 |
25 Feb 19 |
nicklas |
var url = '&exclude='+projects.join(','); |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('PROJECT', event.currentTarget.id, 1, url); |
7604 |
25 Feb 19 |
nicklas |
201 |
} |
7604 |
25 Feb 19 |
nicklas |
202 |
|
7604 |
25 Feb 19 |
nicklas |
203 |
/** |
7604 |
25 Feb 19 |
nicklas |
Callback that add more projects to the list. |
7604 |
25 Feb 19 |
nicklas |
205 |
*/ |
7604 |
25 Feb 19 |
nicklas |
share.addProjectCallback = function(event) |
7604 |
25 Feb 19 |
nicklas |
207 |
{ |
7604 |
25 Feb 19 |
nicklas |
var permissionCode = share.getPermissionCode(); |
7604 |
25 Feb 19 |
nicklas |
var permissionString = share.getPermissionText(permissionCode); |
7604 |
25 Feb 19 |
nicklas |
210 |
|
7604 |
25 Feb 19 |
nicklas |
event.detail.name += ' ['+permissionString+']'; |
7604 |
25 Feb 19 |
nicklas |
event.detail.value = permissionCode; |
7604 |
25 Feb 19 |
nicklas |
event.detail.originalValue = 0; |
7604 |
25 Feb 19 |
nicklas |
214 |
|
7604 |
25 Feb 19 |
nicklas |
Link.addItem('members', 'PROJECT', event.detail); |
7604 |
25 Feb 19 |
nicklas |
if (event.detail.remaining == 0) |
7604 |
25 Feb 19 |
nicklas |
217 |
{ |
7604 |
25 Feb 19 |
nicklas |
share.membersOnChange(); |
7604 |
25 Feb 19 |
nicklas |
219 |
} |
7604 |
25 Feb 19 |
nicklas |
220 |
} |
7604 |
25 Feb 19 |
nicklas |
221 |
|
7604 |
25 Feb 19 |
nicklas |
222 |
/** |
7604 |
25 Feb 19 |
nicklas |
Open a popup dialog for selecting permission templates. |
7604 |
25 Feb 19 |
nicklas |
224 |
*/ |
7604 |
25 Feb 19 |
nicklas |
share.addPermissionTemplates = function(event) |
7604 |
25 Feb 19 |
nicklas |
226 |
{ |
7604 |
25 Feb 19 |
nicklas |
var templates = Link.getIdsInList('members', 'PERMISSIONTEMPLATE'); |
7604 |
25 Feb 19 |
nicklas |
var url = '&exclude='+templates.join(','); |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('PERMISSIONTEMPLATE', event.currentTarget.id, 1, url); |
7604 |
25 Feb 19 |
nicklas |
230 |
} |
7604 |
25 Feb 19 |
nicklas |
231 |
|
7604 |
25 Feb 19 |
nicklas |
232 |
/** |
7604 |
25 Feb 19 |
nicklas |
Callback that add more permission templates to the list. |
7604 |
25 Feb 19 |
nicklas |
234 |
*/ |
7604 |
25 Feb 19 |
nicklas |
share.addPermissionTemplateCallback = function(event) |
7604 |
25 Feb 19 |
nicklas |
236 |
{ |
7604 |
25 Feb 19 |
nicklas |
Link.addItem('members', 'PERMISSIONTEMPLATE', event.detail); |
7604 |
25 Feb 19 |
nicklas |
if (event.detail.remaining == 0) |
7604 |
25 Feb 19 |
nicklas |
239 |
{ |
7604 |
25 Feb 19 |
nicklas |
share.membersOnChange(); |
7604 |
25 Feb 19 |
nicklas |
241 |
} |
7604 |
25 Feb 19 |
nicklas |
242 |
} |
7604 |
25 Feb 19 |
nicklas |
243 |
|
7604 |
25 Feb 19 |
nicklas |
244 |
/** |
7604 |
25 Feb 19 |
nicklas |
Set the permission value to 0 when an item is removed |
7604 |
25 Feb 19 |
nicklas |
246 |
*/ |
7604 |
25 Feb 19 |
nicklas |
share.itemRemoved = function(event) |
7604 |
25 Feb 19 |
nicklas |
248 |
{ |
7604 |
25 Feb 19 |
nicklas |
event.detail.item.value = 0; |
7604 |
25 Feb 19 |
nicklas |
250 |
} |
7604 |
25 Feb 19 |
nicklas |
251 |
|
7604 |
25 Feb 19 |
nicklas |
252 |
/** |
7604 |
25 Feb 19 |
nicklas |
Get a textual description of the permissions that are included in |
7604 |
25 Feb 19 |
nicklas |
the given permission code. |
7604 |
25 Feb 19 |
nicklas |
255 |
*/ |
7604 |
25 Feb 19 |
nicklas |
share.getPermissionText = function(permissionCode) |
7604 |
25 Feb 19 |
nicklas |
257 |
{ |
7604 |
25 Feb 19 |
nicklas |
var s = ''; |
7604 |
25 Feb 19 |
nicklas |
if (permissionCode > 0) |
7604 |
25 Feb 19 |
nicklas |
260 |
{ |
7604 |
25 Feb 19 |
nicklas |
s += permissionCode & Permission.READ ? "R" : "-"; |
7604 |
25 Feb 19 |
nicklas |
s += permissionCode & Permission.USE ? "U" : "-"; |
7604 |
25 Feb 19 |
nicklas |
if (USE_RESTRICTED_WRITE) |
7604 |
25 Feb 19 |
nicklas |
264 |
{ |
7604 |
25 Feb 19 |
nicklas |
s += permissionCode & Permission.RESTRICTED_WRITE ? "A" : "-"; |
7604 |
25 Feb 19 |
nicklas |
266 |
} |
7604 |
25 Feb 19 |
nicklas |
s += permissionCode & Permission.WRITE ? "W" : "-"; |
7604 |
25 Feb 19 |
nicklas |
s += permissionCode & Permission.DELETE ? "D" : "-"; |
7604 |
25 Feb 19 |
nicklas |
s += permissionCode & Permission.SET_OWNER ? "O" : "-"; |
7604 |
25 Feb 19 |
nicklas |
s += permissionCode & Permission.SET_PERMISSION ? "P" : "-"; |
7604 |
25 Feb 19 |
nicklas |
271 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
273 |
{ |
7604 |
25 Feb 19 |
nicklas |
s = 'varying'; |
7604 |
25 Feb 19 |
nicklas |
275 |
} |
7604 |
25 Feb 19 |
nicklas |
return s; |
7604 |
25 Feb 19 |
nicklas |
277 |
} |
7604 |
25 Feb 19 |
nicklas |
278 |
|
7604 |
25 Feb 19 |
nicklas |
279 |
/** |
7604 |
25 Feb 19 |
nicklas |
Get the permission code from the checked checkboxes. |
7604 |
25 Feb 19 |
nicklas |
281 |
*/ |
7604 |
25 Feb 19 |
nicklas |
share.getPermissionCode = function() |
7604 |
25 Feb 19 |
nicklas |
283 |
{ |
7604 |
25 Feb 19 |
nicklas |
var c = 0; |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['share']; |
7604 |
25 Feb 19 |
nicklas |
if (frm['read'].checked) c += Permission.READ; |
7604 |
25 Feb 19 |
nicklas |
if (frm['use'].checked) c += Permission.USE; |
7604 |
25 Feb 19 |
nicklas |
if (frm['restricted_write'].checked) c += Permission.RESTRICTED_WRITE; |
7604 |
25 Feb 19 |
nicklas |
if (frm['write'].checked) c += Permission.WRITE; |
7604 |
25 Feb 19 |
nicklas |
if (frm['delete'].checked) c += Permission.DELETE; |
7604 |
25 Feb 19 |
nicklas |
if (frm['set_owner'].checked) c += Permission.SET_OWNER; |
7604 |
25 Feb 19 |
nicklas |
if (frm['set_permission'].checked) c += Permission.SET_PERMISSION; |
7604 |
25 Feb 19 |
nicklas |
return c; |
7604 |
25 Feb 19 |
nicklas |
294 |
} |
7604 |
25 Feb 19 |
nicklas |
295 |
|
7604 |
25 Feb 19 |
nicklas |
296 |
/** |
7604 |
25 Feb 19 |
nicklas |
The permissions are related and we need to check or uncheck permissions |
7604 |
25 Feb 19 |
nicklas |
depending on what was currently changed. |
7604 |
25 Feb 19 |
nicklas |
299 |
*/ |
7604 |
25 Feb 19 |
nicklas |
share.correctPermissions = function(checked) |
7604 |
25 Feb 19 |
nicklas |
301 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['share']; |
7604 |
25 Feb 19 |
nicklas |
if (checked) |
7604 |
25 Feb 19 |
nicklas |
304 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm['write'].checked = frm['write'].checked || frm['delete'].checked || frm['set_owner'].checked || frm['set_permission'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm['restricted_write'].checked = frm['restricted_write'].checked || frm['write'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm['use'].checked = frm['use'].checked || frm['write'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm['read'].checked = frm['read'].checked || frm['use'].checked || frm['restricted_write'].checked; |
7604 |
25 Feb 19 |
nicklas |
309 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
311 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm['use'].checked = frm['use'].checked && frm['read'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm['restricted_write'].checked = frm['restricted_write'].checked && frm['read'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm['write'].checked = frm['write'].checked && frm['use'].checked && frm['restricted_write'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm['delete'].checked = frm['delete'].checked && frm['write'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm['set_owner'].checked = frm['set_owner'].checked && frm['write'].checked; |
7604 |
25 Feb 19 |
nicklas |
frm['set_permission'].checked = frm['set_permission'].checked && frm['write'].checked; |
7604 |
25 Feb 19 |
nicklas |
318 |
} |
7604 |
25 Feb 19 |
nicklas |
319 |
} |
7604 |
25 Feb 19 |
nicklas |
320 |
|
7604 |
25 Feb 19 |
nicklas |
321 |
/** |
7604 |
25 Feb 19 |
nicklas |
Update the permission checkboxes so that they reflect the given |
7604 |
25 Feb 19 |
nicklas |
permission code. Permissions from teplates or the EVERYONE group |
7604 |
25 Feb 19 |
nicklas |
may disable the permissions. |
7604 |
25 Feb 19 |
nicklas |
325 |
*/ |
7604 |
25 Feb 19 |
nicklas |
share.checkPermissions = function(permissionCode, isEveryone, isTemplate) |
7604 |
25 Feb 19 |
nicklas |
327 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['share']; |
7604 |
25 Feb 19 |
nicklas |
frm['read'].checked = permissionCode & Permission.READ; |
7604 |
25 Feb 19 |
nicklas |
frm['use'].checked = permissionCode & Permission.USE; |
7604 |
25 Feb 19 |
nicklas |
frm['restricted_write'].checked = permissionCode & Permission.RESTRICTED_WRITE; |
7604 |
25 Feb 19 |
nicklas |
frm['write'].checked = permissionCode & Permission.WRITE; |
7604 |
25 Feb 19 |
nicklas |
frm['delete'].checked = permissionCode & Permission.DELETE; |
7604 |
25 Feb 19 |
nicklas |
frm['set_owner'].checked = permissionCode & Permission.SET_OWNER; |
7604 |
25 Feb 19 |
nicklas |
frm['set_permission'].checked = permissionCode & Permission.SET_PERMISSION; |
7604 |
25 Feb 19 |
nicklas |
336 |
|
7604 |
25 Feb 19 |
nicklas |
var disabled = isTemplate || (isEveryone && !SHARE_TO_EVERYONE); |
7604 |
25 Feb 19 |
nicklas |
frm['read'].disabled = disabled; |
7604 |
25 Feb 19 |
nicklas |
frm['use'].disabled = disabled; |
7604 |
25 Feb 19 |
nicklas |
frm['restricted_write'].disabled = disabled || !USE_RESTRICTED_WRITE; |
7604 |
25 Feb 19 |
nicklas |
frm['write'].disabled = disabled; |
7604 |
25 Feb 19 |
nicklas |
frm['delete'].disabled = disabled; |
7604 |
25 Feb 19 |
nicklas |
frm['set_owner'].disabled = disabled; |
7604 |
25 Feb 19 |
nicklas |
frm['set_permission'].disabled = disabled; |
7604 |
25 Feb 19 |
nicklas |
if (isEveryone && !SHARE_TO_EVERYONE) |
7604 |
25 Feb 19 |
nicklas |
346 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.show('share_disabled'); |
7604 |
25 Feb 19 |
nicklas |
348 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
350 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.hide('share_disabled'); |
7604 |
25 Feb 19 |
nicklas |
352 |
} |
7604 |
25 Feb 19 |
nicklas |
353 |
} |
7604 |
25 Feb 19 |
nicklas |
354 |
|
7604 |
25 Feb 19 |
nicklas |
return share; |
7604 |
25 Feb 19 |
nicklas |
356 |
}(); |
7604 |
25 Feb 19 |
nicklas |
357 |
|
7604 |
25 Feb 19 |
nicklas |
Doc.onLoad(Share.initPage); |
7604 |
25 Feb 19 |
nicklas |
359 |
|
7604 |
25 Feb 19 |
nicklas |
360 |
|