From: wolfgang Date: Tue, 22 May 2007 21:19:22 +0000 (+0000) Subject: git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1068 d1b88da0-ebda-0310... X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80ee2e9ecd3b30b84952bb7a4d8aee074770a9a7;p=scalable-opengroupware.org git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1068 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/ChangeLog b/ChangeLog index 06b9a6f5..c142c23e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,82 @@ +2007-05-22 Wolfgang Sourdeau + + * SoObjects/Mailer/SOGoMailObject.m ([SOGoMailObject + -isDeletionAllowed]): completed method with the new imap acl api. + + * SoObjects/SOGo/SOGoObject.m ([SOGoObject -defaultAclRoles]): + removed method. + + * SoObjects/SOGo/SOGoPermissions.m: added the new role + "SOGoMailRole_MessageEraser". + + * UI/Common/UIxAclEditor.m ([UIxAclEditor -defaultUserID]) + ([UIxAclEditor -_prepareUsers]): take the new SOGoObject's + "defaultUserID" method into account. + + * UI/Common/UIxUserRightsEditor.m ([UIxUserRightsEditor -userIsDefaultUser]) + ([UIxUserRightsEditor -_initRights]): take the new SOGoObject's + "defaultUserID" method into account. + + * UI/MailerUI/UIxMailUserRightsEditor.m: added all the missing + methods to support the IMAP acls mentionned in the RFC 4314, + removed the ones specific to Cyrus. + + * SoObjects/SOGo/SOGoObject.m ([SOGoObject -defaultUserID]): new + mandatory method for subclasses. Removed the SOGoDefaultUserID + global var. + + * SoObjects/SOGo/SOGoFolder.m ([SOGoFolder -defaultUserID]): + overriden method to return @"". + + * SoObjects/SOGo/SOGoContentObject.m ([SOGoContentObject + -defaultUserID]): overriden method to return @"". + + * SoObjects/Mailer/SOGoMailFolder.m ([SOGoMailFolder + -aclsForUser:uid]): overriden method. + ([SOGoMailFolder -removeAclsForUsers:users]): overriden method. + ([SOGoMailFolder -setRoles:rolesforUser:uid]): overriden method. + ([SOGoMailFolder -defaultUserID]): overriden method. + ([SOGoMailFolder -hasSupportForDefaultRoles]): overriden method. + +2007-05-18 Wolfgang Sourdeau + + * SoObjects/SOGo/SOGoFolder.m ([SOGoFolder + -aclUsersForObjectAtPath:objectPathArray]): new method that being + forwarded the calles to aclUsers for the GCS-based subclasses of + SOGoObject. + + * SoObjects/Mailer/SOGoMailFolder.m: removed all the previous + methods that would have been used to support IMAP acls. Replaced + them with the new protocol for them that has been implemented in + SOGo during the last few weeks. + + * SoObjects/SOGo/SOGoContentObject.m ([SOGoContentObject + -hasSupportForDefaultRoles]): override method by returning "YES". + + * SoObjects/SOGo/NSArray+Utilities.m ([NSMutableArray + -addObjectUniquely:object]): new method with an explicit name. + + * SoObjects/SOGo/SOGoObject.m ([SOGoObject -aclUsers]): renamed + "acl" to "aclUsers". Now designed to return only the uid of the + users involved in an ACL. + ([SOGoObject -hasSupportForDefaultRoles]): new method returning + "NO" by default. To indicate to the acl editor that we don't want + to handle a default user. + + * SoObjects/SOGo/SOGoPermissions.[hm]: added the + SOGoRole_ObjectReader, SOGoRole_Folder*, and SOGoMailRole_* + symbols. + + * UI/MailerUI/UIxMailUserRightsEditor.[hm]: new class module that + provides a view to the IMAP acls. + + * UI/MailerUI/UIxMailFolderACLEditor.m: removed obsolete module. + + * UI/WebServerResources/MailerUI.js: replaced all invocations of + addEventListener to the use of prototype's Event object. Also, + configured all menus programmatically following descriptions lists + containing their callbacks, or nulls, submenus id or separators. + 2007-05-17 Wolfgang Sourdeau * UI/Common/UIxObjectActions.m ([UIxObjectActions diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 5d708c38..a2cea22a 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -1296,13 +1296,4 @@ static NSNumber *sharedYes = nil; return @"IPF.Appointment"; } -/* acls */ -- (NSArray *) defaultAclRoles -{ - return [NSArray arrayWithObjects: - SOGoCalendarRole_PublicViewer, - SOGoCalendarRole_ConfidentialDAndTViewer, - nil]; -} - @end /* SOGoAppointmentFolder */ diff --git a/SoObjects/Appointments/SOGoFreeBusyObject.m b/SoObjects/Appointments/SOGoFreeBusyObject.m index 724821d5..ae378a12 100644 --- a/SoObjects/Appointments/SOGoFreeBusyObject.m +++ b/SoObjects/Appointments/SOGoFreeBusyObject.m @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #import #import diff --git a/SoObjects/Mailer/SOGoMailFolder.h b/SoObjects/Mailer/SOGoMailFolder.h index ce49d2a4..a698bdaa 100644 --- a/SoObjects/Mailer/SOGoMailFolder.h +++ b/SoObjects/Mailer/SOGoMailFolder.h @@ -41,17 +41,6 @@ NSArray *filenames; NSString *folderType; NGImap4MailboxInfo *selectInfo; - struct { - int didCheckMyRights:1; - int isDeleteAndExpungeAllowed:1; - int isReadAllowed:1; - int isWriteAllowed:1; - int isInsertAllowed:1; - int isPostAllowed:1; - int isCreateAllowed:1; - int hasAdminAccess:1; - int reserved:24; - } somfFlags; } /* messages */ @@ -63,16 +52,6 @@ - (NSException *)expunge; -/* permissions */ - -- (BOOL)isDeleteAndExpungeAllowed; -- (BOOL)isReadAllowed; -- (BOOL)isWriteAllowed; -- (BOOL)isInsertAllowed; -- (BOOL)isPostAllowed; -- (BOOL)isCreateAllowed; -- (BOOL)hasAdminAccess; - /* flags */ - (NSException *)addFlagsToAllMessages:(id)_f; diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index cf537404..6c7c84cb 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -19,13 +19,27 @@ 02111-1307, USA. */ -#include "SOGoMailFolder.h" -#include "SOGoMailObject.h" -#include "SOGoMailAccount.h" -#include "SOGoMailManager.h" -#include -#include "SOGoMailFolderDataSource.h" -#include "common.h" +#import + +#import +#import +#import +#import + +#import +#import +#import + +#import +#import + +#import "SOGoMailObject.h" +#import "SOGoMailAccount.h" +#import "SOGoMailManager.h" +#import "SOGoMailFolderDataSource.h" +#import "SOGoMailFolder.h" + +static NSString *defaultUserID = @"anyone"; @implementation SOGoMailFolder @@ -46,9 +60,9 @@ static BOOL useAltNamespace = NO; } - (void)dealloc { - [self->selectInfo release]; - [self->filenames release]; - [self->folderType release]; + [selectInfo release]; + [filenames release]; + [folderType release]; [super dealloc]; } @@ -68,15 +82,15 @@ static BOOL useAltNamespace = NO; NSArray *uids; unsigned count; - if (self->filenames != nil) - return [self->filenames isNotNull] ? self->filenames : nil; + if (filenames != nil) + return [filenames isNotNull] ? filenames : nil; uids = [self fetchUIDsMatchingQualifier:nil sortOrdering:@"DATE"]; if ([uids isKindOfClass:[NSException class]]) return nil; if ((count = [uids count]) == 0) { - self->filenames = [[NSArray alloc] init]; + filenames = [[NSArray alloc] init]; } else { NSMutableArray *keys; @@ -90,10 +104,10 @@ static BOOL useAltNamespace = NO; k = [k stringByAppendingString:@".mail"]; [keys addObject:k]; } - self->filenames = [keys copy]; + filenames = [keys copy]; [keys release]; } - return self->filenames; + return filenames; } - (EODataSource *)contentDataSourceInContext:(id)_ctx { @@ -110,98 +124,17 @@ static BOOL useAltNamespace = NO; /* returns nil if fetch was successful */ id info; - if (self->selectInfo != nil) + if (selectInfo != nil) return nil; /* select info exists, => no error */ info = [[self imap4Connection] infoForMailboxAtURL:[self imap4URL]]; if ([info isKindOfClass:[NSException class]]) return info; - self->selectInfo = [info retain]; + selectInfo = [info retain]; return nil; /* no error */ } -/* permissions */ - -- (void)_loadACLPermissionFlags { - NSString *rights; - unsigned i, len; - - if (self->somfFlags.didCheckMyRights) - return; - - rights = [[self imap4Connection] myRightsForMailboxAtURL:[self imap4URL]]; - if ([rights isKindOfClass:[NSException class]]) { - [self logWithFormat:@"ERROR: could not retrieve ACL: %@", rights]; - return; - } - - // [self logWithFormat:@"GOT PERM: %@", rights]; - - self->somfFlags.didCheckMyRights = 1; - - /* reset flags */ - self->somfFlags.isDeleteAndExpungeAllowed = 0; - self->somfFlags.isReadAllowed = 0; - self->somfFlags.isWriteAllowed = 0; - self->somfFlags.isInsertAllowed = 0; - self->somfFlags.isPostAllowed = 0; - self->somfFlags.isCreateAllowed = 0; - self->somfFlags.hasAdminAccess = 0; - - for (i = 0, len = [rights length]; i < len; i++) { - switch ([rights characterAtIndex:i]) { - case 'd': self->somfFlags.isDeleteAndExpungeAllowed = 1; break; - case 'r': self->somfFlags.isReadAllowed = 1; break; - case 'w': self->somfFlags.isWriteAllowed = 1; break; - case 'i': self->somfFlags.isInsertAllowed = 1; break; - case 'p': self->somfFlags.isPostAllowed = 1; break; - case 'c': self->somfFlags.isCreateAllowed = 1; break; - case 'a': self->somfFlags.hasAdminAccess = 1; break; - } - } -} - -- (BOOL)isDeleteAndExpungeAllowed { - [self _loadACLPermissionFlags]; - return self->somfFlags.isDeleteAndExpungeAllowed ? YES : NO; -} -- (BOOL)isReadAllowed { - [self _loadACLPermissionFlags]; - return self->somfFlags.isReadAllowed ? YES : NO; -} -- (BOOL)isWriteAllowed { - [self _loadACLPermissionFlags]; - return self->somfFlags.isWriteAllowed ? YES : NO; -} -- (BOOL)isInsertAllowed { - [self _loadACLPermissionFlags]; - return self->somfFlags.isInsertAllowed ? YES : NO; -} -- (BOOL)isPostAllowed { - [self _loadACLPermissionFlags]; - return self->somfFlags.isPostAllowed ? YES : NO; -} - -- (BOOL)isCreateAllowedInACL { - /* we call this directly from UIxMailAccountView */ - [self _loadACLPermissionFlags]; - return self->somfFlags.isCreateAllowed ? YES : NO; -} -- (BOOL)isCreateAllowed { - if (useAltNamespace) { - /* with altnamespace, Cyrus doesn't allow mailboxes under INBOX */ - if ([[self outlookFolderClass] isEqualToString:@"IPF.Inbox"]) - return NO; - } - return [self isCreateAllowedInACL]; -} - -- (BOOL)hasAdminAccess { - [self _loadACLPermissionFlags]; - return self->somfFlags.hasAdminAccess ? YES : NO; -} - /* messages */ - (NSArray *)fetchUIDsMatchingQualifier:(id)_q sortOrdering:(id)_so { @@ -369,22 +302,181 @@ static BOOL useAltNamespace = NO; SOGoMailAccount *account; NSString *n; - if (self->folderType != nil) - return self->folderType; + if (folderType != nil) + return folderType; account = [self mailAccountFolder]; n = [self nameInContainer]; if ([n isEqualToString:[account trashFolderNameInContext:nil]]) - self->folderType = @"IPF.Trash"; + folderType = @"IPF.Trash"; else if ([n isEqualToString:[account inboxFolderNameInContext:nil]]) - self->folderType = @"IPF.Inbox"; + folderType = @"IPF.Inbox"; else if ([n isEqualToString:[account sentFolderNameInContext:nil]]) - self->folderType = @"IPF.Sent"; + folderType = @"IPF.Sent"; else - self->folderType = @"IPF.Folder"; + folderType = @"IPF.Folder"; - return self->folderType; + return folderType; +} + +/* acls */ + +- (NSArray *) _imapAclsToSOGoAcls: (NSString *) imapAcls +{ + unsigned int count, max; + NSMutableArray *SOGoAcls; + + SOGoAcls = [NSMutableArray array]; + max = [imapAcls length]; + for (count = 0; count < max; count++) + { + switch ([imapAcls characterAtIndex: count]) + { + case 'l': + [SOGoAcls addObjectUniquely: SOGoRole_ObjectViewer]; + break; + case 'r': + [SOGoAcls addObjectUniquely: SOGoRole_ObjectReader]; + break; + case 's': + [SOGoAcls addObjectUniquely: SOGoMailRole_SeenKeeper]; + break; + case 'w': + [SOGoAcls addObjectUniquely: SOGoMailRole_Writer]; + break; + case 'i': + [SOGoAcls addObjectUniquely: SOGoRole_ObjectCreator]; + break; + case 'p': + [SOGoAcls addObjectUniquely: SOGoMailRole_Poster]; + break; + case 'k': + [SOGoAcls addObjectUniquely: SOGoRole_FolderCreator]; + break; + case 'x': + [SOGoAcls addObjectUniquely: SOGoRole_ObjectEraser]; + break; + case 't': + [SOGoAcls addObjectUniquely: SOGoMailRole_MessageEraser]; + break; + case 'e': + [SOGoAcls addObjectUniquely: SOGoMailRole_Expunger]; + break; + case 'a': + [SOGoAcls addObjectUniquely: SOGoMailRole_Administrator]; + break; + } + } + + return SOGoAcls; +} + +- (NSString *) _sogoAclsToImapAcls: (NSArray *) sogoAcls +{ + NSMutableString *imapAcls; + NSEnumerator *acls; + NSString *currentAcl; + char character; + + imapAcls = [NSMutableString string]; + acls = [sogoAcls objectEnumerator]; + currentAcl = [acls nextObject]; + while (currentAcl) + { + if ([currentAcl isEqualToString: SOGoRole_ObjectViewer]) + character = 'l'; + else if ([currentAcl isEqualToString: SOGoRole_ObjectReader]) + character = 'r'; + else if ([currentAcl isEqualToString: SOGoMailRole_SeenKeeper]) + character = 's'; + else if ([currentAcl isEqualToString: SOGoMailRole_Writer]) + character = 'w'; + else if ([currentAcl isEqualToString: SOGoRole_ObjectCreator]) + character = 'i'; + else if ([currentAcl isEqualToString: SOGoMailRole_Poster]) + character = 'p'; + else if ([currentAcl isEqualToString: SOGoRole_FolderCreator]) + character = 'k'; + else if ([currentAcl isEqualToString: SOGoRole_ObjectEraser]) + character = 'x'; + else if ([currentAcl isEqualToString: SOGoMailRole_MessageEraser]) + character = 't'; + else if ([currentAcl isEqualToString: SOGoMailRole_Expunger]) + character = 'e'; + else if ([currentAcl isEqualToString: SOGoMailRole_Administrator]) + character = 'a'; + else + character = 0; + + if (character) + [imapAcls appendFormat: @"%c", character]; + + currentAcl = [acls nextObject]; + } + + return imapAcls; +} + +- (NSArray *) aclUsers +{ + NSDictionary *imapAcls; + + imapAcls = [imap4 aclForMailboxAtURL: [self imap4URL]]; + + return [imapAcls allKeys]; +} + +- (NSArray *) aclsForUser: (NSString *) uid +{ + NSDictionary *imapAcls; + NSString *userAcls; + + imapAcls = [imap4 aclForMailboxAtURL: [self imap4URL]]; + userAcls = [imapAcls objectForKey: uid]; + if (!([userAcls length] || [uid isEqualToString: defaultUserID])) + userAcls = [imapAcls objectForKey: defaultUserID]; + + return [self _imapAclsToSOGoAcls: userAcls]; +} + +- (void) removeAclsForUsers: (NSArray *) users +{ + NSEnumerator *uids; + NSString *currentUID; + NSString *folderName; + NGImap4Client *client; + + folderName = [imap4 imap4FolderNameForURL: [self imap4URL]]; + client = [imap4 client]; + + uids = [users objectEnumerator]; + currentUID = [uids nextObject]; + while (currentUID) + { + [client deleteACL: folderName uid: currentUID]; + currentUID = [uids nextObject]; + } +} + +- (void) setRoles: (NSArray *) roles + forUser: (NSString *) uid +{ + NSString *acls, *folderName; + + acls = [self _sogoAclsToImapAcls: roles]; + folderName = [imap4 imap4FolderNameForURL: [self imap4URL]]; + [[imap4 client] setACL: folderName rights: acls uid: uid]; +} + +- (NSString *) defaultUserID +{ + return defaultUserID; +} + +- (BOOL) hasSupportForDefaultRoles +{ + return YES; } @end /* SOGoMailFolder */ diff --git a/SoObjects/Mailer/SOGoMailObject.m b/SoObjects/Mailer/SOGoMailObject.m index 749882e1..68ec6326 100644 --- a/SoObjects/Mailer/SOGoMailObject.m +++ b/SoObjects/Mailer/SOGoMailObject.m @@ -19,15 +19,35 @@ 02111-1307, USA. */ -#include "SOGoMailObject.h" -#include "SOGoMailFolder.h" -#include "SOGoMailAccount.h" -#include "SOGoMailManager.h" -#include "SOGoMailBodyPart.h" -#include -#include -#include -#include "common.h" +#import +#import +#import +#import +#import +#import + +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import + +#import +#import +#import "SOGoMailFolder.h" +#import "SOGoMailAccount.h" +#import "SOGoMailManager.h" +#import "SOGoMailBodyPart.h" + +#import "SOGoMailObject.h" @implementation SOGoMailObject @@ -639,8 +659,15 @@ static BOOL debugSoParts = NO; /* permissions */ -- (BOOL)isDeletionAllowed { - return [[self container] isDeleteAndExpungeAllowed]; +- (BOOL) isDeletionAllowed +{ + NSArray *parentAcl; + NSString *login; + + login = [[context activeUser] login]; + parentAcl = [[self container] aclsForUser: login]; + + return [parentAcl containsObject: SOGoMailRole_MessageEraser]; } /* name lookup */ diff --git a/SoObjects/SOGo/NSArray+Utilities.h b/SoObjects/SOGo/NSArray+Utilities.h index 15cbb174..2617538d 100644 --- a/SoObjects/SOGo/NSArray+Utilities.h +++ b/SoObjects/SOGo/NSArray+Utilities.h @@ -39,4 +39,10 @@ @end +@interface NSMutableArray (SOGoArrayUtilities) + +- (void) addObjectUniquely: (id) object; + +@end + #endif /* NSARRAY_UTILITIES_H */ diff --git a/SoObjects/SOGo/NSArray+Utilities.m b/SoObjects/SOGo/NSArray+Utilities.m index ed30b5e5..75dec348 100644 --- a/SoObjects/SOGo/NSArray+Utilities.m +++ b/SoObjects/SOGo/NSArray+Utilities.m @@ -59,3 +59,14 @@ } @end + +@implementation NSMutableArray (SOGoArrayUtilities) + +- (void) addObjectUniquely: (id) object +{ + if (![self containsObject: object]) + [self addObject: object]; +} + +@end + diff --git a/SoObjects/SOGo/SOGoContentObject.m b/SoObjects/SOGo/SOGoContentObject.m index ed75b3ce..e2b11a44 100644 --- a/SoObjects/SOGo/SOGoContentObject.m +++ b/SoObjects/SOGo/SOGoContentObject.m @@ -218,9 +218,9 @@ : 0 /* 0 means 'do not check' */; /* attempt a save */ - - if ((error = [self saveContentString:[rq contentAsString] - baseVersion:baseVersion]) != nil) + + if ((error = [self saveContentString: [rq contentAsString] + baseVersion: baseVersion]) != nil) return error; /* setup response */ @@ -303,9 +303,9 @@ /* acls */ -- (NSArray *) acls +- (NSArray *) aclUsers { - return [container aclsForObjectAtPath: [self pathArrayToSoObject]]; + return [container aclUsersForObjectAtPath: [self pathArrayToSoObject]]; } - (NSArray *) aclsForUser: (NSString *) uid @@ -343,6 +343,16 @@ forObjectAtPath: [self pathArrayToSoObject]]; } +- (NSString *) defaultUserID +{ + return @""; +} + +- (BOOL) hasSupportForDefaultRoles +{ + return YES; +} + /* message type */ - (NSString *) outlookMessageClass diff --git a/SoObjects/SOGo/SOGoFolder.h b/SoObjects/SOGo/SOGoFolder.h index b5527d49..a6aaf18d 100644 --- a/SoObjects/SOGo/SOGoFolder.h +++ b/SoObjects/SOGo/SOGoFolder.h @@ -72,7 +72,7 @@ - (NSException *) delete; /* acls as a container */ -- (NSArray *) aclsForObjectAtPath: (NSArray *) objectPathArray; +- (NSArray *) aclUsersForObjectAtPath: (NSArray *) objectPathArray; - (NSArray *) aclsForUser: (NSString *) uid forObjectAtPath: (NSArray *) objectPathArray; - (void) setRoles: (NSArray *) roles diff --git a/SoObjects/SOGo/SOGoFolder.m b/SoObjects/SOGo/SOGoFolder.m index a55c3dad..2e3b7469 100644 --- a/SoObjects/SOGo/SOGoFolder.m +++ b/SoObjects/SOGo/SOGoFolder.m @@ -31,6 +31,8 @@ #import #import +static NSString *defaultUserID = @""; + @implementation SOGoFolder + (int) version @@ -266,16 +268,18 @@ /* acls as a container */ -- (NSArray *) aclsForObjectAtPath: (NSArray *) objectPathArray; +- (NSArray *) aclUsersForObjectAtPath: (NSArray *) objectPathArray; { EOQualifier *qualifier; NSString *qs; + NSArray *records; qs = [NSString stringWithFormat: @"c_object = '/%@'", [objectPathArray componentsJoinedByString: @"/"]]; qualifier = [EOQualifier qualifierWithQualifierFormat: qs]; + records = [[self ocsFolder] fetchAclMatchingQualifier: qualifier]; - return [[self ocsFolder] fetchAclMatchingQualifier: qualifier]; + return [records valueForKey: @"c_uid"]; } - (NSArray *) _fetchAclsForUser: (NSString *) uid @@ -339,8 +343,8 @@ [self _cacheRoles: acls forUser: uid forObjectAtPath: objectPath]; } - if (!([acls count] || [uid isEqualToString: SOGoDefaultUserID])) - acls = [self aclsForUser: SOGoDefaultUserID + if (!([acls count] || [uid isEqualToString: defaultUserID])) + acls = [self aclsForUser: defaultUserID forObjectAtPath: objectPathArray]; return acls; @@ -418,15 +422,9 @@ } /* acls */ -- (NSArray *) defaultAclRoles -{ -#warning this should be changed to something useful - return nil; -} - -- (NSArray *) acls +- (NSArray *) aclUsers { - return [self aclsForObjectAtPath: [self pathArrayToSoObject]]; + return [self aclUsersForObjectAtPath: [self pathArrayToSoObject]]; } - (NSArray *) aclsForUser: (NSString *) uid @@ -449,6 +447,16 @@ forObjectAtPath: [self pathArrayToSoObject]]; } +- (NSString *) defaultUserID +{ + return defaultUserID; +} + +- (BOOL) hasSupportForDefaultRoles +{ + return YES; +} + /* WebDAV */ - (BOOL) davIsCollection diff --git a/SoObjects/SOGo/SOGoObject.h b/SoObjects/SOGo/SOGoObject.h index e5a77e73..b265699e 100644 --- a/SoObjects/SOGo/SOGoObject.h +++ b/SoObjects/SOGo/SOGoObject.h @@ -52,8 +52,6 @@ #define $(class) NSClassFromString(class) -extern NSString *SOGoDefaultUserID; - @interface SOGoObject : NSObject { WOContext *context; @@ -100,12 +98,13 @@ extern NSString *SOGoDefaultUserID; /* acls */ -- (NSArray *) defaultAclRoles; -- (NSArray *) acls; +- (NSArray *) aclUsers; - (NSArray *) aclsForUser: (NSString *) uid; - (void) setRoles: (NSArray *) roles forUser: (NSString *) uid; - (void) removeAclsForUsers: (NSArray *) users; +- (NSString *) defaultUserID; +- (BOOL) hasSupportForDefaultRoles; /* description */ diff --git a/SoObjects/SOGo/SOGoObject.m b/SoObjects/SOGo/SOGoObject.m index 57b13cd7..5ca5809f 100644 --- a/SoObjects/SOGo/SOGoObject.m +++ b/SoObjects/SOGo/SOGoObject.m @@ -47,8 +47,6 @@ #import "SOGoObject.h" -NSString *SOGoDefaultUserID = @""; - @interface SOGoObject(Content) - (NSString *)contentAsString; @end @@ -354,23 +352,23 @@ static BOOL kontactGroupDAV = YES; - (SOGoDAVSet *) davAcl { - NSArray *role; - NSEnumerator *acls; + NSArray *roles; + NSEnumerator *uids; NSMutableDictionary *aclsDictionary; - NSDictionary *currentAcl; + NSString *currentUID; SoClassSecurityInfo *sInfo; - acls = [[self acls] objectEnumerator]; aclsDictionary = [NSMutableDictionary dictionary]; + uids = [[self aclUsers] objectEnumerator]; sInfo = [[self class] soClassSecurityInfo]; - currentAcl = [acls nextObject]; - while (currentAcl) + currentUID = [uids nextObject]; + while (currentUID) { - role = [NSArray arrayWithObject: [currentAcl objectForKey: @"role"]]; - [aclsDictionary setObject: [sInfo DAVPermissionsForRoles: role] - forKey: [currentAcl objectForKey: @"uid"]]; - currentAcl = [acls nextObject]; + roles = [self aclsForUser: currentUID]; + [aclsDictionary setObject: [sInfo DAVPermissionsForRoles: roles] + forKey: currentUID]; + currentUID = [uids nextObject]; } [self _appendRolesForPseudoPrincipals: aclsDictionary withClassSecurityInfo: sInfo]; @@ -707,7 +705,7 @@ static BOOL kontactGroupDAV = YES; /* acls */ -- (NSArray *) acls +- (NSArray *) aclUsers { [self subclassResponsibility: _cmd]; @@ -721,22 +719,27 @@ static BOOL kontactGroupDAV = YES; return nil; } -- (NSArray *) defaultAclRoles +- (void) setRoles: (NSArray *) roles + forUser: (NSString *) uid { [self subclassResponsibility: _cmd]; - - return nil; } -- (void) setRoles: (NSArray *) roles - forUser: (NSString *) uid +- (void) removeAclsForUsers: (NSArray *) users { [self subclassResponsibility: _cmd]; } -- (void) removeAclsForUsers: (NSArray *) users +- (NSString *) defaultUserID { [self subclassResponsibility: _cmd]; + + return nil; +} + +- (BOOL) hasSupportForDefaultRoles +{ + return NO; } /* description */ diff --git a/SoObjects/SOGo/SOGoPermissions.h b/SoObjects/SOGo/SOGoPermissions.h index 67ee64be..2b4e60cf 100644 --- a/SoObjects/SOGo/SOGoPermissions.h +++ b/SoObjects/SOGo/SOGoPermissions.h @@ -28,17 +28,25 @@ #import extern NSString *SOGoRole_ObjectCreator; +extern NSString *SOGoRole_ObjectReader; extern NSString *SOGoRole_ObjectEraser; extern NSString *SOGoRole_ObjectViewer; extern NSString *SOGoRole_ObjectEditor; + +extern NSString *SOGoRole_FolderCreator; +extern NSString *SOGoRole_FolderReader; extern NSString *SOGoRole_AuthorizedSubscriber; extern NSString *SOGoRole_None; - extern NSString *SOGoRole_FreeBusy; extern NSString *SOGoRole_FreeBusyLookup; -extern NSString *SOGoPerm_ReadAcls; -extern NSString *SOGoPerm_FreeBusyLookup; +extern NSString *SOGoMailRole_SeenKeeper; +extern NSString *SOGoMailRole_Writer; +extern NSString *SOGoMailRole_Poster; +extern NSString *SOGoMailRole_Expunger; +extern NSString *SOGoMailRole_Creator; +extern NSString *SOGoMailRole_Administrator; +extern NSString *SOGoMailRole_MessageEraser; extern NSString *SOGoCalendarRole_Organizer; extern NSString *SOGoCalendarRole_Participant; @@ -61,6 +69,9 @@ extern NSString *SOGoCalendarRole_ComponentDAndTViewer; extern NSString *SOGoCalendarRole_ComponentModifier; extern NSString *SOGoCalendarRole_ComponentResponder; +extern NSString *SOGoPerm_ReadAcls; +extern NSString *SOGoPerm_FreeBusyLookup; + extern NSString *SOGoCalendarPerm_ViewWholePublicRecords; extern NSString *SOGoCalendarPerm_ViewDAndTOfPublicRecords; extern NSString *SOGoCalendarPerm_ModifyPublicRecords; diff --git a/SoObjects/SOGo/SOGoPermissions.m b/SoObjects/SOGo/SOGoPermissions.m index e750ef31..f5cb1f17 100644 --- a/SoObjects/SOGo/SOGoPermissions.m +++ b/SoObjects/SOGo/SOGoPermissions.m @@ -26,7 +26,12 @@ NSString *SOGoRole_ObjectCreator = @"ObjectCreator"; NSString *SOGoRole_ObjectEraser = @"ObjectEraser"; NSString *SOGoRole_ObjectViewer = @"ObjectViewer"; +NSString *SOGoRole_ObjectReader = @"ObjectReader"; NSString *SOGoRole_ObjectEditor = @"ObjectEditor"; +NSString *SOGoRole_FolderCreator = @"FolderCreator"; +NSString *SOGoRole_FolderEraser = @"FolderEraser"; +NSString *SOGoRole_FolderViewer = @"FolderViewer"; +NSString *SOGoRole_FolderReader = @"FolderReader"; NSString *SOGoRole_AuthorizedSubscriber = @"AuthorizedSubscriber"; NSString *SOGoRole_None = @"None"; @@ -60,6 +65,13 @@ NSString *SOGoCalendarRole_ComponentDAndTViewer = @"ComponentDAndTViewer"; NSString *SOGoCalendarRole_ComponentModifier = @"ComponentModifier"; NSString *SOGoCalendarRole_ComponentResponder = @"ComponentResponder"; +NSString *SOGoMailRole_SeenKeeper = @"MailSeenKeeper"; +NSString *SOGoMailRole_Writer = @"MailWriter"; +NSString *SOGoMailRole_Poster = @"MailPoster"; +NSString *SOGoMailRole_Expunger = @"MailExpunger"; +NSString *SOGoMailRole_Administrator = @"MailAdministrator"; +NSString *SOGoMailRole_MessageEraser = @"MailMessageEraser"; + /* permissions */ NSString *SOGoPerm_ReadAcls = @"ReadAcls"; /* the equivalent of "read-acl" in the WebDAV acls spec, which is @@ -83,3 +95,4 @@ NSString *SOGoCalendarPerm_ViewAllComponent = @"ViewAllComponent"; NSString *SOGoCalendarPerm_ViewDAndT = @"ViewDAndT"; NSString *SOGoCalendarPerm_ModifyComponent = @"ModifyComponent"; NSString *SOGoCalendarPerm_RespondToComponent = @"RespondToComponent"; + diff --git a/UI/Common/UIxAclEditor.h b/UI/Common/UIxAclEditor.h index e4d0b1d3..f8104cee 100644 --- a/UI/Common/UIxAclEditor.h +++ b/UI/Common/UIxAclEditor.h @@ -29,10 +29,11 @@ { BOOL prepared; BOOL publishInFreeBusy; - NSArray *acls; + NSArray *aclUsers; NSArray *savedUIDs; NSMutableArray *users; NSString *currentUser; + NSString *defaultUserID; } - (NSArray *) aclsForObject; diff --git a/UI/Common/UIxAclEditor.m b/UI/Common/UIxAclEditor.m index e0328ace..e6dccdfe 100644 --- a/UI/Common/UIxAclEditor.m +++ b/UI/Common/UIxAclEditor.m @@ -29,6 +29,7 @@ #import #import #import +#import #import "UIxAclEditor.h" @@ -38,11 +39,12 @@ { if ((self = [super init])) { - acls = nil; + aclUsers = nil; prepared = NO; publishInFreeBusy = NO; users = [NSMutableArray new]; currentUser = nil; + defaultUserID = nil; savedUIDs = nil; } @@ -54,15 +56,16 @@ [savedUIDs release]; [users release]; [currentUser release]; + [defaultUserID release]; [super dealloc]; } - (NSArray *) aclsForObject { - if (!acls) - acls = [[self clientObject] acls]; + if (!aclUsers) + aclUsers = [[self clientObject] aclUsers]; - return acls; + return aclUsers; } - (NSString *) _displayNameForUID: (NSString *) uid @@ -86,30 +89,32 @@ - (NSString *) defaultUserID { - return SOGoDefaultUserID; + if (!defaultUserID) + ASSIGN (defaultUserID, [[self clientObject] defaultUserID]); + + return defaultUserID; } - (void) _prepareUsers { NSEnumerator *aclsEnum; - NSDictionary *currentAcl; NSString *currentUID, *ownerLogin; ownerLogin = [[self clientObject] ownerInContext: context]; + if (!defaultUserID) + ASSIGN (defaultUserID, [[self clientObject] defaultUserID]); aclsEnum = [[self aclsForObject] objectEnumerator]; - currentAcl = [aclsEnum nextObject]; - while (currentAcl) + currentUID = [aclsEnum nextObject]; + while (currentUID) { - currentUID = [currentAcl objectForKey: @"c_uid"]; if (!([currentUID isEqualToString: ownerLogin] - || [currentUID isEqualToString: SOGoDefaultUserID] - || [users containsObject: currentUID])) - [users addObject: currentUID]; - currentAcl = [aclsEnum nextObject]; - - prepared = YES; + || [currentUID isEqualToString: defaultUserID])) + [users addObjectUniquely: currentUID]; + currentUID = [aclsEnum nextObject]; } + + prepared = YES; } - (NSArray *) usersForObject diff --git a/UI/Common/UIxUserRightsEditor.h b/UI/Common/UIxUserRightsEditor.h index 35cfe156..0bef18e5 100644 --- a/UI/Common/UIxUserRightsEditor.h +++ b/UI/Common/UIxUserRightsEditor.h @@ -34,6 +34,7 @@ { NSMutableArray *userRights; NSString *uid; + NSString *defaultUserID; } - (NSString *) userDisplayName; diff --git a/UI/Common/UIxUserRightsEditor.m b/UI/Common/UIxUserRightsEditor.m index 8ec44dd4..ad674f63 100644 --- a/UI/Common/UIxUserRightsEditor.m +++ b/UI/Common/UIxUserRightsEditor.m @@ -25,6 +25,7 @@ #import #import #import +#import #import "UIxUserRightsEditor.h" @@ -36,6 +37,7 @@ { uid = nil; userRights = [NSMutableArray new]; + defaultUserID = nil; } return self; @@ -45,6 +47,7 @@ { [uid release]; [userRights release]; + [defaultUserID release]; [super dealloc]; } @@ -55,7 +58,10 @@ - (BOOL) userIsDefaultUser { - return [uid isEqualToString: SOGoDefaultUserID]; + if (!defaultUserID) + ASSIGN (defaultUserID, [[self clientObject] defaultUserID]); + + return [uid isEqualToString: defaultUserID]; } - (NSString *) userDisplayName @@ -75,24 +81,22 @@ NSString *newUID; LDAPUserManager *um; SOGoObject *clientObject; - unsigned int count; response = NO; newUID = [[context request] formValueForKey: @"uid"]; if ([newUID length] > 0) { + if (!defaultUserID) + ASSIGN (defaultUserID, [[self clientObject] defaultUserID]); + um = [LDAPUserManager sharedUserManager]; - if ([newUID isEqualToString: SOGoDefaultUserID] + if ([newUID isEqualToString: defaultUserID] || [[um getEmailForUID: newUID] length] > 0) { ASSIGN (uid, newUID); clientObject = [self clientObject]; [userRights addObjectsFromArray: [clientObject aclsForUser: uid]]; - count = [userRights count]; - if (!count || (count == 1 && [[userRights objectAtIndex: 0] - isEqualToString: SOGoRole_None])) - [userRights setArray: [clientObject defaultAclRoles]]; response = YES; } diff --git a/UI/Contacts/English.lproj/Localizable.strings b/UI/Contacts/English.lproj/Localizable.strings index cca322a0..16704ace 100644 --- a/UI/Contacts/English.lproj/Localizable.strings +++ b/UI/Contacts/English.lproj/Localizable.strings @@ -43,7 +43,7 @@ "New Card" = "New Card"; "New List" = "New List"; "Modify" = "Modify"; -"Access Rights..." = "Access Rights..."; +"Sharing..." = "Sharing..."; "Write" = "Write"; "Delete" = "Delete"; "Instant Message" = "Instant Message"; diff --git a/UI/Contacts/French.lproj/Localizable.strings b/UI/Contacts/French.lproj/Localizable.strings index aaf6e207..0d73332e 100644 --- a/UI/Contacts/French.lproj/Localizable.strings +++ b/UI/Contacts/French.lproj/Localizable.strings @@ -50,7 +50,7 @@ "New Card" = "Nouvelle fiche"; "New List" = "Nouvelle liste"; "Modify" = "Modifier"; -"Access Rights..." = "Partage..."; +"Sharing..." = "Partage..."; "Write" = "Écrire"; "Delete" = "Effacer"; "Instant Message" = "Message instantané"; diff --git a/UI/MailPartViewers/UIxMailPartTextViewer.m b/UI/MailPartViewers/UIxMailPartTextViewer.m index ae25992e..e6d7e66a 100644 --- a/UI/MailPartViewers/UIxMailPartTextViewer.m +++ b/UI/MailPartViewers/UIxMailPartTextViewer.m @@ -39,9 +39,7 @@ - (NSString *) flatContentAsString { NSMutableString *content; - NSString *superContent, *urlText, *newUrlText; - NSRange httpRange, rest, currentURL; - unsigned int length; + NSString *superContent; content = [NSMutableString string]; superContent = [[super flatContentAsString] stringByEscapingHTMLString]; diff --git a/UI/MailerUI/English.lproj/Localizable.strings b/UI/MailerUI/English.lproj/Localizable.strings index 49ea9050..bbf54acb 100644 --- a/UI/MailerUI/English.lproj/Localizable.strings +++ b/UI/MailerUI/English.lproj/Localizable.strings @@ -35,6 +35,21 @@ "Account: " = "Account: "; "Shared Account: " = "Shared Account: "; +/* acls */ +"Default Roles" = "Default Roles"; + +"List and see this folder" = "List and see this folder"; +"Read mails from this folder" = "Read mails from this folder"; +"Mark mails read and unread" = "Mark mails read and unread"; +"Modify the flags of the mails in this folder" = "Modify the flags of the mails in this folder"; +"Insert, copy and move mails into this folder" = "Insert, copy and move mails into this folder"; +"Post mails" = "Post mails"; +"Add subfolders to this folder" = "Add subfolders to this folder"; +"Remove this folder" = "Remove this folder"; +"Erase mails from this folder" = "Erase mails from this folder"; +"Expunge this folder" = "Expunge this folder"; +"Modify the acl of this folder" = "Modify the acl of this folder"; + /* Mail edition */ "From" = "From"; diff --git a/UI/MailerUI/French.lproj/Localizable.strings b/UI/MailerUI/French.lproj/Localizable.strings index 6ba4a8d3..f3ad2063 100644 --- a/UI/MailerUI/French.lproj/Localizable.strings +++ b/UI/MailerUI/French.lproj/Localizable.strings @@ -34,6 +34,21 @@ "Account: " = "Compte : "; "Shared Account: " = "Compte Partagé "; +/* acls */ +"Default Roles" = "Rôles par défaut"; + +"List and see this folder" = "Lister et voir ce dossier"; +"Read mails from this folder" = "Lire les messages de ce dossier"; +"Mark mails read and unread" = "Marquer les messages comme lus ou non-lus"; +"Modify the flags of the mails in this folder" = "Modifier les indicateurs sur les messages"; +"Insert, copy and move mails into this folder" = "Insérer, copier et déplacer des messages dans ce dossier"; +"Post mails" = "Poster des messages"; +"Add subfolders to this folder" = "Ajouter des sous-dossiers à ce dossier"; +"Remove this folder" = "Effacer ce dossier"; +"Erase mails from this folder" = "Effacer des messages de ce dossier"; +"Expunge this folder" = "Compacter ce dossier"; +"Modify the acl of this folder" = "Administrer les droits sur ce dossier"; + /* Mail edition */ "From" = "De"; @@ -106,7 +121,7 @@ "New Folder..." = "Nouveau dossier..."; "Compact This Folder" = "Compacter ce dossier"; "Search Messages..." = "Rechercher dans les messages..."; -"Properties..." = "Propriétés"; +"Sharing..." = "Partage..."; "New Subfolder..." = "Nouveau sous-dossier..."; "Rename Folder..." = "Renommer le dossier..."; "Delete Folder" = "Supprimer le dossier..."; diff --git a/UI/MailerUI/GNUmakefile b/UI/MailerUI/GNUmakefile index 8b3f2108..b8e7a4b8 100644 --- a/UI/MailerUI/GNUmakefile +++ b/UI/MailerUI/GNUmakefile @@ -39,7 +39,7 @@ MailerUI_OBJC_FILES += \ \ UIxFilterList.m \ \ - UIxMailFolderACLEditor.m + UIxMailUserRightsEditor.m # UIxSieveEditor.m MailerUI_RESOURCE_FILES += \ diff --git a/UI/MailerUI/UIxMailFolderACLEditor.m b/UI/MailerUI/UIxMailFolderACLEditor.m deleted file mode 100644 index 9606edb1..00000000 --- a/UI/MailerUI/UIxMailFolderACLEditor.m +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright (C) 2005 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo 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 Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ - -#include - -// TODO: implement - -/* - UIxMailFolderACLEditor - - A component to edit IMAP4 ACLs on folders. It works on SOGoMailFolder - objects. -*/ - -@interface UIxMailFolderACLEditor : UIxComponent -{ -} - -@end - -#include "common.h" - -@implementation UIxMailFolderACLEditor -@end /* UIxMailFolderACLEditor */ diff --git a/UI/MailerUI/UIxMailUserRightsEditor.h b/UI/MailerUI/UIxMailUserRightsEditor.h new file mode 100644 index 00000000..289c95c9 --- /dev/null +++ b/UI/MailerUI/UIxMailUserRightsEditor.h @@ -0,0 +1,58 @@ +/* UIxMailUserRightsEditor.h - this file is part of SOGo + * + * Copyright (C) 2007 Inverse groupe conseil + * + * Author: Wolfgang Sourdeau + * + * 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 UIXMAILUSERRIGHTSEDITOR_H +#define UIXMAILUSERRIGHTSEDITOR_H + +#import + +@interface UIxMailUserRightsEditor : UIxUserRightsEditor + +- (void) setUserCanReadMails: (BOOL) userCanReadMails; +- (BOOL) userCanReadMails; + +- (void) setUserCanWriteMails: (BOOL) userCanWriteMails; +- (BOOL) userCanWriteMails; + +- (void) setUserCanInsertMails: (BOOL) userCanInsertMails; +- (BOOL) userCanInsertMails; + +- (void) setUserCanMarkMailsRead: (BOOL) userCanMarkMailsRead; +- (BOOL) userCanMarkMailsRead; + +- (void) setUserCanEraseMails: (BOOL) userCanEraseMails; +- (BOOL) userCanEraseMails; + +- (void) setUserCanCreateSubfolders: (BOOL) userCanCreateSubfolders; +- (BOOL) userCanCreateSubfolders; + +- (void) setUserCanPostMails: (BOOL) userCanPostMails; +- (BOOL) userCanPostMails; + +- (void) setUserIsAdministrator: (BOOL) userIsAdministrator; +- (BOOL) userIsAdministrator; + +- (void) updateRights; + +@end + +#endif /* UIXMAILUSERRIGHTSEDITOR_H */ diff --git a/UI/MailerUI/UIxMailUserRightsEditor.m b/UI/MailerUI/UIxMailUserRightsEditor.m new file mode 100644 index 00000000..2478b5c5 --- /dev/null +++ b/UI/MailerUI/UIxMailUserRightsEditor.m @@ -0,0 +1,238 @@ +/* UIxMailUserRightsEditor.m - this file is part of SOGo + * + * Copyright (C) 2007 Inverse groupe conseil + * + * Author: Wolfgang Sourdeau + * + * 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 +#import +#import +#import + +#import "UIxMailUserRightsEditor.h" + +@implementation UIxMailUserRightsEditor + +- (void) setUserCanSeeFolder: (BOOL) userCanSeeFolder +{ + if (userCanSeeFolder) + [self appendRight: SOGoRole_ObjectViewer]; + else + [self removeRight: SOGoRole_ObjectViewer]; +} + +- (BOOL) userCanSeeFolder +{ + return [userRights containsObject: SOGoRole_ObjectViewer]; +} + +- (void) setUserCanReadMails: (BOOL) userCanReadMails +{ + if (userCanReadMails) + [self appendRight: SOGoRole_ObjectReader]; + else + [self removeRight: SOGoRole_ObjectReader]; +} + +- (BOOL) userCanReadMails +{ + return [userRights containsObject: SOGoRole_ObjectReader]; +} + +- (void) setUserCanMarkMailsRead: (BOOL) userCanMarkMailsRead +{ + if (userCanMarkMailsRead) + [self appendRight: SOGoMailRole_SeenKeeper]; + else + [self removeRight: SOGoMailRole_SeenKeeper]; +} + +- (BOOL) userCanMarkMailsRead +{ + return [userRights containsObject: SOGoMailRole_SeenKeeper]; +} + +- (void) setUserCanWriteMails: (BOOL) userCanWriteMails +{ + if (userCanWriteMails) + [self appendRight: SOGoMailRole_Writer]; + else + [self removeRight: SOGoMailRole_Writer]; +} + +- (BOOL) userCanWriteMails +{ + return [userRights containsObject: SOGoMailRole_Writer]; +} + +- (void) setUserCanInsertMails: (BOOL) userCanInsertMails +{ + if (userCanInsertMails) + [self appendRight: SOGoRole_ObjectCreator]; + else + [self removeRight: SOGoRole_ObjectCreator]; +} + +- (BOOL) userCanInsertMails +{ + return [userRights containsObject: SOGoRole_ObjectCreator]; +} + +- (void) setUserCanPostMails: (BOOL) userCanPostMails +{ + if (userCanPostMails) + [self appendRight: SOGoMailRole_Poster]; + else + [self removeRight: SOGoMailRole_Poster]; +} + +- (BOOL) userCanPostMails +{ + return [userRights containsObject: SOGoMailRole_Poster]; +} + +- (void) setUserCanCreateSubfolders: (BOOL) userCanCreateSubfolders +{ + if (userCanCreateSubfolders) + [self appendRight: SOGoRole_FolderCreator]; + else + [self removeRight: SOGoRole_FolderCreator]; +} + +- (BOOL) userCanCreateSubfolders +{ + return [userRights containsObject: SOGoRole_FolderCreator]; +} + +- (void) setUserCanRemoveFolder: (BOOL) userCanRemoveFolder +{ + if (userCanRemoveFolder) + [self appendRight: SOGoRole_ObjectEraser]; + else + [self removeRight: SOGoRole_ObjectEraser]; +} + +- (BOOL) userCanRemoveFolder +{ + return [userRights containsObject: SOGoRole_ObjectEraser]; +} + +- (void) setUserCanEraseMails: (BOOL) userCanEraseMails +{ + if (userCanEraseMails) + [self appendRight: SOGoMailRole_MessageEraser]; + else + [self removeRight: SOGoMailRole_MessageEraser]; +} + +- (BOOL) userCanEraseMails +{ + return [userRights containsObject: SOGoMailRole_MessageEraser]; +} + +- (void) setUserCanExpungeFolder: (BOOL) userCanExpungeFolder +{ + if (userCanExpungeFolder) + [self appendRight: SOGoMailRole_Expunger]; + else + [self removeRight: SOGoMailRole_Expunger]; +} + +- (BOOL) userCanExpungeFolder +{ + return [userRights containsObject: SOGoMailRole_Expunger]; +} + +- (void) setUserIsAdministrator: (BOOL) userIsAdministrator +{ + if (userIsAdministrator) + [self appendRight: SOGoMailRole_Administrator]; + else + [self removeRight: SOGoMailRole_Administrator]; +} + +- (BOOL) userIsAdministrator +{ + return [userRights containsObject: SOGoMailRole_Administrator]; +} + +- (void) updateRights +{ + WORequest *request; + + request = [context request]; + + if ([[request formValueForKey: SOGoRole_ObjectViewer] length] > 0) + [self appendRight: SOGoRole_ObjectViewer]; + else + [self removeRight: SOGoRole_ObjectViewer]; + + if ([[request formValueForKey: SOGoRole_ObjectReader] length] > 0) + [self appendRight: SOGoRole_ObjectReader]; + else + [self removeRight: SOGoRole_ObjectReader]; + + if ([[request formValueForKey: SOGoMailRole_SeenKeeper] length] > 0) + [self appendRight: SOGoMailRole_SeenKeeper]; + else + [self removeRight: SOGoMailRole_SeenKeeper]; + + if ([[request formValueForKey: SOGoMailRole_Writer] length] > 0) + [self appendRight: SOGoMailRole_Writer]; + else + [self removeRight: SOGoMailRole_Writer]; + + if ([[request formValueForKey: SOGoRole_ObjectCreator] length] > 0) + [self appendRight: SOGoRole_ObjectCreator]; + else + [self removeRight: SOGoRole_ObjectCreator]; + + if ([[request formValueForKey: SOGoMailRole_Poster] length] > 0) + [self appendRight: SOGoMailRole_Poster]; + else + [self removeRight: SOGoMailRole_Poster]; + + if ([[request formValueForKey: SOGoRole_FolderCreator] length] > 0) + [self appendRight: SOGoRole_FolderCreator]; + else + [self removeRight: SOGoRole_FolderCreator]; + + if ([[request formValueForKey: SOGoRole_ObjectEraser] length] > 0) + [self appendRight: SOGoRole_ObjectEraser]; + else + [self removeRight: SOGoRole_ObjectEraser]; + + if ([[request formValueForKey: SOGoMailRole_MessageEraser] length] > 0) + [self appendRight: SOGoMailRole_MessageEraser]; + else + [self removeRight: SOGoMailRole_MessageEraser]; + + if ([[request formValueForKey: SOGoMailRole_Expunger] length] > 0) + [self appendRight: SOGoMailRole_Expunger]; + else + [self removeRight: SOGoMailRole_Expunger]; + + if ([[request formValueForKey: SOGoMailRole_Administrator] length] > 0) + [self appendRight: SOGoMailRole_Administrator]; + else + [self removeRight: SOGoMailRole_Administrator]; +} + +@end + diff --git a/UI/MailerUI/product.plist b/UI/MailerUI/product.plist index 0979d877..ea820f5b 100644 --- a/UI/MailerUI/product.plist +++ b/UI/MailerUI/product.plist @@ -1,5 +1,5 @@ { /* -*-javascript-*- */ - requires = ( MAIN, CommonUI, Mailer ); /* , Sieve */ + requires = ( MAIN, MainUI, CommonUI, Mailer ); /* , Sieve */ publicResources = ( "uix.css", @@ -131,15 +131,20 @@ pageName = "UIxMailListView"; actionName = "deleteFolder"; }; - editACL = { - protectedBy = "View"; - pageName = "UIxMailFolderACLEditor"; - }; compose = { protectedBy = "View"; actionClass = "UIxMailEditorAction"; actionName = "compose"; }; + userRights = { + protectedBy = "ReadAcls"; + pageName = "UIxMailUserRightsEditor"; + }; + saveUserRights = { + protectedBy = "SaveAcls"; + pageName = "UIxMailUserRightsEditor"; + actionName = "saveUserRights"; + }; }; }; diff --git a/UI/Scheduler/English.lproj/Localizable.strings b/UI/Scheduler/English.lproj/Localizable.strings index 050f12de..05d991c9 100644 --- a/UI/Scheduler/English.lproj/Localizable.strings +++ b/UI/Scheduler/English.lproj/Localizable.strings @@ -70,7 +70,7 @@ "New Calendar..." = "New Calendar..."; "Delete Calendar" = "Delete Calendar"; -"Access Rights..." = "Access Rights..."; +"Sharing..." = "Sharing..."; "Export Calendar..." = "Export Calendar..."; "Publish Calendar..." = "Publish Calendar..."; "Reload Remote Calendars" = "Reload Remote Calendars"; diff --git a/UI/Scheduler/French.lproj/Localizable.strings b/UI/Scheduler/French.lproj/Localizable.strings index 46b02d33..44e9be99 100644 --- a/UI/Scheduler/French.lproj/Localizable.strings +++ b/UI/Scheduler/French.lproj/Localizable.strings @@ -71,7 +71,7 @@ "New Calendar..." = "Nouvel agenda..."; "Delete Calendar" = "Effacer l'agenda"; -"Access Rights..." = "Partage"; +"Sharing..." = "Partage..."; "Export Calendar..." = "Exporter l'agenda..."; "Publish Calendar..." = "Publier l'agenda..."; "Reload Remote Calendars" = "Recharger les agendas distants"; diff --git a/UI/Templates/ContactsUI/UIxContactsFilterPanel.wox b/UI/Templates/ContactsUI/UIxContactsFilterPanel.wox index 916ce36c..8e92f86d 100644 --- a/UI/Templates/ContactsUI/UIxContactsFilterPanel.wox +++ b/UI/Templates/ContactsUI/UIxContactsFilterPanel.wox @@ -7,9 +7,8 @@ > diff --git a/UI/Templates/ContactsUI/UIxContactsListViewContainer.wox b/UI/Templates/ContactsUI/UIxContactsListViewContainer.wox index f53445b0..8a2d8655 100644 --- a/UI/Templates/ContactsUI/UIxContactsListViewContainer.wox +++ b/UI/Templates/ContactsUI/UIxContactsListViewContainer.wox @@ -14,23 +14,24 @@ diff --git a/UI/Templates/MailerUI/UIxMailFolderACLEditor.wox b/UI/Templates/MailerUI/UIxMailFolderACLEditor.wox deleted file mode 100644 index 421c98ca..00000000 --- a/UI/Templates/MailerUI/UIxMailFolderACLEditor.wox +++ /dev/null @@ -1,13 +0,0 @@ - - - TODO: IMAP4 ACL editor - diff --git a/UI/Templates/MailerUI/UIxMailMainFrame.wox b/UI/Templates/MailerUI/UIxMailMainFrame.wox index 1e7be00a..e5e57d9d 100644 --- a/UI/Templates/MailerUI/UIxMailMainFrame.wox +++ b/UI/Templates/MailerUI/UIxMailMainFrame.wox @@ -10,168 +10,120 @@ > @@ -184,16 +136,16 @@ diff --git a/UI/Templates/MailerUI/UIxMailUserRightsEditor.wox b/UI/Templates/MailerUI/UIxMailUserRightsEditor.wox new file mode 100644 index 00000000..998f5b6f --- /dev/null +++ b/UI/Templates/MailerUI/UIxMailUserRightsEditor.wox @@ -0,0 +1,88 @@ + + + +
+ +
+ + + + +
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+
+ + +
+
+
diff --git a/UI/Templates/SchedulerUI/UIxCalFilterPanel.wox b/UI/Templates/SchedulerUI/UIxCalFilterPanel.wox index 44c03cad..c0b6f513 100644 --- a/UI/Templates/SchedulerUI/UIxCalFilterPanel.wox +++ b/UI/Templates/SchedulerUI/UIxCalFilterPanel.wox @@ -7,9 +7,7 @@ > diff --git a/UI/Templates/SchedulerUI/UIxCalMainView.wox b/UI/Templates/SchedulerUI/UIxCalMainView.wox index 62d0d9c2..6c075ace 100644 --- a/UI/Templates/SchedulerUI/UIxCalMainView.wox +++ b/UI/Templates/SchedulerUI/UIxCalMainView.wox @@ -14,10 +14,7 @@ - +
diff --git a/UI/WebServerResources/ContactsUI.js b/UI/WebServerResources/ContactsUI.js index 5e4c664e..33429113 100644 --- a/UI/WebServerResources/ContactsUI.js +++ b/UI/WebServerResources/ContactsUI.js @@ -91,7 +91,7 @@ function contactsListCallback(http) { function onContactFoldersContextMenu(event) { var menu = $("contactFoldersMenu"); menu.addEventListener("hideMenu", onContactFoldersContextMenuHide, false); - onMenuClick(event, "contactFoldersMenu"); + popupMenu(event, "contactFoldersMenu", this); var topNode = $("contactFolders"); var selectedNodes = topNode.getSelectedRows(); @@ -105,7 +105,7 @@ function onContactFoldersContextMenu(event) { function onContactContextMenu(event, element) { var menu = $("contactMenu"); menu.addEventListener("hideMenu", onContactContextMenuHide, false); - onMenuClick(event, "contactMenu"); + popupMenu(event, "contactMenu", element); var topNode = $("contactsList"); var selectedNodes = topNode.getSelectedRows(); @@ -235,31 +235,23 @@ function onContactRowDblClick(event, node) { return false; } -function onMenuEditContact(event, node) { - var node = getParentMenu(node).menuTarget.parentNode; - var contactId = node.getAttribute('id'); +function onMenuEditContact(event) { + var contactId = document.menuTarget.getAttribute('id'); openContactWindow(null, URLForFolderID(currentContactFolder) + "/" + contactId + "/edit"); - - return false; } -function onMenuWriteToContact(event, node) { - var node = getParentMenu(node).menuTarget.parentNode; - var contactId = node.getAttribute('id'); - - openMailComposeWindow(ApplicationBaseURL + currentContactFolder - + "/" + contactId + "/write"); +function onMenuWriteToContact(event) { + var contactId = document.menuTarget.getAttribute('id'); - return false; + openMailComposeWindow(ApplicationBaseURL + currentContactFolder + + "/" + contactId + "/write"); } -function onMenuDeleteContact(event, node) { - uixDeleteSelectedContacts(node); - - return false; +function onMenuDeleteContact(event) { + uixDeleteSelectedContacts(this); } function onToolbarEditSelectedContacts(event) { @@ -611,21 +603,27 @@ function configureContactFolders() { } } -function onAccessRightsMenuEntryMouseUp(event) { - var folders = $("contactFolders"); - var selected = folders.getSelectedNodes()[0]; - var title = this.innerHTML; - var url = URLForFolderID(selected.getAttribute("id")) +function onMenuSharing(event) { + var folders = $("contactFolders"); + var selected = folders.getSelectedNodes()[0]; + var title = this.innerHTML; + var url = URLForFolderID(selected.getAttribute("id")); - openAclWindow(url + "/acls", title); + openAclWindow(url + "/acls", title); } function initializeMenus() { - var menus = new Array("contactFoldersMenu", "contactMenu", "searchMenu"); - initMenusNamed(menus); - - var menuEntry = $("accessRightsMenuEntry"); - menuEntry.addEventListener("mouseup", onAccessRightsMenuEntryMouseUp, false); + menus["menuIds"] = new Array("contactFoldersMenu", "contactMenu", + "searchMenu"); + menus["contactFoldersMenu"] = new Array(null, "-", null, + null, "-", null, "-", + onMenuSharing); + menus["contactMenu"] = new Array(onMenuEditContact, "-", + onMenuWriteToContact, null, "-", + onMenuDeleteContact); + menus["searchMenu"] = new Array(setSearchCriteria); + + initMenus(); } function configureSearchField() { diff --git a/UI/WebServerResources/HTMLElement.js b/UI/WebServerResources/HTMLElement.js index 6168bfb9..44e876b9 100644 --- a/UI/WebServerResources/HTMLElement.js +++ b/UI/WebServerResources/HTMLElement.js @@ -216,7 +216,7 @@ HTMLElement.prototype.onContextMenu = function(event) { HTMLElement.prototype.attachMenu = function(menuName) { this.sogoContextMenu = $(menuName); - this.addEventListener("contextmenu", this.onContextMenu, true); + Event.observe(this, "contextmenu", this.onContextMenu); } HTMLElement.prototype.select = function() { diff --git a/UI/WebServerResources/MailerUI.js b/UI/WebServerResources/MailerUI.js index 20739d87..075d020c 100644 --- a/UI/WebServerResources/MailerUI.js +++ b/UI/WebServerResources/MailerUI.js @@ -4,228 +4,240 @@ var currentMessages = new Array(); var maxCachedMessages = 20; var cachedMessages = new Array(); var currentMailbox = ''; + +var usersRightsWindowHeight = 320; +var usersRightsWindowWidth = 400; + /* mail list */ function openMessageWindow(msguid, url) { - var wId = ''; - if (msguid) { - wId += "SOGo_msg_" + msguid; - markMailReadInWindow(window, msguid); - } - var msgWin = window.open(url, wId, - "width=680,height=520,resizable=1,scrollbars=1,toolbar=0," - + "location=0,directories=0,status=0,menubar=0,copyhistory=0"); - if (msguid) { - msgWin.messageId = msguid; - msgWin.messageURL = ApplicationBaseURL + currentMailbox + "/" + msguid; - } - msgWin.focus(); - - return false; + var wId = ''; + if (msguid) { + wId += "SOGo_msg_" + msguid; + markMailReadInWindow(window, msguid); + } + var msgWin = window.open(url, wId, + "width=680,height=520,resizable=1,scrollbars=1,toolbar=0," + + "location=0,directories=0,status=0,menubar=0,copyhistory=0"); + if (msguid) { + msgWin.messageId = msguid; + msgWin.messageURL = ApplicationBaseURL + currentMailbox + "/" + msguid; + } + msgWin.focus(); + + return false; } function onMessageDoubleClick(event) { - resetSelection(window); - var msguid = this.parentNode.id.substr(4); - - return openMessageWindow(msguid, - ApplicationBaseURL + currentMailbox + "/" - + msguid + "/popupview"); + resetSelection(window); + var msguid = this.parentNode.id.substr(4); + + return openMessageWindow(msguid, + ApplicationBaseURL + currentMailbox + "/" + + msguid + "/popupview"); } function toggleMailSelect(sender) { - var row; - row = $(sender.name); - row.className = sender.checked ? "tableview_selected" : "tableview"; + var row; + row = $(sender.name); + row.className = sender.checked ? "tableview_selected" : "tableview"; } function clearSearch(sender) { - var searchField = window.$("search"); - if (searchField) searchField.value=""; - return true; + var searchField = window.$("search"); + if (searchField) searchField.value=""; + return true; } /* mail editor */ function validateEditorInput(sender) { - var errortext = ""; - var field; - - field = document.pageform.subject; - if (field.value == "") - errortext = errortext + labels.error_missingsubject + "\n"; - - if (!UIxRecipientSelectorHasRecipients()) - errortext = errortext + labels.error_missingrecipients + "\n"; - - if (errortext.length > 0) { - alert(labels.error_validationfailed.decodeEntities() + ":\n" - + errortext.decodeEntities()); - return false; - } - return true; + var errortext = ""; + var field; + + field = document.pageform.subject; + if (field.value == "") + errortext = errortext + labels.error_missingsubject + "\n"; + + if (!UIxRecipientSelectorHasRecipients()) + errortext = errortext + labels.error_missingrecipients + "\n"; + + if (errortext.length > 0) { + alert(labels.error_validationfailed.decodeEntities() + ":\n" + + errortext.decodeEntities()); + return false; + } + return true; } function clickedEditorSend(sender) { - if (!validateEditorInput(sender)) - return false; + if (!validateEditorInput(sender)) + return false; - document.pageform.action="send"; - document.pageform.submit(); - // if everything is ok, close the window - return true; + document.pageform.action="send"; + document.pageform.submit(); + // if everything is ok, close the window + return true; } function clickedEditorAttach(sender) { - var urlstr; - - urlstr = "viewAttachments"; - window.open(urlstr, "SOGo_attach", - "width=320,height=320,resizable=1,scrollbars=1,toolbar=0," + - "location=0,directories=0,status=0,menubar=0,copyhistory=0"); - return false; /* stop following the link */ -} + var urlstr; + + urlstr = "viewAttachments"; + window.open(urlstr, "SOGo_attach", + "width=320,height=320,resizable=1,scrollbars=1,toolbar=0," + + "location=0,directories=0,status=0,menubar=0,copyhistory=0"); + return false; /* stop following the link */ + } function clickedEditorSave(sender) { - document.pageform.action="save"; - document.pageform.submit(); - refreshOpener(); - return true; + document.pageform.action="save"; + document.pageform.submit(); + refreshOpener(); + return true; } function clickedEditorDelete(sender) { - document.pageform.action="delete"; - document.pageform.submit(); - refreshOpener(); - window.close(); - return true; + document.pageform.action="delete"; + document.pageform.submit(); + refreshOpener(); + window.close(); + return true; } function openAddressbook(sender) { - var urlstr; - - urlstr = ApplicationBaseURL + "/../Contacts/?popup=YES"; - var w = window.open(urlstr, "Addressbook", - "width=640,height=400,resizable=1,scrollbars=1,toolbar=0," - + "location=0,directories=0,status=0,menubar=0,copyhistory=0"); - w.focus(); + var urlstr; + + urlstr = ApplicationBaseURL + "/../Contacts/?popup=YES"; + var w = window.open(urlstr, "Addressbook", + "width=640,height=400,resizable=1,scrollbars=1,toolbar=0," + + "location=0,directories=0,status=0,menubar=0,copyhistory=0"); + w.focus(); + + return false; +} + +function onMenuSharing(event) { + var folderID = document.menuTarget.getAttribute("dataname"); + var urlstr = URLForFolderID(folderID) + "/acls"; + event.preventDefault(); - return false; + openAclWindow(urlstr); } /* mail list DOM changes */ function markMailInWindow(win, msguid, markread) { - var msgDiv; - - msgDiv = win.$("div_" + msguid); - if (msgDiv) { - if (markread) { - msgDiv.removeClassName("mailer_unreadmailsubject"); - msgDiv.addClassName("mailer_readmailsubject"); - msgDiv = win.$("unreaddiv_" + msguid); - if (msgDiv) - { - msgDiv.setAttribute("class", "mailerUnreadIcon"); - msgDiv.setAttribute("id", "readdiv_" + msguid); - msgDiv.setAttribute("src", ResourcesURL + "/icon_read.gif"); - msgDiv.setAttribute("onclick", "mailListMarkMessage(this," - + " 'markMessageUnread', " + msguid - + ", false);" - +" return false;"); - var title = msgDiv.getAttribute("title-markunread"); - if (title) - msgDiv.setAttribute("title", title); - } - } - else { - msgDiv.removeClassName('mailer_readmailsubject'); - msgDiv.addClassName('mailer_unreadmailsubject'); - msgDiv = win.$("readdiv_" + msguid); - if (msgDiv) - { - msgDiv.setAttribute("class", "mailerReadIcon"); - msgDiv.setAttribute("id", "unreaddiv_" + msguid); - msgDiv.setAttribute("src", ResourcesURL + "/icon_unread.gif"); - msgDiv.setAttribute("onclick", "mailListMarkMessage(this," - + " 'markMessageRead', " + msguid - + ", true);" - +" return false;"); - var title = msgDiv.getAttribute("title-markread"); - if (title) - msgDiv.setAttribute("title", title); - } - } - return true; - } - else - return false; + var msgDiv; + + msgDiv = win.$("div_" + msguid); + if (msgDiv) { + if (markread) { + msgDiv.removeClassName("mailer_unreadmailsubject"); + msgDiv.addClassName("mailer_readmailsubject"); + msgDiv = win.$("unreaddiv_" + msguid); + if (msgDiv) + { + msgDiv.setAttribute("class", "mailerUnreadIcon"); + msgDiv.setAttribute("id", "readdiv_" + msguid); + msgDiv.setAttribute("src", ResourcesURL + "/icon_read.gif"); + msgDiv.setAttribute("onclick", "mailListMarkMessage(this," + + " 'markMessageUnread', " + msguid + + ", false);" + +" return false;"); + var title = msgDiv.getAttribute("title-markunread"); + if (title) + msgDiv.setAttribute("title", title); + } + } + else { + msgDiv.removeClassName('mailer_readmailsubject'); + msgDiv.addClassName('mailer_unreadmailsubject'); + msgDiv = win.$("readdiv_" + msguid); + if (msgDiv) + { + msgDiv.setAttribute("class", "mailerReadIcon"); + msgDiv.setAttribute("id", "unreaddiv_" + msguid); + msgDiv.setAttribute("src", ResourcesURL + "/icon_unread.gif"); + msgDiv.setAttribute("onclick", "mailListMarkMessage(this," + + " 'markMessageRead', " + msguid + + ", true);" + +" return false;"); + var title = msgDiv.getAttribute("title-markread"); + if (title) + msgDiv.setAttribute("title", title); + } + } + return true; + } + else + return false; } function markMailReadInWindow(win, msguid) { - /* this is called by UIxMailView with window.opener */ - return markMailInWindow(win, msguid, true); + /* this is called by UIxMailView with window.opener */ + return markMailInWindow(win, msguid, true); } /* main window */ function reopenToRemoveLocationBar() { - // we cannot really use this, see below at the close comment - if (window.locationbar && window.locationbar.visible) { - newwin = window.open(window.location.href, "SOGo", - "width=800,height=600,resizable=1,scrollbars=1," + - "toolbar=0,location=0,directories=0,status=0," + - "menubar=0,copyhistory=0"); - if (newwin) { - window.close(); // this does only work for windows opened by scripts! - newwin.focus(); - return true; - } - return false; - } - return true; + // we cannot really use this, see below at the close comment + if (window.locationbar && window.locationbar.visible) { + newwin = window.open(window.location.href, "SOGo", + "width=800,height=600,resizable=1,scrollbars=1," + + "toolbar=0,location=0,directories=0,status=0," + + "menubar=0,copyhistory=0"); + if (newwin) { + window.close(); // this does only work for windows opened by scripts! + newwin.focus(); + return true; + } + return false; + } + return true; } /* mail list reply */ function openMessageWindowsForSelection(action) { - if (document.body.hasClassName("popup")) - win = openMessageWindow(window.messageId, - window.messageURL + "/" + action /* url */); - else { - var messageList = $("messageList"); - var rows = messageList.getSelectedRowsId(); - var idset = ""; - for (var i = 0; i < rows.length; i++) - win = openMessageWindow(rows[i].substr(4) /* msguid */, - ApplicationBaseURL + currentMailbox - + "/" + rows[i].substr(4) - + "/" + action /* url */); - } - - return false; + if (document.body.hasClassName("popup")) + win = openMessageWindow(window.messageId, + window.messageURL + "/" + action /* url */); + else { + var messageList = $("messageList"); + var rows = messageList.getSelectedRowsId(); + var idset = ""; + for (var i = 0; i < rows.length; i++) + win = openMessageWindow(rows[i].substr(4) /* msguid */, + ApplicationBaseURL + currentMailbox + + "/" + rows[i].substr(4) + + "/" + action /* url */); + } + + return false; } function mailListMarkMessage(event) { - var http = createHTTPClient(); - var url = ApplicationBaseURL + currentMailbox + "/" + action + "?uid=" + msguid; - - if (http) { - // TODO: add parameter to signal that we are only interested in OK - http.open("POST", url + "&jsonly=1", false /* not async */); - http.send(""); - if (http.status != 200) { - // TODO: refresh page? - alert("Message Mark Failed: " + http.statusText); - window.location.reload(); - } - else { - markMailInWindow(window, msguid, markread); - } - } - else { - window.location.href = url; - } + var http = createHTTPClient(); + var url = ApplicationBaseURL + currentMailbox + "/" + action + "?uid=" + msguid; + + if (http) { + // TODO: add parameter to signal that we are only interested in OK + http.open("POST", url + "&jsonly=1", false /* not async */); + http.send(""); + if (http.status != 200) { + // TODO: refresh page? + alert("Message Mark Failed: " + http.statusText); + window.location.reload(); + } + else { + markMailInWindow(window, msguid, markread); + } + } + else { + window.location.href = url; + } } /* maillist row highlight */ @@ -233,148 +245,148 @@ function mailListMarkMessage(event) { var oldMaillistHighlight = null; // to remember deleted/selected style function ml_highlight(sender) { - oldMaillistHighlight = sender.className; - if (oldMaillistHighlight == "tableview_highlight") - oldMaillistHighlight = null; - sender.className = "tableview_highlight"; + oldMaillistHighlight = sender.className; + if (oldMaillistHighlight == "tableview_highlight") + oldMaillistHighlight = null; + sender.className = "tableview_highlight"; } function ml_lowlight(sender) { - if (oldMaillistHighlight) { - sender.className = oldMaillistHighlight; - oldMaillistHighlight = null; - } - else - sender.className = "tableview"; + if (oldMaillistHighlight) { + sender.className = oldMaillistHighlight; + oldMaillistHighlight = null; + } + else + sender.className = "tableview"; } /* folder operations */ function ctxFolderAdd(sender) { - var folderName; - - folderName = prompt("Foldername: "); - if (folderName == undefined) - return false; - if (folderName == "") - return false; - - // TODO: should use a form-POST or AJAX - window.location.href = "createFolder?name=" + escape(folderName); - return false; + var folderName; + + folderName = prompt("Foldername: "); + if (folderName == undefined) + return false; + if (folderName == "") + return false; + + // TODO: should use a form-POST or AJAX + window.location.href = "createFolder?name=" + escape(folderName); + return false; } function ctxFolderDelete(sender) { - if (!confirm("Delete current folder?").decodeEntities()) - return false; - - // TODO: should use a form-POST or AJAX - window.location.href = "deleteFolder"; - return false; + if (!confirm("Delete current folder?").decodeEntities()) + return false; + + // TODO: should use a form-POST or AJAX + window.location.href = "deleteFolder"; + return false; } /* bulk delete of messages */ function uixDeleteSelectedMessages(sender) { - var failCount = 0; - - var messageList = $("messageList"); - var rowIds = messageList.getSelectedRowsId(); - - for (var i = 0; i < rowIds.length; i++) { - var url, http; - var rowId = rowIds[i].substr(4); - /* send AJAX request (synchronously) */ - - var messageId = currentMailbox + "/" + rowId; - url = ApplicationBaseURL + messageId + "/trash?jsonly=1"; - http = createHTTPClient(); - http.open("GET", url, false /* not async */); - http.send(""); - if (http.status != 200) { /* request failed */ - failCount++; + var failCount = 0; + + var messageList = $("messageList"); + var rowIds = messageList.getSelectedRowsId(); + + for (var i = 0; i < rowIds.length; i++) { + var url, http; + var rowId = rowIds[i].substr(4); + /* send AJAX request (synchronously) */ + + var messageId = currentMailbox + "/" + rowId; + url = ApplicationBaseURL + messageId + "/trash?jsonly=1"; + http = createHTTPClient(); + http.open("GET", url, false /* not async */); + http.send(""); + if (http.status != 200) { /* request failed */ + failCount++; http = null; continue; - } else { - deleteCachedMessage(messageId); - if (currentMessages[currentMailbox] == rowId) { - var div = $('messageContent'); - div.innerHTML = ""; - currentMessages[currentMailbox] = null; + } else { + deleteCachedMessage(messageId); + if (currentMessages[currentMailbox] == rowId) { + var div = $('messageContent'); + div.innerHTML = ""; + currentMessages[currentMailbox] = null; + } } - } - http = null; + http = null; - /* remove from page */ + /* remove from page */ - /* line-through would be nicer, but hiding is OK too */ - var row = $(rowIds[i]); - row.parentNode.removeChild(row); - } + /* line-through would be nicer, but hiding is OK too */ + var row = $(rowIds[i]); + row.parentNode.removeChild(row); + } - if (failCount > 0) - alert("Could not delete " + failCount + " messages!"); - - return false; + if (failCount > 0) + alert("Could not delete " + failCount + " messages!"); + + return false; } function moveMessages(rowIds, folder) { - var failCount = 0; - - for (var i = 0; i < rowIds.length; i++) { - var url, http; - - /* send AJAX request (synchronously) */ - - var messageId = currentMailbox + "/" + rowIds[i]; - url = ApplicationBaseURL + messageId + "/move?jsonly=1&tofolder=" + folder; - http = createHTTPClient(); - http.open("GET", url, false /* not async */); - http.send(""); - if (http.status == 200) { - var row = $("row_" + rowIds[i]); - row.parentNode.removeChild(row); - deleteCachedMessage(messageId); - if (currentMessages[currentMailbox] == rowIds[i]) { - var div = $('messageContent'); - div.innerHTML = ""; - currentMessages[currentMailbox] = null; + var failCount = 0; + + for (var i = 0; i < rowIds.length; i++) { + var url, http; + + /* send AJAX request (synchronously) */ + + var messageId = currentMailbox + "/" + rowIds[i]; + url = ApplicationBaseURL + messageId + "/move?jsonly=1&tofolder=" + folder; + http = createHTTPClient(); + http.open("GET", url, false /* not async */); + http.send(""); + if (http.status == 200) { + var row = $("row_" + rowIds[i]); + row.parentNode.removeChild(row); + deleteCachedMessage(messageId); + if (currentMessages[currentMailbox] == rowIds[i]) { + var div = $('messageContent'); + div.innerHTML = ""; + currentMessages[currentMailbox] = null; + } } - } - else /* request failed */ - failCount++; + else /* request failed */ + failCount++; - /* remove from page */ + /* remove from page */ - /* line-through would be nicer, but hiding is OK too */ - } + /* line-through would be nicer, but hiding is OK too */ + } - if (failCount > 0) - alert("Could not move " + failCount + " messages!"); - - return failCount; + if (failCount > 0) + alert("Could not move " + failCount + " messages!"); + + return failCount; } function onMenuDeleteMessage(event) { - uixDeleteSelectedMessages(); - event.preventDefault(); + uixDeleteSelectedMessages(); + event.preventDefault(); } function onMailboxTreeItemClick(event) { - var topNode = $("d"); - var mailbox = this.parentNode.getAttribute("dataname"); + var topNode = $("d"); + var mailbox = this.parentNode.getAttribute("dataname"); - if (topNode.selectedEntry) { - log ("deselecting"); - topNode.selectedEntry.deselect(); - } - this.select(); - topNode.selectedEntry = this; + if (topNode.selectedEntry) { + log ("deselecting"); + topNode.selectedEntry.deselect(); + } + this.select(); + topNode.selectedEntry = this; - if (this.parentNode.getAttribute("datatype") != "account") - openMailbox(mailbox); - event.preventDefault(); + if (this.parentNode.getAttribute("datatype") != "account") + openMailbox(mailbox); + event.preventDefault(); } function _refreshWindowMailbox() { @@ -390,269 +402,267 @@ function refreshMailbox() { } function openMailbox(mailbox, reload) { - if (mailbox != currentMailbox || reload) { - currentMailbox = mailbox; - var url = ApplicationBaseURL + mailbox + "/view?noframe=1&desc=1"; - var mailboxContent = $("mailboxContent"); - var rightDragHandle = $("rightDragHandle"); - var messageContent = $("messageContent"); - messageContent.innerHTML = ''; - if (mailbox.lastIndexOf("/") == 0) { - var url = (ApplicationBaseURL + currentMailbox + "/" - + "/view?noframe=1"); - if (document.messageAjaxRequest) { - document.messageAjaxRequest.aborted = true; - document.messageAjaxRequest.abort(); - } - document.messageAjaxRequest - = triggerAjaxRequest(url, messageCallback); - mailboxContent.innerHTML = ''; - mailboxContent.style.visibility = "hidden;"; - rightDragHandle.style.visibility = "hidden;"; - messageContent.style.top = "0px;"; - } else { - if (document.messageListAjaxRequest) { - document.messageListAjaxRequest.aborted = true; - document.messageListAjaxRequest.abort(); - } - if (currentMessages[mailbox]) { - loadMessage(currentMessages[mailbox]); - url += '&pageforuid=' + currentMessages[mailbox]; - } - document.messageListAjaxRequest - = triggerAjaxRequest(url, messageListCallback, - currentMessages[mailbox]); - if (mailboxContent.style.visibility == "hidden") { - mailboxContent.style.visibility = "visible;"; - rightDragHandle.style.visibility = "visible;"; - messageContent.style.top = (rightDragHandle.offsetTop - + rightDragHandle.offsetHeight - + 'px;'); + if (mailbox != currentMailbox || reload) { + currentMailbox = mailbox; + var url = ApplicationBaseURL + mailbox + "/view?noframe=1&desc=1"; + var mailboxContent = $("mailboxContent"); + var rightDragHandle = $("rightDragHandle"); + var messageContent = $("messageContent"); + messageContent.innerHTML = ''; + if (mailbox.lastIndexOf("/") == 0) { + var url = (ApplicationBaseURL + currentMailbox + "/" + + "/view?noframe=1"); + if (document.messageAjaxRequest) { + document.messageAjaxRequest.aborted = true; + document.messageAjaxRequest.abort(); + } + document.messageAjaxRequest + = triggerAjaxRequest(url, messageCallback); + mailboxContent.innerHTML = ''; + mailboxContent.style.visibility = "hidden;"; + rightDragHandle.style.visibility = "hidden;"; + messageContent.style.top = "0px;"; + } else { + if (document.messageListAjaxRequest) { + document.messageListAjaxRequest.aborted = true; + document.messageListAjaxRequest.abort(); + } + if (currentMessages[mailbox]) { + loadMessage(currentMessages[mailbox]); + url += '&pageforuid=' + currentMessages[mailbox]; + } + document.messageListAjaxRequest + = triggerAjaxRequest(url, messageListCallback, + currentMessages[mailbox]); + if (mailboxContent.style.visibility == "hidden") { + mailboxContent.style.visibility = "visible;"; + rightDragHandle.style.visibility = "visible;"; + messageContent.style.top = (rightDragHandle.offsetTop + + rightDragHandle.offsetHeight + + 'px;'); + } } - } - } -// triggerAjaxRequest(mailbox, 'toolbar', toolbarCallback); + } + // triggerAjaxRequest(mailbox, 'toolbar', toolbarCallback); } function openMailboxAtIndex(element) { - var idx = element.getAttribute("idx"); - var url = ApplicationBaseURL + currentMailbox + "/view?noframe=1&idx=" + idx; + var idx = element.getAttribute("idx"); + var url = ApplicationBaseURL + currentMailbox + "/view?noframe=1&idx=" + idx; - if (document.messageListAjaxRequest) { - document.messageListAjaxRequest.aborted = true; - document.messageListAjaxRequest.abort(); - } - document.messageListAjaxRequest - = triggerAjaxRequest(url, messageListCallback); + if (document.messageListAjaxRequest) { + document.messageListAjaxRequest.aborted = true; + document.messageListAjaxRequest.abort(); + } + document.messageListAjaxRequest + = triggerAjaxRequest(url, messageListCallback); - return false; + return false; } function messageListCallback(http) { - var div = $('mailboxContent'); - - if (http.readyState == 4 - && http.status == 200) { - document.messageListAjaxRequest = null; - div.innerHTML = http.responseText; - var selected = http.callbackData; - if (selected) { - var row = $('row_' + selected); - row.select(); - } - configureMessageListEvents(); - configureSortableTableHeaders(); - } - else - log ("ajax fuckage"); + var div = $('mailboxContent'); + + if (http.readyState == 4 + && http.status == 200) { + document.messageListAjaxRequest = null; + div.innerHTML = http.responseText; + var selected = http.callbackData; + if (selected) { + var row = $('row_' + selected); + row.select(); + } + configureMessageListEvents(); + configureSortableTableHeaders(); + } + else + log("ajax fuckage"); } function onMessageContextMenu(event) { - var menu = $('messageListMenu'); - menu.addEventListener("hideMenu", onMessageContextMenuHide, false); - onMenuClick(event, 'messageListMenu'); + log("messagelistmenu"); + var menu = $('messageListMenu'); + Event.observe(menu, "hideMenu", onMessageContextMenuHide); + popupMenu(event, "messageListMenu", this); - var topNode = $('messageList'); - var selectedNodes = topNode.getSelectedRows(); - for (var i = 0; i < selectedNodes.length; i++) - selectedNodes[i].deselect(); - topNode.menuSelectedRows = selectedNodes; - topNode.menuSelectedEntry = this; - this.select(); + var topNode = $('messageList'); + var selectedNodes = topNode.getSelectedRows(); + for (var i = 0; i < selectedNodes.length; i++) + selectedNodes[i].deselect(); + topNode.menuSelectedRows = selectedNodes; + topNode.menuSelectedEntry = this; + this.select(); } function onMessageContextMenuHide(event) { - var topNode = $('messageList'); + var topNode = $('messageList'); - if (topNode.menuSelectedEntry) { - topNode.menuSelectedEntry.deselect(); - topNode.menuSelectedEntry = null; - } - if (topNode.menuSelectedRows) { - var nodes = topNode.menuSelectedRows; - for (var i = 0; i < nodes.length; i++) - nodes[i].select(); - topNode.menuSelectedRows = null; - } + if (topNode.menuSelectedEntry) { + topNode.menuSelectedEntry.deselect(); + topNode.menuSelectedEntry = null; + } + if (topNode.menuSelectedRows) { + var nodes = topNode.menuSelectedRows; + for (var i = 0; i < nodes.length; i++) + nodes[i].select(); + topNode.menuSelectedRows = null; + } } function onFolderMenuClick(event) { - var onhide, menuName; - - var menutype = this.parentNode.getAttribute("datatype"); -// log("parentNode: " + this.parentNode.tagName); -// log("menutype: " + menutype); - if (menutype) { - if (menutype == "inbox") { - menuName = "inboxIconMenu"; - } else if (menutype == "account") { - menuName = "accountIconMenu"; - } else if (menutype == "trash") { - menuName = "trashIconMenu"; - } else { + var onhide, menuName; + + var menutype = this.parentNode.getAttribute("datatype"); + // log("parentNode: " + this.parentNode.tagName); + // log("menutype: " + menutype); + if (menutype) { + if (menutype == "inbox") { + menuName = "inboxIconMenu"; + } else if (menutype == "account") { + menuName = "accountIconMenu"; + } else if (menutype == "trash") { + menuName = "trashIconMenu"; + } else { + menuName = "mailboxIconMenu"; + } + } else { menuName = "mailboxIconMenu"; - } - } else { - menuName = "mailboxIconMenu"; - } + } - var menu = $(menuName); - menu.addEventListener("hideMenu", onFolderMenuHide, false); - onMenuClick(event, menuName); + var menu = $(menuName); + Event.observe(menu, "hideMenu", onFolderMenuHide); + popupMenu(event, menuName, this.parentNode); - var topNode = $('d'); - if (topNode.selectedEntry) - topNode.selectedEntry.deselect(); - if (topNode.menuSelectedEntry) - topNode.menuSelectedEntry.deselect(); - topNode.menuSelectedEntry = this; - this.select(); + var topNode = $('d'); + if (topNode.selectedEntry) + topNode.selectedEntry.deselect(); + if (topNode.menuSelectedEntry) + topNode.menuSelectedEntry.deselect(); + topNode.menuSelectedEntry = this; + this.select(); } function onFolderMenuHide(event) { - var topNode = $('d'); + var topNode = $('d'); - if (topNode.menuSelectedEntry) { - topNode.menuSelectedEntry.deselect(); - topNode.menuSelectedEntry = null; - } - if (topNode.selectedEntry) - topNode.selectedEntry.select(); + if (topNode.menuSelectedEntry) { + topNode.menuSelectedEntry.deselect(); + topNode.menuSelectedEntry = null; + } + if (topNode.selectedEntry) + topNode.selectedEntry.select(); } function deleteCachedMessage(messageId) { - var done = false; - var counter = 0; - - while (counter < cachedMessages.length - && !done) - if (cachedMessages[counter] - && cachedMessages[counter]['idx'] == messageId) { - cachedMessages.splice(counter, 1); - done = true; - } - else - counter++; + var done = false; + var counter = 0; + + while (counter < cachedMessages.length + && !done) + if (cachedMessages[counter] + && cachedMessages[counter]['idx'] == messageId) { + cachedMessages.splice(counter, 1); + done = true; + } + else + counter++; } function getCachedMessage(idx) { - var message = null; - var counter = 0; - - while (counter < cachedMessages.length - && message == null) - if (cachedMessages[counter] - && cachedMessages[counter]['idx'] == currentMailbox + '/' + idx) - message = cachedMessages[counter]; - else - counter++; + var message = null; + var counter = 0; + + while (counter < cachedMessages.length + && message == null) + if (cachedMessages[counter] + && cachedMessages[counter]['idx'] == currentMailbox + '/' + idx) + message = cachedMessages[counter]; + else + counter++; - return message; + return message; } function storeCachedMessage(cachedMessage) { - var oldest = -1; - var timeOldest = -1; - var counter = 0; - - if (cachedMessages.length < maxCachedMessages) - oldest = cachedMessages.length; - else { - while (cachedMessages[counter]) { - if (oldest == -1 - || cachedMessages[counter]['time'] < timeOldest) { - oldest = counter; - timeOldest = cachedMessages[counter]['time']; + var oldest = -1; + var timeOldest = -1; + var counter = 0; + + if (cachedMessages.length < maxCachedMessages) + oldest = cachedMessages.length; + else { + while (cachedMessages[counter]) { + if (oldest == -1 + || cachedMessages[counter]['time'] < timeOldest) { + oldest = counter; + timeOldest = cachedMessages[counter]['time']; + } + counter++; } - counter++; - } - if (oldest == -1) - oldest = 0; - } + if (oldest == -1) + oldest = 0; + } - cachedMessages[oldest] = cachedMessage; + cachedMessages[oldest] = cachedMessage; } function onMessageSelectionChange() { - var rows = this.getSelectedRowsId(); - if (rows.length == 1) { - var idx = rows[0].substr(4); + var rows = this.getSelectedRowsId(); + if (rows.length == 1) { + var idx = rows[0].substr(4); - if (currentMessages[currentMailbox] != idx) { - currentMessages[currentMailbox] = idx; - loadMessage(idx); - } - } + if (currentMessages[currentMailbox] != idx) { + currentMessages[currentMailbox] = idx; + loadMessage(idx); + } + } } function loadMessage(idx) { - if (document.messageAjaxRequest) { - document.messageAjaxRequest.aborted = true; - document.messageAjaxRequest.abort(); - } - - var cachedMessage = getCachedMessage(idx); - - if (cachedMessage == null) { - var url = (ApplicationBaseURL + currentMailbox + "/" - + idx + "/view?noframe=1"); - document.messageAjaxRequest - = triggerAjaxRequest(url, messageCallback, idx); - markMailInWindow(window, idx, true); - } else { - var div = $('messageContent'); - div.innerHTML = cachedMessage['text']; - cachedMessage['time'] = (new Date()).getTime(); - document.messageAjaxRequest = null; - configureLinksInMessage(); - } + if (document.messageAjaxRequest) { + document.messageAjaxRequest.aborted = true; + document.messageAjaxRequest.abort(); + } + + var cachedMessage = getCachedMessage(idx); + + if (cachedMessage == null) { + var url = (ApplicationBaseURL + currentMailbox + "/" + + idx + "/view?noframe=1"); + document.messageAjaxRequest + = triggerAjaxRequest(url, messageCallback, idx); + markMailInWindow(window, idx, true); + } else { + var div = $('messageContent'); + div.innerHTML = cachedMessage['text']; + cachedMessage['time'] = (new Date()).getTime(); + document.messageAjaxRequest = null; + configureLinksInMessage(); + } } function configureLinksInMessage() { var messageDiv = $('messageContent'); var mailContentDiv = document.getElementsByClassName('mailer_mailcontent', messageDiv)[0]; - mailContentDiv.addEventListener("contextmenu", onMessageContentMenu, false); + Event.observe(mailContentDiv, "contextmenu", onMessageContentMenu); var anchors = messageDiv.getElementsByTagName('a'); for (var i = 0; i < anchors.length; i++) if (anchors[i].href.substring(0,7) == "mailto:") { - anchors[i].addEventListener("click", onEmailAddressClick, false); - anchors[i].addEventListener("contextmenu", onEmailAddressClick, - false); + Event.observe(anchors[i], "click", onEmailAddressClick); + Event.observe(anchors[i], "contextmenu", onEmailAddressClick); } else - anchors[i].addEventListener("click", onMessageAnchorClick, false); + Event.observe(anchors[i], "click", onMessageAnchorClick); } function onMessageContentMenu(event) { - onMenuClick(event, 'messageContentMenu'); - event.preventDefault(); -}; + popupMenu(event, 'messageContentMenu', this); +} function onEmailAddressClick(event) { - onMenuClick(event, 'addressMenu'); - event.preventDefault(); + popupMenu(event, 'addressMenu', this); } function onMessageAnchorClick (event) { @@ -661,48 +671,48 @@ function onMessageAnchorClick (event) { } function messageCallback(http) { - var div = $('messageContent'); - - if (http.readyState == 4 - && http.status == 200) { - document.messageAjaxRequest = null; - div.innerHTML = http.responseText; - configureLinksInMessage(); - - if (http.callbackData) { - var cachedMessage = new Array(); - cachedMessage['idx'] = currentMailbox + '/' + http.callbackData; - cachedMessage['time'] = (new Date()).getTime(); - cachedMessage['text'] = http.responseText; - if (cachedMessage['text'].length < 30000) - storeCachedMessage(cachedMessage); - } - } - else - log ("ajax fuckage"); + var div = $('messageContent'); + + if (http.readyState == 4 + && http.status == 200) { + document.messageAjaxRequest = null; + div.innerHTML = http.responseText; + configureLinksInMessage(); + + if (http.callbackData) { + var cachedMessage = new Array(); + cachedMessage['idx'] = currentMailbox + '/' + http.callbackData; + cachedMessage['time'] = (new Date()).getTime(); + cachedMessage['text'] = http.responseText; + if (cachedMessage['text'].length < 30000) + storeCachedMessage(cachedMessage); + } + } + else + log ("ajax fuckage"); } function processMailboxMenuAction(mailbox) { - var currentNode, upperNode; - var mailboxName; - var action; + var currentNode, upperNode; + var mailboxName; + var action; - mailboxName = mailbox.getAttribute('mailboxname'); - currentNode = mailbox; - upperNode = null; + mailboxName = mailbox.getAttribute('mailboxname'); + currentNode = mailbox; + upperNode = null; - while (currentNode - && !currentNode.hasAttribute('mailboxaction')) - currentNode = currentNode.parentNode.parentNode.parentMenuItem; + while (currentNode + && !currentNode.hasAttribute('mailboxaction')) + currentNode = currentNode.parentNode.parentNode.parentMenuItem; - if (currentNode) - { + if (currentNode) + { action = currentNode.getAttribute('mailboxaction'); -// var rows = collectSelectedRows(); -// var rString = rows.join(', '); -// alert("performing '" + action + "' on " + rString -// + " to " + mailboxName); - } + // var rows = collectSelectedRows(); + // var rString = rows.join(', '); + // alert("performing '" + action + "' on " + rString + // + " to " + mailboxName); + } } var rowSelectionCount = 0; @@ -710,28 +720,28 @@ var rowSelectionCount = 0; validateControls(); function showElement(e, shouldShow) { - e.style.display = shouldShow ? "" : "none"; + e.style.display = shouldShow ? "" : "none"; } function enableElement(e, shouldEnable) { - if(!e) - return; - if(shouldEnable) { - if(e.hasAttribute("disabled")) - e.removeAttribute("disabled"); - } - else { - e.setAttribute("disabled", "1"); - } + if(!e) + return; + if(shouldEnable) { + if(e.hasAttribute("disabled")) + e.removeAttribute("disabled"); + } + else { + e.setAttribute("disabled", "1"); + } } function validateControls() { - var e = $("moveto"); - this.enableElement(e, rowSelectionCount > 0); + var e = $("moveto"); + this.enableElement(e, rowSelectionCount > 0); } function moveTo(uri) { - alert("MoveTo: " + uri); + alert("MoveTo: " + uri); } function deleteSelectedMails() { @@ -755,45 +765,45 @@ function onMenuForwardMessage(event) { } /* contacts */ -function newContactFromEmail(sender) { - var mailto = sender.parentNode.parentNode.menuTarget.innerHTML; - -// var emailre -// = /([a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z])/g; -// emailre.exec(mailto); -// email = RegExp.$1; - -// var namere = /(\w[\w\ _-]+)\ (<|<)/; -// var c_name = ''; -// if (namere.test(mailto)) { -// namere.exec(mailto); -// c_name += RegExp.$1; -// } - - var email = extractEmailAddress(mailto); - var c_name = extractEmailName(mailto); - if (email.length > 0) - { +function newContactFromEmail(event) { + var mailto = document.menuTarget.innerHTML; + + // var emailre + // = /([a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z])/g; + // emailre.exec(mailto); + // email = RegExp.$1; + + // var namere = /(\w[\w\ _-]+)\ (<|<)/; + // var c_name = ''; + // if (namere.test(mailto)) { + // namere.exec(mailto); + // c_name += RegExp.$1; + // } + + var email = extractEmailAddress(mailto); + var c_name = extractEmailName(mailto); + if (email.length > 0) + { var url = UserFolderURL + "Contacts/new?contactEmail=" + email; if (c_name) - url += "&contactFN=" + c_name; + url += "&contactFN=" + c_name; w = window.open(url, null, "width=546,height=490,resizable=1,scrollbars=1,toolbar=0," + "location=0,directories=0,status=0,menubar=0,copyhistory=0"); w.focus(); - } + } - return false; /* stop following the link */ -} + return false; /* stop following the link */ + } function newEmailTo(sender) { - return openMailTo(sender.parentNode.parentNode.menuTarget.innerHTML); + return openMailTo(document.menuTarget.innerHTML); } function expandUpperTree(node) { - var currentNode = node.parentNode; + var currentNode = node.parentNode; - while (currentNode.className != "dtree") { + while (currentNode.className != "dtree") { if (currentNode.className == 'clip') { var id = currentNode.getAttribute("id"); var number = parseInt(id.substr(2)); @@ -803,204 +813,203 @@ function expandUpperTree(node) { } } currentNode = currentNode.parentNode; - } + } } function initMailboxSelection(mailboxName) { - currentMailbox = mailboxName; -// log("initMailboxSelection: " + mailboxName); - var tree = $("d"); - var treeNodes = document.getElementsByClassName("dTreeNode", tree); - var i = 0; - while (i < treeNodes.length - && treeNodes[i].getAttribute("dataname") != currentMailbox) - i++; - if (i < treeNodes.length) { -// log ("found mailbox"); - var links = document.getElementsByClassName("node", treeNodes[i]); - if (tree.selectedEntry) - tree.selectedEntry.deselect(); - links[0].select(); - tree.selectedEntry = links[0]; - expandUpperTree(links[0]); - } + currentMailbox = mailboxName; + // log("initMailboxSelection: " + mailboxName); + var tree = $("d"); + var treeNodes = document.getElementsByClassName("dTreeNode", tree); + var i = 0; + while (i < treeNodes.length + && treeNodes[i].getAttribute("dataname") != currentMailbox) + i++; + if (i < treeNodes.length) { + // log ("found mailbox"); + var links = document.getElementsByClassName("node", treeNodes[i]); + if (tree.selectedEntry) + tree.selectedEntry.deselect(); + links[0].select(); + tree.selectedEntry = links[0]; + expandUpperTree(links[0]); + } } function onHeaderClick(event) { - if (document.messageListAjaxRequest) { - document.messageListAjaxRequest.aborted = true; - document.messageListAjaxRequest.abort(); - } - url = ApplicationBaseURL + currentMailbox + "/" + this.link; - if (!this.link.match(/noframe=/)) - url += "&noframe=1"; - document.messageListAjaxRequest - = triggerAjaxRequest(url, messageListCallback); + if (document.messageListAjaxRequest) { + document.messageListAjaxRequest.aborted = true; + document.messageListAjaxRequest.abort(); + } + url = ApplicationBaseURL + currentMailbox + "/" + this.link; + if (!this.link.match(/noframe=/)) + url += "&noframe=1"; + document.messageListAjaxRequest + = triggerAjaxRequest(url, messageListCallback); - event.preventDefault(); + event.preventDefault(); } function onSearchFormSubmit() { - log ("search not implemented"); + log ("search not implemented"); - return false; + return false; } function pouetpouet(event) { - window.alert("pouet pouet"); + window.alert("pouet pouet"); } var mailboxSpanAcceptType = function(type) { - return (type == "mailRow"); + return (type == "mailRow"); } var mailboxSpanEnter = function() { - this.addClassName("_dragOver"); + this.addClassName("_dragOver"); } var mailboxSpanExit = function() { - this.removeClassName("_dragOver"); + this.removeClassName("_dragOver"); } var mailboxSpanDrop = function(data) { - var success = false; + var success = false; - if (data) { - var folder = this.parentNode.parentNode.getAttribute("dataname"); - if (folder != currentMailbox) - success = (moveMessages(data, folder) == 0); - } - else - success = false; + if (data) { + var folder = this.parentNode.parentNode.getAttribute("dataname"); + if (folder != currentMailbox) + success = (moveMessages(data, folder) == 0); + } + else + success = false; - return success; + return success; } var plusSignEnter = function() { - var nodeNr = parseInt(this.id.substr(2)); - if (!d.aNodes[nodeNr]._io) - this.plusSignTimer = setTimeout("openPlusSign('" + nodeNr + "');", 1000); + var nodeNr = parseInt(this.id.substr(2)); + if (!d.aNodes[nodeNr]._io) + this.plusSignTimer = setTimeout("openPlusSign('" + nodeNr + "');", 1000); } var plusSignExit = function() { - if (this.plusSignTimer) { - clearTimeout(this.plusSignTimer); - this.plusSignTimer = null; - } + if (this.plusSignTimer) { + clearTimeout(this.plusSignTimer); + this.plusSignTimer = null; + } } function openPlusSign(nodeNr) { - d.nodeStatus(1, nodeNr, d.aNodes[nodeNr]._ls); - d.aNodes[nodeNr]._io = 1; - this.plusSignTimer = null; + d.nodeStatus(1, nodeNr, d.aNodes[nodeNr]._ls); + d.aNodes[nodeNr]._io = 1; + this.plusSignTimer = null; } var messageListGhost = function () { - var newDiv = document.createElement("div"); -// newDiv.style.width = "25px;"; -// newDiv.style.height = "25px;"; - newDiv.style.backgroundColor = "#aae;"; - newDiv.style.border = "2px solid #a3a;"; - newDiv.style.padding = "5px;"; - newDiv.ghostOffsetX = 10; - newDiv.ghostOffsetY = 5; + var newDiv = document.createElement("div"); + // newDiv.style.width = "25px;"; + // newDiv.style.height = "25px;"; + newDiv.style.backgroundColor = "#aae;"; + newDiv.style.border = "2px solid #a3a;"; + newDiv.style.padding = "5px;"; + newDiv.ghostOffsetX = 10; + newDiv.ghostOffsetY = 5; - var imgCode = ''; + var imgCode = ''; - var current = this; - while (!current.getSelectedRows) - current = current.parentNode; - var count = current.getSelectedRows().length; - var text = imgCode + '
' + count + ' messages...'; - newDiv.innerHTML = text; + var current = this; + while (!current.getSelectedRows) + current = current.parentNode; + var count = current.getSelectedRows().length; + var text = imgCode + '
' + count + ' messages...'; + newDiv.innerHTML = text; - return newDiv; + return newDiv; } var messageListData = function(type) { - var rows = this.parentNode.parentNode.getSelectedRowsId(); - var msgIds = new Array(); - for (var i = 0; i < rows.length; i++) - msgIds.push(rows[i].substr(4)); + var rows = this.parentNode.parentNode.getSelectedRowsId(); + var msgIds = new Array(); + for (var i = 0; i < rows.length; i++) + msgIds.push(rows[i].substr(4)); - return msgIds; + return msgIds; } function configureMessageListEvents() { - var messageList = $("messageList"); - if (messageList) { - messageList.addEventListener("selectionchange", - onMessageSelectionChange, false); - var rows = messageList.tBodies[0].rows; - var start = 0; - if (rows.length > 1) { - while (rows[start].cells[0].hasClassName("tbtv_headercell") - || rows[start].cells[0].hasClassName("tbtv_navcell")) - start++; - for (var i = start; i < rows.length; i++) { - rows[i].addEventListener("mousedown", onRowClick, false); - rows[i].addEventListener("contextmenu", onMessageContextMenu, false); - - rows[i].dndTypes = function() { return new Array("mailRow"); }; - rows[i].dndGhost = messageListGhost; - rows[i].dndDataForType = messageListData; - document.DNDManager.registerSource(rows[i]); - - for (var j = 0; j < rows[i].cells.length; j++) { - var cell = rows[i].cells[j]; - cell.addEventListener("mousedown", listRowMouseDownHandler, false); - if (j == 2 || j == 3 || j == 5) - cell.addEventListener("dblclick", onMessageDoubleClick, false); - else if (j == 4) { - var img = cell.childNodesWithTag("img")[0]; - img.addEventListener("click", mailListMarkMessage, false); - } - } + var messageList = $("messageList"); + if (messageList) { + Event.observe(messageList, "selectionchange", onMessageSelectionChange); + var rows = messageList.tBodies[0].rows; + var start = 0; + if (rows.length > 1) { + while (rows[start].cells[0].hasClassName("tbtv_headercell") + || rows[start].cells[0].hasClassName("tbtv_navcell")) + start++; + for (var i = start; i < rows.length; i++) { + Event.observe(rows[i], "mousedown", onRowClick); + Event.observe(rows[i], "contextmenu", onMessageContextMenu); + + rows[i].dndTypes = function() { return new Array("mailRow"); }; + rows[i].dndGhost = messageListGhost; + rows[i].dndDataForType = messageListData; + document.DNDManager.registerSource(rows[i]); + + for (var j = 0; j < rows[i].cells.length; j++) { + var cell = rows[i].cells[j]; + Event.observe(cell, "mousedown", listRowMouseDownHandler); + if (j == 2 || j == 3 || j == 5) + Event.observe(cell, "dblclick", onMessageDoubleClick); + else if (j == 4) { + var img = cell.childNodesWithTag("img")[0]; + Event.observe(img, "click", mailListMarkMessage); + } + } + } } - } - } + } } function configureDragHandles() { - var handle = $("verticalDragHandle"); - if (handle) { - handle.addInterface(SOGoDragHandlesInterface); - handle.leftBlock=$("leftPanel"); - handle.rightBlock=$("rightPanel"); - } + var handle = $("verticalDragHandle"); + if (handle) { + handle.addInterface(SOGoDragHandlesInterface); + handle.leftBlock=$("leftPanel"); + handle.rightBlock=$("rightPanel"); + } - handle = $("rightDragHandle"); - if (handle) { - handle.addInterface(SOGoDragHandlesInterface); - handle.upperBlock=$("mailboxContent"); - handle.lowerBlock=$("messageContent"); - } + handle = $("rightDragHandle"); + if (handle) { + handle.addInterface(SOGoDragHandlesInterface); + handle.upperBlock=$("mailboxContent"); + handle.lowerBlock=$("messageContent"); + } } /* dnd */ function initDnd() { -// log ("MailerUI initDnd"); - - var tree = $("d"); - if (tree) { - var images = tree.getElementsByTagName("img"); - for (var i = 0; i < images.length; i++) { - if (images[i].id[0] == 'j') { - images[i].dndAcceptType = mailboxSpanAcceptType; - images[i].dndEnter = plusSignEnter; - images[i].dndExit = plusSignExit; - document.DNDManager.registerDestination(images[i]); + // log ("MailerUI initDnd"); + + var tree = $("d"); + if (tree) { + var images = tree.getElementsByTagName("img"); + for (var i = 0; i < images.length; i++) { + if (images[i].id[0] == 'j') { + images[i].dndAcceptType = mailboxSpanAcceptType; + images[i].dndEnter = plusSignEnter; + images[i].dndExit = plusSignExit; + document.DNDManager.registerDestination(images[i]); + } + } + var nodes = document.getElementsByClassName("nodeName", tree); + for (var i = 0; i < nodes.length; i++) { + nodes[i].dndAcceptType = mailboxSpanAcceptType; + nodes[i].dndEnter = mailboxSpanEnter; + nodes[i].dndExit = mailboxSpanExit; + nodes[i].dndDrop = mailboxSpanDrop; + document.DNDManager.registerDestination(nodes[i]); } - } - var nodes = document.getElementsByClassName("nodeName", tree); - for (var i = 0; i < nodes.length; i++) { - nodes[i].dndAcceptType = mailboxSpanAcceptType; - nodes[i].dndEnter = mailboxSpanEnter; - nodes[i].dndExit = mailboxSpanExit; - nodes[i].dndDrop = mailboxSpanDrop; - document.DNDManager.registerDestination(nodes[i]); - } - } + } } /* stub */ @@ -1009,66 +1018,91 @@ function refreshContacts() { } function openInbox(node) { - var done = false; - openMailbox(node.parentNode.getAttribute("dataname")); - var tree = $("d"); - tree.selectedEntry = node; - node.select(); - var currentNode = node.parentNode.parentNode; - while (!done) { - var number = currentNode.getAttribute("id").substr(2); - d.o(number); - if (number == "1") - done = true; - else - currentNode = currentNode.parentNode; - } + var done = false; + openMailbox(node.parentNode.getAttribute("dataname")); + var tree = $("d"); + tree.selectedEntry = node; + node.select(); + var currentNode = node.parentNode.parentNode; + while (!done) { + var number = currentNode.getAttribute("id").substr(2); + d.o(number); + if (number == "1") + done = true; + else + currentNode = currentNode.parentNode; + } } function configureSearchField() { var searchValue = $("searchValue"); - searchValue.addEventListener("mousedown", onSearchMouseDown, false); - searchValue.addEventListener("click", popupSearchMenu, false); - searchValue.addEventListener("blur", onSearchBlur, false); - searchValue.addEventListener("focus", onSearchFocus, false); - searchValue.addEventListener("keydown", onSearchKeyDown, false); -} - -var initMailer = { - handleEvent: function (event) { - if (!document.body.hasClassName("popup")) { - configureSearchField(); - var inboxFound = false; - configureMessageListEvents(); - initDnd(); - var tree = $("d"); - var nodes = document.getElementsByClassName("node", tree); - for (i = 0; i < nodes.length; i++) { - nodes[i].addEventListener("click", onMailboxTreeItemClick, false); - nodes[i].addEventListener("contextmenu", onFolderMenuClick, false); - if (!inboxFound - && nodes[i].parentNode.getAttribute("datatype") == "inbox") { - openInbox(nodes[i]); - inboxFound = true; - } + Event.observe(searchValue, "mousedown", onSearchMouseDown); + Event.observe(searchValue, "click", popupSearchMenu); + Event.observe(searchValue, "blur", onSearchBlur); + Event.observe(searchValue, "focus", onSearchFocus); + Event.observe(searchValue, "keydown", onSearchKeyDown); +} + +function initMailer(event) { + if (!document.body.hasClassName("popup")) { + configureSearchField(); + var inboxFound = false; + configureMessageListEvents(); + initDnd(); + var tree = $("d"); + var nodes = document.getElementsByClassName("node", tree); + for (i = 0; i < nodes.length; i++) { + Event.observe(nodes[i], "click", onMailboxTreeItemClick); + Event.observe(nodes[i], "contextmenu", onFolderMenuClick); + if (!inboxFound + && nodes[i].parentNode.getAttribute("datatype") == "inbox") { + openInbox(nodes[i]); + inboxFound = true; } } - - /* - , 'onMailboxTreeItemClick(this);' -