]> err.no Git - scalable-opengroupware.org/commitdiff
rewrote the AnaisUidSelector - it's now unable to add duplicate ids
authorznek <znek@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 19 Jul 2005 10:14:43 +0000 (10:14 +0000)
committerznek <znek@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 19 Jul 2005 10:14:43 +0000 (10:14 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@821 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/UI/Anais/AnaisUidSelector.m
SOGo/UI/Anais/ChangeLog
SOGo/UI/Anais/Version
SOGo/UI/Scheduler/ChangeLog
SOGo/UI/Scheduler/UIxCalView.m
SOGo/UI/Scheduler/Version
SOGo/UI/Templates/AnaisUidSelector.wox
SOGo/UI/Templates/ChangeLog

index 3afb9d3a85a1f50e6294fb1e73a122cf94aeef42..0b2841dd6c1c4b989f50987040caee2ae1261c03 100644 (file)
 
 @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 <NGObjWeb/SoUser.h>
+#include <NGObjWeb/WOContext+SoObjects.h>
 #include <SOGo/AgenorUserManager.h>
 #include <SOGo/SOGoUser.h>
-#include <SOGo/WOContext+Agenor.h>
+#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:@"<span class=\""
-                                          @"anais_me\">%@</span>",
-            _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:@"<span id=\"%@\"%@>%@</span>",
+                                    [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
index 2bfca1c409204090243ff74d8e0632973670e6ce..c5c679b34b5c052305b6a5ef01875596d96330d5 100644 (file)
@@ -1,3 +1,7 @@
+2005-07-19  Marcus Mueller  <znek@mulle-kybernetik.com>
+
+       * AnaisUidSelector.m: completely rewritten (v0.9.23)
+
 2005-07-18  Marcus Mueller  <znek@mulle-kybernetik.com>
 
        * AnaisUidSelector.m: rewritten to add the CN's to the displayed
index 57a068113f8ac53fc285ec4edac31e094f676c2f..84aa7bf9437f84304553f79bc4f5b66ab5400b50 100644 (file)
@@ -1,3 +1,3 @@
 # $Id: Version 165 2004-08-05 17:55:50Z znek $
 
-SUBMINOR_VERSION:=22
+SUBMINOR_VERSION:=23
index b1adf6a178e4deeebc0a3e65a28adf45b08025a0..a44be11bf80384d61d10449c8e87bd4d4924bfec 100644 (file)
@@ -1,3 +1,9 @@
+2005-07-19  Marcus Mueller  <znek@mulle-kybernetik.com>
+
+       * 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  <helge.hess@opengroupware.org>
 
        * UIxAppointmentEditor.m: moved iCalRecurrenceRule to separate file
index 17c5487b7e0ac0b1058b2005ce21e226657cc209..692efd77177af808aaf57c430676cdfd88b833fc 100644 (file)
@@ -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"];
index 7e185334e149c25ac28ba3fb5945aaa1e21f468f..358e5c98208dfd9b10ef7a208eae7d8061e825e7 100644 (file)
@@ -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
index efe50a4ac56adddd0d7930826bc71b7310b46b9e..f342015ae3c3c9d04f09592e5791ce65aa027f3e 100644 (file)
@@ -7,7 +7,72 @@
       xmlns:label="OGo:label"
  >
   <script language="JavaScript">
-    <var:string value="jsCode" const:escapeHTML="NO" />
+    function clearElementWithId(elemId) {
+      var o = document.getElementById(elemId);
+      var dst = o.parentNode;
+      var n = document.createElement('td');
+      n.setAttribute('id', elemId);
+      n.setAttribute('align', 'left');
+      n.setAttribute('class', 'anais_uids');
+      dst.replaceChild(n, o);
+    }
+    function clearUidList() {
+      clearElementWithId('userCNs');
+      var e = document.getElementById('userUIDString');
+      e.setAttribute('value', '');
+      var td = document.getElementById('addMeToo');
+      td.setAttribute('style', 'visibility:visible');
+      td = document.getElementById('clearUidList');
+      td.setAttribute('style', 'visibility:hidden');
+      td = document.getElementById('showUidList');
+      td.setAttribute('style', 'visibility:hidden');
+    }
+    function addMeToo() {
+      addUid('', '', '<var:string value="context.activeUser.login" />', '', '<var:string value="context.activeUser.cn" />', '');
+      var td = document.getElementById('addMeToo');
+      td.setAttribute('style', 'visibility:hidden');
+    }
+    function clearAllAndAddMe() {
+      clearUidList();
+      addMeToo();
+    }
+    function addUidFromAnais(type, email, uid, sn, cn, dn) {
+      addUid(type, email, uid, sn, cn, dn); 
+    }
+    function addUid(type, email, uid, sn, cn, dn) {
+      if(!uid)
+        return;
+      var e = document.getElementById(uid);
+      if (e)
+        return;
+      e     = document.getElementById('userUIDString');
+      var s = e.getAttribute('value');
+      if(s)
+        s = s + ',' + uid;
+      else
+        s = uid;
+      e.setAttribute('value', s);
+      
+      // add CN
+      var td = document.getElementById('userCNs');
+      var text;
+      if(td.hasChildNodes()) {
+        text = document.createTextNode(', ');
+        td.appendChild(text);
+      }
+      text     = document.createTextNode(cn);
+      var span = document.createElement('span');
+      span.setAttribute('id', uid);
+      if(uid == '<var:string value="context.activeUser.login" />')
+        span.setAttribute('class', 'anais_me');
+      span.appendChild(text);
+      td.appendChild(span);
+
+      td = document.getElementById('clearUidList');
+      td.setAttribute('style', 'visibility:visible');
+      td = document.getElementById('showUidList');
+      td.setAttribute('style', 'visibility:visible');
+    }
   </script>
   <table cellspacing="2" cellpadding="0" width="100%" border="0">
     <var:if condition="isAccessRestricted" const:negate="YES">
               <span id="showUidList" class="button_submit_env">
                 <form var:href="showHref">
                   <input type="hidden"
-                         name="anaisUIDString"
-                         id="anaisUIDString"
-                         var:value="calendarUIDString"
+                         name="userUIDString"
+                         id="userUIDString"
+                         var:value="userUIDString"
                   />
                   <input type="hidden"
                          name="previousMethod"
       </tr>
     </var:if>
     <tr valign="top">
-      <td id="anaisUIDList"
+      <td id="userCNs"
           align="left"
           class="anais_uids"
-      ><var:foreach list="calendarUIDs"
-                    item="uid"
-       ><var:string value="prettyUid"
+      ><var:foreach list="userUIDs"
+                    item="userUID"
+                    index="userUIDIdx"
+       ><var:if condition="needsComma">, </var:if>
+        <var:string value="prettyCN"
                     const:escapeHTML="NO"
         /></var:foreach>
       </td>
index 95263781530af8f201c31628fd214f8820e4cd13..2a5c4d90727f8d9d742f55f53de7ba826784c7ce 100644 (file)
@@ -1,3 +1,8 @@
+2005-07-19  Marcus Mueller  <znek@mulle-kybernetik.com>
+
+       * AnaisUidSelector.wox: moved JavaScript into component, renamed quite
+         a lot of stuff to reflect the current implementation
+
 2005-07-19  Helge Hess  <helge.hess@opengroupware.org>
 
        * UIxAppointmentEditor.wox: use parsing function from skycalendar.js