From f1da116a55427b177adfb959c0bb4c542cd6109c Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Fri, 21 Oct 2011 20:12:38 +0000 Subject: [PATCH] See ChangeLog. Monotone-Parent: f6c6bfab15922450127ccb9597bbc97468d695c0 Monotone-Revision: afd67b085b60bc29f1319198a1796a532db22ebf Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2011-10-21T20:12:38 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 23 ++++++++++++++++++ SoObjects/SOGo/SOGoUserManager.m | 4 ++++ UI/Common/UIxAclEditor.m | 20 +++++++++------- UI/MainUI/SOGoUserHomePage.m | 3 ++- UI/Templates/UIxAclEditor.wox | 2 +- UI/WebServerResources/UIxAclEditor.css | 6 ++++- UI/WebServerResources/UIxAclEditor.js | 15 ++++++------ .../UIxContactsUserFolders.js | 24 ++++++++++++++----- UI/WebServerResources/UIxMailToSelection.js | 3 +++ 9 files changed, 75 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index d9c52c637..7b43649f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2011-10-21 Francis Lachapelle + + * SoObjects/SOGo/SOGoUserManager.m + (-_compactAndCompleteContacts:): add the key "isGroup" when defined. + + * UI/MainUI/SOGoUserHomePage.m (:_usersForResults:inDomain:): + add a boolean value in the returning array that identifies if the + user is actually a group. + + * UI/Common/UIxAclEditor.m (-currentUserClass): return the CSS + class that identifies the user as a single contact or list of contacts. + + * UI/WebServerResources/UIxContactsUserFolders.js + (addUserLineToTree): extract the new field that is set to 1 when + the user is actually a group. + + * UI/WebServerResources/UIxAclEditor.js (addUser): new argument to + to identify the type of user (person or group). + + * UI/WebServerResources/UIxMailToSelection.js + (expandContactListCallback): don't expand contacts without an + email address. + 2011-10-19 Wolfgang Sourdeau * OpenChange/MAPIStoreDraftsMessage.m (-getPrDisplayTo:inMemCtx:) diff --git a/SoObjects/SOGo/SOGoUserManager.m b/SoObjects/SOGo/SOGoUserManager.m index 9fa124793..7113769c8 100644 --- a/SoObjects/SOGo/SOGoUserManager.m +++ b/SoObjects/SOGo/SOGoUserManager.m @@ -804,6 +804,7 @@ NSArray *newContacts; NSMutableArray *emails; NSString *uid, *email, *info; + NSNumber *isGroup; compactContacts = [NSMutableDictionary dictionary]; while ((userEntry = [contacts nextObject])) @@ -844,6 +845,9 @@ && ![[returnContact objectForKey: @"c_info"] length]) [returnContact setObject: info forKey: @"c_info"]; [self _fillContactMailRecords: returnContact]; + isGroup = [userEntry objectForKey: @"isGroup"]; + if (isGroup) + [returnContact setObject: isGroup forKey: @"isGroup"]; } } diff --git a/UI/Common/UIxAclEditor.m b/UI/Common/UIxAclEditor.m index e825a8bcd..27f6cfd89 100644 --- a/UI/Common/UIxAclEditor.m +++ b/UI/Common/UIxAclEditor.m @@ -96,9 +96,6 @@ aclsEnum = [[self aclsForObject] objectEnumerator]; while ((currentUID = [aclsEnum nextObject])) { - if ([currentUID hasPrefix: @"@"]) - // NOTE: don't remove the prefix if we want to identify the lists visually - currentUID = [currentUID substringFromIndex: 1]; if (!([currentUID isEqualToString: ownerLogin] || [currentUID isEqualToString: defaultUserID] || [currentUID isEqualToString: @"anonymous"])) @@ -117,20 +114,25 @@ - (NSString *) currentUser { - return currentUser; + return ([currentUser hasPrefix: @"@"] + ? [currentUser substringFromIndex: 1] + : currentUser); +} + +- (NSString *) currentUserClass +{ + return ([currentUser hasPrefix: @"@"] + ? @"normal-group" + : @"normal-user"); } - (NSString *) currentUserDisplayName { SOGoUserManager *um; - NSString *s; um = [SOGoUserManager sharedUserManager]; - s = ([currentUser hasPrefix: @"@"] - ? [currentUser substringFromIndex: 1] - : currentUser); - return [um getFullEmailForUID: s]; + return [um getFullEmailForUID: [self currentUser]]; } - (BOOL) canSubscribeUsers diff --git a/UI/MainUI/SOGoUserHomePage.m b/UI/MainUI/SOGoUserHomePage.m index 2d79eef0a..86a8f0a1d 100644 --- a/UI/MainUI/SOGoUserHomePage.m +++ b/UI/MainUI/SOGoUserHomePage.m @@ -326,7 +326,7 @@ NSMutableArray *jsonResponse, *jsonLine; NSArray *allUsers; int count, max; - BOOL activeUserIsInDomain; + BOOL activeUserIsInDomain, isGroup; login = [[context activeUser] login]; activeUserIsInDomain = ([domain length] == 0 || [[[context activeUser] domain] isEqualToString: domain]); @@ -352,6 +352,7 @@ [jsonLine addObject: uid]; [jsonLine addObject: [contact objectForKey: @"cn"]]; [jsonLine addObject: [contact objectForKey: @"c_email"]]; + [jsonLine addObject: [NSNumber numberWithBool: [[contact objectForKey: @"isGroup"] boolValue]]]; contactInfo = [contact objectForKey: @"c_info"]; if (contactInfo) [jsonLine addObject: contactInfo]; diff --git a/UI/Templates/UIxAclEditor.wox b/UI/Templates/UIxAclEditor.wox index b9ed8f443..d567d39d7 100644 --- a/UI/Templates/UIxAclEditor.wox +++ b/UI/Templates/UIxAclEditor.wox @@ -38,7 +38,7 @@
  • + >
  • diff --git a/UI/WebServerResources/UIxAclEditor.css b/UI/WebServerResources/UIxAclEditor.css index 7c599e59b..6fa681531 100644 --- a/UI/WebServerResources/UIxAclEditor.css +++ b/UI/WebServerResources/UIxAclEditor.css @@ -51,9 +51,13 @@ UL#userList LI background-repeat: no-repeat; background-position: 4px center; } -UL#userList LI.normal-user +UL#userList LI.normal-user, +UL#userList LI.normal-person { background-image: url("abcard.png"); } +UL#userList LI.normal-group +{ background-image: url("ablist.png"); } + UL#userList LI.any-user { background-image: url("abcard-anyone.png"); border-top: 1px dotted #555; } diff --git a/UI/WebServerResources/UIxAclEditor.js b/UI/WebServerResources/UIxAclEditor.js index 94d3949ed..f11ced3dc 100644 --- a/UI/WebServerResources/UIxAclEditor.js +++ b/UI/WebServerResources/UIxAclEditor.js @@ -9,18 +9,18 @@ var AclEditor = { var usersToSubscribe = []; -function addUser(userName, userID) { +function addUser(userName, userID, type) { var result = false; if (!$(userID)) { var ul = $("userList"); var lis = ul.childNodesWithTag("li"); var newNode = nodeForUser(userName, userID, canSubscribeUsers); - newNode.addClassName("normal-user"); + newNode.addClassName("normal-" + type); var count = lis.length - 1; var nextLi = null; while (count > -1 && !nextLi) { - if ($(lis[count]).hasClassName("normal-user")) { + if ($(lis[count]).hasClassName("normal-person")) { nextLi = lis[count+1]; } else { @@ -142,7 +142,8 @@ function subscribeToFolder(refreshCallback, refreshCallbackData) { var result = true; if (UserLogin != refreshCallbackData["folder"]) { result = addUser(refreshCallbackData["folderName"], - refreshCallbackData["folder"]); + refreshCallbackData["folder"], + refreshCallbackData["type"]); } else refreshCallbackData["window"].alert(_("You cannot subscribe to a folder that you own!")); @@ -223,9 +224,9 @@ function onAclCloseHandler(event) { + "/subscribeUsers?uids=" + usersToSubscribe.join(",")); new Ajax.Request(url, { asynchronous: false, - method: 'get', - onFailure: function(transport) { - log("Can't expunge current folder: " + transport.status); + method: 'get', + onFailure: function(transport) { + log("Can't subscribe users: " + transport.status); } }); } diff --git a/UI/WebServerResources/UIxContactsUserFolders.js b/UI/WebServerResources/UIxContactsUserFolders.js index a59f2e7fe..a2dd8f418 100644 --- a/UI/WebServerResources/UIxContactsUserFolders.js +++ b/UI/WebServerResources/UIxContactsUserFolders.js @@ -37,15 +37,26 @@ function usersSearchCallback(http) { } function addUserLineToTree(tree, parent, line) { + // line[0] = uid + // line[1] = cn + // line[2] = email + // line[3] = 1 if it's a group + // line[4] = contact info var icon = ResourcesURL + '/busy.gif'; var email = line[1] + " <" + line[2] + ">"; - if (line[3] && !line[3].empty()) - email += ", " + line[3].split("\n").join("; "); // extra contact info - tree.add(parent, 0, email, 0, '#', line[0], 'person', + if (line[4] && !line[4].empty()) + email += ", " + line[4].split("\n").join("; "); // extra contact info + var icon_card = 'abcard.png'; + var datatype = 'person'; + if (line[3]) { + icon_card = 'ablist.png'; + datatype = 'group'; + } + tree.add(parent, 0, email, 0, '#', line[0], datatype, '', '', - ResourcesURL + '/abcard.png', - ResourcesURL + '/abcard.png'); + ResourcesURL + '/' + icon_card, + ResourcesURL + '/' + icon_card); if (window.opener.userFolderType != "user") { tree.add(parent + 1, parent, _("Please wait..."), 0, '#', null, null, '', '', icon, icon); @@ -198,6 +209,7 @@ function onConfirmFolderSelection(event) { if (topNode && topNode.selectedEntry) { var node = topNode.selectedEntry.parentNode; var folder = node.getAttribute("dataname"); + var type = node.getAttribute("datatype"); var folderName; if (window.opener.userFolderType == "user") { @@ -217,7 +229,7 @@ function onConfirmFolderSelection(event) { folderName = folderName.replace(/>,.*(\))?$/, ">)$1", "g"); } - var data = { folderName: folderName, folder: folder, window: window }; + var data = { folderName: folderName, folder: folder, type: type, window: window }; if (parent$(accessToSubscribedFolder(folder))) window.alert(_("You have already subscribed to that folder!")); else diff --git a/UI/WebServerResources/UIxMailToSelection.js b/UI/WebServerResources/UIxMailToSelection.js index aae4f32fc..4452e0613 100644 --- a/UI/WebServerResources/UIxMailToSelection.js +++ b/UI/WebServerResources/UIxMailToSelection.js @@ -107,6 +107,9 @@ function expandContactListCallback (http) { if (http.status == 200) { var data = http.responseText.evalJSON(true); // TODO: Should check for duplicated entries + for (var i = data.length - 1; i >= 0; i--) + // Remove contacts with no email address + if (data[i][2].length == 0) data.splice(i, 1); if (data.length >= 1) { var text = data[0][2]; if (data[0][1].length)