merge of '6ce902c8df1995a79c1ab0e0d78013b688e25dbd'

and 'b2d0da06fffc88971705a5c6cf4b5a85fd76e93d'

Monotone-Parent: 6ce902c8df1995a79c1ab0e0d78013b688e25dbd
Monotone-Parent: b2d0da06fffc88971705a5c6cf4b5a85fd76e93d
Monotone-Revision: 6705a0eaf721b2addcf26cc8ef50da0979eb563d

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2007-05-17T23:13:45
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2007-05-17 23:13:45 +00:00
21 changed files with 172 additions and 72 deletions

View File

@@ -1,3 +1,29 @@
2007-05-17 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/Common/UIxObjectActions.m ([UIxObjectActions
-addUserInAclsAction]): save the previous roles of the user
(unlikely) or the default roles, or None instead of saving the
roles that should appear the first time in the role editor when no
default has been set...
* SoObjects/SOGo/SOGoObject.m: defined a new constant
"SOGoDefaultUserID".
* SoObjects/SOGo/SOGoFolder.m ([SOGoFolder
-setRoles:rolesforUser:uidforObjectAtPath:objectPathArray]):
ignore the "AuthorizedSubscriber" role and add the "None" role
when no other role is found.
* UI/Common/UIxAclEditor.m: added a button for the new default
user roles feature.
* UI/Common/UIxUserRightsEditor.m ([UIxUserRightsEditor
-_initRights]): don't take the "None" role into account when
initializing the list of current roles.
* SoObjects/SOGo/SOGoPermissions.m: added a new void role
"SOGoRole_None".
2007-05-16 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/SOGo/NSString+Utilities.m ([NSString

View File

@@ -31,8 +31,6 @@
#import <unistd.h>
#import <stdlib.h>
static NSString *defaultUser = @"<default>";
@implementation SOGoFolder
+ (int) version
@@ -341,8 +339,9 @@ static NSString *defaultUser = @"<default>";
[self _cacheRoles: acls forUser: uid forObjectAtPath: objectPath];
}
if (!([acls count] || [uid isEqualToString: defaultUser]))
acls = [self aclsForUser: defaultUser forObjectAtPath: objectPathArray];
if (!([acls count] || [uid isEqualToString: SOGoDefaultUserID]))
acls = [self aclsForUser: SOGoDefaultUserID
forObjectAtPath: objectPathArray];
return acls;
}
@@ -369,19 +368,14 @@ static NSString *defaultUser = @"<default>";
}
}
- (void) setRoles: (NSArray *) roles
forUser: (NSString *) uid
forObjectAtPath: (NSArray *) objectPathArray
- (void) _commitRoles: (NSArray *) roles
forUID: (NSString *) uid
forObject: (NSString *) objectPath
{
EOAdaptorChannel *channel;
GCSFolder *folder;
NSEnumerator *userRoles;
NSString *SQL, *currentRole, *objectPath;
[self removeAclsForUsers: [NSArray arrayWithObject: uid]
forObjectAtPath: objectPathArray];
objectPath = [objectPathArray componentsJoinedByString: @"/"];
[self _cacheRoles: roles forUser: uid forObjectAtPath: objectPath];
NSString *SQL, *currentRole;
folder = [self ocsFolder];
channel = [folder acquireAclChannel];
@@ -389,21 +383,40 @@ static NSString *defaultUser = @"<default>";
currentRole = [userRoles nextObject];
while (currentRole)
{
if (![currentRole isEqualToString: SOGoRole_AuthorizedSubscriber])
{
SQL = [NSString stringWithFormat: @"INSERT INTO %@"
@" (c_object, c_uid, c_role)"
@" VALUES ('/%@', '%@', '%@')",
[folder aclTableName],
objectPath, uid, currentRole];
[channel evaluateExpressionX: SQL];
}
SQL = [NSString stringWithFormat: @"INSERT INTO %@"
@" (c_object, c_uid, c_role)"
@" VALUES ('/%@', '%@', '%@')",
[folder aclTableName],
objectPath, uid, currentRole];
[channel evaluateExpressionX: SQL];
currentRole = [userRoles nextObject];
}
[folder releaseChannel: channel];
}
- (void) setRoles: (NSArray *) roles
forUser: (NSString *) uid
forObjectAtPath: (NSArray *) objectPathArray
{
NSString *objectPath;
NSMutableArray *newRoles;
[self removeAclsForUsers: [NSArray arrayWithObject: uid]
forObjectAtPath: objectPathArray];
newRoles = [NSMutableArray arrayWithArray: roles];
[newRoles removeObject: SOGoRole_AuthorizedSubscriber];
[newRoles removeObject: SOGoRole_None];
objectPath = [objectPathArray componentsJoinedByString: @"/"];
[self _cacheRoles: newRoles forUser: uid
forObjectAtPath: objectPath];
if (![newRoles count])
[newRoles addObject: SOGoRole_None];
[self _commitRoles: newRoles forUID: uid forObject: objectPath];
}
/* acls */
- (NSArray *) defaultAclRoles
{

View File

@@ -52,6 +52,8 @@
#define $(class) NSClassFromString(class)
extern NSString *SOGoDefaultUserID;
@interface SOGoObject : NSObject
{
WOContext *context;

View File

@@ -20,8 +20,8 @@
*/
#if LIB_FOUNDATION_LIBRARY
#error SOGo won't work properly with libFoundation. Please use gnustep-base \
instead.
#error SOGo will not work properly with libFoundation. \
Please use gnustep-base instead.
#endif
#import <NGObjWeb/WEClientCapabilities.h>
@@ -47,6 +47,8 @@
#import "SOGoObject.h"
NSString *SOGoDefaultUserID = @"<default>";
@interface SOGoObject(Content)
- (NSString *)contentAsString;
@end

View File

@@ -32,6 +32,7 @@ extern NSString *SOGoRole_ObjectEraser;
extern NSString *SOGoRole_ObjectViewer;
extern NSString *SOGoRole_ObjectEditor;
extern NSString *SOGoRole_AuthorizedSubscriber;
extern NSString *SOGoRole_None;
extern NSString *SOGoRole_FreeBusy;
extern NSString *SOGoRole_FreeBusyLookup;

View File

@@ -28,6 +28,7 @@ NSString *SOGoRole_ObjectEraser = @"ObjectEraser";
NSString *SOGoRole_ObjectViewer = @"ObjectViewer";
NSString *SOGoRole_ObjectEditor = @"ObjectEditor";
NSString *SOGoRole_AuthorizedSubscriber = @"AuthorizedSubscriber";
NSString *SOGoRole_None = @"None";
NSString *SOGoRole_FreeBusy = @"FreeBusy"; /* for the "freebusy" special user
*/

View File

@@ -3,6 +3,7 @@
/* toolbars */
"Save" = "Save";
"Close" = "Close";
"Edit User Rights" = "Edit User Rights";
"Home" = "Home";
"Calendar" = "Calendar";
@@ -21,4 +22,6 @@
"Publish the Free/Busy information" = "Publish the Free/Busy information";
"Default Roles" = "Default Roles";
"Sorry, the user rights can not be configured for that object." = "Sorry, the user rights can not be configured for that object.";

View File

@@ -1,8 +1,7 @@
/* this file is in UTF-8 format! */
/* toolbars */
"Save" = "Sauver";
"Close" = "Fermer";
"Edit User Rights" = "Édition des droits";
"Home" = "Accueil";
"Calendar" = "Agenda";
@@ -24,4 +23,6 @@
"(Unchecked = assistant, checked = delegate)" = "(Coché = assistant, décoché = délégué)";
"Publish the Free/Busy information" = "Publier l'occupation du temps";
"Default Roles" = "Rôles par défaut";
"Sorry, the user rights can not be configured for that object." = "Sorry, the user rights can not be configured for that object.";

View File

@@ -84,6 +84,11 @@
return [self _displayNameForUID: ownerLogin];
}
- (NSString *) defaultUserID
{
return SOGoDefaultUserID;
}
- (void) _prepareUsers
{
NSEnumerator *aclsEnum;
@@ -98,6 +103,7 @@
{
currentUID = [currentAcl objectForKey: @"c_uid"];
if (!([currentUID isEqualToString: ownerLogin]
|| [currentUID isEqualToString: SOGoDefaultUserID]
|| [users containsObject: currentUID]))
[users addObject: currentUID];
currentAcl = [aclsEnum nextObject];

View File

@@ -27,6 +27,7 @@
#import <NGObjWeb/WOResponse.h>
#import <SoObjects/SOGo/LDAPUserManager.h>
#import <SoObjects/SOGo/SOGoObject.h>
#import <SoObjects/SOGo/SOGoPermissions.h>
#import "UIxObjectActions.h"
@@ -49,9 +50,9 @@
um = [LDAPUserManager sharedUserManager];
if ([um contactInfosForUserWithUIDorEmail: uid])
{
clientObject = [self clientObject];
[clientObject setRoles: [clientObject defaultAclRoles]
forUser: uid];
clientObject = [self clientObject];
[clientObject setRoles: [clientObject aclsForUser: uid]
forUser: uid];
code = 204;
}
}
@@ -78,7 +79,8 @@
um = [LDAPUserManager sharedUserManager];
if ([um contactInfosForUserWithUIDorEmail: uid])
{
[[self clientObject] removeAclsForUsers: [NSArray arrayWithObject: uid]];
[[self clientObject] removeAclsForUsers:
[NSArray arrayWithObject: uid]];
code = 204;
}
}

View File

@@ -24,6 +24,7 @@
#import <NGObjWeb/WOResponse.h>
#import <NGObjWeb/WORequest.h>
#import <SoObjects/SOGo/LDAPUserManager.h>
#import <SoObjects/SOGo/SOGoPermissions.h>
#import "UIxUserRightsEditor.h"
@@ -52,10 +53,15 @@
return uid;
}
- (BOOL) userIsDefaultUser
{
return [uid isEqualToString: SOGoDefaultUserID];
}
- (NSString *) userDisplayName
{
LDAPUserManager *um;
um = [LDAPUserManager sharedUserManager];
return [NSString stringWithFormat: @"%@ <%@>",
@@ -66,9 +72,10 @@
- (BOOL) _initRights
{
BOOL response;
NSString *newUID, *email;
NSString *newUID;
LDAPUserManager *um;
SOGoObject *clientObject;
unsigned int count;
response = NO;
@@ -76,15 +83,17 @@
if ([newUID length] > 0)
{
um = [LDAPUserManager sharedUserManager];
email = [um getEmailForUID: newUID];
if ([email length] > 0)
if ([newUID isEqualToString: SOGoDefaultUserID]
|| [[um getEmailForUID: newUID] length] > 0)
{
ASSIGN (uid, newUID);
clientObject = [self clientObject];
[userRights addObjectsFromArray: [clientObject aclsForUser: uid]];
if (![userRights count])
[userRights addObjectsFromArray: [clientObject defaultAclRoles]];
count = [userRights count];
if (!count || (count == 1 && [[userRights objectAtIndex: 0]
isEqualToString: SOGoRole_None]))
[userRights setArray: [clientObject defaultAclRoles]];
response = YES;
}
}
@@ -118,8 +127,7 @@
else
{
[self updateRights];
[[self clientObject] setRoles: userRights
forUser: uid];
[[self clientObject] setRoles: userRights forUser: uid];
response = [self jsCloseWithRefreshMethod: nil];
}

View File

@@ -102,6 +102,7 @@
"Unable to subscribe to that folder!"
= "Unable to subscribe to that folder!";
"Default Roles" = "Default Roles";
"User rights for:" = "User rights for:";
"This person can add cards to this addressbook."

View File

@@ -115,6 +115,7 @@
"Unable to subscribe to that folder!"
= "Impossible de vous inscrire à ce dossier!";
"Default Roles" = "Rôles par défaut";
"User rights for:" = "Autorisations pour :";
"This person can add cards to this addressbook."

View File

@@ -82,6 +82,7 @@
"Forbidden" = "Forbidden";
/* acls */
"Default Roles" = "Default Roles";
"User rights for:" = "User rights for:";
"label_Public" = "Public";
"label_Private" = "Private";

View File

@@ -83,6 +83,7 @@
"Forbidden" = "Accès non autorisée";
/* acls */
"Default Roles" = "Rôles par défaut";
"User rights for:" = "Autorisations pour :";
"label_Public" = "Public";
"label_Private" = "Privé";

View File

@@ -13,8 +13,13 @@
<form id="userRightsForm" const:href="saveUserRights">
<input type="hidden" name="uid" var:value="uid"/>
<div class="title">
<label><var:string label:value="User rights for:"/><br/>
<span class="value"><var:string value="userDisplayName"/></span></label>
<var:if condition="userIsDefaultUser">
<label><span class="value"><var:string label:value="Default Roles"
/></span></label>
</var:if><var:if condition="userIsDefaultUser" const:negate="YES">
<label><var:string label:value="User rights for:"/><br/>
<span class="value"><var:string value="userDisplayName"
/></span></label></var:if>
</div>
<div class="calendarUserRights">
<label><input type="checkbox" class="checkBox"

View File

@@ -13,8 +13,13 @@
<form id="userRightsForm" const:href="saveUserRights">
<input type="hidden" name="uid" var:value="uid"/>
<div class="title">
<label><var:string label:value="User rights for:"/><br/>
<span class="value"><var:string value="userDisplayName"/></span></label>
<var:if condition="userIsDefaultUser">
<label><span class="value"><var:string label:value="Default Roles"
/></span></label>
</var:if><var:if condition="userIsDefaultUser" const:negate="YES">
<label><var:string label:value="User rights for:"/><br/>
<span class="value"><var:string value="userDisplayName"
/></span></label></var:if>
</div>
<div class="calendarUserRights">
<table>

View File

@@ -14,12 +14,16 @@
<form id="aclForm" const:href="saveAcls">
<div class="acls">
<div id="userSelectorHeader">
<input type="hidden" name="defaultUserID" id="defaultUserID"
var:value="defaultUserID"/>
<input type="hidden" name="action" value="saveAcls"/>
<input type="hidden" id="userUIDS" name="userUIDS"
var:value="userUIDS"/>
<label><var:string label:value="Owner:"/><br/>
<span class="value"><strong><var:string value="ownerName"/></strong></span></label><br/>
</div>
<input id="defaultRolesBtn" type="button"
class="button" label:value="Default Roles"/>
<div class="userSelector" id="userRoles">
<var:if condition="currentUserIsOwner">
<span id="userSelectorButtons">

View File

@@ -17,12 +17,17 @@ DIV.acls LABEL
DIV#userSelectorHeader
{ margin: 1em; }
INPUT#defaultRolesBtn
{ position: absolute;
top: 5em;
left: 1em; }
DIV#userRoles
{ position: absolute;
padding: 0px;
margin: 0px;
left: 1em;
top: 5em;
top: 7em;
right: 1em;
bottom: 0px; }

View File

@@ -1,6 +1,7 @@
/* test */
var contactSelectorAction = 'acls-contacts';
var defaultUserID = '';
function addUser(userName, userID) {
if (!$(userID)) {
@@ -17,12 +18,17 @@ function addUser(userName, userID) {
function addUserCallback(http) {
}
function setEventsOnUserNode(node) {
Event.observe(node, "mousedown", listRowMouseDownHandler);
Event.observe(node, "dblclick", onOpenUserRights);
Event.observe(node, "click", onRowClick);
}
function nodeForUser(userName, userId) {
var node = document.createElement("li");
node.setAttribute("id", userId);
node.setAttribute("class", "");
node.addEventListener("mousedown", listRowMouseDownHandler, true);
node.addEventListener("click", onRowClick, true);
setEventsOnUserNode(node);
var image = document.createElement("img");
image.setAttribute("src", ResourcesURL + "/abcard.gif");
@@ -81,44 +87,50 @@ function subscribeToFolder(refreshCallback, refreshCallbackData) {
refreshCallbackData["folder"]);
}
function openRightsForUserID(userID) {
var url = window.location.href;
var elements = url.split("/");
elements[elements.length-1] = "userRights?uid=" + userID;
window.open(elements.join("/"), "",
"width=" + this.userRightsWidth
+ ",height=" + this.userRightsHeight
+ ",resizable=0,scrollbars=0,toolbar=0,"
+ "location=0,directories=0,status=0,menubar=0,copyhistory=0");
}
function openRightsForUser(button) {
var nodes = $("userList").getSelectedRows();
if (nodes.length > 0) {
var url = window.location.href;
var elements = url.split("/");
elements[elements.length-1] = ("userRights?uid="
+ nodes[0].getAttribute("id"));
window.open(elements.join("/"), "",
"width=" + this.userRightsWidth
+ ",height=" + this.userRightsHeight
+ ",resizable=0,scrollbars=0,toolbar=0,"
+ "location=0,directories=0,status=0,menubar=0,copyhistory=0");
}
if (nodes.length > 0)
openRightsForUserID(nodes[0].getAttribute("id"));
return false;
}
function openRightsForDefaultUser(event) {
openRightsForUserID(defaultUserID);
event.preventDefault();
}
function onOpenUserRights(event) {
openRightsForUser();
event.preventDefault();
}
function onAclLoadHandler() {
var ul = $("userList");
var lis = ul.childNodesWithTag("li");
for (var i = 0; i < lis.length; i++) {
lis[i].addEventListener("mousedown", listRowMouseDownHandler, false);
lis[i].addEventListener("dblclick", onOpenUserRights, false);
lis[i].addEventListener("click", onRowClick, false);
}
defaultUserID = $("defaultUserID").value;
Event.observe($("defaultRolesBtn"), "click", openRightsForDefaultUser);
var ul = $("userList");
var lis = ul.childNodesWithTag("li");
for (var i = 0; i < lis.length; i++)
setEventsOnUserNode(lis[i]);
var buttons = $("userSelectorButtons").childNodesWithTag("a");
buttons[0].addEventListener("click", onUserAdd, false);
buttons[1].addEventListener("click", onUserRemove, false);
var buttons = $("userSelectorButtons").childNodesWithTag("a");
Event.observe(buttons[0], "click", onUserAdd);
Event.observe(buttons[1], "click", onUserRemove);
this.userRightsHeight = window.opener.getUsersRightsWindowHeight();
this.userRightsWidth = window.opener.getUsersRightsWindowWidth();
this.userRightsHeight = window.opener.getUsersRightsWindowHeight();
this.userRightsWidth = window.opener.getUsersRightsWindowWidth();
}
window.addEventListener("load", onAclLoadHandler, false);
Event.observe(window, "load", onAclLoadHandler);

View File

@@ -941,7 +941,7 @@ function openExternalLink(anchor) {
function openAclWindow(url) {
var w = window.open(url, "aclWindow",
"width=300,height=300,resizable=1,scrollbars=1,toolbar=0,"
"width=420,height=300,resizable=1,scrollbars=1,toolbar=0,"
+ "location=0,directories=0,status=0,menubar=0"
+ ",copyhistory=0");
w.opener = window;