1 /* UIxCalMainView.m - this file is part of SOGo
3 * Copyright (C) 2006 Inverse groupe conseil
5 * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
7 * This file is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This file is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #import <Foundation/NSArray.h>
24 #import <Foundation/NSCalendarDate.h>
25 #import <Foundation/NSString.h>
26 #import <Foundation/NSUserDefaults.h>
27 #import <Foundation/NSValue.h>
29 #import <NGObjWeb/WOResponse.h>
31 #import <SOGo/SOGoUser.h>
33 #import "UIxCalMainView.h"
35 #import <Appointments/SOGoAppointmentFolder.h>
37 static NSMutableArray *monthMenuItems = nil;
38 static NSMutableArray *yearMenuItems = nil;
40 @implementation UIxCalMainView
42 - (NSArray *) monthMenuItems
48 monthMenuItems = [NSMutableArray arrayWithCapacity: 12];
50 for (count = 1; count < 13; count++)
51 [monthMenuItems addObject:
52 [NSString stringWithFormat: @"%.2d", count]];
53 [monthMenuItems retain];
56 return monthMenuItems;
59 - (void) setMonthMenuItem: (NSString *) aMonthMenuItem
61 monthMenuItem = aMonthMenuItem;
64 - (NSString *) monthMenuItem
69 - (NSString *) monthMenuItemLabel
71 return [self localizedNameForMonthOfYear: [monthMenuItem intValue]];
74 - (NSArray *) yearMenuItems
80 year = [[NSCalendarDate date] yearOfCommonEra];
81 yearMenuItems = [NSMutableArray arrayWithCapacity: 11];
82 for (count = -5; count < 6; count++)
83 [yearMenuItems addObject: [NSNumber numberWithInt: year + count]];
84 [yearMenuItems retain];
90 - (void) setYearMenuItem: (NSNumber *) aYearMenuItem
92 yearMenuItem = aYearMenuItem;
95 - (NSNumber *) yearMenuItem
100 - (id) batchDeleteAction
103 SOGoAppointmentFolder *clientObject;
105 ids = [[self queryParameterForKey: @"ids"] componentsSeparatedByString: @"/"];
108 clientObject = [self clientObject];
109 [clientObject deleteEntriesWithIds: ids];
115 - (id <WOActionResults>) updateCalendarsAction
117 WOResponse *response;
120 ud = [[context activeUser] userDefaults];
121 [ud setObject: [self queryParameterForKey: @"ids"]
122 forKey: @"calendaruids"];
124 response = [context response];
125 [response setStatus: 200];
126 [response setHeader: @"text/html; charset=\"utf-8\"" forKey: @"content-type"];
131 - (id <WOActionResults>) checkRightsAction
133 WOResponse *response;
135 NSString *uids, *uid;
136 NSMutableString *rights;
138 unsigned int count, max;
141 ud = [[context activeUser] userDefaults];
142 uids = [ud stringForKey: @"calendaruids"];
144 response = [context response];
145 [response setStatus: 200];
146 [response setHeader: @"text/plain; charset=\"utf-8\""
147 forKey: @"content-type"];
148 rights = [NSMutableString string];
149 if ([uids length] > 0)
151 ids = [uids componentsSeparatedByString: @","];
153 for (count = 0; count < max; count++)
155 uid = [ids objectAtIndex: count];
156 if ([uid hasPrefix: @"-"])
157 uid = [uid substringFromIndex: 1];
158 result = ([self calendarFolderForUID: uid] != nil);
160 [rights appendFormat: @"%d", result];
162 [rights appendFormat: @",%d", result];
165 [response appendContentString: rights];