See ChangeLog
Monotone-Parent: f4d1aaac3bdf07ab4ee67974f65577c30c1bb0fe Monotone-Revision: ec9c129ca2ad9336942f829750ea17901e60315b Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2007-10-14T16:07:22 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
cb0d2b7051
commit
7d182c760f
|
@ -1,3 +1,12 @@
|
|||
2007-10-10 Ludovic Marcotte <ludovic@inverse.ca>
|
||||
|
||||
* We now send advisory emails when folders
|
||||
are created / deleted.
|
||||
|
||||
* Fixed the sending of advisory emails upon
|
||||
ACL changes on folders.
|
||||
|
||||
|
||||
2007-10-10 Ludovic Marcotte <ludovic@inverse.ca>
|
||||
|
||||
* UI/Scheduler/UIxComponentEditor.m
|
||||
|
|
|
@ -585,7 +585,7 @@ static BOOL useAltNamespace = NO;
|
|||
return userPath;
|
||||
}
|
||||
|
||||
- (NSString *) httpURLForAdvisoryToUser: (NSString *) uid;
|
||||
- (NSString *) httpURLForAdvisoryToUser: (NSString *) uid
|
||||
{
|
||||
SOGoUser *user;
|
||||
NSString *otherUsersPath, *url;
|
||||
|
@ -609,7 +609,7 @@ static BOOL useAltNamespace = NO;
|
|||
return url;
|
||||
}
|
||||
|
||||
- (NSString *) resourceURLForAdvisoryToUser: (NSString *) uid;
|
||||
- (NSString *) resourceURLForAdvisoryToUser: (NSString *) uid
|
||||
{
|
||||
NSURL *selfURL, *userURL;
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#import <NGObjWeb/SoObject+SoDAV.h>
|
||||
#import <NGObjWeb/SoSelectorInvocation.h>
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
#import <NGObjWeb/WOApplication.h>
|
||||
#import <NGExtensions/NSNull+misc.h>
|
||||
#import <NGExtensions/NSObject+Logs.h>
|
||||
#import <EOControl/EOQualifier.h>
|
||||
|
@ -41,6 +42,7 @@
|
|||
#import <GDLContentStore/GCSFolderType.h>
|
||||
#import <GDLContentStore/NSURL+GCS.h>
|
||||
#import <SaxObjC/XMLNamespaces.h>
|
||||
#import <UI/SOGoUI/SOGoFolderAdvisory.h>
|
||||
|
||||
#import "NSArray+Utilities.h"
|
||||
#import "NSString+Utilities.h"
|
||||
|
@ -255,15 +257,35 @@ static NSString *defaultUserID = @"<default>";
|
|||
return @"";
|
||||
}
|
||||
|
||||
- (void) sendFolderAdvisoryTemplate: (NSString *) template
|
||||
{
|
||||
NSString *language, *pageName;
|
||||
SOGoUser *user;
|
||||
SOGoFolderAdvisory *page;
|
||||
WOApplication *app;
|
||||
|
||||
user = [SOGoUser userWithLogin: [[context activeUser] login] roles: nil];
|
||||
language = [user language];
|
||||
pageName = [NSString stringWithFormat: @"SOGoFolder%@%@Advisory",
|
||||
language, template];
|
||||
|
||||
app = [WOApplication application];
|
||||
page = [app pageWithName: pageName inContext: context];
|
||||
[page setFolderObject: self];
|
||||
[page setRecipientUID: [[context activeUser] login]];
|
||||
[page send];
|
||||
}
|
||||
|
||||
- (BOOL) create
|
||||
{
|
||||
NSException *result;
|
||||
|
||||
// [self dieHard];
|
||||
result = [[self folderManager] createFolderOfType: [self folderType]
|
||||
withName: displayName
|
||||
atPath: ocsPath];
|
||||
|
||||
if (!result) [self sendFolderAdvisoryTemplate: @"Addition"];
|
||||
|
||||
return (result == nil);
|
||||
}
|
||||
|
||||
|
@ -271,12 +293,17 @@ static NSString *defaultUserID = @"<default>";
|
|||
{
|
||||
NSException *error;
|
||||
|
||||
// We just fetch our displayName since our table will use it!
|
||||
[self displayName];
|
||||
|
||||
if ([nameInContainer isEqualToString: @"personal"])
|
||||
error = [NSException exceptionWithHTTPStatus: 403
|
||||
reason: @"folder 'personal' cannot be deleted"];
|
||||
else
|
||||
error = [[self folderManager] deleteFolderAtPath: ocsPath];
|
||||
|
||||
if (!error) [self sendFolderAdvisoryTemplate: @"Removal"];
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@ libSOGoUI_OBJC_FILES += \
|
|||
SOGoAptFormatter.m \
|
||||
SOGoJSStringFormatter.m \
|
||||
WOContext+UIx.m \
|
||||
\
|
||||
SOGoACLAdvisory.m
|
||||
SOGoACLAdvisory.m \
|
||||
SOGoFolderAdvisory.m
|
||||
|
||||
# make
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@
|
|||
- (NSString *) aclMethod
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
@ -211,19 +211,25 @@
|
|||
@end
|
||||
|
||||
@implementation SOGoACLEnglishAdditionAdvisory
|
||||
- (NSString *) aclMethod { return @"add"; }
|
||||
@end
|
||||
|
||||
@implementation SOGoACLEnglishRemovalAdvisory
|
||||
- (NSString *) aclMethod { return @"remove"; }
|
||||
@end
|
||||
|
||||
@implementation SOGoACLFrenchAdditionAdvisory
|
||||
- (NSString *) aclMethod { return @"add"; }
|
||||
@end
|
||||
|
||||
@implementation SOGoACLFrenchRemovalAdvisory
|
||||
- (NSString *) aclMethod { return @"remove"; }
|
||||
@end
|
||||
|
||||
@implementation SOGoACLGermanAdditionAdvisory
|
||||
- (NSString *) aclMethod { return @"add"; }
|
||||
@end
|
||||
|
||||
@implementation SOGoACLGermanRemovalAdvisory
|
||||
- (NSString *) aclMethod { return @"remove"; }
|
||||
@end
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
/* SOGoFolderAdvisory.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2007 Inverse groupe conseil
|
||||
*
|
||||
* Author: Ludovic Marcotte <ludovic@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 SOGOFOLDERADVISORY_H
|
||||
#define SOGOFOLDERADVISORY_H
|
||||
|
||||
#import "UIxComponent.h"
|
||||
#import "../../SoObjects/SOGo/SOGoFolder.h"
|
||||
|
||||
@interface SOGoFolderAdvisory : UIxComponent
|
||||
{
|
||||
NSString *recipientUID;
|
||||
SOGoFolder *folderObject;
|
||||
BOOL isSubject;
|
||||
BOOL isBody;
|
||||
}
|
||||
|
||||
- (void) setFolderObject: (SOGoFolder *) theFolder;
|
||||
- (void) setRecipientUID: (NSString *) newRecipientUID;
|
||||
- (void) send;
|
||||
|
||||
- (BOOL) isSubject;
|
||||
- (BOOL) isBody;
|
||||
|
||||
- (NSString *) subject;
|
||||
- (NSString *) body;
|
||||
- (NSString *) folderMethod;
|
||||
|
||||
@end
|
||||
|
||||
@interface SOGoFolderEnglishAdditionAdvisory : SOGoFolderAdvisory
|
||||
@end
|
||||
|
||||
@interface SOGoFolderEnglishRemovalAdvisory : SOGoFolderAdvisory
|
||||
@end
|
||||
|
||||
@interface SOGoFolderFrenchAdditionAdvisory : SOGoFolderAdvisory
|
||||
@end
|
||||
|
||||
@interface SOGoFolderFrenchRemovalAdvisory : SOGoFolderAdvisory
|
||||
@end
|
||||
|
||||
@interface SOGoFolderGermanAdditionAdvisory : SOGoFolderAdvisory
|
||||
@end
|
||||
|
||||
@interface SOGoFolderGermanRemovalAdvisory : SOGoFolderAdvisory
|
||||
@end
|
||||
|
||||
#endif /* SOGOFOLDERADVISORY_H */
|
|
@ -0,0 +1,227 @@
|
|||
/* SOGoFolderAdvisory.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2007 Inverse groupe conseil
|
||||
*
|
||||
* Author: Ludovic Marcotte <ludovic@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import <NGObjWeb/WOResponse.h>
|
||||
#import <NGExtensions/NGHashMap.h>
|
||||
#import <NGMail/NGMimeMessage.h>
|
||||
#import <NGMime/NGMimeBodyPart.h>
|
||||
#import <NGMime/NGMimeMultipartBody.h>
|
||||
|
||||
#import <SoObjects/SOGo/SOGoMailer.h>
|
||||
#import <SoObjects/SOGo/SOGoUser.h>
|
||||
#import <SoObjects/SOGo/SOGoObject.h>
|
||||
#import <SoObjects/SOGo/LDAPUserManager.h>
|
||||
#import <SoObjects/SOGo/NSCalendarDate+SOGo.h>
|
||||
|
||||
#import "SOGoFolderAdvisory.h"
|
||||
|
||||
@implementation SOGoFolderAdvisory
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
recipientUID = nil;
|
||||
folderObject = nil;
|
||||
isSubject = NO;
|
||||
isBody = NO;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[recipientUID release];
|
||||
[folderObject release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) setFolderObject: (SOGoFolder *) theFolder
|
||||
{
|
||||
ASSIGN(folderObject, theFolder);
|
||||
}
|
||||
|
||||
- (void) setRecipientUID: (NSString *) newRecipientUID
|
||||
{
|
||||
ASSIGN (recipientUID, newRecipientUID);
|
||||
}
|
||||
|
||||
- (BOOL) isSubject
|
||||
{
|
||||
return isSubject;
|
||||
}
|
||||
|
||||
- (BOOL) isBody
|
||||
{
|
||||
return isBody;
|
||||
}
|
||||
|
||||
- (NSString *) displayName
|
||||
{
|
||||
return [folderObject displayName];
|
||||
}
|
||||
|
||||
- (NSString *) httpFolderURL
|
||||
{
|
||||
NSMutableString *url;
|
||||
|
||||
#warning the url returned by SOGoMail may be empty, we need to handle that
|
||||
url = [NSMutableString stringWithString: [[folderObject soURL] absoluteString]];
|
||||
|
||||
if (![url hasSuffix: @"/"])
|
||||
[url appendString: @"/"];
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
- (NSString *) subject
|
||||
{
|
||||
NSString *subject;
|
||||
|
||||
isSubject = YES;
|
||||
subject = [[self generateResponse] contentAsString];
|
||||
isSubject = NO;
|
||||
|
||||
return [subject stringByTrimmingSpaces];
|
||||
}
|
||||
|
||||
- (NSString *) body
|
||||
{
|
||||
NSString *body;
|
||||
|
||||
isBody = YES;
|
||||
body = [[self generateResponse] contentAsString];
|
||||
isBody = NO;
|
||||
|
||||
return [body stringByTrimmingSpaces];
|
||||
}
|
||||
|
||||
- (NSString *) folderMethod
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NGMimeBodyPart *) _textPart
|
||||
{
|
||||
NGMutableHashMap *headerMap;
|
||||
NGMimeBodyPart *part;
|
||||
NSData *body;
|
||||
|
||||
headerMap = [NGMutableHashMap hashMapWithCapacity: 1];
|
||||
[headerMap setObject: @"text/plain; charset=utf-8" forKey: @"content-type"];
|
||||
|
||||
part = [NGMimeBodyPart bodyPartWithHeader: headerMap];
|
||||
body = [[self body] dataUsingEncoding: NSUTF8StringEncoding];
|
||||
[part setBody: [self body]];
|
||||
|
||||
return part;
|
||||
}
|
||||
|
||||
- (NGMimeBodyPart *) _sogoNotificationPart
|
||||
{
|
||||
NGMutableHashMap *headerMap;
|
||||
NGMimeBodyPart *part;
|
||||
NSData *body;
|
||||
|
||||
/* calendar part */
|
||||
headerMap = [NGMutableHashMap hashMapWithCapacity: 1];
|
||||
[headerMap setObject: [NSString stringWithFormat:
|
||||
@"%@; method=%@; type=%@; charset=%@",
|
||||
@"application/x-sogo-notification",
|
||||
[self folderMethod], [folderObject folderType],
|
||||
@"utf-8"]
|
||||
forKey: @"content-type"];
|
||||
|
||||
part = [NGMimeBodyPart bodyPartWithHeader: headerMap];
|
||||
body = [[self httpFolderURL] dataUsingEncoding: NSUTF8StringEncoding];
|
||||
[part setBody: body];
|
||||
|
||||
return part;
|
||||
}
|
||||
|
||||
- (void) send
|
||||
{
|
||||
NSString *recipient, *date;
|
||||
NGMutableHashMap *headerMap;
|
||||
NGMimeMessage *message;
|
||||
NGMimeMultipartBody *body;
|
||||
SOGoUser *activeUser;
|
||||
NSDictionary *identity;
|
||||
NSString *from, *fullMail;
|
||||
|
||||
activeUser = [context activeUser];
|
||||
identity = [activeUser primaryIdentity];
|
||||
from = [identity objectForKey: @"email"];
|
||||
fullMail = [NSString stringWithFormat: @"%@ <%@>",
|
||||
[identity objectForKey: @"fullName"], from];
|
||||
|
||||
recipient = [[LDAPUserManager sharedUserManager]
|
||||
getFullEmailForUID: recipientUID];
|
||||
|
||||
headerMap = [NGMutableHashMap hashMapWithCapacity: 5];
|
||||
[headerMap setObject: @"multipart/alternative" forKey: @"content-type"];
|
||||
[headerMap setObject: fullMail forKey: @"From"];
|
||||
[headerMap setObject: recipient forKey: @"To"];
|
||||
date = [[NSCalendarDate date] rfc822DateString];
|
||||
[headerMap setObject: date forKey: @"Date"];
|
||||
[headerMap setObject: [self subject] forKey: @"Subject"];
|
||||
message = [NGMimeMessage messageWithHeader: headerMap];
|
||||
|
||||
body = [[NGMimeMultipartBody alloc] initWithPart: message];
|
||||
[body addBodyPart: [self _textPart]];
|
||||
[body addBodyPart: [self _sogoNotificationPart]];
|
||||
[message setBody: body];
|
||||
[body release];
|
||||
|
||||
[[SOGoMailer sharedMailer] sendMimePart: message
|
||||
toRecipients: [NSArray arrayWithObject: recipient]
|
||||
sender: from];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation SOGoFolderEnglishAdditionAdvisory
|
||||
- (NSString *) folderMethod { return @"add"; }
|
||||
@end
|
||||
|
||||
@implementation SOGoFolderEnglishRemovalAdvisory
|
||||
- (NSString *) folderMethod { return @"remove"; }
|
||||
@end
|
||||
|
||||
@implementation SOGoFolderFrenchAdditionAdvisory
|
||||
- (NSString *) folderMethod { return @"add"; }
|
||||
@end
|
||||
|
||||
@implementation SOGoFolderFrenchRemovalAdvisory
|
||||
- (NSString *) folderMethod { return @"remove"; }
|
||||
@end
|
||||
|
||||
@implementation SOGoFolderGermanAdditionAdvisory
|
||||
- (NSString *) folderMethod { return @"add"; }
|
||||
@end
|
||||
|
||||
@implementation SOGoFolderGermanRemovalAdvisory
|
||||
- (NSString *) folderMethod { return @"remove"; }
|
||||
@end
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" standalone="yes"?>
|
||||
<!DOCTYPE container>
|
||||
<container
|
||||
xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:var="http://www.skyrix.com/od/binding"
|
||||
xmlns:const="http://www.skyrix.com/od/constant"
|
||||
xmlns:rsrc="OGo:url"
|
||||
xmlns:label="OGo:label">
|
||||
|
||||
<var:if condition="isSubject">
|
||||
<var:string value="displayName"/> has been created
|
||||
</var:if>
|
||||
|
||||
<var:if condition="isBody">
|
||||
The <var:string value="displayName"/> folder has been created.
|
||||
|
||||
You can access this resource remotely by using the following URL:
|
||||
|
||||
<var:string value="httpFolderURL"/>
|
||||
</var:if>
|
||||
|
||||
</container>
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" standalone="yes"?>
|
||||
<!DOCTYPE container>
|
||||
<container
|
||||
xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:var="http://www.skyrix.com/od/binding"
|
||||
xmlns:const="http://www.skyrix.com/od/constant"
|
||||
xmlns:rsrc="OGo:url"
|
||||
xmlns:label="OGo:label">
|
||||
|
||||
<var:if condition="isSubject">
|
||||
<var:string value="displayName"/> has been deleted
|
||||
</var:if>
|
||||
|
||||
<var:if condition="isBody">
|
||||
The <var:string value="displayName"/> folder has been deleted.
|
||||
|
||||
The following URL is now no longer active:
|
||||
|
||||
<var:string value="httpFolderURL"/>
|
||||
</var:if>
|
||||
|
||||
</container>
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" standalone="yes"?>
|
||||
<!DOCTYPE container>
|
||||
<container
|
||||
xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:var="http://www.skyrix.com/od/binding"
|
||||
xmlns:const="http://www.skyrix.com/od/constant"
|
||||
xmlns:rsrc="OGo:url"
|
||||
xmlns:label="OGo:label">
|
||||
|
||||
<var:if condition="isSubject">
|
||||
<var:string value="displayName"/> a été créé
|
||||
</var:if>
|
||||
|
||||
<var:if condition="isBody">
|
||||
Le dossier <var:string value="displayName"/> a été créé.
|
||||
|
||||
Vous pouvez accèder à distance à ce dossier avec le lien suivant:
|
||||
|
||||
<var:string value="httpFolderURL"/>
|
||||
</var:if>
|
||||
|
||||
</container>
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" standalone="yes"?>
|
||||
<!DOCTYPE container>
|
||||
<container
|
||||
xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:var="http://www.skyrix.com/od/binding"
|
||||
xmlns:const="http://www.skyrix.com/od/constant"
|
||||
xmlns:rsrc="OGo:url"
|
||||
xmlns:label="OGo:label">
|
||||
|
||||
<var:if condition="isSubject">
|
||||
<var:string value="displayName"/> a été supprimé
|
||||
</var:if>
|
||||
|
||||
<var:if condition="isBody">
|
||||
Le dossier <var:string value="displayName"/> a été supprimé.
|
||||
|
||||
Le lien suivant n'est plus actif:
|
||||
|
||||
<var:string value="httpFolderURL"/>
|
||||
</var:if>
|
||||
|
||||
</container>
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" standalone="yes"?>
|
||||
<!DOCTYPE container>
|
||||
<container
|
||||
xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:var="http://www.skyrix.com/od/binding"
|
||||
xmlns:const="http://www.skyrix.com/od/constant"
|
||||
xmlns:rsrc="OGo:url"
|
||||
xmlns:label="OGo:label">
|
||||
|
||||
<var:if condition="isSubject">
|
||||
<var:string value="displayName"/> has been created
|
||||
</var:if>
|
||||
|
||||
<var:if condition="isBody">
|
||||
The <var:string value="displayName"/> folder has been created.
|
||||
|
||||
You can access this resource remotely by using the following URL:
|
||||
|
||||
<var:string value="httpFolderURL"/>
|
||||
</var:if>
|
||||
|
||||
</container>
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" standalone="yes"?>
|
||||
<!DOCTYPE container>
|
||||
<container
|
||||
xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:var="http://www.skyrix.com/od/binding"
|
||||
xmlns:const="http://www.skyrix.com/od/constant"
|
||||
xmlns:rsrc="OGo:url"
|
||||
xmlns:label="OGo:label">
|
||||
|
||||
<var:if condition="isSubject">
|
||||
<var:string value="displayName"/> has been deleted
|
||||
</var:if>
|
||||
|
||||
<var:if condition="isBody">
|
||||
The <var:string value="displayName"/> folder has been deleted.
|
||||
|
||||
The following URL is now no longer active:
|
||||
|
||||
<var:string value="httpFolderURL"/>
|
||||
</var:if>
|
||||
|
||||
</container>
|
Loading…
Reference in New Issue