mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-26 23:39:33 +00:00
Monotone-Parent: d3ba36ba8bfc76739a9e1820c3fe106f3e68d71a
Monotone-Revision: 4fa23faeb7b6dfed2046ea79c364ca3e961e3d3c Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-04-24T22:49:38 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
15
ChangeLog
15
ChangeLog
@@ -1,5 +1,20 @@
|
||||
2007-04-24 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* UI/Common/UIxUserRightsEditor.m ([UIxUserRightsEditor -defaultAction])
|
||||
([UIxUserRightsEditor -saveUserRightsAction]): new action methods
|
||||
which should never be overriden.
|
||||
([UIxUserRightsEditor -appendRight:newRight])
|
||||
([UIxUserRightsEditor -removeRight:right])
|
||||
([UIxUserRightsEditor -appendExclusiveRight:newRightfromList:list])
|
||||
([UIxUserRightsEditor -removeAllRightsFromList:list]): new utility
|
||||
methods that can be used by the subclasses.
|
||||
([UIxUserRightsEditor -prepareRightsForm]): new method that should
|
||||
mandatorily be overriden to prepare the elements of the subclassed
|
||||
form.
|
||||
([UIxUserRightsEditor -updateRights]): new method that should
|
||||
mandatorily be overriden to update the user rights from the
|
||||
elements of the subclassed form.
|
||||
|
||||
* UI/Common/UIxAclEditor.m ([UIxAclEditor -_prepareUsers]): we
|
||||
check if the uid is already listed before adding it to our array.
|
||||
This is because the acl table can contain more than one record per
|
||||
|
||||
@@ -25,7 +25,28 @@
|
||||
|
||||
#import <SOGoUI/UIxComponent.h>
|
||||
|
||||
@class NSMutableArray;
|
||||
@class NSString;
|
||||
|
||||
@protocol WOActionResults;
|
||||
|
||||
@interface UIxUserRightsEditor : UIxComponent
|
||||
{
|
||||
NSMutableArray *userRights;
|
||||
NSString *uid;
|
||||
}
|
||||
|
||||
- (NSString *) userDisplayName;
|
||||
- (NSString *) uid;
|
||||
|
||||
- (void) appendRight: (NSString *) newRight;
|
||||
- (void) appendExclusiveRight: (NSString *) newRight
|
||||
fromList: (NSArray *) list;
|
||||
- (void) removeRight: (NSString *) right;
|
||||
- (void) removeAllRightsFromList: (NSArray *) list;
|
||||
|
||||
- (void) prepareRightsForm;
|
||||
- (void) updateRights;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -20,8 +20,144 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import <NGObjWeb/NSException+HTTP.h>
|
||||
#import <NGObjWeb/WOResponse.h>
|
||||
#import <NGObjWeb/WORequest.h>
|
||||
#import <SoObjects/SOGo/AgenorUserManager.h>
|
||||
|
||||
#import "UIxUserRightsEditor.h"
|
||||
|
||||
@implementation UIxUserRightsEditor
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
uid = nil;
|
||||
userRights = [NSMutableArray new];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[uid release];
|
||||
[userRights release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSString *) uid
|
||||
{
|
||||
return uid;
|
||||
}
|
||||
|
||||
- (NSString *) userDisplayName
|
||||
{
|
||||
AgenorUserManager *um;
|
||||
|
||||
um = [AgenorUserManager sharedUserManager];
|
||||
|
||||
return [NSString stringWithFormat: @"%@ <%@>",
|
||||
[um getCNForUID: uid],
|
||||
[um getEmailForUID: uid]];
|
||||
}
|
||||
|
||||
- (BOOL) _initRights
|
||||
{
|
||||
BOOL response;
|
||||
NSString *newUID, *email;
|
||||
AgenorUserManager *um;
|
||||
SOGoObject *clientObject;
|
||||
|
||||
response = NO;
|
||||
|
||||
newUID = [[context request] formValueForKey: @"uid"];
|
||||
if ([newUID length] > 0)
|
||||
{
|
||||
um = [AgenorUserManager sharedUserManager];
|
||||
email = [um getEmailForUID: newUID];
|
||||
if ([email length] > 0)
|
||||
{
|
||||
ASSIGN (uid, newUID);
|
||||
clientObject = [self clientObject];
|
||||
[userRights addObjectsFromArray: [clientObject aclsForUser: uid]];
|
||||
if (![userRights count])
|
||||
[userRights addObjectsFromArray: [clientObject defaultAclRoles]];
|
||||
|
||||
response = YES;
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
- (id <WOActionResults>) defaultAction
|
||||
{
|
||||
id <WOActionResults> response;
|
||||
|
||||
if (![self _initRights])
|
||||
response = [NSException exceptionWithHTTPStatus: 403
|
||||
reason: @"No such user."];
|
||||
else
|
||||
{
|
||||
[self prepareRightsForm];
|
||||
response = self;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
- (id <WOActionResults>) saveUserRightsAction
|
||||
{
|
||||
id <WOActionResults> response;
|
||||
|
||||
if (![self _initRights])
|
||||
response = [NSException exceptionWithHTTPStatus: 403
|
||||
reason: @"No such user."];
|
||||
else
|
||||
{
|
||||
[self updateRights];
|
||||
[[self clientObject] setRoles: userRights
|
||||
forUser: uid];
|
||||
response = [self jsCloseWithRefreshMethod: nil];
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
- (void) appendRight: (NSString *) newRight
|
||||
{
|
||||
if (![userRights containsObject: newRight])
|
||||
[userRights addObject: newRight];
|
||||
}
|
||||
|
||||
- (void) removeRight: (NSString *) right
|
||||
{
|
||||
if ([userRights containsObject: right])
|
||||
[userRights removeObject: right];
|
||||
}
|
||||
|
||||
- (void) appendExclusiveRight: (NSString *) newRight
|
||||
fromList: (NSArray *) list
|
||||
{
|
||||
[userRights removeObjectsInArray: list];
|
||||
[self appendRight: newRight];
|
||||
}
|
||||
|
||||
- (void) removeAllRightsFromList: (NSArray *) list
|
||||
{
|
||||
[userRights removeObjectsInArray: list];
|
||||
}
|
||||
|
||||
- (void) prepareRightsForm
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (void) updateRights
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user