]> err.no Git - scalable-opengroupware.org/commitdiff
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1099 d1b88da0-ebda-0310...
authorwolfgang <wolfgang@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Wed, 4 Jul 2007 20:33:18 +0000 (20:33 +0000)
committerwolfgang <wolfgang@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Wed, 4 Jul 2007 20:33:18 +0000 (20:33 +0000)
ChangeLog
Main/SOGo.m
NEWS [new file with mode: 0644]
SoObjects/Appointments/SOGoAppointmentFolder.m
SoObjects/Appointments/SOGoCalendarComponent.m
SoObjects/Mailer/SOGoMailObject.m
SoObjects/SOGo/SOGoAuthenticator.m
SoObjects/SOGo/SOGoFolder.m
SoObjects/SOGo/SOGoUser.m

index 85d34b2531591a40cc8a2e8d1e7c956cda7e3735..f64b2b057f53051a9f5bbe2803068ecd36a70923 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,36 @@
 2007-07-04  Wolfgang Sourdeau  <wsourdeau@inverse.ca>
 
+       * SoObjects/Mailer/SOGoMailObject.m ([SOGoMailObject
+       -contentAsString]): returns the message encoded in ISO Latin 1
+       again.
+
+       * SoObjects/SOGo/SOGoUser.m ([SOGoUser +initialize]): read the
+       SOGoSuperUsername user defaults.
+       ([SOGoUser -initWithLogin:newLoginroles:newRoles]): simplified
+       method.
+       ([SOGoUser -rolesForObject:objectinContext:context]): if the
+       current user is the superuser, grant him/her the "owner" role.
+
+       * SoObjects/SOGo/SOGoFolder.m ([SOGoFolder -ocsFolder]): create
+       the folder only if the current user is the owner of the future
+       folder.
+
+       * SoObjects/Appointments/SOGoCalendarComponent.m
+       ([SOGoCalendarComponent -contentAsString]): we return the content
+       based on the permissions returned by the security manager instead
+       of by looking at the user roles.
+
+       * SoObjects/Appointments/SOGoAppointmentFolder.m
+       ([SOGoAppointmentFolder -calendarFolders]): read the calendar
+       folders of the user to whom this folder belongs instead of the
+       active user. This way, a delegate user will be able to have the
+       same view that the original user has if he connects from his user
+       directory.
+
+       * Main/SOGo.m ([SOGo -lookupUser:_keyinContext:]): check if the
+       user exists before creating the SOGoUserFolder instance. If not,
+       returns nil.
+
        * UI/MailerUI/UIxMailSourceView.[hm]: new class module designed to
        return the message source code in plain text.
 
index efe2accf10744be180d986661e89eb076a33dd07..0ee12f43c1aae009650187b94b3a9e784b91a515 100644 (file)
@@ -43,6 +43,7 @@
 
 #import <SoObjects/SOGo/SOGoAuthenticator.h>
 #import <SoObjects/SOGo/SOGoUserFolder.h>
+#import <SoObjects/SOGo/SOGoUser.h>
 #import <SoObjects/SOGo/SOGoPermissions.h>
 
 #import "SOGoProductLoader.h"
@@ -241,9 +242,20 @@ static BOOL debugObjectAllocation = NO;
   return YES;
 }
 
-- (id)lookupUser:(NSString *)_key inContext:(id)_ctx {
-  return [$(@"SOGoUserFolder") objectWithName:_key
-          inContainer: self];
+- (id) lookupUser: (NSString *) _key
+       inContext: (id)_ctx
+{
+  SOGoUser *user;
+  id userFolder;
+
+  user = [SOGoUser userWithLogin: _key roles: nil];
+  if (user)
+    userFolder = [$(@"SOGoUserFolder") objectWithName: _key
+                  inContainer: self];
+  else
+    userFolder = nil;
+
+  return userFolder;
 }
 
 - (void) _setupLocaleInContext: (WOContext *) _ctx
@@ -289,7 +301,7 @@ static BOOL debugObjectAllocation = NO;
 
   if ([self isUserName:_key inContext:_ctx])
     return [self lookupUser:_key inContext:_ctx];
-  
+
   return nil;
 }
 
diff --git a/NEWS b/NEWS
new file mode 100644 (file)
index 0000000..4d5694a
--- /dev/null
+++ b/NEWS
@@ -0,0 +1,6 @@
+0.9.0 (200707XX)
+----------------
+- added the ability to specify a super user through the SOGoSuperUsername user default;
+- added the ability to view the message source;
+- no longer autocreate folders if we are not their owners;
+- made compatible with PostgreSQL 8.2;
index 6f098b7b579ff1c07a7e0e1481b45712da6d91ae..4e7257c302a450ee68d4efddf144a46bc794aa5d 100644 (file)
@@ -1229,20 +1229,21 @@ static NSNumber   *sharedYes = nil;
 {
   NSMutableDictionary *userCalendar, *calendarDict;
   NSMutableArray *calendarFolders;
-  SOGoUser *activeUser;
+  SOGoUser *calendarUser;
   BOOL firstActive;
 
   calendarFolders = [NSMutableArray new];
   [calendarFolders autorelease];
 
-  activeUser = [context activeUser];
+  calendarUser = [SOGoUser userWithLogin: [self ownerInContext: context]
+                          roles: nil];
   userCalendar = [NSMutableDictionary new];
   [userCalendar autorelease];
   [userCalendar setObject: @"/" forKey: @"folder"];
   [userCalendar setObject: @"Calendar" forKey: @"displayName"];
   [calendarFolders addObject: userCalendar];
 
-  calendarDict = [[activeUser userSettings] objectForKey: @"Calendar"];
+  calendarDict = [[calendarUser userSettings] objectForKey: @"Calendar"];
   firstActive = [[calendarDict objectForKey: @"activateUserFolder"] boolValue];
   firstActive = ([self _appendSubscribedFolders:
                         [calendarDict objectForKey: @"SubscribedFolders"]
index 5f707b181415f4bb278f6b3b23a9b22109f76c7c..5f987aa5bde27b969a581f7baa4c74e9ae820b21 100644 (file)
@@ -111,23 +111,38 @@ static BOOL sendEMailNotifications = NO;
 
 - (NSString *) contentAsString
 {
-  NSString *uid;
   iCalCalendar *tmpCalendar;
   iCalRepeatableEntityObject *tmpComponent;
-  NSArray *roles;
+//   NSArray *roles;
+//   NSString *uid;
+  SoSecurityManager *sm;
 
   if (!calContent)
     {
-      uid = [[context activeUser] login];
-      roles = [self aclsForUser: uid];
-      if ([roles containsObject: SOGoCalendarRole_Organizer]
-         || [roles containsObject: SOGoCalendarRole_Participant]
-         || [roles containsObject: SOGoCalendarRole_ComponentViewer])
-       {
-         calContent = content;
-         [calContent retain];
-       }
-      else if ([roles containsObject: SOGoCalendarRole_ComponentDAndTViewer])
+//       uid = [[context activeUser] login];
+//       roles = [self aclsForUser: uid];
+//       if ([roles containsObject: SOGoCalendarRole_Organizer]
+//       || [roles containsObject: SOGoCalendarRole_Participant]
+//       || [roles containsObject: SOGoCalendarRole_ComponentViewer])
+//     calContent = content;
+//       else if ([roles containsObject: SOGoCalendarRole_ComponentDAndTViewer])
+//     {
+//       tmpCalendar = [[self calendar: NO] copy];
+//       tmpComponent = (iCalRepeatableEntityObject *)
+//         [tmpCalendar firstChildWithTag: [self componentTag]];
+//       [self _filterComponent: tmpComponent];
+//       calContent = [tmpCalendar versitString];
+//       [tmpCalendar release];
+//     }
+//       else
+//     calContent = nil;
+
+      sm = [SoSecurityManager sharedSecurityManager];
+      if (![sm validatePermission: SOGoCalendarPerm_ViewAllComponent
+              onObject: self inContext: context])
+       calContent = content;
+      else if (![sm validatePermission: SOGoCalendarPerm_ViewDAndT
+                   onObject: self inContext: context])
        {
          tmpCalendar = [[self calendar: NO] copy];
          tmpComponent = (iCalRepeatableEntityObject *)
@@ -606,7 +621,6 @@ static BOOL sendEMailNotifications = NO;
       else if ([roles containsObject: SOGoRole_ObjectCreator])
        [roles addObject: SOGoCalendarRole_Organizer];
     }
-//     }
 
   return roles;
 }
index a8b76bdb240b282eb1c00529e391c25ba5dba1ec..29c6a0ea7789d148253865d8f47033b082ff5d94 100644 (file)
@@ -435,9 +435,8 @@ static BOOL debugSoParts       = NO;
   if ([content isKindOfClass:[NSException class]])
     return (id)content;
   
-#warning the encoding here might be wrong...
-  s = [[NSString alloc] initWithData: content 
-                       encoding: NSUTF8StringEncoding];
+  s = [[NSString alloc] initWithData: content
+                       encoding: NSISOLatin1StringEncoding];
   if (s == nil) {
     [self logWithFormat:
            @"ERROR: could not convert data of length %d to string", 
index fa9a0526de7abc588db9c43d0db3a36d3a6644e6..cb67ba4c63a7218b5ff654ec83ee53ad5a677864 100644 (file)
@@ -41,7 +41,7 @@
  
   if (!auth)
     auth = [self new];
-  
+
   return auth;
 }
 
     anonymous
       = [[SOGoUser alloc] initWithLogin: @"anonymous"
                          roles: [NSArray arrayWithObject: SoRole_Anonymous]];
-//   if (!freebusy)
-//     freebusy
-//       = [[SOGoUser alloc] initWithLogin: @"freebusy"
-//                           roles: [NSArray arrayWithObject: SOGoRole_FreeBusy]];
 
   login = [self checkCredentialsInContext:_ctx];
   if (login)
       if ([login isEqualToString: @"anonymous"])
         {
           traversalPath = [_ctx objectForKey: @"SoRequestTraversalPath"];
-//           if ([[traversalPath lastObject] isEqualToString: @"freebusy.ifb"])
-//             user = freebusy;
-//           else
          user = anonymous;
         }
       else
index 5eb8adb813218abfbf548f07fdac364e3c74e5c0..d3f73984a7bf12334a34292f2ac4913d6c34813f 100644 (file)
@@ -28,6 +28,7 @@
 #import <Foundation/NSURL.h>
 
 #import <NGObjWeb/SoObject.h>
+#import <NGObjWeb/WOContext+SoObjects.h>
 #import <NGExtensions/NSNull+misc.h>
 #import <NGExtensions/NSObject+Logs.h>
 #import <EOControl/EOQualifier.h>
@@ -38,6 +39,7 @@
 #import <SaxObjC/XMLNamespaces.h>
 
 #import "SOGoPermissions.h"
+#import "SOGoUser.h"
 
 #import "SOGoFolder.h"
 
@@ -151,11 +153,14 @@ static NSString *defaultUserID = @"<default>";
 - (GCSFolder *) ocsFolder
 {
   GCSFolder *folder;
+  NSString *userLogin;
 
   if (!ocsFolder)
     {
       ocsFolder = [self ocsFolderForPath: [self ocsPath]];
+      userLogin = [[context activeUser] login];
       if (!ocsFolder
+         && [userLogin isEqualToString: [self ownerInContext: context]]
          && [self folderIsMandatory]
          && [self create])
        ocsFolder = [self ocsFolderForPath: [self ocsPath]];
index 87383f4d866abc02ed3e7500e181b3aed47eee6b..17f20876d605725647bce9988ae45db911ec8479 100644 (file)
@@ -39,6 +39,7 @@
 static NSTimeZone *serverTimeZone = nil;
 static NSString *fallbackIMAP4Server = nil;
 static NSString *defaultLanguage = nil;
+static NSString *superUsername = nil;
 static NSURL *AgenorProfileURL = nil;
 static BOOL acceptAnyUser = NO;
 
@@ -57,7 +58,7 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
 
 + (void) initialize
 {
-  NSString *tzName;
+  NSString *tzName, *nsUsername;
   NSUserDefaults *ud;
   NSString *profileURL;
 
@@ -84,6 +85,12 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
       if (!defaultLanguage)
        ASSIGN (defaultLanguage, @"English");
     }
+  if (!superUsername)
+    {
+      nsUsername = [ud stringForKey: @"SOGoSuperUsername"];
+      if ([nsUsername length] > 0)
+       ASSIGN (superUsername, nsUsername);
+    }
 
   acceptAnyUser = (![ud stringForKey: @"AuthentificationMethod"]);
 }
@@ -120,21 +127,17 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
   LDAPUserManager *um;
   NSString *realUID;
 
-  if ([newLogin isEqualToString: @"anonymous"]
+  if (acceptAnyUser
+      || [newLogin isEqualToString: @"anonymous"]
       || [newLogin isEqualToString: @"freebusy"])
-    self = [super initWithLogin: newLogin roles: newRoles];
+    realUID = newLogin;
   else
     {
-      if (acceptAnyUser)
-       realUID = newLogin;
-      else
-       {
-         um = [LDAPUserManager sharedUserManager];
-         realUID = [[um contactInfosForUserWithUIDorEmail: newLogin]
-                  objectForKey: @"c_uid"];
-       }
-      self = [super initWithLogin: realUID roles: newRoles];
+      um = [LDAPUserManager sharedUserManager];
+      realUID = [[um contactInfosForUserWithUIDorEmail: newLogin]
+                 objectForKey: @"c_uid"];
     }
+  self = [super initWithLogin: realUID roles: newRoles];
 
   return self;
 }
@@ -289,9 +292,10 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
 - (NSUserDefaults *) userDefaults
 {
   if (!userDefaults)
-    userDefaults = [[AgenorUserDefaults alloc] initWithTableURL: AgenorProfileURL
-                                              uid: login
-                                              fieldName: @"defaults"];
+    userDefaults
+      = [[AgenorUserDefaults alloc] initWithTableURL: AgenorProfileURL
+                                   uid: login
+                                   fieldName: @"defaults"];
 
   return userDefaults;
 }
@@ -299,9 +303,10 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
 - (NSUserDefaults *) userSettings
 {
   if (!userSettings)
-    userSettings = [[AgenorUserDefaults alloc] initWithTableURL: AgenorProfileURL
-                                              uid: login
-                                              fieldName: @"settings"];
+    userSettings
+      = [[AgenorUserDefaults alloc] initWithTableURL: AgenorProfileURL
+                                   uid: login
+                                   fieldName: @"settings"];
 
   return userSettings;
 }
@@ -356,8 +361,9 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
   if (folder != nil)
     return [folder isNotNull] ? folder : nil;
   
-  folder = [[WOApplication application] lookupName:[self login]
-                                       inContext:_ctx acquire:NO];
+  folder = [[WOApplication application] lookupName: [self login]
+                                       inContext: _ctx
+                                       acquire: NO];
   if ([folder isKindOfClass:[NSException class]])
     return folder;
   
@@ -403,7 +409,8 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
   if (sogoRoles)
     [rolesForObject addObjectsFromArray: sogoRoles];
 
-  if ([[object ownerInContext: context] isEqualToString: [self login]])
+  if ((superUsername && [login isEqualToString: superUsername])
+      || [[object ownerInContext: context] isEqualToString: login])
     [rolesForObject addObject: SoRole_Owner];
   if ([object isKindOfClass: [SOGoObject class]])
     {