Monotone-Parent: 01c5e5314c26ef13463ba2e2dec3d854ef793f1d

Monotone-Revision: eea6de6db85c76d95dc3f6d1ca4e05b3fa7fc455

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2010-03-10T21:53:26
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2010-03-10 21:53:26 +00:00
parent 3b056b3226
commit 251a538c12
8 changed files with 187 additions and 182 deletions

View File

@ -1,3 +1,29 @@
2010-03-10 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/WebServerResources/SchedulerUI.js (updateCalendarProperties):
the displayname can now also be set by subscribers, in their own
environment.
* UI/Scheduler/UIxCalendarProperties.m (-setCalendarName:): this
action is now unconditional.
(-calendarNameIsDisabled): removed obsolete accessor.
* SoObjects/SOGo/SOGoGCSFolder.m
(-setFolderPropertyValue:inCategory:): new setter for properties
pertaining to the ACTIVE user (who may or may not be the owner).
(-folderPropertyValueInCategory:): getter corollary to the new
method above.
(-_fetchDisplayNameFromSubscriber): new method for getting the
display name of the folder for the active user.
(renameTo:): split the method in an instance for the owner and
another one for subscribers. Respectively: _ownerRenameTo: and
_subscriberRenameTo:. The latter invoke the new methods above.
* SoObjects/Appointments/SOGoAppointmentFolder.m
(_setCalendarProperty:forKey:): replaced method with a new
and more generic accessor from SOGoGCSFolder
"setFolderPropertyValue:inCategory:".
2010-03-09 Wolfgang Sourdeau <wsourdeau@inverse.ca> 2010-03-09 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/Common/WODirectAction+SOGo.m * UI/Common/WODirectAction+SOGo.m

View File

@ -278,53 +278,11 @@ static NSNumber *sharedYes = nil;
return objectClass; return objectClass;
} }
- (void) _setCalendarProperty: (id) theValue
forKey: (NSString *) theKey
{
SOGoUserSettings *settings;
NSMutableDictionary *calendarSettings, *values;
settings = [[context activeUser] userSettings];
calendarSettings = [settings objectForKey: @"Calendar"];
if (!calendarSettings)
{
calendarSettings = [NSMutableDictionary dictionary];
[settings setObject: calendarSettings
forKey: @"Calendar"];
}
values = [calendarSettings objectForKey: theKey];
if (theValue)
{
if (!values)
{
// Create the property dictionary
values = [NSMutableDictionary dictionary];
[calendarSettings setObject: values forKey: theKey];
}
[values setObject: theValue forKey: [self folderReference]];
}
else if (values)
{
// Remove the property for the calendar
[values removeObjectForKey: [self folderReference]];
if ([values count] == 0)
// Also remove the property dictionary when empty
[calendarSettings removeObjectForKey: theKey];
}
[settings synchronize];
}
- (NSString *) calendarColor - (NSString *) calendarColor
{ {
SOGoUserSettings *settings;
NSDictionary *colors;
NSString *color; NSString *color;
settings = [[context activeUser] userSettings]; color = [self folderPropertyValueInCategory: @"FolderColors"];
colors = [[settings objectForKey: @"Calendar"]
objectForKey: @"FolderColors"];
color = [colors objectForKey: [self folderReference]];
if (!color) if (!color)
color = defaultColor; color = defaultColor;
@ -333,78 +291,63 @@ static NSNumber *sharedYes = nil;
- (void) setCalendarColor: (NSString *) newColor - (void) setCalendarColor: (NSString *) newColor
{ {
if ([newColor length]) if (![newColor length])
[self _setCalendarProperty: newColor newColor = nil;
forKey: @"FolderColors"];
else [self setFolderPropertyValue: newColor
[self _setCalendarProperty: nil inCategory: @"FolderColors"];
forKey: @"FolderColors"];
} }
- (BOOL) showCalendarAlarms - (BOOL) showCalendarAlarms
{ {
SOGoUserSettings *settings; NSNumber *showAlarms;
NSDictionary *values;
id test;
BOOL show = YES;
settings = [[context activeUser] userSettings]; showAlarms = [self folderPropertyValueInCategory: @"FolderShowAlarms"];
values = [[settings objectForKey: @"Calendar"]
objectForKey: @"FolderShowAlarms"];
test = [values objectForKey: [self folderReference]];
if (test)
show = [test boolValue];
return show; return (showAlarms ? [showAlarms boolValue] : YES);
} }
- (void) setShowCalendarAlarms: (BOOL) new - (void) setShowCalendarAlarms: (BOOL) new
{ {
NSNumber *showAlarms;
if (new) if (new)
[self _setCalendarProperty: nil showAlarms = nil;
forKey: @"FolderShowAlarms"];
else else
[self _setCalendarProperty: [NSNumber numberWithBool: new] showAlarms = [NSNumber numberWithBool: NO];
forKey: @"FolderShowAlarms"];
[self setFolderPropertyValue: showAlarms
inCategory: @"FolderShowAlarms"];
} }
- (BOOL) showCalendarTasks - (BOOL) showCalendarTasks
{ {
SOGoUserSettings *settings; NSNumber *showTasks;
NSDictionary *values;
id test;
BOOL show = YES;
settings = [[context activeUser] userSettings]; showTasks = [self folderPropertyValueInCategory: @"FolderShowTasks"];
values = [[settings objectForKey: @"Calendar"]
objectForKey: @"FolderShowTasks"];
test = [values objectForKey: [self folderReference]];
if (test)
show = [test boolValue];
return show; return (showTasks ? [showTasks boolValue] : YES);
} }
- (void) setShowCalendarTasks: (BOOL) new - (void) setShowCalendarTasks: (BOOL) new
{ {
NSNumber *showTasks;
/* the default value is "YES", so we keep only those with a value of "NO"... */
if (new) if (new)
[self _setCalendarProperty: nil showTasks = nil;
forKey: @"FolderShowTasks"];
else else
[self _setCalendarProperty: [NSNumber numberWithBool: new] showTasks = [NSNumber numberWithBool: NO];
forKey: @"FolderShowTasks"];
[self setFolderPropertyValue: showTasks
inCategory: @"FolderShowTasks"];
} }
- (NSString *) syncTag - (NSString *) syncTag
{ {
SOGoUserSettings *settings;
NSDictionary *syncTags;
NSString *syncTag; NSString *syncTag;
settings = [[context activeUser] userSettings]; syncTag = [self folderPropertyValueInCategory: @"FolderSyncTags"];
syncTags = [[settings objectForKey: @"Calendar"]
objectForKey: @"FolderSyncTags"];
syncTag = [syncTags objectForKey: [self folderReference]];
if (!syncTag) if (!syncTag)
syncTag = @""; syncTag = @"";
@ -413,71 +356,46 @@ static NSNumber *sharedYes = nil;
- (void) setSyncTag: (NSString *) newSyncTag - (void) setSyncTag: (NSString *) newSyncTag
{ {
// Check for duplicated tags
SOGoUserSettings *settings;
NSDictionary *syncTags;
NSArray *values;
if ([newSyncTag length]) if ([newSyncTag length])
{ {
// Check for duplicated tags
SOGoUserSettings *settings;
NSMutableDictionary *calendarSettings;
NSMutableDictionary *syncTags;
NSEnumerator *keysList;
NSString *key;
BOOL hasDuplicate;
hasDuplicate = NO;
settings = [[context activeUser] userSettings]; settings = [[context activeUser] userSettings];
calendarSettings = [settings objectForKey: @"Calendar"]; syncTags = [[settings objectForKey: @"Calendar"]
if (calendarSettings) objectForKey: @"FolderSyncTags"];
{ values = [syncTags allValues];
syncTags = [calendarSettings objectForKey: @"FolderSyncTags"]; if (![values containsObject: newSyncTag])
if (syncTags) [self setFolderPropertyValue: newSyncTag
{ inCategory: @"FolderSyncTags"];
keysList = [syncTags keyEnumerator];
while ((key = (NSString*)[keysList nextObject])) {
if (![key isEqualToString: [self folderReference]]
&& [(NSString*)[syncTags objectForKey: key] isEqualToString: newSyncTag])
{
hasDuplicate = YES;
break;
}
}
}
}
if (!hasDuplicate)
[self _setCalendarProperty: newSyncTag
forKey: @"FolderSyncTags"];
} }
else else
{ [self setFolderPropertyValue: nil
[self _setCalendarProperty: nil inCategory: @"FolderSyncTags"];
forKey: @"FolderSyncTags"];
}
} }
- (BOOL) synchronizeCalendar - (BOOL) synchronizeCalendar
{ {
SOGoUserSettings *settings; NSNumber *synchronize;
NSDictionary *values;
id test;
BOOL synchronize = NO;
settings = [[context activeUser] userSettings]; synchronize = [self folderPropertyValueInCategory: @"FolderSynchronize"];
values = [[settings objectForKey: @"Calendar"]
objectForKey: @"FolderSynchronize"];
test = [values objectForKey: [self folderReference]];
if (test)
synchronize = [test boolValue];
return synchronize; return [synchronize boolValue];
} }
- (void) setSynchronizeCalendar: (BOOL) new - (void) setSynchronizeCalendar: (BOOL) new
{ {
NSNumber *synchronize;
if (new) if (new)
[self _setCalendarProperty: [NSNumber numberWithBool: new] synchronize = [NSNumber numberWithBool: YES];
forKey: @"FolderSynchronize"];
else else
[self _setCalendarProperty: nil synchronize = nil;
forKey: @"FolderSynchronize"];
[self setFolderPropertyValue: synchronize
inCategory: @"FolderSynchronize"];
} }
/* selection */ /* selection */

View File

@ -69,6 +69,10 @@
- (NSString *) folderReference; - (NSString *) folderReference;
- (NSArray *) pathArrayToFolder; - (NSArray *) pathArrayToFolder;
- (void) setFolderPropertyValue: (id) theValue
inCategory: (NSString *) theKey;
- (id) folderPropertyValueInCategory: (NSString *) theKey;
/* lower level fetches */ /* lower level fetches */
- (BOOL) nameExistsInFolder: (NSString *) objectName; - (BOOL) nameExistsInFolder: (NSString *) objectName;

View File

@ -209,9 +209,61 @@ static NSArray *childRecordFields = nil;
/* accessors */ /* accessors */
- (void) setFolderPropertyValue: (id) theValue
inCategory: (NSString *) theKey
{
SOGoUserSettings *settings;
NSMutableDictionary *folderSettings, *values;
NSString *module;
settings = [[context activeUser] userSettings];
module = [container nameInContainer];
folderSettings = [settings objectForKey: module];
if (!folderSettings)
{
folderSettings = [NSMutableDictionary dictionary];
[settings setObject: folderSettings forKey: module];
}
values = [folderSettings objectForKey: theKey];
if (theValue)
{
if (!values)
{
// Create the property dictionary
values = [NSMutableDictionary dictionary];
[folderSettings setObject: values forKey: theKey];
}
[values setObject: theValue forKey: [self folderReference]];
}
else if (values)
{
// Remove the property for the folder
[values removeObjectForKey: [self folderReference]];
if ([values count] == 0)
// Also remove the property dictionary when empty
[folderSettings removeObjectForKey: theKey];
}
[settings synchronize];
}
- (id) folderPropertyValueInCategory: (NSString *) theKey
{
SOGoUserSettings *settings;
NSDictionary *folderSettings;
id value;
settings = [[context activeUser] userSettings];
folderSettings = [settings objectForKey: [container nameInContainer]];
value = [[folderSettings objectForKey: theKey]
objectForKey: [self folderReference]];
return value;
}
- (void) _setDisplayNameFromRow: (NSDictionary *) row - (void) _setDisplayNameFromRow: (NSDictionary *) row
{ {
NSString *currentLogin, *ownerLogin, *primaryDN; NSString *primaryDN;
NSDictionary *ownerIdentity; NSDictionary *ownerIdentity;
primaryDN = [row objectForKey: @"c_foldername"]; primaryDN = [row objectForKey: @"c_foldername"];
@ -223,11 +275,9 @@ static NSArray *childRecordFields = nil;
else else
[displayName appendString: primaryDN]; [displayName appendString: primaryDN];
currentLogin = [[context activeUser] login]; if (!activeUserIsOwner)
ownerLogin = [self ownerInContext: context];
if (![currentLogin isEqualToString: ownerLogin])
{ {
ownerIdentity = [[SOGoUser userWithLogin: ownerLogin roles: nil] ownerIdentity = [[SOGoUser userWithLogin: owner]
primaryIdentity]; primaryIdentity];
[displayName [displayName
appendString: [ownerIdentity keysWithFormat: appendString: [ownerIdentity keysWithFormat:
@ -236,7 +286,10 @@ static NSArray *childRecordFields = nil;
} }
} }
- (void) _fetchDisplayName /* This method fetches the display name defined by the owner, but is also the
fallback when a subscriber has not redefined the display name yet in his
environment. */
- (void) _fetchDisplayNameFromOwner
{ {
GCSChannelManager *cm; GCSChannelManager *cm;
EOAdaptorChannel *fc; EOAdaptorChannel *fc;
@ -265,10 +318,25 @@ static NSArray *childRecordFields = nil;
} }
} }
- (void) _fetchDisplayNameFromSubscriber
{
displayName = [self folderPropertyValueInCategory: @"FolderDisplayNames"];
[displayName retain];
}
- (NSString *) displayName - (NSString *) displayName
{ {
if (!displayName) if (!displayName)
[self _fetchDisplayName]; {
if (activeUserIsOwner)
[self _fetchDisplayNameFromOwner];
else
{
[self _fetchDisplayNameFromSubscriber];
if (!displayName)
[self _fetchDisplayNameFromOwner];
}
}
return displayName; return displayName;
} }
@ -335,24 +403,15 @@ static NSArray *childRecordFields = nil;
- (NSException *) setDavDisplayName: (NSString *) newName - (NSException *) setDavDisplayName: (NSString *) newName
{ {
NSException *error; NSException *error;
NSArray *currentRoles;
currentRoles = [[context activeUser] rolesForObject: self if ([newName length])
inContext: context];
if ([currentRoles containsObject: SoRole_Owner])
{ {
if ([newName length]) [self renameTo: newName];
{ error = nil;
[self renameTo: newName];
error = nil;
}
else
error = [NSException exceptionWithHTTPStatus: 400
reason: @"Empty string"];
} }
else else
error = [NSException exceptionWithHTTPStatus: 403 error = [NSException exceptionWithHTTPStatus: 400
reason: @"Modification denied."]; reason: @"Empty string"];
return error; return error;
} }
@ -437,23 +496,20 @@ static NSArray *childRecordFields = nil;
return error; return error;
} }
- (void) renameTo: (NSString *) newName - (void) _ownerRenameTo: (NSString *) newName
{ {
GCSChannelManager *cm; GCSChannelManager *cm;
EOAdaptorChannel *fc; EOAdaptorChannel *fc;
NSURL *folderLocation; NSURL *folderLocation;
NSString *sql; NSString *sql;
#warning SOGoFolder should have the corresponding method
[displayName release];
displayName = nil;
cm = [GCSChannelManager defaultChannelManager]; cm = [GCSChannelManager defaultChannelManager];
folderLocation folderLocation
= [[GCSFolderManager defaultFolderManager] folderInfoLocation]; = [[GCSFolderManager defaultFolderManager] folderInfoLocation];
fc = [cm acquireOpenChannelForURL: folderLocation]; fc = [cm acquireOpenChannelForURL: folderLocation];
if (fc) if (fc)
{ {
#warning GDLContentStore should provide methods for renaming folders
sql sql
= [NSString stringWithFormat: (@"UPDATE %@ SET c_foldername = '%@'" = [NSString stringWithFormat: (@"UPDATE %@ SET c_foldername = '%@'"
@" WHERE c_path = '%@'"), @" WHERE c_path = '%@'"),
@ -467,6 +523,25 @@ static NSArray *childRecordFields = nil;
} }
} }
- (void) _subscriberRenameTo: (NSString *) newName
{
if ([newName length])
[self setFolderPropertyValue: newName
inCategory: @"FolderDisplayNames"];
}
- (void) renameTo: (NSString *) newName
{
#warning SOGoFolder should have the corresponding method
[displayName release];
displayName = nil;
if (activeUserIsOwner)
[self _ownerRenameTo: newName];
else
[self _subscriberRenameTo: newName];
}
- (NSArray *) fetchContentObjectNames - (NSArray *) fetchContentObjectNames
{ {
NSArray *records, *names; NSArray *records, *names;

View File

@ -34,7 +34,6 @@
- (NSString *) calendarName; - (NSString *) calendarName;
- (void) setCalendarName: (NSString *) newName; - (void) setCalendarName: (NSString *) newName;
- (NSString *) calendarNameIsDisabled;
- (NSString *) calendarColor; - (NSString *) calendarColor;
- (void) setCalendarColor: (NSString *) newColor; - (void) setCalendarColor: (NSString *) newColor;

View File

@ -56,22 +56,7 @@
- (void) setCalendarName: (NSString *) newName - (void) setCalendarName: (NSString *) newName
{ {
NSString *login; [calendar renameTo: newName];
login = [[context activeUser] login];
if ([login isEqualToString: [calendar ownerInContext: context]])
[calendar renameTo: newName];
}
- (NSString *) calendarNameIsDisabled
{
NSString *login;
login = [[context activeUser] login];
return ([login isEqualToString: [calendar ownerInContext: context]]
? @"false" : @"true");
} }
- (NSString *) calendarColor - (NSString *) calendarColor

View File

@ -19,7 +19,6 @@
<div><span class="label"><var:string label:value="Name:"/></span <div><span class="label"><var:string label:value="Name:"/></span
><span class="content"><input type="text" ><span class="content"><input type="text"
name="calendarName" id="calendarName" name="calendarName" id="calendarName"
var:disabled="calendarNameIsDisabled"
class="textField" class="textField"
var:value="calendarName" var:value="calendarName"
/></span></div> /></span></div>

View File

@ -2154,13 +2154,12 @@ function updateCalendarProperties(calendarID, calendarName, calendarColor) {
if (idParts[0] != UserLogin) if (idParts[0] != UserLogin)
nodeID = "/" + idParts[0].asCSSIdentifier() + "_" + folderName; nodeID = "/" + idParts[0].asCSSIdentifier() + "_" + folderName;
else { else
nodeID = "/" + folderName; nodeID = "/" + folderName;
// log("nodeID: " + nodeID); // log("nodeID: " + nodeID);
var calendarNode = $(nodeID); var calendarNode = $(nodeID);
var childNodes = calendarNode.childNodes; var childNodes = calendarNode.childNodes;
childNodes[childNodes.length-1].nodeValue = calendarName; childNodes[childNodes.length-1].nodeValue = calendarName;
}
appendStyleElement(nodeID, calendarColor); appendStyleElement(nodeID, calendarColor);
} }