mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-06-05 02:19:43 +00:00
Monotone-Parent: c494ba259363880f5d46e8931a1708d1ba1aed45
Monotone-Revision: 5f57280bc0c8371b942a310b60e1dfa1a790fb84 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-09-30T18:05:14 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -1,5 +1,34 @@
|
||||
2010-09-30 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* UI/WebServerResources/UIxContactsUserFolders.js:
|
||||
(onConfirmFolderSelection): fixed the regexp used when sanitizing
|
||||
a username containing a user info field.
|
||||
|
||||
* SoObjects/Mailer/SOGoMailAccount.m (-identities): the account
|
||||
identities are now kept in an ivar until the account object is
|
||||
released. Moreoever, we invoke the new
|
||||
"_appendDelegatorIdentities" method when the account
|
||||
nameInContainer is "0".
|
||||
(-_appendDelegatorIdentities): new method that appends the mail
|
||||
values of all delegators for the owner user.
|
||||
|
||||
* UI/WebServerResources/MailerUI.js: (onMenuAccountDelegation):
|
||||
new menu action for showing the new dialog below.
|
||||
(onAccountIconMenuPrepareVisibility): new setup function.
|
||||
|
||||
* UI/MailerUI/UIxMailAccountActions.m (-addDelegateAction)
|
||||
(-removeDelegation): new action methods.
|
||||
|
||||
* SoObjects/Mailer/SOGoUser+Mailer.m: new category module.
|
||||
(mailDelegators, addMailDelegator, removeMailDelegator): new
|
||||
accessors.
|
||||
|
||||
* UI/MailerUI/UIxMailUserDelegationEditor.m: new window for
|
||||
choosing account delegates
|
||||
|
||||
* UI/WebServerResources/UIxMailUserDelegationEditor.js: new page
|
||||
file, derived from UIxAclEditor.js.
|
||||
|
||||
* SoObjects/SOGo/NSDictionary+BSJSONAdditions.m
|
||||
(+[NSMutableDictionary dictionaryWithJSONString:]): return nil
|
||||
directly if the json string is empty.
|
||||
|
||||
@@ -37,7 +37,8 @@ Mailer_OBJC_FILES += \
|
||||
\
|
||||
EOQualifier+MailDAV.m \
|
||||
NSData+Mail.m \
|
||||
NSString+Mail.m
|
||||
NSString+Mail.m \
|
||||
SOGoUser+Mailer.m
|
||||
|
||||
Mailer_RESOURCE_FILES += \
|
||||
Version \
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
*/
|
||||
|
||||
@class NSArray;
|
||||
@class NSMutableArray;
|
||||
@class NSString;
|
||||
|
||||
@class SOGoMailFolder;
|
||||
@@ -55,6 +56,7 @@ typedef enum {
|
||||
SOGoSentFolder *sentFolder;
|
||||
SOGoTrashFolder *trashFolder;
|
||||
SOGoIMAPAclStyle imapAclStyle;
|
||||
NSMutableArray *identities;
|
||||
}
|
||||
|
||||
- (SOGoIMAPAclStyle) imapAclStyle;
|
||||
@@ -89,6 +91,11 @@ typedef enum {
|
||||
- (NSArray *) otherUsersFolderNamespaces;
|
||||
- (NSArray *) sharedFolderNamespaces;
|
||||
|
||||
/* account delegation */
|
||||
- (NSArray *) delegates;
|
||||
- (void) addDelegates: (NSArray *) newDelegates;
|
||||
- (void) removeDelegates: (NSArray *) oldDelegates;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __Mailer_SOGoMailAccount_H__ */
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
#import <SOGo/SOGoDomainDefaults.h>
|
||||
#import <SOGo/SOGoUser.h>
|
||||
#import <SOGo/SOGoUserDefaults.h>
|
||||
#import <SOGo/SOGoUserSettings.h>
|
||||
|
||||
#import "SOGoDraftsFolder.h"
|
||||
#import "SOGoMailFolder.h"
|
||||
@@ -53,7 +52,7 @@
|
||||
#import "SOGoSentFolder.h"
|
||||
#import "SOGoSieveConverter.h"
|
||||
#import "SOGoTrashFolder.h"
|
||||
|
||||
#import "SOGoUser+Mailer.h"
|
||||
|
||||
#import "SOGoMailAccount.h"
|
||||
|
||||
@@ -71,6 +70,7 @@ static NSString *sieveScriptName = @"sogo";
|
||||
sentFolder = nil;
|
||||
trashFolder = nil;
|
||||
imapAclStyle = undefined;
|
||||
identities = nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -82,6 +82,7 @@ static NSString *sieveScriptName = @"sogo";
|
||||
[draftsFolder release];
|
||||
[sentFolder release];
|
||||
[trashFolder release];
|
||||
[identities release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@@ -482,17 +483,47 @@ static NSString *sieveScriptName = @"sogo";
|
||||
return mailAccount;
|
||||
}
|
||||
|
||||
- (void) _appendDelegatorIdentities
|
||||
{
|
||||
NSArray *delegators;
|
||||
SOGoUser *delegatorUser;
|
||||
NSDictionary *delegatorAccount;
|
||||
NSInteger count, max;
|
||||
|
||||
delegators = [[SOGoUser userWithLogin: owner] mailDelegators];
|
||||
max = [delegators count];
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
delegatorUser = [SOGoUser
|
||||
userWithLogin: [delegators objectAtIndex: count]];
|
||||
if (delegatorUser)
|
||||
{
|
||||
delegatorAccount = [[delegatorUser mailAccounts]
|
||||
objectAtIndex: 0];
|
||||
[identities addObjectsFromArray:
|
||||
[delegatorAccount objectForKey: @"identities"]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray *) identities
|
||||
{
|
||||
return [[self _mailAccount] objectForKey: @"identities"];
|
||||
if (!identities)
|
||||
{
|
||||
identities = [[[self _mailAccount] objectForKey: @"identities"]
|
||||
mutableCopy];
|
||||
if ([nameInContainer isEqualToString: @"0"])
|
||||
[self _appendDelegatorIdentities];
|
||||
}
|
||||
|
||||
return identities;
|
||||
}
|
||||
|
||||
- (NSString *) signature
|
||||
{
|
||||
NSArray *identities;
|
||||
NSString *signature;
|
||||
|
||||
identities = [self identities];
|
||||
[self identities];
|
||||
if ([identities count] > 0)
|
||||
signature = [[identities objectAtIndex: 0] objectForKey: @"signature"];
|
||||
else
|
||||
@@ -766,6 +797,93 @@ static NSString *sieveScriptName = @"sogo";
|
||||
return trashFolder;
|
||||
}
|
||||
|
||||
/* account delegation */
|
||||
- (NSArray *) delegates
|
||||
{
|
||||
NSDictionary *mailSettings;
|
||||
SOGoUser *ownerUser;
|
||||
NSArray *delegates;
|
||||
|
||||
if ([nameInContainer isEqualToString: @"0"])
|
||||
{
|
||||
ownerUser = [SOGoUser userWithLogin: [self ownerInContext: context]];
|
||||
mailSettings = [[ownerUser userSettings] objectForKey: @"Mail"];
|
||||
delegates = [mailSettings objectForKey: @"DelegateTo"];
|
||||
if (!delegates)
|
||||
delegates = [NSArray array];
|
||||
}
|
||||
else
|
||||
delegates = nil;
|
||||
|
||||
return delegates;
|
||||
}
|
||||
|
||||
- (void) _setDelegates: (NSArray *) newDelegates
|
||||
{
|
||||
SOGoUser *ownerUser;
|
||||
SOGoUserSettings *settings;
|
||||
|
||||
ownerUser = [SOGoUser userWithLogin: [self ownerInContext: context]];
|
||||
settings = [ownerUser userSettings];
|
||||
[[settings objectForKey: @"Mail"] setObject: newDelegates
|
||||
forKey: @"DelegateTo"];
|
||||
[settings synchronize];
|
||||
}
|
||||
|
||||
- (void) addDelegates: (NSArray *) newDelegates
|
||||
{
|
||||
NSMutableArray *delegates;
|
||||
NSInteger count, max;
|
||||
NSString *currentDelegate;
|
||||
SOGoUser *delegateUser;
|
||||
|
||||
if ([nameInContainer isEqualToString: @"0"])
|
||||
{
|
||||
delegates = [[self delegates] mutableCopy];
|
||||
[delegates autorelease];
|
||||
max = [newDelegates count];
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
currentDelegate = [newDelegates objectAtIndex: 0];
|
||||
delegateUser = [SOGoUser userWithLogin: currentDelegate];
|
||||
if (delegateUser)
|
||||
{
|
||||
[delegates addObjectUniquely: currentDelegate];
|
||||
[delegateUser addMailDelegator: owner];
|
||||
}
|
||||
}
|
||||
|
||||
[self _setDelegates: delegates];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) removeDelegates: (NSArray *) oldDelegates
|
||||
{
|
||||
NSMutableArray *delegates;
|
||||
NSInteger count, max;
|
||||
NSString *currentDelegate;
|
||||
SOGoUser *delegateUser;
|
||||
|
||||
if ([nameInContainer isEqualToString: @"0"])
|
||||
{
|
||||
delegates = [[self delegates] mutableCopy];
|
||||
[delegates autorelease];
|
||||
max = [oldDelegates count];
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
currentDelegate = [oldDelegates objectAtIndex: 0];
|
||||
delegateUser = [SOGoUser userWithLogin: currentDelegate];
|
||||
if (delegateUser)
|
||||
{
|
||||
[delegates removeObject: currentDelegate];
|
||||
[delegateUser removeMailDelegator: owner];
|
||||
}
|
||||
}
|
||||
|
||||
[self _setDelegates: delegates];
|
||||
}
|
||||
}
|
||||
|
||||
/* WebDAV */
|
||||
|
||||
- (NSString *) davContentType
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/* SOGoUser+Mailer.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2010 Inverse inc.
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef SOGOUSER_MAILER_H
|
||||
#define SOGOUSER_MAILER_H
|
||||
|
||||
#import <SOGo/SOGoUser.h>
|
||||
|
||||
@interface SOGoUser (SOGoMailExtensions)
|
||||
|
||||
- (NSArray *) mailDelegators;
|
||||
- (void) addMailDelegator: (NSString *) newDelegator;
|
||||
- (void) removeMailDelegator: (NSString *) oldDelegator;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* SOGOUSER_MAILER_H */
|
||||
@@ -0,0 +1,77 @@
|
||||
/* SOGoUser+Mailer.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2010 Inverse inc.
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import <SOGo/NSArray+Utilities.h>
|
||||
#import <SOGo/SOGoUserSettings.h>
|
||||
|
||||
#import "SOGoUser+Mailer.h"
|
||||
|
||||
@implementation SOGoUser (SOGoMailExtensions)
|
||||
|
||||
- (NSArray *) mailDelegators
|
||||
{
|
||||
NSDictionary *mailSettings;
|
||||
NSArray *mailDelegators;
|
||||
|
||||
mailSettings = [[self userSettings] objectForKey: @"Mail"];
|
||||
mailDelegators = [mailSettings objectForKey: @"DelegateFrom"];
|
||||
if (!mailDelegators)
|
||||
mailDelegators = [NSArray array];
|
||||
|
||||
return mailDelegators;
|
||||
}
|
||||
|
||||
- (void) _setMailDelegators: (NSArray *) newDelegators
|
||||
{
|
||||
SOGoUserSettings *settings;
|
||||
|
||||
settings = [self userSettings];
|
||||
[[settings objectForKey: @"Mail"] setObject: newDelegators
|
||||
forKey: @"DelegateFrom"];
|
||||
[settings synchronize];
|
||||
}
|
||||
|
||||
- (void) addMailDelegator: (NSString *) newDelegator
|
||||
{
|
||||
NSMutableArray *delegators;
|
||||
|
||||
delegators = [[self mailDelegators] mutableCopy];
|
||||
[delegators autorelease];
|
||||
[delegators addObjectUniquely: newDelegator];
|
||||
|
||||
[self _setMailDelegators: delegators];
|
||||
}
|
||||
|
||||
- (void) removeMailDelegator: (NSString *) oldDelegator
|
||||
{
|
||||
NSMutableArray *delegators;
|
||||
|
||||
delegators = [[self mailDelegators] mutableCopy];
|
||||
[delegators autorelease];
|
||||
[delegators removeObject: oldDelegator];
|
||||
|
||||
[self _setMailDelegators: delegators];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -194,6 +194,8 @@
|
||||
"Delete Folder" = "Apagar Pasta";
|
||||
"Use This Folder For" = "Usar Esta Pasta Para";
|
||||
"Get Messages for Account" = "Receber Mensagens por Conta";
|
||||
"Properties..." = "Properties...";
|
||||
"Delegation..." = "Delegation...";
|
||||
|
||||
/* Use This Folder menu */
|
||||
"Sent Messages" = "Enviar Mensagens";
|
||||
|
||||
@@ -195,6 +195,8 @@
|
||||
"Delete Folder" = "Smazat složku";
|
||||
"Use This Folder For" = "Použít tuto složku pro";
|
||||
"Get Messages for Account" = "Stáhnout zprávy pro účet";
|
||||
"Properties..." = "Properties...";
|
||||
"Delegation..." = "Delegation...";
|
||||
|
||||
/* Use This Folder menu */
|
||||
"Sent Messages" = "Odeslané zprávy";
|
||||
|
||||
@@ -194,6 +194,8 @@
|
||||
"Delete Folder" = "Map verwijderen";
|
||||
"Use This Folder For" = "De map gebruiken voor...";
|
||||
"Get Messages for Account" = "Berichten ophalen voor account";
|
||||
"Properties..." = "Properties...";
|
||||
"Delegation..." = "Delegation...";
|
||||
|
||||
/* Use This Folder menu */
|
||||
"Sent Messages" = "Berichten verzenden";
|
||||
|
||||
@@ -194,6 +194,8 @@
|
||||
"Delete Folder" = "Delete Folder";
|
||||
"Use This Folder For" = "Use This Folder For";
|
||||
"Get Messages for Account" = "Get Messages for Account";
|
||||
"Properties..." = "Properties...";
|
||||
"Delegation..." = "Delegation...";
|
||||
|
||||
/* Use This Folder menu */
|
||||
"Sent Messages" = "Sent Messages";
|
||||
|
||||
@@ -194,6 +194,8 @@
|
||||
"Delete Folder" = "Supprimer le dossier...";
|
||||
"Use This Folder For" = "Utiliser ce dossier pour";
|
||||
"Get Messages for Account" = "Relever les messages de ce compte";
|
||||
"Properties..." = "Propriétés...";
|
||||
"Delegation..." = "Délégation...";
|
||||
|
||||
/* Use This Folder menu */
|
||||
"Sent Messages" = "les message envoyés";
|
||||
|
||||
@@ -32,6 +32,7 @@ MailerUI_OBJC_FILES += \
|
||||
UIxMailWindowCloser.m \
|
||||
\
|
||||
UIxMailUserRightsEditor.m \
|
||||
UIxMailUserDelegationEditor.m \
|
||||
# UIxMailEditorAction.m \
|
||||
# UIxMailReplyAction.m \
|
||||
# UIxMailForwardAction.m \
|
||||
|
||||
@@ -194,6 +194,8 @@
|
||||
"Delete Folder" = "Löschen";
|
||||
"Use This Folder For" = "Diesen Ordner verwenden für";
|
||||
"Get Messages for Account" = "Neue Nachrichten empfangen";
|
||||
"Properties..." = "Properties...";
|
||||
"Delegation..." = "Delegation...";
|
||||
|
||||
/* Use This Folder menu */
|
||||
"Sent Messages" = "Gesendete Nachrichten";
|
||||
|
||||
@@ -194,6 +194,8 @@
|
||||
"Delete Folder" = "Mappa törlése";
|
||||
"Use This Folder For" = "Mappa használata az alábbira:";
|
||||
"Get Messages for Account" = "Fiók üzeneteinek letöltése";
|
||||
"Properties..." = "Properties...";
|
||||
"Delegation..." = "Delegation...";
|
||||
|
||||
/* Use This Folder menu */
|
||||
"Sent Messages" = "Elküldött üzenetek";
|
||||
|
||||
@@ -189,6 +189,8 @@
|
||||
"Delete Folder" = "Cancella cartella";
|
||||
"Use This Folder For" = "Usa questa cartella per";
|
||||
"Get Messages for Account" = "Scarica messaggi per l'account";
|
||||
"Properties..." = "Properties...";
|
||||
"Delegation..." = "Delegation...";
|
||||
|
||||
/* Use This Folder menu */
|
||||
"Sent Messages" = "Messaggi inviati";
|
||||
|
||||
@@ -194,6 +194,8 @@
|
||||
"Delete Folder" = "Usuń folder";
|
||||
"Use This Folder For" = "Użyj tego foldera do";
|
||||
"Get Messages for Account" = "Pobierz wiadomości z konta";
|
||||
"Properties..." = "Properties...";
|
||||
"Delegation..." = "Delegation...";
|
||||
|
||||
/* Use This Folder menu */
|
||||
"Sent Messages" = "Wysłane";
|
||||
|
||||
@@ -194,6 +194,8 @@
|
||||
"Delete Folder" = "Удалить папку";
|
||||
"Use This Folder For" = "Использовать эту папку для";
|
||||
"Get Messages for Account" = "Получить новые сообщения";
|
||||
"Properties..." = "Properties...";
|
||||
"Delegation..." = "Delegation...";
|
||||
|
||||
/* Use This Folder menu */
|
||||
"Sent Messages" = "Отправленные сообщения";
|
||||
|
||||
@@ -194,6 +194,8 @@
|
||||
"Delete Folder" = "Borrar carpeta";
|
||||
"Use This Folder For" = "Usar esta carpeta para";
|
||||
"Get Messages for Account" = "Recibir mensajes para cuenta";
|
||||
"Properties..." = "Properties...";
|
||||
"Delegation..." = "Delegation...";
|
||||
|
||||
/* Use This Folder menu */
|
||||
"Sent Messages" = "Enviar mensajes";
|
||||
|
||||
@@ -194,6 +194,8 @@
|
||||
"Delete Folder" = "Ta bort mapp";
|
||||
"Use This Folder For" = "Använd mapp till";
|
||||
"Get Messages for Account" = "Hämta nya meddelanden för konto";
|
||||
"Properties..." = "Properties...";
|
||||
"Delegation..." = "Delegation...";
|
||||
|
||||
/* Use This Folder menu */
|
||||
"Sent Messages" = "Skickade meddelanden";
|
||||
|
||||
@@ -231,4 +231,41 @@
|
||||
return [self redirectToLocation: url];
|
||||
}
|
||||
|
||||
- (WOResponse *) _performDelegationAction: (SEL) action
|
||||
{
|
||||
SOGoMailAccount *co;
|
||||
WOResponse *response;
|
||||
NSString *uid;
|
||||
|
||||
co = [self clientObject];
|
||||
if ([[co nameInContainer] isEqualToString: @"0"])
|
||||
{
|
||||
uid = [[context request] formValueForKey: @"uid"];
|
||||
if ([uid length] > 0)
|
||||
{
|
||||
[co performSelector: action
|
||||
withObject: [NSArray arrayWithObject: uid]];
|
||||
response = [self responseWith204];
|
||||
}
|
||||
else
|
||||
response = [self responseWithStatus: 500
|
||||
andString: @"Missing 'uid' parameter."];
|
||||
}
|
||||
else
|
||||
response = [self responseWithStatus: 403
|
||||
andString: @"This action cannot be performed on secondary accounts."];
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
- (WOResponse *) addDelegateAction
|
||||
{
|
||||
return [self _performDelegationAction: @selector (addDelegates:)];
|
||||
}
|
||||
|
||||
- (WOResponse *) removeDelegateAction
|
||||
{
|
||||
return [self _performDelegationAction: @selector (removeDelegates:)];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
/* UIxMailUserDelegationEditor.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2010 Inverse inc.
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import <SOGo/SOGoUserManager.h>
|
||||
#import <Mailer/SOGoMailAccount.h>
|
||||
|
||||
#import <SOGoUI/UIxComponent.h>
|
||||
|
||||
@interface UIxMailUserDelegationEditor : UIxComponent
|
||||
{
|
||||
NSArray *delegates;
|
||||
NSString *currentDelegate;
|
||||
}
|
||||
|
||||
- (NSArray *) delegates;
|
||||
- (void) setCurrentDelegate: (NSString *) newCurrentDelegate;
|
||||
- (NSString *) currentDelegate;
|
||||
|
||||
@end
|
||||
|
||||
@implementation UIxMailUserDelegationEditor
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
delegates = nil;
|
||||
currentDelegate = nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[delegates release];
|
||||
[currentDelegate release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSArray *) delegates
|
||||
{
|
||||
if (!delegates)
|
||||
{
|
||||
delegates = [[self clientObject] delegates];
|
||||
[delegates retain];
|
||||
}
|
||||
|
||||
return delegates;
|
||||
}
|
||||
|
||||
- (void) setCurrentDelegate: (NSString *) newCurrentDelegate
|
||||
{
|
||||
ASSIGN (currentDelegate, newCurrentDelegate);
|
||||
}
|
||||
|
||||
- (NSString *) currentDelegate
|
||||
{
|
||||
return currentDelegate;
|
||||
}
|
||||
|
||||
- (NSString *) currentDelegateDisplayName
|
||||
{
|
||||
SOGoUserManager *um;
|
||||
NSString *s;
|
||||
|
||||
um = [SOGoUserManager sharedUserManager];
|
||||
s = ([currentDelegate hasPrefix: @"@"]
|
||||
? [currentDelegate substringFromIndex: 1]
|
||||
: currentDelegate);
|
||||
|
||||
return [um getFullEmailForUID: s];
|
||||
}
|
||||
|
||||
- (id) defaultAction
|
||||
{
|
||||
id response;
|
||||
SOGoMailAccount *co;
|
||||
|
||||
co = [self clientObject];
|
||||
if ([[co nameInContainer] isEqualToString: @"0"])
|
||||
response = self;
|
||||
else
|
||||
response = [self responseWithStatus: 403
|
||||
andString: @"The list of account delegates cannot be modified on secondary accounts."];
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -194,6 +194,8 @@
|
||||
"Delete Folder" = "Вилучити";
|
||||
"Use This Folder For" = "Використати цю теку як";
|
||||
"Get Messages for Account" = "Отримати нові повідомлення";
|
||||
"Properties..." = "Properties...";
|
||||
"Delegation..." = "Delegation...";
|
||||
|
||||
/* Use This Folder menu */
|
||||
"Sent Messages" = "Відіслані";
|
||||
|
||||
@@ -194,6 +194,8 @@
|
||||
"Delete Folder" = "Dileu Ffolder";
|
||||
"Use This Folder For" = "Defyddio'r Ffolder yma am";
|
||||
"Get Messages for Account" = "Cael negeseuon ar gyfer Cyfrif";
|
||||
"Properties..." = "Properties...";
|
||||
"Delegation..." = "Delegation...";
|
||||
|
||||
/* Use This Folder menu */
|
||||
"Sent Messages" = "Negeseuon anfonwyd";
|
||||
|
||||
@@ -393,6 +393,20 @@
|
||||
actionClass = "UIxMailFolderActions";
|
||||
actionName = "createFolder";
|
||||
};
|
||||
delegation = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxMailUserDelegationEditor";
|
||||
};
|
||||
addDelegate = {
|
||||
protectedBy = "View";
|
||||
actionClass = "UIxMailAccountActions";
|
||||
actionName = "addDelegate";
|
||||
};
|
||||
removeDelegate = {
|
||||
protectedBy = "View";
|
||||
actionClass = "UIxMailAccountActions";
|
||||
actionName = "removeDelegate";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -38,9 +38,9 @@
|
||||
<li><var:string label:value="Subscribe..." /></li>
|
||||
<li><var:string label:value="Get Messages for Account" /></li>
|
||||
<li><var:string label:value="New Folder..." /></li>
|
||||
<li><!-- separator --></li>
|
||||
<li><var:string label:value="Search Messages..." /></li>
|
||||
<li><var:string label:value="Properties..." /></li>
|
||||
<li><var:string label:value="Delegation..." /></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" standalone="yes"?>
|
||||
<!DOCTYPE var:component>
|
||||
<var:component xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:var="http://www.skyrix.com/od/binding"
|
||||
xmlns:const="http://www.skyrix.com/od/constant"
|
||||
xmlns:uix="OGo:uix"
|
||||
xmlns:label="OGo:label"
|
||||
xmlns:rsrc="OGo:url"
|
||||
className="UIxPageFrame"
|
||||
title="title"
|
||||
const:toolbar="none"
|
||||
const:popup="YES">
|
||||
|
||||
<form id="delegationForm" const:href="saveDelegation">
|
||||
<div class="delegation">
|
||||
<div class="delegateSelector" id="delegates">
|
||||
<div id="delegateSelectorButtons">
|
||||
<a href="#" id="addDelegate" class="smallToolbarButton"><span>
|
||||
<img rsrc:src="add-contact.gif" label:title="Add..." /></span></a>
|
||||
<a href="#" id="deleteDelegate" class="smallToolbarButton"><span>
|
||||
<img rsrc:src="remove-contact.gif" label:title="Remove" /></span></a>
|
||||
</div>
|
||||
<ul id="delegateList">
|
||||
<var:foreach list="delegates" item="currentDelegate"
|
||||
><li var:id="currentDelegate" class="normal-user">
|
||||
<span class="userFullName"
|
||||
><var:string value="currentDelegateDisplayName"
|
||||
/></span
|
||||
></li>
|
||||
</var:foreach>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</var:component>
|
||||
@@ -2370,6 +2370,28 @@ function onMessageListMenuPrepareVisibility() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function onAccountIconMenuPrepareVisibility() {
|
||||
/* This methods disables or enables the "Delegation..." menu option on
|
||||
mail accounts. */
|
||||
if (document.menuTarget) {
|
||||
var mbx = document.menuTarget.getAttribute("dataname");
|
||||
if (mbx) {
|
||||
var lis = this.getElementsByTagName("li");
|
||||
var li = lis[lis.length - 1];
|
||||
var parts = mbx.split("/");
|
||||
var acctNbr = parseInt(parts[1]);
|
||||
if (acctNbr > 0) {
|
||||
li.addClassName("disabled");
|
||||
}
|
||||
else {
|
||||
li.removeClassName("disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function onFolderMenuPrepareVisibility() {
|
||||
/* This methods disables or enables the "Sharing" menu option on
|
||||
mailboxes. */
|
||||
@@ -2485,9 +2507,15 @@ function onMenuArchiveFolder(event) {
|
||||
event.stop();
|
||||
}
|
||||
|
||||
function onMenuAccountDelegation(event) {
|
||||
var folderID = document.menuTarget.getAttribute("dataname");
|
||||
var urlstr = ApplicationBaseURL + folderID + "/delegation";
|
||||
openAclWindow(urlstr);
|
||||
}
|
||||
|
||||
function getMenus() {
|
||||
var menus = {
|
||||
accountIconMenu: [ null, null, onMenuCreateFolder, null, null, null ],
|
||||
accountIconMenu: [ null, null, onMenuCreateFolder, null, null, onMenuAccountDelegation ],
|
||||
inboxIconMenu: [ null, null, null, "-", null,
|
||||
onMenuCreateFolder, onMenuExpungeFolder,
|
||||
onMenuArchiveFolder, "-", null,
|
||||
@@ -2555,6 +2583,11 @@ function getMenus() {
|
||||
labelMenu.prepareVisibility = onLabelMenuPrepareVisibility;
|
||||
}
|
||||
|
||||
var labelMenu = $("label-menu");
|
||||
if (labelMenu) {
|
||||
labelMenu.prepareVisibility = onLabelMenuPrepareVisibility;
|
||||
}
|
||||
|
||||
var markMenu = $("mark-menu");
|
||||
if (markMenu) {
|
||||
markMenu.prepareVisibility = onMarkMenuPrepareVisibility;
|
||||
@@ -2568,6 +2601,11 @@ function getMenus() {
|
||||
}
|
||||
}
|
||||
|
||||
var accountIconMenu = $("accountIconMenu");
|
||||
if (accountIconMenu) {
|
||||
accountIconMenu.prepareVisibility = onAccountIconMenuPrepareVisibility;
|
||||
}
|
||||
|
||||
var folderMenus = [ "inboxIconMenu", "trashIconMenu", "mailboxIconMenu" ];
|
||||
for (var i = 0; i < folderMenus.length; i++) {
|
||||
var menu = $(folderMenus[i]);
|
||||
|
||||
@@ -205,7 +205,7 @@ function onConfirmFolderSelection(event) {
|
||||
var email = (span.innerHTML
|
||||
.replace("<", "<", "g")
|
||||
.replace(">", ">", "g"));
|
||||
folderName = email;
|
||||
folderName = email.replace(/>,.*$/, ">", "g");
|
||||
}
|
||||
else {
|
||||
var resource = $(topNode.selectedEntry).down("SPAN.nodeName");
|
||||
@@ -214,8 +214,8 @@ function onConfirmFolderSelection(event) {
|
||||
.replace("<", "<", "g")
|
||||
.replace(">", ">", "g"));
|
||||
folderName = resource.innerHTML + ' (' + email + ')';
|
||||
folderName = folderName.replace(/>,.*(\))?$/, ">)$1", "g");
|
||||
}
|
||||
folderName = folderName.replace(/>,.*(\))?$/, ">)$1", "g");
|
||||
|
||||
var data = { folderName: folderName, folder: folder, window: window };
|
||||
if (parent$(accessToSubscribedFolder(folder)))
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
DIV.delegation
|
||||
{ position: absolute;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
right: 0px;
|
||||
bottom: 0px;
|
||||
padding: 0px;
|
||||
border: 0px;
|
||||
margin: 0px; }
|
||||
|
||||
DIV.delegation LABEL
|
||||
{ white-space: nowrap;
|
||||
width: 100%; }
|
||||
|
||||
#delegateRoles
|
||||
{ position: absolute;
|
||||
top: 5px;
|
||||
left: 0px;
|
||||
right: 0px;
|
||||
bottom: 0px; }
|
||||
|
||||
#delegateSelectorButtons
|
||||
{ margin-left: 5px;
|
||||
padding-bottom: 2px; }
|
||||
|
||||
UL#delegateList
|
||||
{ position: absolute;
|
||||
left: 0px;
|
||||
right: 0px;
|
||||
top: 40px;
|
||||
bottom: 0px;
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
white-space: nowrap;
|
||||
overflow: auto;
|
||||
border-bottom: 1px solid #fff;
|
||||
border-right: 1px solid #fff;
|
||||
border-top: 1px solid #909090;
|
||||
border-left: 1px solid #909090;
|
||||
background-color: #CCDDEC;
|
||||
list-style-type: none;
|
||||
list-style-image: none; }
|
||||
|
||||
UL#delegateList LI
|
||||
{ clear: both;
|
||||
cursor: pointer;
|
||||
height: 20px;
|
||||
margin-left: 0px;
|
||||
padding-left: 24px;
|
||||
background-repeat: no-repeat;
|
||||
background-position: 4px center;
|
||||
background-image: url("abcard.png"); }
|
||||
|
||||
DIV#delegateSelectorButtons A.smallToolbarButton
|
||||
{ float: left; }
|
||||
|
||||
SPAN.userFullName
|
||||
{ margin-top: 2px; }
|
||||
@@ -0,0 +1,111 @@
|
||||
var contactSelectorAction = 'delegation-contacts';
|
||||
|
||||
function addDelegate(delegateName, delegateID) {
|
||||
var result = false;
|
||||
if (!$(delegateID)) {
|
||||
var ul = $("delegateList");
|
||||
var newNode = nodeForDelegate(delegateName, delegateID);
|
||||
ul.appendChild(newNode);
|
||||
|
||||
var url = window.location.href;
|
||||
var elements = url.split("/");
|
||||
elements[elements.length-1] = ("addDelegate?uid="
|
||||
+ delegateID);
|
||||
triggerAjaxRequest(elements.join("/"), addDelegateCallback, newNode);
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function addDelegateCallback(http) {
|
||||
if (http.readyState == 4) {
|
||||
if (!isHttpStatus204(http.status)) {
|
||||
var node = http.callbackData;
|
||||
node.parentNode.removeChild(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setEventsOnDelegateNode(node) {
|
||||
node.observe("mousedown", listRowMouseDownHandler);
|
||||
node.observe("selectstart", listRowMouseDownHandler);
|
||||
node.observe("click", onRowClick);
|
||||
}
|
||||
|
||||
function nodeForDelegate(delegateName, delegateId) {
|
||||
var node = createElement("li");
|
||||
node.id = delegateId;
|
||||
|
||||
var span = createElement("span");
|
||||
span.addClassName("userFullName");
|
||||
span.appendChild(document.createTextNode(" " + delegateName));
|
||||
node.appendChild(span);
|
||||
|
||||
setEventsOnDelegateNode(node);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function onDelegateAdd(event) {
|
||||
openUserFolderSelector(null, "user");
|
||||
|
||||
preventDefault(event);
|
||||
}
|
||||
|
||||
function removeDelegateCallback(http) {
|
||||
var node = http.callbackData;
|
||||
|
||||
if (http.readyState == 4
|
||||
&& isHttpStatus204(http.status))
|
||||
node.parentNode.removeChild(node);
|
||||
else
|
||||
log("error deleting delegate: " + node.getAttribute("id"));
|
||||
}
|
||||
|
||||
function onDelegateRemove(event) {
|
||||
var delegateList = $("delegateList");
|
||||
var nodes = delegateList.getSelectedRows();
|
||||
|
||||
var url = window.location.href;
|
||||
var elements = url.split("/");
|
||||
elements[elements.length-1] = "removeDelegate?uid=";
|
||||
var baseURL = elements.join("/");
|
||||
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
var delegateId = nodes[i].id;
|
||||
triggerAjaxRequest(baseURL + delegateId, removeDelegateCallback,
|
||||
nodes[i]);
|
||||
}
|
||||
preventDefault(event);
|
||||
}
|
||||
|
||||
function subscribeToFolder(refreshCallback, refreshCallbackData) {
|
||||
var result = true;
|
||||
if (UserLogin != refreshCallbackData["folder"]) {
|
||||
result = addDelegate(refreshCallbackData["folderName"],
|
||||
refreshCallbackData["folder"]);
|
||||
}
|
||||
else
|
||||
refreshCallbackData["window"].alert(_("You cannot subscribe to a folder that you own!"));
|
||||
return result;
|
||||
}
|
||||
|
||||
function onDelegationLoadHandler() {
|
||||
var ul = $("delegateList");
|
||||
var lis = ul.childNodesWithTag("li");
|
||||
for (var i = 0; i < lis.length; i++)
|
||||
setEventsOnDelegateNode(lis[i]);
|
||||
|
||||
var buttonArea = $("delegateSelectorButtons");
|
||||
if (buttonArea) {
|
||||
var buttons = buttonArea.childNodesWithTag("a");
|
||||
$("addDelegate").stopObserving ("click");
|
||||
$("deleteDelegate").stopObserving ("click");
|
||||
$("addDelegate").observe("mousedown", onDelegateAdd);
|
||||
$("deleteDelegate").observe("mousedown", onDelegateRemove);
|
||||
}
|
||||
|
||||
Event.observe(window, "unload", onDelegationCloseHandler);
|
||||
}
|
||||
|
||||
document.observe("dom:loaded", onDelegationLoadHandler);
|
||||
Reference in New Issue
Block a user