Monotone-Parent: 1cdfe706bc85c7be9cf57e45cb80919dbba2e825
Monotone-Revision: 283329aac9fb69692301c1e7d74db0ce8e6fc222 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-03-27T18:10:01 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
b6733a726a
commit
4509a3a7b4
|
@ -1,3 +1,8 @@
|
|||
2007-03-27 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* UI/Common/UIxFolderActions.m: new module implementing web
|
||||
actions common to all GCS-based folders.
|
||||
|
||||
2007-03-26 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* UI/Scheduler/UIxCalDayTable.m ([UIxCalDayTable -labelForDay]):
|
||||
|
|
|
@ -14,9 +14,9 @@ CommonUI_OBJC_FILES += \
|
|||
UIxPrintPageFrame.m \
|
||||
UIxSortButton.m \
|
||||
UIxAppNavView.m \
|
||||
UIxJSClose.m \
|
||||
\
|
||||
UIxAclEditor.m \
|
||||
UIxFolderActions.m \
|
||||
UIxElemBuilder.m \
|
||||
UIxTabView.m \
|
||||
UIxTabItem.m \
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
/* UIxFolderActions.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2007 Inverse groupe conseil
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef UIXFOLDERACTIONS_H
|
||||
#define UIXFOLDERACTIONS_H
|
||||
|
||||
#import <NGObjWeb/WODirectAction.h>
|
||||
|
||||
@class SOGoFolder;
|
||||
@class NSString;
|
||||
@class NSUserDefaults;
|
||||
@class NSMutableString;
|
||||
@class NSMutableDictionary;
|
||||
|
||||
@interface UIxFolderActions : WODirectAction
|
||||
{
|
||||
SOGoFolder *clientObject;
|
||||
AgenorUserManager *um;
|
||||
NSUserDefaults *ud;
|
||||
NSString *owner;
|
||||
NSString *login;
|
||||
NSString *baseFolder;
|
||||
NSMutableString *subscriptionPointer;
|
||||
NSMutableDictionary *moduleSettings;
|
||||
}
|
||||
|
||||
- (WOResponse *) subscribeAction;
|
||||
- (WOResponse *) unsubscribeAction;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* UIXFOLDERACTIONS_H */
|
|
@ -0,0 +1,137 @@
|
|||
/* UIxFolderActions.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2007 Inverse groupe conseil
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSUserDefaults.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
|
||||
#import <NGObjWeb/WOContext.h>
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
#import <NGObjWeb/WOResponse.h>
|
||||
|
||||
#import <SOGo/AgenorUserManager.h>
|
||||
#import <SOGo/SOGoUser.h>
|
||||
#import <SOGo/SOGoObject.h>
|
||||
|
||||
#import "UIxFolderActions.h"
|
||||
|
||||
@implementation UIxFolderActions
|
||||
|
||||
- (void) _setupContext
|
||||
{
|
||||
NSString *clientClass;
|
||||
|
||||
login = [[context activeUser] login];
|
||||
clientObject = [self clientObject];
|
||||
owner = [clientObject ownerInContext: nil];
|
||||
|
||||
clientClass = NSStringFromClass([clientObject class]);
|
||||
if ([clientClass isEqualToString: @"SOGoContactGCSFolder"])
|
||||
baseFolder = @"Contacts";
|
||||
else if ([clientClass isEqualToString: @"SOGoAppointmentFolder"])
|
||||
baseFolder = @"Calendar";
|
||||
else
|
||||
baseFolder = nil;
|
||||
|
||||
um = [AgenorUserManager sharedUserManager];
|
||||
ud = [um getUserSettingsForUID: login];
|
||||
moduleSettings = [ud objectForKey: baseFolder];
|
||||
if (!moduleSettings)
|
||||
{
|
||||
moduleSettings = [NSMutableDictionary new];
|
||||
[moduleSettings autorelease];
|
||||
}
|
||||
[ud setObject: moduleSettings forKey: baseFolder];
|
||||
|
||||
subscriptionPointer = [NSMutableString stringWithFormat: @"%@:%@",
|
||||
owner, baseFolder];
|
||||
if ([baseFolder isEqualToString: @"Contacts"])
|
||||
[subscriptionPointer appendFormat: @"/%@",
|
||||
[clientObject nameInContainer]];
|
||||
}
|
||||
|
||||
- (WOResponse *) _realActionWithFolderName: (NSDictionary *) folderDict
|
||||
{
|
||||
WOResponse *response;
|
||||
NSMutableDictionary *folderSubscription;
|
||||
|
||||
response = [context response];
|
||||
if ([owner isEqualToString: login])
|
||||
{
|
||||
[response setStatus: 403];
|
||||
[response appendContentString:
|
||||
@"You cannot (un)subscribe to a folder that you own!"];
|
||||
}
|
||||
else
|
||||
{
|
||||
folderSubscription
|
||||
= [moduleSettings objectForKey: @"SubscribedFolders"];
|
||||
if (!folderSubscription)
|
||||
{
|
||||
folderSubscription = [NSMutableDictionary dictionary];
|
||||
[moduleSettings setObject: folderSubscription
|
||||
forKey: @"SubscribedFolders"];
|
||||
}
|
||||
if (folderDict)
|
||||
[folderSubscription setObject: folderDict
|
||||
forKey: subscriptionPointer];
|
||||
else
|
||||
[folderSubscription removeObjectForKey: subscriptionPointer];
|
||||
|
||||
[ud synchronize];
|
||||
[response setStatus: 204];
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
- (WOResponse *) subscribeAction
|
||||
{
|
||||
NSString *email;
|
||||
NSMutableDictionary *folderDict;
|
||||
NSString *folderName;
|
||||
|
||||
[self _setupContext];
|
||||
email = [NSString stringWithFormat: @"%@ <%@>",
|
||||
[um getCNForUID: owner], [um getEmailForUID: owner]];
|
||||
if ([baseFolder isEqualToString: @"Contacts"])
|
||||
folderName = [NSString stringWithFormat: @"%@ (%@)",
|
||||
[clientObject nameInContainer], email];
|
||||
else
|
||||
folderName = email;
|
||||
|
||||
folderDict = [NSMutableDictionary new];
|
||||
[folderDict setObject: folderName forKey: @"displayName"];
|
||||
[folderDict setObject: [NSNumber numberWithBool: NO] forKey: @"active"];
|
||||
|
||||
return [self _realActionWithFolderName: folderDict];
|
||||
}
|
||||
|
||||
- (WOResponse *) unsubscribeAction
|
||||
{
|
||||
[self _setupContext];
|
||||
|
||||
return [self _realActionWithFolderName: nil];
|
||||
}
|
||||
|
||||
@end
|
|
@ -1,47 +1,57 @@
|
|||
{ /* -*-javascript-*- */
|
||||
requires = ( MAIN, Mailer );
|
||||
requires = ( MAIN, Mailer );
|
||||
|
||||
publicResources = (
|
||||
calendar.css,
|
||||
uix.css,
|
||||
menu_logo_top.gif,
|
||||
line_left.gif,
|
||||
line_stretch.gif,
|
||||
line_right.gif,
|
||||
box_topleft.gif,
|
||||
box_top.gif,
|
||||
box_topright.gif,
|
||||
box_left.gif,
|
||||
box_right.gif,
|
||||
box_botleft.gif,
|
||||
box_bottom.gif,
|
||||
box_botright.gif,
|
||||
tab_selected.gif,
|
||||
tab_.gif,
|
||||
corner_right.gif,
|
||||
closewindow.gif,
|
||||
OGoLogo.gif,
|
||||
upward_sorted.gif,
|
||||
downward_sorted.gif,
|
||||
non_sorted.gif
|
||||
publicResources = (
|
||||
calendar.css,
|
||||
uix.css,
|
||||
menu_logo_top.gif,
|
||||
line_left.gif,
|
||||
line_stretch.gif,
|
||||
line_right.gif,
|
||||
box_topleft.gif,
|
||||
box_top.gif,
|
||||
box_topright.gif,
|
||||
box_left.gif,
|
||||
box_right.gif,
|
||||
box_botleft.gif,
|
||||
box_bottom.gif,
|
||||
box_botright.gif,
|
||||
tab_selected.gif,
|
||||
tab_.gif,
|
||||
corner_right.gif,
|
||||
closewindow.gif,
|
||||
OGoLogo.gif,
|
||||
upward_sorted.gif,
|
||||
downward_sorted.gif,
|
||||
non_sorted.gif
|
||||
);
|
||||
|
||||
factories = {
|
||||
};
|
||||
factories = {
|
||||
};
|
||||
|
||||
categories = {
|
||||
SOGoFolder = {
|
||||
methods = {
|
||||
acls = {
|
||||
protectedBy = "ReadAcls";
|
||||
pageName = "UIxAclEditor";
|
||||
};
|
||||
saveAcls = {
|
||||
protectedBy = "SaveAcls";
|
||||
pageName = "UIxAclEditor";
|
||||
actionName = "saveAcls";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
categories = {
|
||||
SOGoFolder = {
|
||||
methods = {
|
||||
subscribe = {
|
||||
protectedBy = "View";
|
||||
actionClass = "UIxFolderActions";
|
||||
actionName = "subscribe";
|
||||
};
|
||||
unsubscribe = {
|
||||
protectedBy = "View";
|
||||
actionClass = "UIxFolderActions";
|
||||
actionName = "unsubscribe";
|
||||
};
|
||||
acls = {
|
||||
protectedBy = "ReadAcls";
|
||||
pageName = "UIxAclEditor";
|
||||
};
|
||||
saveAcls = {
|
||||
protectedBy = "SaveAcls";
|
||||
pageName = "UIxAclEditor";
|
||||
actionName = "saveAcls";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue