Monotone-Parent: ea72255819157346b8579f8e17c6e9fb6c5c0d34

Monotone-Revision: a1294497e9f6ed0ee90d2f695f0735f2eb1ced11

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2008-08-10T21:44:25
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2008-08-10 21:44:25 +00:00
parent bfccdd5738
commit ac468edb0a
14 changed files with 322 additions and 271 deletions

View File

@@ -750,18 +750,39 @@ _occurenceHasID (iCalRepeatableEntityObject *occurence, NSString *recID)
uids = [NSMutableArray array];
persons = [iCalPersons objectEnumerator];
currentPerson = [persons nextObject];
while (currentPerson)
while ((currentPerson = [persons nextObject]))
{
uid = [currentPerson uid];
if (uid)
[uids addObject: uid];
currentPerson = [persons nextObject];
}
return uids;
}
- (NSException *) copyToFolder: (SOGoGCSFolder *) newFolder
{
NSArray *elements;
NSString *newUID;
unsigned int count, max;
iCalCalendar *calendar;
SOGoCalendarComponent *newComponent;
newUID = [self globallyUniqueObjectId];
calendar = [self calendar: NO secure: NO];
elements = [calendar allObjects];
max = [elements count];
for (count = 0; count < max; count++)
[[elements objectAtIndex: count] setUid: newUID];
newComponent = [[self class] objectWithName:
[NSString stringWithFormat: @"%@.ics", newUID]
inContainer: newFolder];
return [newComponent saveContentString: [calendar versitString]];
}
- (NSString *) _roleOfOwner: (iCalRepeatableEntityObject *) component
{
NSString *role;

View File

@@ -60,6 +60,27 @@
return card;
}
/* actions */
- (NSException *) copyToFolder: (SOGoGCSFolder *) newFolder
{
NGVCard *newCard;
NSString *newUID;
SOGoContactGCSEntry *newContact;
// Change the contact UID
newUID = [self globallyUniqueObjectId];
newCard = [self vCard];
[newCard setUid: newUID];
newContact = [[self class] objectWithName:
[NSString stringWithFormat: @"%@.vcf", newUID]
inContainer: newFolder];
return [newContact saveContentString: [newCard versitString]];
}
/* DAV */
- (NSString *) davContentType

View File

@@ -27,6 +27,7 @@
#import <NGCards/NGVCard.h>
#import <NGCards/CardVersitRenderer.h>
#import "SOGoContactGCSEntry.h"
#import "SOGoContactLDIFEntry.h"
@implementation SOGoContactLDIFEntry
@@ -200,6 +201,26 @@
{
}
/* DAV */
- (NSException *) copyToFolder: (SOGoGCSFolder *) newFolder
{
NGVCard *newCard;
NSString *newUID;
SOGoContactGCSEntry *newContact;
// Change the contact UID
newUID = [self globallyUniqueObjectId];
newCard = [self vCard];
[newCard setUid: newUID];
newContact = [SOGoContactGCSEntry objectWithName:
[NSString stringWithFormat: @"%@.vcf", newUID]
inContainer: newFolder];
return [newContact saveContentString: [newCard versitString]];
}
/* message type */
- (NSString *) outlookMessageClass

View File

@@ -59,9 +59,13 @@
- (NSException *) saveContentString: (NSString *) _str
baseVersion: (unsigned int) _baseVersion;
- (NSException *) saveContentString: (NSString *)_str;
/* actions */
- (NSException *) copyToFolder: (SOGoGCSFolder *) newFolder;
- (NSException *) moveToFolder: (SOGoGCSFolder *) newFolder;
- (NSException *) delete;
/* etag support */
/* DAV support */
- (id) davEntityTag;
- (NSString *) davCreationDate;

View File

@@ -198,6 +198,30 @@
return [self saveContentString: newContent baseVersion: 0];
}
/* actions */
- (NSException *) copyToFolder: (SOGoGCSFolder *) newFolder
{
[self subclassResponsibility: _cmd];
return nil;
}
- (NSException *) moveToFolder: (SOGoGCSFolder *) newFolder
{
SOGoContentObject *newObject;
NSException *ex;
newObject = [[self class] objectWithName: nameInContainer
inContainer: newFolder];
[newObject setIsNew: YES];
ex = [newObject saveContentString: content];
if (!ex)
ex = [self delete];
return ex;
}
- (NSException *) delete
{
/* Note: "iCal multifolder saves" are implemented in the apt subclass! */

View File

@@ -21,6 +21,7 @@
*/
#import <Foundation/NSDictionary.h>
#import <Foundation/NSEnumerator.h>
#import <Foundation/NSString.h>
#import <Foundation/NSUserDefaults.h>
#import <Foundation/NSURL.h>
@@ -32,10 +33,13 @@
#import <NGObjWeb/WOResponse.h>
#import <NGObjWeb/SoSecurityManager.h>
#import <NGObjWeb/SoClassSecurityInfo.h>
#import <NGObjWeb/NSException+HTTP.h>
#import <SoObjects/SOGo/LDAPUserManager.h>
#import <SoObjects/SOGo/NSArray+Utilities.h>
#import <SoObjects/SOGo/SOGoContentObject.h>
#import <SoObjects/SOGo/SOGoGCSFolder.h>
#import <SoObjects/SOGo/SOGoParentFolder.h>
#import <SoObjects/SOGo/SOGoPermissions.h>
#import <SoObjects/SOGo/SOGoUser.h>
@@ -219,4 +223,135 @@
return response;
}
- (NSException*) _moveContacts: (NSArray*) contactsId
toFolder: (NSString*) destinationFolderId
andKeepCopy: (BOOL) keepCopy
{
NSEnumerator *uids;
NSException *ex;
NSString *uid;
SOGoContentObject *currentChild;
SOGoGCSFolder *sourceFolder, *destinationFolder;
SOGoParentFolder *folders;
SoSecurityManager *sm;
WORequest *request;
unsigned int errorCount;
sm = [SoSecurityManager sharedSecurityManager];
request = [context request];
ex = nil;
errorCount = 0;
// Search the specified destination folder
sourceFolder = [self clientObject];
folders = [sourceFolder container];
destinationFolder = [folders lookupName: destinationFolderId
inContext: nil
acquire: NO];
if (destinationFolder)
{
// Verify write access to the folder
ex = [sm validatePermission: SoPerm_AddDocumentsImagesAndFiles
onObject: destinationFolder
inContext: context];
if (!ex)
{
uids = [contactsId objectEnumerator];
while ((uid = [uids nextObject]))
{
// Search the currentChild ID
currentChild = [sourceFolder lookupName: uid
inContext: [self context]
acquire: NO];
if ([currentChild isKindOfClass: [NSException class]])
errorCount++;
else
{
if (keepCopy)
ex = [currentChild copyToFolder: destinationFolder];
else
ex = [currentChild moveToFolder: destinationFolder];
if (ex)
errorCount++;
}
}
}
}
else
ex = [NSException exceptionWithName: @"UnknownDestinationFolder"
reason: @"Unknown Destination Folder"
userInfo: nil];
if (errorCount > 0)
// At least one currentChild was not copied
ex = [NSException exceptionWithHTTPStatus: 400
reason: @"Invalid Contact"];
else if (ex != nil)
// Destination address book doesn't exist or is not writable
ex = [NSException exceptionWithHTTPStatus: 403
reason: [ex name]];
return ex;
}
- (id <WOActionResults>) copyAction
{
WORequest *request;
id <WOActionResults> response;
NSString *destinationFolderId;
NSArray *contactsId;
NSException *ex;
request = [context request];
ex = nil;
if ((destinationFolderId = [request formValueForKey: @"folder"]) &&
(contactsId = [request formValuesForKey: @"uid"]))
{
ex = [self _moveContacts: contactsId
toFolder: destinationFolderId
andKeepCopy: YES];
if (ex != nil)
response = (id)ex;
}
else
response = [NSException exceptionWithHTTPStatus: 400
reason: @"missing 'folder' and/or 'uid' parameter"];
if (ex == nil)
response = [self responseWith204];
return response;
}
- (id <WOActionResults>) moveAction
{
WORequest *request;
id <WOActionResults> response;
NSString *destinationFolderId;
NSArray *contactsId;
NSException *ex;
request = [context request];
ex = nil;
if ((destinationFolderId = [request formValueForKey: @"folder"]) &&
(contactsId = [request formValuesForKey: @"uid"]))
{
ex = [self _moveContacts: contactsId
toFolder: destinationFolderId
andKeepCopy: NO];
if (ex != nil)
response = (id)ex;
}
else
response = [NSException exceptionWithHTTPStatus: 400
reason: @"missing 'folder' and/or 'uid' parameter"];
if (ex == nil)
response = [self responseWith204];
return response;
}
@end

View File

@@ -116,6 +116,16 @@
actionClass = "UIxFolderActions";
actionName = "batchDelete";
};
copy = {
protectedBy = "Access Contents Information";
actionClass = "UIxFolderActions";
actionName = "copy";
};
move = {
protectedBy = "Delete Objects";
actionClass = "UIxFolderActions";
actionName = "move";
};
};
};
};

View File

@@ -21,8 +21,7 @@ ContactsUI_OBJC_FILES = \
UIxListEditor.m \
UIxContactsListView.m \
UIxContactsListViewContainer.m \
UIxContactFoldersView.m \
UIxContactFolderActions.m \
UIxContactFoldersView.m
ContactsUI_RESOURCE_FILES += \
Version \

View File

@@ -1,39 +0,0 @@
/* UIxContactFolderActions.h - this file is part of SOGo
*
* Copyright (C) 2008 Inverse groupe conseil
*
* Author: Francis Lachapelle <flachapelle@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 UIXCONTACTFOLDERACTIONS_H
#define UIXCONTACTFOLDERACTIONS_H
#import <NGObjWeb/WODirectAction.h>
@class WOResponse;
@interface UIxContactFolderActions : WODirectAction
{
}
- (id <WOActionResults>) copyAction;
- (id <WOActionResults>) moveAction;
@end
#endif /* UIXCONTACTFOLDERACTIONS_H */

View File

@@ -1,205 +0,0 @@
/* UIxContactFolderActions.m - this file is part of SOGo
*
* Copyright (C) 2008 Inverse groupe conseil
*
* Author: Francis Lachapelle <flachapelle@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/NSDictionary.h>
#import <Foundation/NSEnumerator.h>
#import <NGObjWeb/NSException+HTTP.h>
#import <NGObjWeb/SoPermissions.h>
#import <NGObjWeb/SoSecurityManager.h>
#import <NGObjWeb/WOContext+SoObjects.h>
#import <NGObjWeb/WORequest.h>
#import <NGObjWeb/WOResponse.h>
#import <NGCards/NGVCard.h>
#import <Contacts/SOGoContactFolders.h>
#import <Contacts/SOGoContactObject.h>
#import <SoObjects/SOGo/NSArray+Utilities.h>
#import <SoObjects/SOGo/NSObject+Utilities.h>
#import <SoObjects/SOGo/NSString+Utilities.h>
#import <SoObjects/SOGo/SOGoContentObject.h>
#import <SoObjects/SOGo/SOGoFolder.h>
#import <SoObjects/SOGo/SOGoUser.h>
#import "../Common/WODirectAction+SOGo.h"
#import "UIxContactFolderActions.h"
@implementation UIxContactFolderActions
- (NSException*) _moveContacts: (NSArray*) contactsId
toFolder: (NSString*) destinationFolderId
andKeepCopy: (BOOL) keepCopy
{
NGVCard *card;
NSEnumerator *uids;
NSException *ex;
NSString *uid, *newUid;
id <SOGoContactObject> contact;
SOGoContactFolders *folders;
SOGoParentFolder *sourceFolder, *destinationFolder;
SOGoContentObject *newContact;
SoSecurityManager *sm;
WORequest *request;
unsigned int errorCount;
sm = [SoSecurityManager sharedSecurityManager];
request = [context request];
ex = nil;
errorCount = 0;
// Search the specified destination folder
sourceFolder = [self clientObject];
folders = [(SOGoUserFolder*)[[sourceFolder container] container] privateContacts: @"Contacts"
inContext: nil];
destinationFolder = [folders lookupName: destinationFolderId
inContext: nil
acquire: NO];
if (destinationFolder)
{
// Verify write access to the folder
ex = [sm validatePermission: SoPerm_AddDocumentsImagesAndFiles
onObject: destinationFolder
inContext: context];
if (ex == nil)
{
uids = [contactsId objectEnumerator];
uid = [uids nextObject];
while (uid)
{
// Search the contact ID
contact = [sourceFolder lookupName: uid
inContext: [self context]
acquire: NO];
if ([(NSObject*)contact isKindOfClass: [NSException class]])
errorCount++;
else
{
card = [contact vCard];
if (keepCopy)
{
// Change the contact UID
newUid = [SOGoObject globallyUniqueObjectId];
[card setUid: newUid];
newContact = [SOGoContentObject objectWithName: newUid
inContainer: destinationFolder];
}
else
// Don't change the contact UID
newContact = [SOGoContentObject objectWithName: [contact nameInContainer]
inContainer: (SOGoGCSFolder*)destinationFolder];
ex = [newContact saveContentString: [card versitString]];
if (ex == nil && !keepCopy)
// Delete the original contact if necessary
ex = [contact delete];
if (ex != nil)
errorCount++;
}
uid = [uids nextObject];
}
}
}
else
ex = [NSException exceptionWithName: @"UnkownDestinationFolder"
reason: @"Unknown Destination Folder"
userInfo: nil];
if (errorCount > 0)
// At least one contact was not copied
ex = [NSException exceptionWithHTTPStatus: 400
reason: @"Invalid Contact"];
else if (ex != nil)
// Destination address book doesn't exist or is not writable
ex = [NSException exceptionWithHTTPStatus: 403
reason: [ex name]];
return ex;
}
- (id <WOActionResults>) copyAction
{
WORequest *request;
id <WOActionResults> response;
NSString *destinationFolderId;
NSArray *contactsId;
NSException *ex;
request = [context request];
ex = nil;
if ((destinationFolderId = [request formValueForKey: @"folder"]) &&
(contactsId = [request formValuesForKey: @"uid"]))
{
ex = [self _moveContacts: contactsId
toFolder: destinationFolderId
andKeepCopy: YES];
if (ex != nil)
response = (id)ex;
}
else
response = [NSException exceptionWithHTTPStatus: 400
reason: @"missing 'folder' and/or 'uid' parameter"];
if (ex == nil)
response = [self responseWith204];
return response;
}
- (id <WOActionResults>) moveAction
{
WORequest *request;
id <WOActionResults> response;
NSString *destinationFolderId;
NSArray *contactsId;
NSException *ex;
request = [context request];
ex = nil;
if ((destinationFolderId = [request formValueForKey: @"folder"]) &&
(contactsId = [request formValuesForKey: @"uid"]))
{
ex = [self _moveContacts: contactsId
toFolder: destinationFolderId
andKeepCopy: NO];
if (ex != nil)
response = (id)ex;
}
else
response = [NSException exceptionWithHTTPStatus: 400
reason: @"missing 'folder' and/or 'uid' parameter"];
if (ex == nil)
response = [self responseWith204];
return response;
}
@end

View File

@@ -96,16 +96,6 @@
pageName = "UIxContactsUserRightsEditor";
actionName = "saveUserRights";
};
copy = {
protectedBy = "Access Contents Information";
actionClass = "UIxContactFolderActions";
actionName = "copy";
};
move = {
protectedBy = "Delete Objects";
actionClass = "UIxContactFolderActions";
actionName = "move";
};
};
};
@@ -137,9 +127,9 @@
actionName = "canAccessContent";
};
copy = {
protectedBy = "Access Contents Information";
actionClass = "UIxContactFolderActions";
actionName = "copy";
protectedBy = "Access Contents Information";
actionClass = "UIxFolderActions";
actionName = "copy";
};
};
};

View File

@@ -23,6 +23,8 @@
#include <math.h>
#import <NGObjWeb/SoObject.h>
#import <NGObjWeb/SoPermissions.h>
#import <NGObjWeb/SoSecurityManager.h>
#import <NGObjWeb/WORequest.h>
#import <NGObjWeb/WOResponse.h>
#import <NGObjWeb/NSException+HTTP.h>
@@ -36,6 +38,7 @@
#import <SoObjects/SOGo/SOGoUser.h>
#import <SoObjects/SOGo/SOGoContentObject.h>
#import <SoObjects/Appointments/SOGoAppointmentFolder.h>
#import <SoObjects/Appointments/SOGoAppointmentsFolder.h>
#import <SoObjects/Appointments/SOGoAppointmentObject.h>
#import <SoObjects/Appointments/SOGoComponentOccurence.h>
@@ -230,7 +233,36 @@
- (id <WOActionResults>) saveAction
{
[[self clientObject] saveComponent: event];
NSString *newCalendar;
SOGoAppointmentFolder *thisFolder, *newFolder;
SOGoAppointmentFolders *parentFolder;
SOGoAppointmentObject *co;
SoSecurityManager *sm;
NSException *ex;
co = [self clientObject];
[co saveComponent: event];
newCalendar = [self queryParameterForKey: @"moveToCalendar"];
if ([newCalendar length])
{
sm = [SoSecurityManager sharedSecurityManager];
thisFolder = [co container];
if (![sm validatePermission: SoPerm_DeleteObjects
onObject: thisFolder
inContext: context])
{
parentFolder = [[self container] container];
newFolder = [[thisFolder container] lookupName: newCalendar
inContext: context
acquire: NO];
if (![sm validatePermission: SoPerm_AddDocumentsImagesAndFiles
onObject: newFolder
inContext: context])
ex = [co moveToFolder: newFolder];
}
}
return [self jsCloseWithRefreshMethod: @"refreshEventsAndDisplay()"];
}

View File

@@ -21,6 +21,8 @@
*/
#import <NGObjWeb/SoObject.h>
#import <NGObjWeb/SoPermissions.h>
#import <NGObjWeb/SoSecurityManager.h>
#import <NGObjWeb/WORequest.h>
#import <NGObjWeb/WOResponse.h>
#import <NGObjWeb/NSException+HTTP.h>
@@ -314,9 +316,39 @@
return result;
}
#warning this method could be replaced with a method common with UIxAppointmentEditor...
- (id <WOActionResults>) saveAction
{
[[self clientObject] saveComponent: todo];
NSString *newCalendar;
SOGoAppointmentFolder *thisFolder, *newFolder;
SOGoAppointmentFolders *parentFolder;
SOGoTaskObject *co;
SoSecurityManager *sm;
NSException *ex;
co = [self clientObject];
[co saveComponent: todo];
newCalendar = [self queryParameterForKey: @"moveToCalendar"];
if ([newCalendar length])
{
sm = [SoSecurityManager sharedSecurityManager];
thisFolder = [co container];
if (![sm validatePermission: SoPerm_DeleteObjects
onObject: thisFolder
inContext: context])
{
parentFolder = [[self container] container];
newFolder = [[thisFolder container] lookupName: newCalendar
inContext: context
acquire: NO];
if (![sm validatePermission: SoPerm_AddDocumentsImagesAndFiles
onObject: newFolder
inContext: context])
ex = [co moveToFolder: newFolder];
}
}
return [self jsCloseWithRefreshMethod: @"refreshTasks()"];
}

View File

@@ -70,10 +70,18 @@ function onMenuSetClassification(event) {
function onChangeCalendar(event) {
var calendars = $("calendarFoldersList").value.split(",");
var form = document.forms["editform"];
var urlElems = form.getAttribute("action").split("/");
var urlElems = form.getAttribute("action").split("?");
var choice = calendars[this.value];
urlElems[urlElems.length-3] = choice;
form.setAttribute("action", urlElems.join("/"));
var urlParam = "moveToCalendar=" + choice;
if (urlElems.length == 1)
urlElems.push(urlParam);
else
urlElems[2] = urlParam;
while (urlElems.length > 2)
urlElems.pop();
form.setAttribute("action", urlElems.join("?"));
}
function initializeDocumentHref() {
@@ -111,9 +119,7 @@ function onComponentEditorLoad(event) {
initializeDocumentHref();
initializePrivacyMenu();
var list = $("calendarList");
list.observe("mousedown",
onChangeCalendar.bindAsEventListener(list),
false);
list.observe("change", onChangeCalendar, false);
list.fire("mousedown");
var menuItems = $("itemPrivacyList").childNodesWithTag("li");