Monotone-Parent: 719e48a98f49b93c9135226ca220043964d2cfdd

Monotone-Revision: f261c808456800f2a75a751af5871d3dc8fdd693

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2006-12-14T20:20:40
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2006-12-14 20:20:40 +00:00
parent 893fae023f
commit 8fab0af88d
5 changed files with 307 additions and 0 deletions
+3
View File
@@ -1,5 +1,8 @@
2006-12-14 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/Common/UIxAclEditor.[hm]: new component that provides a
general editor for folder acls.
* SoObjects/SOGo/NSString+Utilities.[hm]: old "NSString+URL"
renamed.
([NSString -davMethodToObjC]): method that returns the method name
+42
View File
@@ -0,0 +1,42 @@
/* UIxAclEditor.h - this file is part of SOGo
*
* Copyright (C) 2006 Inverse groupe conseil
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef UIXACLEDITOR_H
#define UIXACLEDITOR_H
#import <SOGoUI/UIxComponent.h>
@interface UIxAclEditor : UIxComponent
{
BOOL prepared;
NSArray *acls;
NSMutableArray *users;
NSMutableArray *checkedUsers;
NSString *ownerCN;
}
- (NSArray *) aclsForFolder;
- (NSString *) ownerCN;
@end
#endif /* UIXACLEDITOR_H */
+158
View File
@@ -0,0 +1,158 @@
/* UIxAclEditor.m - this file is part of SOGo
*
* Copyright (C) 2006 Inverse groupe conseil
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#import <Foundation/NSArray.h>
#import <Foundation/NSKeyValueCoding.h>
#import <NGObjWeb/SoUser.h>
#import <NGObjWeb/WORequest.h>
#import <NGCards/iCalPerson.h>
#import <SoObjects/SOGo/AgenorUserManager.h>
#import <SoObjects/SOGo/SOGoAclsFolder.h>
#import <SoObjects/SOGo/SOGoPermissions.h>
#import "UIxAclEditor.h"
@implementation UIxAclEditor
- (id) init
{
if ((self = [super init]))
{
acls = nil;
prepared = NO;
users = [NSMutableArray new];
checkedUsers = [NSMutableArray new];
ownerCN = nil;
}
return self;
}
- (void) dealloc
{
[users release];
[checkedUsers release];
if (ownerCN)
[ownerCN release];
[super dealloc];
}
- (NSArray *) aclsForFolder
{
SOGoAclsFolder *folder;
if (!acls)
{
folder = [SOGoAclsFolder aclsFolder];
acls = [folder aclsForObject: [self clientObject]];
}
return acls;
}
- (NSString *) ownerCN
{
if (!ownerCN)
{
ownerCN = [[self clientObject] ownerInContext: context];
[ownerCN retain];
}
return ownerCN;
}
- (void) _prepareUsers
{
NSEnumerator *aclsEnum;
AgenorUserManager *um;
NSDictionary *currentAcl;
iCalPerson *currentUser;
NSString *currentUID;
aclsEnum = [[self aclsForFolder] objectEnumerator];
um = [AgenorUserManager sharedUserManager];
currentAcl = [aclsEnum nextObject];
while (currentAcl)
{
currentUID = [currentAcl objectForKey: @"uid"];
if (![currentUID isEqualToString: @"freebusy"])
{
currentUser = [um iCalPersonWithUid: currentUID];
if (![[currentUser cn] isEqualToString: [self ownerCN]])
{
if ([[currentAcl objectForKey: @"role"]
isEqualToString: SOGoRole_Delegate])
[checkedUsers addObject: currentUser];
[users addObject: currentUser];
}
}
currentAcl = [aclsEnum nextObject];
prepared = YES;
}
}
- (NSArray *) usersForFolder
{
if (!prepared)
[self _prepareUsers];
return users;
}
- (NSArray *) checkedUsers
{
if (!prepared)
[self _prepareUsers];
return checkedUsers;
}
- (NSString *) toolbar
{
return (([[self ownerCN] isEqualToString: [[context activeUser] login]])
? @"SOGoAclOwner.toolbar" : @"SOGoAclAssistant.toolbar");
}
- (id) saveAclsAction
{
NSString *uids;
WORequest *request;
SOGoAclsFolder *folder;
SOGoObject *clientObject;
folder = [SOGoAclsFolder aclsFolder];
request = [context request];
clientObject = [self clientObject];
uids = [request formValueForKey: @"delegates"];
[folder setRoleForObject: clientObject
forUsers: [uids componentsSeparatedByString: @","]
to: SOGoRole_Delegate];
uids = [request formValueForKey: @"assistants"];
[folder setRoleForObject: clientObject
forUsers: [uids componentsSeparatedByString: @","]
to: SOGoRole_Assistant];
return [self jsCloseWithRefreshMethod: nil];
}
@end
+29
View File
@@ -0,0 +1,29 @@
<?xml version="1.0" standalone="yes"?>
<var:component xmlns="http://www.w3.org/1999/xhtml"
xmlns:var="http://www.skyrix.com/od/binding"
xmlns:const="http://www.skyrix.com/od/constant"
xmlns:uix="OGo:uix"
xmlns:label="OGo:label"
className="UIxPageFrame"
title="title"
var:toolbar="toolbar"
const:popup="YES">
<form id="aclForm" const:href="saveAcls">
<div class="acls">
<input type="hidden" name="action" value="saveAcls" />
<input type="hidden" name="delegates" id="delegates" />
<input type="hidden" name="assistants" id="assistants" />
<label><var:string label:value="Owner:" />
<span class="value"><strong><var:string value="ownerCN" /></strong></span></label><br />
<var:component className="UIxContactSelector"
const:selectorId="userRoles"
const:hasCheckBoxes="YES"
const:checkBoxOnChange="return updateAclStatus(this);"
contacts="usersForFolder"
checkedBoxes="checkedUsers"
/>
<span class="legend"><var:string label:value="(Unchecked = assistant, checked = delegate)" /></span>
</div>
</form>
</var:component>
+75
View File
@@ -0,0 +1,75 @@
/* test */
var contactSelectorAction = 'acls-contacts';
function addContact(tag, fullContactName, contactId, contactName,
contactEmail) {
if (tag == "assistant")
addUser(contactName, contactId, false);
else if (tag == "delegate")
addUser(contactName, contactId, true);
}
function addUser(userName, userId, checked) {
var uidList = $("uixselector-userRoles-uidList");
var uids;
if (uidList.value.length > 0) {
uids = uidList.value.split(",");
} else {
uids = new Array();
}
if (uids.indexOf(userId) < 0) {
uids.push(userId);
var ul = $("uixselector-userRoles-display");
ul.appendChild(nodeForUser(userName, userId, checked));
uidList.value = uids.join(",");
}
log("addUser: " + uidList.value);
}
function nodeForUser(userName, userId, checked) {
var node = document.createElement("li");
node.setAttribute("uid", userId);
node.setAttribute("class", "");
node.addEventListener("mousedown", listRowMouseDownHandler, true);
node.addEventListener("click", onRowClick, true);
var checkbox = document.createElement("input");
checkbox.setAttribute("type", "checkbox");
checkbox.setAttribute("class", "checkBox");
checkbox.checked = checked;
checkbox.addEventListener("change", updateAclStatus, true);
node.appendChild(checkbox);
node.appendChild(document.createTextNode(userName));
return node;
}
function updateAclStatus() {
}
function saveAcls() {
var form = $("aclForm");
var lis = $("uixselector-userRoles-display").childNodesWithTag("li");
var assistants = new Array();
var delegates = new Array();
for (var i = 0; i < lis.length; i++) {
var uName = lis[i].getAttribute("uid");
var cb = lis[i].childNodesWithTag("input")[0];
if (cb.checked)
delegates.push(uName);
else
assistants.push(uName);
}
$("assistants").value = assistants.join(",");
$("delegates").value = delegates.join(",");
form.submit();
return false;
}