Calendar+Addressbook export
Monotone-Parent: fb2522bcdcf167e7ba3e95a03948f9bfad2b7870 Monotone-Revision: 1e66868696d71db915497bde02848e689ed48c7a Monotone-Author: crobert@inverse.ca Monotone-Date: 2009-09-02T13:24:02 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
484e4b605f
commit
5658838afd
|
@ -1,3 +1,8 @@
|
|||
2009-09-02 Cyril Robert <crobert@inverse.ca>
|
||||
|
||||
* UI/Contacts/UIxContactsListView.m (exportAction): Added
|
||||
* UI/Scheduler/UIxCalView.m (exportAction): Added
|
||||
|
||||
2009-08-27 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* SoObjects/Appointments/SOGoCalendarProxy.[hm]: new class module
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2009-09-02 Cyril Robert <crobert@inverse.ca>
|
||||
|
||||
* NGVCard.m (ldifString): Added, to support exporting
|
||||
* NGVList.m (ldifString): Added, to support exporting
|
||||
|
||||
2009-08-27 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* iCalPerson.m (-setDelegatedTo:, -setDelegatedFrom:)
|
||||
|
|
|
@ -157,6 +157,7 @@ typedef enum
|
|||
- (NSString *) preferredEMail;
|
||||
- (NSString *) preferredTel;
|
||||
- (CardElement *) preferredAdr;
|
||||
- (NSString *) ldifString;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -508,4 +508,100 @@
|
|||
return str;
|
||||
}
|
||||
|
||||
|
||||
- (NSString *) ldifString
|
||||
{
|
||||
NSMutableString *rc;
|
||||
NSString *buffer;
|
||||
NSMutableArray *array;
|
||||
id tmp;
|
||||
|
||||
rc = [NSMutableString string];
|
||||
|
||||
[rc appendFormat: @"dn: cn=%@,mail=%@\n", [self fn], [self preferredEMail]];
|
||||
[rc appendFormat: @"objectclass: top\nobjectclass: person\nobjectclass: "
|
||||
@"organizationalPerson\nobjectclass: inetOrgPerson\nobjectclass: "
|
||||
@"mozillaAbPersonObsolete\n"];
|
||||
[rc appendFormat: @"givenName: %@\n", [[self n] objectAtIndex: 1]];
|
||||
[rc appendFormat: @"sn: %@\n", [[self n] objectAtIndex: 0]];
|
||||
[rc appendFormat: @"cn: %@\n", [self fn]];
|
||||
[rc appendFormat: @"mail: %@\n", [self preferredEMail]];
|
||||
[rc appendFormat: @"modifytimestamp: 0Z\n"];
|
||||
|
||||
buffer = [self nickname];
|
||||
if (buffer && [buffer length] > 0)
|
||||
[rc appendFormat: @"mozillaNickname: %@\n", buffer];
|
||||
|
||||
array = [NSMutableArray arrayWithArray: [self childrenWithTag: @"email"]];
|
||||
[array removeObjectsInArray: [self childrenWithTag: @"email"
|
||||
andAttribute: @"type"
|
||||
havingValue: @"pref"]];
|
||||
if ([array count])
|
||||
{
|
||||
buffer = [[array objectAtIndex: [array count]-1] value: 0];
|
||||
|
||||
if ([buffer caseInsensitiveCompare: [self preferredEMail]] != NSOrderedSame)
|
||||
[rc appendFormat: @"mozillaSecondEmail: %@\n", buffer];
|
||||
}
|
||||
|
||||
array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"home"];
|
||||
if ([array count])
|
||||
[rc appendFormat: @"homePhone: %@\n", [[array objectAtIndex: 0] value: 0]];
|
||||
array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"fax"];
|
||||
if ([array count])
|
||||
[rc appendFormat: @"fax: %@\n", [[array objectAtIndex: 0] value: 0]];
|
||||
array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"cell"];
|
||||
if ([array count])
|
||||
[rc appendFormat: @"mobile: %@\n", [[array objectAtIndex: 0] value: 0]];
|
||||
array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"pager"];
|
||||
if ([array count])
|
||||
[rc appendFormat: @"pager: %@\n", [[array objectAtIndex: 0] value: 0]];
|
||||
|
||||
array = [self childrenWithTag: @"adr" andAttribute: @"type" havingValue: @"home"];
|
||||
if ([array count])
|
||||
{
|
||||
tmp = [array objectAtIndex: 0];
|
||||
[rc appendFormat: @"homeStreet: %@\n", [tmp value: 0]];
|
||||
[rc appendFormat: @"mozillaHomeLocalityName: %@\n", [tmp value: 1]];
|
||||
[rc appendFormat: @"mozillaHomeState: %@\n", [tmp value: 2]];
|
||||
[rc appendFormat: @"mozillaHomePostalCode: %@\n", [tmp value: 3]];
|
||||
[rc appendFormat: @"mozillaHomeCountryName: %@\n", [tmp value: 4]];
|
||||
}
|
||||
|
||||
array = [self org];
|
||||
if (array && [array count])
|
||||
[rc appendFormat: @"o: %@\n", [array objectAtIndex: 0]];
|
||||
|
||||
array = [self childrenWithTag: @"adr" andAttribute: @"type" havingValue: @"work"];
|
||||
if ([array count])
|
||||
{
|
||||
tmp = [array objectAtIndex: 0];
|
||||
[rc appendFormat: @"street: %@\n", [tmp value: 0]];
|
||||
[rc appendFormat: @"l: %@\n", [tmp value: 1]];
|
||||
[rc appendFormat: @"st: %@\n", [tmp value: 2]];
|
||||
[rc appendFormat: @"postalCode: %@\n", [tmp value: 3]];
|
||||
[rc appendFormat: @"c: %@\n", [tmp value: 4]];
|
||||
}
|
||||
|
||||
array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"work"];
|
||||
if ([array count])
|
||||
[rc appendFormat: @"telephoneNumber: %@\n", [[array objectAtIndex: 0] value: 0]];
|
||||
|
||||
array = [self childrenWithTag: @"url" andAttribute: @"type" havingValue: @"work"];
|
||||
if ([array count])
|
||||
[rc appendFormat: @"workurl: %@\n", [[array objectAtIndex: 0] value: 0]];
|
||||
|
||||
array = [self childrenWithTag: @"url" andAttribute: @"type" havingValue: @"home"];
|
||||
if ([array count])
|
||||
[rc appendFormat: @"homeurl: %@\n", [[array objectAtIndex: 0] value: 0]];
|
||||
|
||||
tmp = [self note];
|
||||
if (tmp && [tmp length])
|
||||
[rc appendFormat: @"description: %@\n", tmp];
|
||||
|
||||
[rc appendFormat: @"\n"];
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@end /* NGVCard */
|
||||
|
|
|
@ -64,6 +64,8 @@
|
|||
- (void) deleteCardReference: (NGVCardReference *) cardRef;
|
||||
- (NSArray *) cardReferences;
|
||||
|
||||
- (NSString *) ldifString;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* NGVLIST_H */
|
||||
|
|
|
@ -197,4 +197,36 @@
|
|||
return [self childrenWithTag: @"card"];
|
||||
}
|
||||
|
||||
- (NSString *) ldifString
|
||||
{
|
||||
NSMutableString *rc;
|
||||
NSMutableArray *array;
|
||||
NGVCardReference *tmp;
|
||||
int i, count;
|
||||
|
||||
rc = [NSMutableString string];
|
||||
|
||||
[rc appendFormat: @"dn: cn=%@\n", [self fn]];
|
||||
[rc appendFormat: @"objectclass: top\nobjectclass: groupOfNames\n"];
|
||||
[rc appendFormat: @"cn: %@\n", [self fn]];
|
||||
if ([self nickname])
|
||||
[rc appendFormat: @"mozillaNickname: %@\n", [self nickname]];
|
||||
if ([self description])
|
||||
[rc appendFormat: @"description: %@\n", [self description]];
|
||||
|
||||
array = [self cardReferences];
|
||||
count = [array count];
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
tmp = [array objectAtIndex: i];
|
||||
[rc appendFormat: @"member: cn=%@,mail=%@\n",
|
||||
[tmp fn], [tmp email]];
|
||||
}
|
||||
|
||||
[rc appendFormat: @"\n"];
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -178,3 +178,5 @@
|
|||
"Contacts" = "Contacts";
|
||||
"Add" = "Add";
|
||||
"Lists can't be moved or copied." = "Lists can't be moved or copied.";
|
||||
|
||||
"Export" = "Export";
|
||||
|
|
|
@ -178,3 +178,5 @@
|
|||
"Contacts" = "Contacts";
|
||||
"Add" = "Add";
|
||||
"Lists can't be moved or copied." = "Lists can't be moved or copied.";
|
||||
|
||||
"Export" = "Export";
|
||||
|
|
|
@ -178,3 +178,5 @@
|
|||
"Contacts" = "Contacts";
|
||||
"Add" = "Add";
|
||||
"Lists can't be moved or copied." = "Lists can't be moved or copied.";
|
||||
|
||||
"Export" = "Export";
|
||||
|
|
|
@ -178,3 +178,5 @@
|
|||
"Contacts" = "Contacts";
|
||||
"Add" = "Add";
|
||||
"Lists can't be moved or copied." = "Lists can't be moved or copied.";
|
||||
|
||||
"Export" = "Export";
|
||||
|
|
|
@ -178,3 +178,5 @@
|
|||
"Contacts" = "Contacts";
|
||||
"Add" = "Ajouter";
|
||||
"Lists can't be moved or copied." = "Les listes ne peuvent pas être déplacées ou copiées.";
|
||||
|
||||
"Export" = "Exporter";
|
||||
|
|
|
@ -178,3 +178,5 @@
|
|||
"Contacts" = "Contacts";
|
||||
"Add" = "Add";
|
||||
"Lists can't be moved or copied." = "Lists can't be moved or copied.";
|
||||
|
||||
"Export" = "Export";
|
||||
|
|
|
@ -178,3 +178,5 @@
|
|||
"Contacts" = "Contacts";
|
||||
"Add" = "Add";
|
||||
"Lists can't be moved or copied." = "Lists can't be moved or copied.";
|
||||
|
||||
"Export" = "Export";
|
||||
|
|
|
@ -178,3 +178,5 @@
|
|||
"Contacts" = "Contacts";
|
||||
"Add" = "Add";
|
||||
"Lists can't be moved or copied." = "Lists can't be moved or copied.";
|
||||
|
||||
"Export" = "Export";
|
||||
|
|
|
@ -163,3 +163,5 @@
|
|||
"Contacts" = "Contacts";
|
||||
"Add" = "Add";
|
||||
"Lists can't be moved or copied." = "Lists can't be moved or copied.";
|
||||
|
||||
"Export" = "Export";
|
||||
|
|
|
@ -178,3 +178,5 @@
|
|||
"Contacts" = "Contacts";
|
||||
"Add" = "Add";
|
||||
"Lists can't be moved or copied." = "Lists can't be moved or copied.";
|
||||
|
||||
"Export" = "Export";
|
||||
|
|
|
@ -34,6 +34,11 @@
|
|||
#import <Contacts/SOGoContactFolder.h>
|
||||
#import <Contacts/SOGoContactFolders.h>
|
||||
|
||||
#import <NGCards/NGVCard.h>
|
||||
#import <NGCards/NGVList.h>
|
||||
#import <SoObjects/Contacts/SOGoContactGCSEntry.h>
|
||||
#import <SoObjects/Contacts/SOGoContactGCSList.h>
|
||||
|
||||
#import "UIxContactsListView.h"
|
||||
|
||||
@implementation UIxContactsListView
|
||||
|
@ -178,4 +183,45 @@
|
|||
return YES;
|
||||
}
|
||||
|
||||
|
||||
- (id <WOActionResults>) exportAction
|
||||
{
|
||||
WORequest *request;
|
||||
id <WOActionResults> response;
|
||||
NSArray *contactsId;
|
||||
NSEnumerator *uids;
|
||||
NSString *uid;
|
||||
id currentChild;
|
||||
id sourceFolder;
|
||||
NSMutableString *content;
|
||||
|
||||
content = [NSMutableString string];
|
||||
request = [context request];
|
||||
if ( (contactsId = [request formValuesForKey: @"uid"]) )
|
||||
{
|
||||
sourceFolder = [self clientObject];
|
||||
uids = [contactsId objectEnumerator];
|
||||
while ((uid = [uids nextObject]))
|
||||
{
|
||||
currentChild = [sourceFolder lookupName: uid
|
||||
inContext: [self context]
|
||||
acquire: NO];
|
||||
if ([currentChild respondsToSelector: @selector (vCard)])
|
||||
[content appendFormat: [[currentChild vCard] ldifString]];
|
||||
else if ([currentChild respondsToSelector: @selector (vList)])
|
||||
[content appendFormat: [[currentChild vList] ldifString]];
|
||||
}
|
||||
}
|
||||
response = [[WOResponse alloc] init];
|
||||
[response autorelease];
|
||||
[response setHeader: @"text/directory"
|
||||
forKey:@"content-type"];
|
||||
[response setHeader: @"attachment;filename=SavedContacts.ldif"
|
||||
forKey: @"Content-Disposition"];
|
||||
[response setContent: [content dataUsingEncoding: NSUTF8StringEncoding]];
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@end /* UIxContactsListView */
|
||||
|
|
|
@ -162,3 +162,5 @@
|
|||
"Contacts" = "Contacts";
|
||||
"Add" = "Add";
|
||||
"Lists can't be moved or copied." = "Lists can't be moved or copied.";
|
||||
|
||||
"Export" = "Export";
|
||||
|
|
|
@ -98,6 +98,11 @@
|
|||
pageName = "UIxContactsListView";
|
||||
actionName = "mailerContacts";
|
||||
};
|
||||
export = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxContactsListView";
|
||||
actionName = "export";
|
||||
};
|
||||
userRights = {
|
||||
protectedBy = "ReadAcls";
|
||||
pageName = "UIxContactsUserRightsEditor";
|
||||
|
|
|
@ -31,12 +31,17 @@
|
|||
#import <NGCards/NGCards.h>
|
||||
|
||||
#import <SoObjects/Appointments/SOGoAppointmentFolder.h>
|
||||
#import <SoObjects/Appointments/SOGoAppointmentObject.h>
|
||||
#import <SoObjects/SOGo/NSArray+Utilities.h>
|
||||
#import <SoObjects/SOGo/SOGoUser.h>
|
||||
#import <SoObjects/SOGo/SOGoObject.h>
|
||||
|
||||
#import <SOGoUI/SOGoAptFormatter.h>
|
||||
|
||||
#import <NGCards/iCalCalendar.h>
|
||||
#import <NGCards/iCalEvent.h>
|
||||
#import <GDLContentStore/GCSFolder.h>
|
||||
|
||||
#import "UIxCalView.h"
|
||||
|
||||
@interface UIxCalView (PrivateAPI)
|
||||
|
@ -632,4 +637,61 @@ static BOOL shouldDisplayWeekend = NO;
|
|||
return r;
|
||||
}
|
||||
|
||||
|
||||
- (WOResponse *) exportAction
|
||||
{
|
||||
WOResponse *response;
|
||||
SOGoAppointmentFolder *folder;
|
||||
SOGoAppointmentObject *appt;
|
||||
NSArray *array, *values, *fields;
|
||||
NSMutableString *rc;
|
||||
iCalCalendar *calendar, *component;
|
||||
int i, count;
|
||||
|
||||
fields = [NSArray arrayWithObjects: @"c_name", @"c_content", nil];
|
||||
rc = [NSMutableString string];
|
||||
|
||||
response = [[WOResponse alloc] init];
|
||||
[response autorelease];
|
||||
|
||||
folder = [self clientObject];
|
||||
calendar = [iCalCalendar groupWithTag: @"vcalendar"];
|
||||
|
||||
array = [[folder ocsFolder] fetchFields: fields matchingQualifier: nil];
|
||||
count = [array count];
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
appt = [folder lookupName: [[array objectAtIndex: i] objectForKey: @"c_name"]
|
||||
inContext: [self context]
|
||||
acquire: NO];
|
||||
|
||||
component = [appt calendar: NO secure: NO];
|
||||
values = [component events];
|
||||
if (values && [values count])
|
||||
[calendar addChildren: values];
|
||||
values = [component todos];
|
||||
if (values && [values count])
|
||||
[calendar addChildren: values];
|
||||
values = [component journals];
|
||||
if (values && [values count])
|
||||
[calendar addChildren: values];
|
||||
values = [component freeBusys];
|
||||
if (values && [values count])
|
||||
[calendar addChildren: values];
|
||||
values = [component childrenWithTag: @"vtimezone"];
|
||||
if (values && [values count])
|
||||
[calendar addChildren: values];
|
||||
}
|
||||
NSLog ([calendar versitString]);
|
||||
|
||||
[response setHeader: @"text/calendar"
|
||||
forKey:@"content-type"];
|
||||
[response setHeader: @"attachment;filename=Calendar.ics"
|
||||
forKey: @"Content-Disposition"];
|
||||
[response setContent: [[calendar versitString] dataUsingEncoding: NSUTF8StringEncoding]];
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@end /* UIxCalView */
|
||||
|
|
|
@ -79,6 +79,11 @@
|
|||
actionClass = "UIxCalListingActions";
|
||||
actionName = "findPossibleSlot";
|
||||
};
|
||||
export = {
|
||||
protectedBy = "View";
|
||||
actionClass = "UIxCalListingActions";
|
||||
actionName = "export";
|
||||
};
|
||||
dayview = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxCalDayView";
|
||||
|
@ -144,6 +149,11 @@
|
|||
pageName = "UIxCalView";
|
||||
actionName = "redirectForUIDs";
|
||||
};
|
||||
export = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxCalView";
|
||||
actionName = "export";
|
||||
};
|
||||
userRights = {
|
||||
protectedBy = "ReadAcls";
|
||||
pageName = "UIxCalUserRightsEditor";
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
<li><!-- separator --></li>
|
||||
<li><var:string label:value="Move To" /></li>
|
||||
<li><var:string label:value="Copy To" /></li>
|
||||
<li><var:string label:value="Export" /></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -214,7 +214,9 @@ function onFolderMenuHide(event) {
|
|||
|
||||
function _onContactMenuAction(folderItem, action, refresh) {
|
||||
var selectedFolders = $("contactFolders").getSelectedNodes();
|
||||
var folderId = $(folderItem).readAttribute("folderId").substring(1);
|
||||
var folderId = $(folderItem).readAttribute("folderId");
|
||||
if (folderId)
|
||||
folderId = folderId.substring (1);
|
||||
if (Object.isArray(document.menuTarget) && selectedFolders.length > 0) {
|
||||
var selectedFolderId = $(selectedFolders[0]).readAttribute("id");
|
||||
var contactIds = $(document.menuTarget).collect(function(row) {
|
||||
|
@ -227,7 +229,6 @@ function _onContactMenuAction(folderItem, action, refresh) {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var url = ApplicationBaseURL + selectedFolderId + "/" + action
|
||||
+ "?folder=" + folderId + "&uid="
|
||||
|
@ -248,6 +249,19 @@ function onContactMenuMove(event) {
|
|||
_onContactMenuAction(this, "move", true);
|
||||
}
|
||||
|
||||
function onMenuExportContact (event) {
|
||||
var selectedFolders = $("contactFolders").getSelectedNodes();
|
||||
var selectedFolderId = $(selectedFolders[0]).readAttribute("id");
|
||||
if (selectedFolderId != "/shared") {
|
||||
var contactIds = $(document.menuTarget).collect(function(row) {
|
||||
return row.getAttribute("id");
|
||||
});
|
||||
var url = ApplicationBaseURL + selectedFolderId + "/export"
|
||||
+ "?uid=" + contactIds.join("&uid=");
|
||||
window.location.href = url;
|
||||
}
|
||||
}
|
||||
|
||||
function actionContactCallback(http) {
|
||||
if (http.readyState == 4)
|
||||
if (isHttpStatus204(http.status)) {
|
||||
|
@ -977,7 +991,8 @@ function getMenus() {
|
|||
menus["contactMenu"] = new Array(onMenuEditContact, "-",
|
||||
onMenuWriteToContact, onMenuAIMContact,
|
||||
"-", onMenuDeleteContact, "-",
|
||||
"moveContactMenu", "copyContactMenu");
|
||||
"moveContactMenu", "copyContactMenu",
|
||||
onMenuExportContact);
|
||||
menus["searchMenu"] = new Array(setSearchCriteria);
|
||||
|
||||
var contactFoldersMenu = $("contactFoldersMenu");
|
||||
|
|
|
@ -1738,7 +1738,7 @@ function getMenus() {
|
|||
menus["calendarsMenu"] = new Array(onCalendarModify,
|
||||
"-",
|
||||
onCalendarNew, onCalendarRemove,
|
||||
"-", null, null, "-",
|
||||
"-", onCalendarExport, null, "-",
|
||||
null, "-", onMenuSharing);
|
||||
menus["searchMenu"] = new Array(setSearchCriteria);
|
||||
|
||||
|
@ -1877,6 +1877,17 @@ function onCalendarAdd(event) {
|
|||
openUserFolderSelector(onFolderSubscribeCB, "calendar");
|
||||
preventDefault(event);
|
||||
}
|
||||
function onCalendarExport(event) {
|
||||
var node = $("calendarList").getSelectedNodes().first();
|
||||
var owner = node.getAttribute("owner");
|
||||
var folderId = node.getAttribute("id");
|
||||
if (owner == UserLogin) {
|
||||
var folderIdElements = folderId.split(":");
|
||||
var id = folderIdElements[0].replace (/^\/+/g, '');
|
||||
var url = ApplicationBaseURL + "/" + id + "/export";
|
||||
window.location.href = url;
|
||||
}
|
||||
}
|
||||
|
||||
function setEventsOnCalendar(checkBox, li) {
|
||||
li.observe("mousedown", listRowMouseDownHandler);
|
||||
|
|
Loading…
Reference in New Issue