Monotone-Parent: 47f011047becbfa93b21ffe7ca90810b1d9af684

Monotone-Revision: 29abd2cf2766adecab1dfb2ef0813cc697753b58

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2010-06-08T13:38:32
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2010-06-08 13:38:32 +00:00
parent bbe1bae54d
commit 5d66f62205
4 changed files with 48 additions and 72 deletions

View File

@@ -1,5 +1,16 @@
2010-06-08 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/WebServerResources/SchedulerUI.js:
(onCalendarsMenuPrepareVisibility): the "export" menu option is
now disabled for non-owner users, since the function itself will
not do anything otherwise.
(onCalendarExport): we make use of the URLForFolderId method,
which reduces code size.
* UI/Scheduler/UIxCalFolderActions.m (-exportAction): this web
method is now bound to the ICS folder object, thereby removing
duplicate code.
* SoObjects/Appointments/SOGoAppointmentFolderObject.m
(-displayName, -davDisplayName): new accessors that are forwarded
to the real folder object.

View File

@@ -31,6 +31,7 @@
#import <NGExtensions/NSNull+misc.h>
#import <Appointments/SOGoAppointmentFolder.h>
#import <Appointments/SOGoAppointmentFolderICS.h>
#import <Appointments/SOGoAppointmentObject.h>
#import <GDLContentStore/GCSFolder.h>
#import <NGCards/iCalCalendar.h>
@@ -42,63 +43,19 @@
- (WOResponse *) exportAction
{
WOResponse *response;
SOGoAppointmentFolder *folder;
SOGoAppointmentObject *appt;
NSArray *array, *values, *fields;
NSMutableString *rc;
SOGoAppointmentFolderICS *folderICS;
NSString *filename;
iCalCalendar *calendar, *component;
int i, count;
fields = [NSArray arrayWithObjects: @"c_name", @"c_content", nil];
rc = [NSMutableString string];
response = [context response];
folder = [self clientObject];
calendar = [iCalCalendar groupWithTag: @"vcalendar"];
/* We have to use bareFetchFields because we don't want to process anything
* (RRULES for example) */
array = [folder bareFetchFields: fields
from: nil
to: nil
title: nil
component: nil
additionalFilters: 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];
}
filename = [NSString stringWithFormat: @"attachment;filename=\"%@.ics\"",
[folder displayName]];
[response setHeader: @"application/octet-stream; charset=utf-8"
forKey:@"content-type"];
[response setHeader: filename
folderICS = [self clientObject];
response = [self responseWithStatus: 200
andString: [folderICS contentAsString]];
[response setHeader: @"text/calendar; charset=utf-8"
forKey: @"content-type"];
filename = [NSString stringWithFormat: @"attachment; filename=\"%@.ics\"",
[folderICS displayName]];
[response setHeader: filename
forKey: @"Content-Disposition"];
[response setContent: [[calendar versitString] dataUsingEncoding: NSUTF8StringEncoding]];
return response;
}

View File

@@ -149,11 +149,6 @@
pageName = "UIxCalView";
actionName = "redirectForUIDs";
};
export = {
protectedBy = "View";
actionClass = "UIxCalFolderActions";
actionName = "export";
};
import = {
protectedBy = "View";
actionClass = "UIxCalFolderActions";
@@ -181,6 +176,16 @@
};
};
SOGoAppointmentFolderICS = {
methods = {
export = {
protectedBy = "View";
actionClass = "UIxCalFolderActions";
actionName = "export";
};
};
};
SOGoCalendarComponent = {
};

View File

@@ -2080,12 +2080,20 @@ function onCalendarsMenuPrepareVisibility() {
var selected = folders.getSelectedNodes();
if (selected.length > 0) {
var folderOwner = selected[0].getAttribute("owner");
var sharingOption = $(this).down("ul").childElements().last();
// Disable the "Sharing" option when calendar is not owned by user
if (folderOwner == UserLogin || IsSuperUser)
sharingOption.removeClassName("disabled");
else
sharingOption.addClassName("disabled");
var lis = $(this).down("ul").childElements();
/* distance: sharing = length - 1, export = length - 7 */
var endDists = [ 1, 7 ];
for (var i = 0; i < endDists.length; i++) {
var dist = lis.length - endDists[i];
var option = $(lis[dist]);
if (folderOwner == UserLogin || IsSuperUser)
option.removeClassName("disabled");
else
option.addClassName("disabled");
}
var deleteCalendarOption = $("deleteCalendarMenuItem");
// Swith between Delete and Unsubscribe
if (folderOwner == UserLogin)
@@ -2312,14 +2320,9 @@ function addWebCalendarCallback (http) {
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;
}
var url = URLForFolderID(folderId) + ".ics/export";
window.location.href = url;
}
function onCalendarImport(event) {