]> err.no Git - scalable-opengroupware.org/blob - UI/Scheduler/UIxFreeBusyUserSelector.m
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1017 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / UI / Scheduler / UIxFreeBusyUserSelector.m
1 /* UIxFreeBusyUserSelector.m - this file is part of SOGo
2  *
3  * Copyright (C) 2006 Inverse groupe conseil
4  *
5  * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
6  *
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)
10  * any later version.
11  *
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.
16  *
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.
21  */
22
23 #import <Foundation/NSArray.h>
24 #import <Foundation/NSValue.h>
25
26 #import <NGCards/iCalPerson.h>
27 #import <NGObjWeb/WORequest.h>
28
29 #import <SoObjects/SOGo/AgenorUserManager.h>
30
31 #import "UIxComponent+Agenor.h"
32 #import "UIxFreeBusyUserSelector.h"
33
34 @implementation UIxFreeBusyUserSelector
35
36 - (id) init
37 {
38   if ((self = [super init]))
39     {
40       startDate = nil;
41       endDate = nil;
42       dayStartHour = [NSNumber numberWithInt: 8];
43       [dayStartHour retain];
44       dayEndHour = [NSNumber numberWithInt: 18];
45       [dayEndHour retain];
46       contacts = nil;
47       selectorId = nil;
48     }
49
50   return self;
51 }
52
53 - (void) dealloc
54 {
55   [dayStartHour release];
56   [dayEndHour release];
57   if (contacts)
58     [contacts release];
59   if (selectorId)
60     [selectorId release];
61   [super dealloc];
62 }
63
64 - (void) setStartDate: (NSCalendarDate *) newStartDate
65 {
66   startDate = newStartDate;
67 }
68
69 - (NSCalendarDate *) startDate
70 {
71   return startDate;
72 }
73
74 - (void) setEndDate: (NSCalendarDate *) newEndDate
75 {
76   endDate = newEndDate;
77 }
78
79 - (NSCalendarDate *) endDate
80 {
81   return endDate;
82 }
83
84 - (void) setDayStartHour: (NSNumber *) newDayStartHour
85 {
86   ASSIGN (dayStartHour, newDayStartHour);
87 }
88
89 - (NSNumber *) dayStartHour
90 {
91   return dayStartHour;
92 }
93
94 - (void) setDayEndHour: (NSNumber *) newDayEndHour
95 {
96   ASSIGN (dayEndHour, newDayEndHour);
97 }
98
99 - (NSNumber *) dayEndHour
100 {
101   return dayEndHour;
102 }
103
104 - (void) setSelectorId: (NSString *) newSelectorId
105 {
106   ASSIGN (selectorId, newSelectorId);
107 }
108
109 - (NSString *) selectorId
110 {
111   return selectorId;
112 }
113
114 - (void) setContacts: (NSArray *) newContacts
115 {
116   ASSIGN (contacts, newContacts);
117 }
118
119 - (NSArray *) contacts
120 {
121   return contacts;
122 }
123
124 /* callbacks */
125 - (void) takeValuesFromRequest: (WORequest *) request
126                      inContext: (WOContext *) context
127 {
128   NSArray *newContacts;
129
130   newContacts
131     = [self getICalPersonsFromValue: [request formValueForKey: selectorId]];
132   ASSIGN (contacts, newContacts);
133   if ([contacts count] > 0)
134     NSLog (@"got %i attendees: %@", [contacts count], contacts);
135   else
136     NSLog (@"got no attendees!");
137 }
138
139 /* in-template operations */
140 - (NSString *) initialContactsAsString
141 {
142   NSEnumerator *persons;
143   iCalPerson *person;
144   NSMutableArray *participants;
145
146   participants = [NSMutableArray arrayWithCapacity: [contacts count]];
147   persons = [contacts objectEnumerator];
148   person = [persons nextObject];
149   while (person)
150     {
151       [participants addObject: [person cn]];
152       person = [persons nextObject];
153     }
154
155   return [participants componentsJoinedByString: @","];
156 }
157
158 - (NSString *) freeBusyViewId
159 {
160   return [NSString stringWithFormat: @"parentOf%@", [selectorId capitalizedString]];
161 }
162  
163 @end