From: znek Date: Tue, 19 Jul 2005 10:14:43 +0000 (+0000) Subject: rewrote the AnaisUidSelector - it's now unable to add duplicate ids X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f545895361059144ec93b8c1d39786f6a7804416;p=scalable-opengroupware.org rewrote the AnaisUidSelector - it's now unable to add duplicate ids git-svn-id: http://svn.opengroupware.org/SOGo/trunk@821 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/UI/Anais/AnaisUidSelector.m b/SOGo/UI/Anais/AnaisUidSelector.m index 3afb9d3a..0b2841dd 100644 --- a/SOGo/UI/Anais/AnaisUidSelector.m +++ b/SOGo/UI/Anais/AnaisUidSelector.m @@ -31,184 +31,113 @@ @interface AnaisUidSelector : UIxComponent { - NSArray *calendarUIDs; - NSString *uid; - NSString *userUid; - NSString *userCN; + NSString *userUID; + NSString *userUIDString; + NSString *activeUserCN; + int userUIDIdx; } -- (NSString *)prettyUid; -- (NSString *)userUid; -- (NSString *)userCN; -- (NSString *)_colorizedUid:(NSString *)_uid; +- (NSString *)prettyCN; - (NSString *)showHref; -- (NSString *)jsCode; - @end #include "common.h" #include +#include #include #include -#include +#include "SoObjects/Appointments/SOGoAppointmentFolder.h" @implementation AnaisUidSelector -- (id)init { - self = [super init]; - if(self) { - } - return self; -} - - (void)dealloc { - [self->calendarUIDs release]; - [self->uid release]; - [self->userUid release]; - [super dealloc]; + [self->userUID release]; + [self->userUIDString release]; + [self->activeUserCN release]; + [super dealloc]; } -- (void)setCalendarUIDs:(NSArray *)_calendarUIDs { - ASSIGN(self->calendarUIDs, _calendarUIDs); +/* Accessors */ + +- (void)setUserUID:(NSString *)_userUID { + ASSIGN(self->userUID, _userUID); } -- (NSArray *)calendarUIDs { - return self->calendarUIDs; +- (NSString *)userUID { + return self->userUID; } -- (void)setUid:(NSString *)_uid { - ASSIGN(self->uid, _uid); +- (void)setUserUIDIdx:(int)_userUIDIdx { + self->userUIDIdx = _userUIDIdx; } -- (NSString *)uid { - return self->uid; +- (int)userUIDIdx { + return self->userUIDIdx; +} +- (BOOL)needsComma { + return self->userUIDIdx == 0 ? NO : YES; } -- (NSString *)prettyUid { - AgenorUserManager *um; - NSString *cn; - if([self->calendarUIDs objectAtIndex:0] == self->uid) - return [self _colorizedUid:[self userCN]]; +- (NSString *)userUIDString { + if (!self->userUIDString) { + NSString *calendarUIDString; - um = [AgenorUserManager sharedUserManager]; - cn = [um getCNForUID:self->uid]; - return [NSString stringWithFormat:@", %@", [self _colorizedUid:cn]]; + calendarUIDString = [[[self clientObject] calendarUIDs] + componentsJoinedByString:@","]; + ASSIGN(self->userUIDString, calendarUIDString); + } + return self->userUIDString; } -- (NSString *)_colorizedUid:(NSString *)_uid { - if([_uid isEqualToString:[self userCN]]) { - _uid = [NSString stringWithFormat:@"%@", - _uid]; - } - return _uid; -} -/* Href */ +/* Helpers */ -- (NSString *)showHref { - return [self completeHrefForMethod:@"show"]; +- (NSArray *)userUIDs { + return [[self userUIDString] componentsSeparatedByString:@","]; } - -/* Helper */ - -- (NSString *)userUid { - if(!self->userUid) { - ASSIGN(self->userUid, [[self user] login]); +- (NSString *)activeUserCN { + if (!self->activeUserCN) { + activeUserCN = [[[[self context] activeUser] cn] retain]; } - return self->userUid; + return self->activeUserCN; } -- (NSString *)userCN { - if (!self->userCN) { - ASSIGN(self->userCN, [[[self context] activeUser] cn]); - } - return self->userCN; +- (NSString *)prettyCN { + AgenorUserManager *um; + NSString *cn; + NSString *classPart; + + um = [AgenorUserManager sharedUserManager]; + cn = [um getCNForUID:[self userUID]]; + if ([cn isEqualToString:[self activeUserCN]]) + classPart = @" class=\"anais_me\""; + else + classPart = @""; + + return [NSString stringWithFormat:@"%@", + [self userUID], + classPart, + cn]; } -- (NSString *)calendarUIDString { - return [[self calendarUIDs] componentsJoinedByString:@","]; + +/* Href */ + +- (NSString *)showHref { + return [self completeHrefForMethod:@"show"]; } /* this is to determine the initial visibility of the 'addMeToo' button */ - (NSString *)meTooStyle { - if([[self calendarUIDs] containsObject:userUid]) - return @"visibility:hidden"; - return @"visibility:visible"; + if([[self userUIDString] rangeOfString:[[[self context] activeUser] + login]].length > 0) + return @"visibility:hidden"; + return @"visibility:visible"; } -/* JavaScript */ - -- (NSString *)jsCode { - static NSString *script = \ - @"function clearElementWithId(elemId) {\n" - @" var o = document.getElementById(elemId);\n" - @" var dst = o.parentNode;\n" - @" var n = document.createElement('td');\n" - @" n.setAttribute('id', elemId);\n" - @" n.setAttribute('align', 'left');\n" - @" n.setAttribute('class', 'anais_uids');\n" - @" dst.replaceChild(n, o);\n" - @"}\n" - @"function clearUidList() {\n" - @" clearElementWithId('anaisUIDList');\n" - @" var e = document.getElementById('anaisUIDString');\n" - @" e.setAttribute('value', '');\n" - @" var td = document.getElementById('addMeToo');\n" - @" td.setAttribute('style', 'visibility:visible');\n" - @" td = document.getElementById('clearUidList');\n" - @" td.setAttribute('style', 'visibility:hidden');\n" - @" td = document.getElementById('showUidList');\n" - @" td.setAttribute('style', 'visibility:hidden');\n" - @"}\n" - @"function addMeToo() {\n" - @" addUid('', '', '%@', '', '%@', '');\n" - @" var td = document.getElementById('addMeToo');\n" - @" td.setAttribute('style', 'visibility:hidden');\n" - @"}\n" - @"function clearAllAndAddMe() {\n" - @" clearUidList();\n" - @" addMeToo();\n" - @"}\n" - @"function addUidFromAnais(type, email, uid, sn, cn, dn) {\n" - @" addUid(type, email, uid, sn, cn, dn); \n" - @"}\n" - @"function addUid(type, email, uid, sn, cn, dn) {\n" - @" if(!uid)\n" - @" return;\n" - @" var e = document.getElementById('anaisUIDString');\n" - @" var s = e.getAttribute('value');\n" - @" if(s)\n" - @" s = s + ',' + uid;\n" - @" else\n" - @" s = uid;\n" - @" e.setAttribute('value', s);\n" - @" var td = document.getElementById('anaisUIDList');\n" - @" var text;\n" - @" if(td.hasChildNodes()) {\n" - @" text = document.createTextNode(', ');\n" - @" td.appendChild(text);\n" - @" }\n" - @" text = document.createTextNode(cn);\n" - @" if(uid == '%@') {\n" - @" var span = document.createElement('span');\n" - @" span.setAttribute('class', 'anais_me');\n" - @" span.appendChild(text);\n" - @" td.appendChild(span);\n" - @" }\n" - @" else {\n" - @" td.appendChild(text);\n" - @" }\n" - @" td = document.getElementById('clearUidList');\n" - @" td.setAttribute('style', 'visibility:visible');\n" - @" td = document.getElementById('showUidList');\n" - @" td.setAttribute('style', 'visibility:visible');\n" - @"}\n" - @""; - - return [NSString stringWithFormat:script, - [self userUid], - [self userCN], - [self userUid]]; +/* actions */ + +- (BOOL)shouldTakeValuesFromRequest:(WORequest *)_rq inContext:(WOContext*)_c { + return YES; } @end diff --git a/SOGo/UI/Anais/ChangeLog b/SOGo/UI/Anais/ChangeLog index 2bfca1c4..c5c679b3 100644 --- a/SOGo/UI/Anais/ChangeLog +++ b/SOGo/UI/Anais/ChangeLog @@ -1,3 +1,7 @@ +2005-07-19 Marcus Mueller + + * AnaisUidSelector.m: completely rewritten (v0.9.23) + 2005-07-18 Marcus Mueller * AnaisUidSelector.m: rewritten to add the CN's to the displayed diff --git a/SOGo/UI/Anais/Version b/SOGo/UI/Anais/Version index 57a06811..84aa7bf9 100644 --- a/SOGo/UI/Anais/Version +++ b/SOGo/UI/Anais/Version @@ -1,3 +1,3 @@ # $Id: Version 165 2004-08-05 17:55:50Z znek $ -SUBMINOR_VERSION:=22 +SUBMINOR_VERSION:=23 diff --git a/SOGo/UI/Scheduler/ChangeLog b/SOGo/UI/Scheduler/ChangeLog index b1adf6a1..a44be11b 100644 --- a/SOGo/UI/Scheduler/ChangeLog +++ b/SOGo/UI/Scheduler/ChangeLog @@ -1,3 +1,9 @@ +2005-07-19 Marcus Mueller + + * UIxCalView.m: renamed 'anaisUIDString' to 'userUIDString' in order + to be independent from the Anais bundle but still provide the same + functionality (v0.9.138) + 2005-07-19 Helge Hess * UIxAppointmentEditor.m: moved iCalRecurrenceRule to separate file diff --git a/SOGo/UI/Scheduler/UIxCalView.m b/SOGo/UI/Scheduler/UIxCalView.m index 17c5487b..692efd77 100644 --- a/SOGo/UI/Scheduler/UIxCalView.m +++ b/SOGo/UI/Scheduler/UIxCalView.m @@ -436,7 +436,7 @@ static BOOL shouldDisplayWeekend = NO; req = [[self context] request]; - uidsString = [req formValueForKey:@"anaisUIDString"]; + uidsString = [req formValueForKey:@"userUIDString"]; uidsString = [uidsString stringByTrimmingWhiteSpaces]; prevMethod = [req formValueForKey:@"previousMethod"]; diff --git a/SOGo/UI/Scheduler/Version b/SOGo/UI/Scheduler/Version index 7e185334..358e5c98 100644 --- a/SOGo/UI/Scheduler/Version +++ b/SOGo/UI/Scheduler/Version @@ -1,6 +1,6 @@ # Version file -SUBMINOR_VERSION:=137 +SUBMINOR_VERSION:=138 # v0.9.136 requires SOGoUI v0.9.30 # v0.9.123 requires Appointments v0.9.35 diff --git a/SOGo/UI/Templates/AnaisUidSelector.wox b/SOGo/UI/Templates/AnaisUidSelector.wox index efe50a4a..f342015a 100644 --- a/SOGo/UI/Templates/AnaisUidSelector.wox +++ b/SOGo/UI/Templates/AnaisUidSelector.wox @@ -7,7 +7,72 @@ xmlns:label="OGo:label" > @@ -48,9 +113,9 @@
- diff --git a/SOGo/UI/Templates/ChangeLog b/SOGo/UI/Templates/ChangeLog index 95263781..2a5c4d90 100644 --- a/SOGo/UI/Templates/ChangeLog +++ b/SOGo/UI/Templates/ChangeLog @@ -1,3 +1,8 @@ +2005-07-19 Marcus Mueller + + * AnaisUidSelector.wox: moved JavaScript into component, renamed quite + a lot of stuff to reflect the current implementation + 2005-07-19 Helge Hess * UIxAppointmentEditor.wox: use parsing function from skycalendar.js
, +