Monotone-Parent: a4c9cd2589743e62f753935bba32b3bcc889f831
Monotone-Revision: bffd38536f21b982c86617f97c2dff0009e442e1 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-04-24T22:36:20 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
82859a5a66
commit
3c915f8a2e
|
@ -1,3 +1,9 @@
|
|||
2007-04-24 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* UI/Scheduler/UIxCalUserRightsEditor.[hm]: new component class
|
||||
module and subclass of UIxUserRightsEditor specific to the
|
||||
handling of user rights on calendar folders.
|
||||
|
||||
2007-04-23 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* SoObjects/Appointments/SOGoAppointmentFolder.m
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/* UIxCalUserRightsEditor.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2007 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 UIXCALUSERRIGHTSEDITOR_H
|
||||
#define UIXCALUSERRIGHTSEDITOR_H
|
||||
|
||||
#import <UI/Common/UIxUserRightsEditor.h>
|
||||
|
||||
@class NSArray;
|
||||
@class NSString;
|
||||
@class NSMutableDictionary;
|
||||
|
||||
@interface UIxCalUserRightsEditor : UIxUserRightsEditor
|
||||
{
|
||||
NSString *currentRight;
|
||||
NSString *currentRightType;
|
||||
NSMutableDictionary *rights;
|
||||
}
|
||||
|
||||
- (NSArray *) objectRights;
|
||||
- (void) setCurrentRight: (NSString *) newCurrentRight;
|
||||
- (NSString *) currentRight;
|
||||
|
||||
- (NSArray *) rightTypes;
|
||||
- (void) setCurrentRightType: (NSString *) newCurrentRightType;
|
||||
- (NSString *) currentRightType;
|
||||
- (NSString *) currentRightTypeLabel;
|
||||
- (NSString *) currentRightTypeName;
|
||||
- (NSString *) currentRightSelection;
|
||||
|
||||
- (void) setUserCanCreateObjects: (BOOL) userCanCreateObjects;
|
||||
- (BOOL) userCanCreateObjects;
|
||||
|
||||
- (void) setUserCanEraseObjects: (BOOL) userCanEraseObjects;
|
||||
- (BOOL) userCanEraseObjects;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* UIXCALUSERRIGHTSEDITOR_H */
|
|
@ -0,0 +1,204 @@
|
|||
/* UIxCalUserRightsEditor.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2007 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 <NGObjWeb/WORequest.h>
|
||||
#import <SoObjects/SOGo/SOGoPermissions.h>
|
||||
|
||||
#import "UIxCalUserRightsEditor.h"
|
||||
|
||||
@implementation UIxCalUserRightsEditor
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
currentRight = nil;
|
||||
currentRightType = nil;
|
||||
rights = [NSMutableDictionary new];
|
||||
[rights setObject: @"None" forKey: @"Public"];
|
||||
[rights setObject: @"None" forKey: @"Private"];
|
||||
[rights setObject: @"None" forKey: @"Confidential"];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[currentRight release];
|
||||
[currentRightType release];
|
||||
[rights release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) prepareRightsForm
|
||||
{
|
||||
NSEnumerator *roles, *types;
|
||||
NSString *role, *type;
|
||||
unsigned int length;
|
||||
|
||||
roles = [userRights objectEnumerator];
|
||||
role = [roles nextObject];
|
||||
while (role)
|
||||
{
|
||||
types = [[self rightTypes] objectEnumerator];
|
||||
type = [types nextObject];
|
||||
while (type)
|
||||
{
|
||||
if ([role hasPrefix: type])
|
||||
{
|
||||
length = [type length];
|
||||
[rights setObject: [role substringFromIndex: length]
|
||||
forKey: type];
|
||||
}
|
||||
type = [types nextObject];
|
||||
}
|
||||
role = [roles nextObject];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray *) _rightsForType: (NSString *) type
|
||||
{
|
||||
NSMutableArray *rightsForType;
|
||||
NSEnumerator *commonRights;
|
||||
NSString *currentCommonRight;
|
||||
|
||||
rightsForType = [NSMutableArray new];
|
||||
[rightsForType autorelease];
|
||||
commonRights = [[self objectRights] objectEnumerator];
|
||||
currentCommonRight = [commonRights nextObject];
|
||||
while (currentCommonRight)
|
||||
{
|
||||
[rightsForType addObject: [NSString stringWithFormat: @"%@%@",
|
||||
type, currentCommonRight]];
|
||||
currentCommonRight = [commonRights nextObject];
|
||||
}
|
||||
|
||||
return rightsForType;
|
||||
}
|
||||
|
||||
- (void) updateRights
|
||||
{
|
||||
NSEnumerator *types;
|
||||
NSString *currentType, *currentValue;
|
||||
NSArray *rightsForType;
|
||||
WORequest *request;
|
||||
|
||||
request = [context request];
|
||||
types = [[self rightTypes] objectEnumerator];
|
||||
currentType = [types nextObject];
|
||||
while (currentType)
|
||||
{
|
||||
rightsForType = [self _rightsForType: currentType];
|
||||
currentValue
|
||||
= [request formValueForKey:
|
||||
[NSString stringWithFormat: @"%@Right", currentType]];
|
||||
if ([currentValue isEqualToString: @"None"])
|
||||
[self removeAllRightsFromList: rightsForType];
|
||||
else
|
||||
[self appendExclusiveRight: [NSString stringWithFormat: @"%@%@",
|
||||
currentType, currentValue]
|
||||
fromList: rightsForType];
|
||||
currentType = [types nextObject];
|
||||
}
|
||||
|
||||
if ([[request formValueForKey: @"ObjectCreator"] length] > 0)
|
||||
[self appendRight: SOGoRole_ObjectCreator];
|
||||
else
|
||||
[self removeRight: SOGoRole_ObjectCreator];
|
||||
|
||||
if ([[request formValueForKey: @"ObjectEraser"] length] > 0)
|
||||
[self appendRight: SOGoRole_ObjectEraser];
|
||||
else
|
||||
[self removeRight: SOGoRole_ObjectEraser];
|
||||
}
|
||||
|
||||
- (NSArray *) objectRights
|
||||
{
|
||||
return
|
||||
[NSArray arrayWithObjects:
|
||||
@"Viewer", @"DAndTViewer", @"Modifier", @"Responder", @"None", nil];
|
||||
}
|
||||
|
||||
- (void) setCurrentRight: (NSString *) newCurrentRight
|
||||
{
|
||||
ASSIGN (currentRight, newCurrentRight);
|
||||
}
|
||||
|
||||
- (NSString *) currentRight
|
||||
{
|
||||
return currentRight;
|
||||
}
|
||||
|
||||
- (NSArray *) rightTypes
|
||||
{
|
||||
return
|
||||
[NSArray arrayWithObjects: @"Public", @"Private", @"Confidential", nil];
|
||||
}
|
||||
|
||||
- (void) setCurrentRightType: (NSString *) newCurrentRightType
|
||||
{
|
||||
ASSIGN (currentRightType, newCurrentRightType);
|
||||
}
|
||||
|
||||
- (NSString *) currentRightType
|
||||
{
|
||||
return currentRightType;
|
||||
}
|
||||
|
||||
- (NSString *) currentRightTypeLabel
|
||||
{
|
||||
return [self labelForKey:
|
||||
[NSString stringWithFormat: @"label_%@", currentRightType]];
|
||||
}
|
||||
|
||||
- (NSString *) currentRightTypeName
|
||||
{
|
||||
return [NSString stringWithFormat: @"%@Right", currentRightType];
|
||||
}
|
||||
|
||||
- (NSString *) currentRightSelection
|
||||
{
|
||||
return [rights objectForKey: currentRightType];
|
||||
}
|
||||
|
||||
- (void) setUserCanCreateObjects: (BOOL) userCanCreateObjects
|
||||
{
|
||||
[self appendRight: SOGoRole_ObjectCreator];
|
||||
}
|
||||
|
||||
- (BOOL) userCanCreateObjects
|
||||
{
|
||||
return [userRights containsObject: SOGoRole_ObjectCreator];
|
||||
}
|
||||
|
||||
- (void) setUserCanEraseObjects: (BOOL) userCanEraseObjects
|
||||
{
|
||||
[self appendRight: SOGoRole_ObjectEraser];
|
||||
}
|
||||
|
||||
- (BOOL) userCanEraseObjects
|
||||
{
|
||||
return [userRights containsObject: SOGoRole_ObjectEraser];
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in New Issue