propagate from branch 'ca.inverse.sogo.1_3_12' (head 235258efee8273e9b6d2822d3d5da125520631c7)

to branch 'ca.inverse.sogo' (head b2bfdd5b59fed2950707131eca171b4758bcd635)

Monotone-Parent: 235258efee8273e9b6d2822d3d5da125520631c7
Monotone-Parent: b2bfdd5b59fed2950707131eca171b4758bcd635
Monotone-Revision: f67fbb0139df60f0e98c0aede6b166d1a8b15d81

Monotone-Author: flachapelle@inverse.ca
Monotone-Date: 2012-02-08T04:24:33
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Francis Lachapelle
2012-02-08 04:24:33 +00:00
132 changed files with 5043 additions and 3264 deletions
+2
View File
@@ -52,6 +52,8 @@
categories = [[self categories] mutableCopy];
[categories autorelease];
if (!categories)
categories = [NSMutableArray array];
if (set)
{
if (![categories containsObject: category])
+3 -7
View File
@@ -27,22 +27,18 @@
@class NSString;
@class NSMutableDictionary;
@class NGVCard;
@class SOGoContactFolder;
@interface UIxContactEditor : UIxComponent
{
id addressBookItem;
NSString *preferredEmail;
NSString *item;
NGVCard *card;
NSMutableArray *photosURL;
NSMutableDictionary *snapshot; /* contains the values for editing */
NSMutableDictionary *ldifRecord; /* contains the values for editing */
SOGoContactFolder *componentAddressBook;
NSArray *contactCategories;
}
- (NSMutableDictionary *) ldifRecord;
- (void) setAddressBookItem: (id) _item;
- (id) addressBookItem;
+93 -559
View File
@@ -34,8 +34,6 @@
#import <NGExtensions/NSNull+misc.h>
#import <NGCards/NGVCard.h>
#import <NGCards/NGVCardPhoto.h>
#import <NGCards/NSArray+NGCards.h>
#import <SOGo/NSArray+Utilities.h>
#import <SOGo/NSString+Utilities.h>
@@ -50,20 +48,23 @@
#import "UIxContactEditor.h"
static Class SOGoContactGCSEntryK = Nil;
@implementation UIxContactEditor
+ (void) initialize
{
SOGoContactGCSEntryK = [SOGoContactGCSEntry class];
}
- (id) init
{
if ((self = [super init]))
{
snapshot = [[NSMutableDictionary alloc] initWithCapacity: 16];
preferredEmail = nil;
photosURL = nil;
ldifRecord = nil;
addressBookItem = nil;
item = nil;
card = nil;
componentAddressBook = nil;
contactCategories = nil;
}
return self;
@@ -71,18 +72,35 @@
- (void) dealloc
{
[snapshot release];
[preferredEmail release];
[photosURL release];
[ldifRecord release];
[addressBookItem release];
[item release];
[componentAddressBook release];
[contactCategories release];
[super dealloc];
}
/* accessors */
- (NSMutableDictionary *) ldifRecord
{
NSDictionary *clientLDIFRecord;
NSString *queryValue;
if (!ldifRecord)
{
clientLDIFRecord = [[self clientObject] ldifRecord];
ldifRecord = [clientLDIFRecord mutableCopy];
queryValue = [self queryParameterForKey: @"contactEmail"];
if ([queryValue length] > 0)
[ldifRecord setObject: queryValue forKey: @"mail"];
queryValue = [self queryParameterForKey: @"contactFN"];
if ([queryValue length] > 0)
[ldifRecord setObject: queryValue forKey: @"displayname"];
}
return ldifRecord;
}
- (void) setAddressBookItem: (id) _item
{
ASSIGN (addressBookItem, _item);
@@ -130,27 +148,6 @@
/* load/store content format */
// - (void) _fixupSnapshot
// {
// NSString *currentKey, *currentString;
// NSMutableString *newString;
// NSArray *keys;
// unsigned int count, max;
// keys = [snapshot allKeys];
// max = [keys count];
// for (count = 0; count < max; count++)
// {
// currentKey = [keys objectAtIndex: count];
// currentString = [snapshot objectForKey: currentKey];
// newString = [currentString mutableCopy];
// [newString autorelease];
// [newString replaceString: @";" withString: @"\\;"];
// if (![newString isEqualToString: currentString])
// [snapshot setObject: newString forKey: currentKey];
// }
// }
/* helper */
- (NSString *) _completeURIForMethod: (NSString *) _method
@@ -179,12 +176,7 @@
- (BOOL) isNew
{
id co;
co = [self clientObject];
return ([co isKindOfClass: [SOGoContentObject class]]
&& [co isNew]);
return ([[self clientObject] isNew]);
}
- (NSArray *) addressBooksList
@@ -205,14 +197,13 @@
while (currentFolder)
{
if ([currentFolder isEqual: folder] ||
([currentFolder isKindOfClass: [SOGoContactGCSFolder class]] &&
![sm validatePermission: SoPerm_AddDocumentsImagesAndFiles
onObject: currentFolder
inContext: context]))
![sm validatePermission: SoPerm_AddDocumentsImagesAndFiles
onObject: currentFolder
inContext: context])
[addressBooksList addObject: currentFolder];
currentFolder = [folders nextObject];
}
return addressBooksList;
}
@@ -245,26 +236,30 @@
return fDisplayName;
}
- (void) setContactCategories: (NSString *) jsonCategories
- (BOOL) supportCategories
{
return [[self clientObject] isKindOfClass: SOGoContactGCSEntryK];
}
- (void) setJsonContactCategories: (NSString *) jsonCategories
{
NSArray *newCategories;
newCategories = [jsonCategories objectFromJSONString];
if ([newCategories isKindOfClass: [NSArray class]])
ASSIGN (contactCategories, newCategories);
[[self ldifRecord] setObject: newCategories
forKey: @"vcardcategories"];
else
[[self ldifRecord] removeObjectForKey: @"vcardcategories"];
}
- (NSString *) contactCategories
- (NSString *) jsonContactCategories
{
NSString *jsonCats;
NSArray *categories;
if (!contactCategories)
ASSIGN (contactCategories, [card categories]);
jsonCats = [contactCategories jsonRepresentation];
if (!jsonCats)
jsonCats = @"[]";
categories = [[self ldifRecord] objectForKey: @"vcardcategories"];
return jsonCats;
return [categories jsonRepresentation];
}
- (NSArray *) _languageContactsCategories
@@ -279,11 +274,11 @@
return [categoryLabels trimmedComponents];
}
- (NSArray *) _fetchAndCombineCategoriesList: (NSArray *) contactCats
- (NSArray *) _fetchAndCombineCategoriesList
{
NSString *ownerLogin;
SOGoUserDefaults *ud;
NSArray *cats, *newCats;
NSArray *cats, *newCats, *contactCategories;
ownerLogin = [[self clientObject] ownerInContext: context];
ud = [[SOGoUser userWithLogin: ownerLogin] userDefaults];
@@ -291,9 +286,10 @@
if (!cats)
cats = [self _languageContactsCategories];
if (contactCats)
contactCategories = [[self ldifRecord] objectForKey: @"vcardcategories"];
if (contactCategories)
{
newCats = [cats mergedArrayWithArray: contactCats];
newCats = [cats mergedArrayWithArray: contactCategories];
if ([newCats count] != [cats count])
{
cats = [newCats sortedArrayUsingSelector:
@@ -311,7 +307,7 @@
NSArray *cats;
NSString *list;
cats = [self _fetchAndCombineCategoriesList: [card categories]];
cats = [self _fetchAndCombineCategoriesList];
list = [cats jsonRepresentation];
if (!list)
list = @"[]";
@@ -328,311 +324,7 @@
actionName = [[request requestHandlerPath] lastPathComponent];
return ([[self clientObject] isKindOfClass: [SOGoContactGCSEntry class]]
&& [actionName hasPrefix: @"save"]);
}
- (void) _setSnapshotValue: (NSString *) key
to: (NSString *) aValue
{
if (!aValue)
aValue = @"";
[snapshot setObject: aValue forKey: key];
}
- (NSMutableDictionary *) snapshot
{
return snapshot;
}
- (NSString *) _simpleValueForType: (NSString *) aType
inArray: (NSArray *) anArray
excluding: (NSString *) aTypeToExclude
{
NSArray *elements;
NSString *value;
elements = [anArray cardElementsWithAttribute: @"type"
havingValue: aType];
value = nil;
if ([elements count] > 0)
{
CardElement *ce;
int i;
for (i = 0; i < [elements count]; i++)
{
ce = [elements objectAtIndex: i];
value = [ce flattenedValuesForKey: @""];
if (!aTypeToExclude)
break;
if (![ce hasAttribute: @"type" havingValue: aTypeToExclude])
break;
value = nil;
}
}
return value;
}
- (void) _setupEmailFields
{
NSArray *elements;
NSString *workMail, *homeMail, *prefMail, *potential;
unsigned int max;
elements = [card childrenWithTag: @"email"];
max = [elements count];
workMail = [self _simpleValueForType: @"work"
inArray: elements excluding: nil];
homeMail = [self _simpleValueForType: @"home"
inArray: elements excluding: nil];
prefMail = [self _simpleValueForType: @"pref"
inArray: elements excluding: nil];
if (max > 0)
{
potential = [[elements objectAtIndex: 0] flattenedValuesForKey: @""];
if (!workMail)
{
if (homeMail && homeMail == potential)
{
if (max > 1)
workMail = [[elements objectAtIndex: 1] flattenedValuesForKey: @""];
}
else
workMail = potential;
}
if (!homeMail && max > 1)
{
if (workMail && workMail == potential)
homeMail = [[elements objectAtIndex: 1] flattenedValuesForKey: @""];
else
homeMail = potential;
}
if (prefMail)
{
if (prefMail == workMail)
preferredEmail = @"work";
else if (prefMail == homeMail)
preferredEmail = @"home";
}
}
[self _setSnapshotValue: @"workMail" to: workMail];
[self _setSnapshotValue: @"homeMail" to: homeMail];
[self _setSnapshotValue: @"mozillaUseHtmlMail"
to: [[card uniqueChildWithTag: @"x-mozilla-html"] flattenedValuesForKey: @""]];
}
- (void) _setupOrgFields
{
NSMutableArray *orgServices;
CardElement *org;
NSString *service;
NSUInteger count, max;
org = [card org];
[self _setSnapshotValue: @"workCompany"
to: [org flattenedValueAtIndex: 0 forKey: @""]];
max = [[org valuesForKey: @""] count];
if (max > 1)
{
orgServices = [NSMutableArray arrayWithCapacity: max];
for (count = 1; count < max; count++)
{
service = [org flattenedValueAtIndex: count forKey: @""];
if ([service length] > 0)
[orgServices addObject: service];
}
[self _setSnapshotValue: @"workService"
to: [orgServices componentsJoinedByString: @", "]];
}
}
- (NSString *) preferredEmail
{
return preferredEmail;
}
- (void) setPreferredEmail: (NSString *) aString
{
preferredEmail = aString;
}
- (void) _retrieveQueryParameter: (NSString *) queryKey
intoSnapshotValue: (NSString *) snapshotKey
{
NSString *queryValue;
queryValue = [self queryParameterForKey: queryKey];
if (queryValue && [queryValue length] > 0)
[self _setSnapshotValue: snapshotKey to: queryValue];
}
- (void) initSnapshot
{
NSArray *elements;
CardElement *element;
element = [card n];
[self _setSnapshotValue: @"sn"
to: [element flattenedValueAtIndex: 0 forKey: @""]];
[self _setSnapshotValue: @"givenName"
to: [element flattenedValueAtIndex: 1 forKey: @""]];
[self _setSnapshotValue: @"fn" to: [card fn]];
[self _setSnapshotValue: @"nickname" to: [card nickname]];
elements = [card childrenWithTag: @"tel"];
// We do this (exclude FAX) in order to avoid setting the WORK number as the FAX
// one if we do see the FAX field BEFORE the WORK number.
[self _setSnapshotValue: @"telephoneNumber"
to: [self _simpleValueForType: @"work" inArray: elements excluding: @"fax"]];
[self _setSnapshotValue: @"homeTelephoneNumber"
to: [self _simpleValueForType: @"home" inArray: elements excluding: @"fax"]];
[self _setSnapshotValue: @"mobile"
to: [self _simpleValueForType: @"cell" inArray: elements excluding: nil]];
[self _setSnapshotValue: @"facsimileTelephoneNumber"
to: [self _simpleValueForType: @"fax" inArray: elements excluding: nil]];
[self _setSnapshotValue: @"pager"
to: [self _simpleValueForType: @"pager" inArray: elements excluding: nil]];
// If we don't have a "home" and "work" phone number but
// we have a "voice" one defined, we set it to the "work" value
// This can happen when we have :
// VERSION:2.1
// N:name;surname;;;;
// TEL;VOICE;HOME:
// TEL;VOICE;WORK:
// TEL;PAGER:
// TEL;FAX;WORK:
// TEL;CELL:514 123 1234
// TEL;VOICE:450 456 6789
// ADR;HOME:;;;;;;
// ADR;WORK:;;;;;;
// ADR:;;;;;;
if ([[snapshot objectForKey: @"telephoneNumber"] length] == 0 &&
[[snapshot objectForKey: @"homeTelephoneNumber"] length] == 0 &&
[elements count] > 0)
{
[self _setSnapshotValue: @"telephoneNumber"
to: [self _simpleValueForType: @"voice" inArray: elements excluding: nil]];
}
[self _setupEmailFields];
[self _setSnapshotValue: @"screenName"
to: [[card uniqueChildWithTag: @"x-aim"] flattenedValuesForKey: @""]];
elements = [card childrenWithTag: @"adr"
andAttribute: @"type" havingValue: @"work"];
if (elements && [elements count] > 0)
{
element = [elements objectAtIndex: 0];
[self _setSnapshotValue: @"workExtendedAddress"
to: [element flattenedValueAtIndex: 1 forKey: @""]];
[self _setSnapshotValue: @"workStreetAddress"
to: [element flattenedValueAtIndex: 2 forKey: @""]];
[self _setSnapshotValue: @"workCity"
to: [element flattenedValueAtIndex: 3 forKey: @""]];
[self _setSnapshotValue: @"workState"
to: [element flattenedValueAtIndex: 4 forKey: @""]];
[self _setSnapshotValue: @"workPostalCode"
to: [element flattenedValueAtIndex: 5 forKey: @""]];
[self _setSnapshotValue: @"workCountry"
to: [element flattenedValueAtIndex: 6 forKey: @""]];
}
elements = [card childrenWithTag: @"adr"
andAttribute: @"type" havingValue: @"home"];
if (elements && [elements count] > 0)
{
element = [elements objectAtIndex: 0];
[self _setSnapshotValue: @"homeExtendedAddress"
to: [element flattenedValueAtIndex: 1 forKey: @""]];
[self _setSnapshotValue: @"homeStreetAddress"
to: [element flattenedValueAtIndex: 2 forKey: @""]];
[self _setSnapshotValue: @"homeCity"
to: [element flattenedValueAtIndex: 3 forKey: @""]];
[self _setSnapshotValue: @"homeState"
to: [element flattenedValueAtIndex: 4 forKey: @""]];
[self _setSnapshotValue: @"homePostalCode"
to: [element flattenedValueAtIndex: 5 forKey: @""]];
[self _setSnapshotValue: @"homeCountry"
to: [element flattenedValueAtIndex: 6 forKey: @""]];
}
elements = [card childrenWithTag: @"url"];
[self _setSnapshotValue: @"workURL"
to: [self _simpleValueForType: @"work" inArray: elements excluding: nil]];
[self _setSnapshotValue: @"homeURL"
to: [self _simpleValueForType: @"home" inArray: elements excluding: nil]];
// If we don't have a "work" or "home" URL but we still have
// an URL field present, let's add it to the "home" value
if ([[snapshot objectForKey: @"workURL"] length] == 0 &&
[[snapshot objectForKey: @"homeURL"] length] == 0 &&
[elements count] > 0)
{
[self _setSnapshotValue: @"homeURL"
to: [[elements objectAtIndex: 0] flattenedValuesForKey: @""]];
}
// If we do have a "work" URL but no "home" URL but two
// values URLs present, let's add the second one as the home URL
else if ([[snapshot objectForKey: @"workURL"] length] > 0 &&
[[snapshot objectForKey: @"homeURL"] length] == 0 &&
[elements count] > 1)
{
int i;
for (i = 0; i < [elements count]; i++)
{
if ([[[elements objectAtIndex: i] flattenedValuesForKey: @""]
caseInsensitiveCompare: [snapshot objectForKey: @"workURL"]] != NSOrderedSame)
{
[self _setSnapshotValue: @"homeURL"
to: [[elements objectAtIndex: i] flattenedValuesForKey: @""]];
break;
}
}
}
[self _setSnapshotValue: @"calFBURL"
to: [[card uniqueChildWithTag: @"FBURL"] flattenedValuesForKey: @""]];
[self _setSnapshotValue: @"title" to: [card title]];
[self _setupOrgFields];
[self _setSnapshotValue: @"bday" to: [card bday]];
[self _setSnapshotValue: @"tz" to: [card tz]];
[self _setSnapshotValue: @"note" to: [card note]];
[self _retrieveQueryParameter: @"contactEmail"
intoSnapshotValue: @"workMail"];
[self _retrieveQueryParameter: @"contactFN"
intoSnapshotValue: @"fn"];
}
- (id <WOActionResults>) defaultAction
{
card = [[self clientObject] vCard];
if (card)
[self initSnapshot];
else
return [NSException exceptionWithHTTPStatus:404 /* Not Found */
reason: @"could not open contact"];
return self;
return ([actionName hasPrefix: @"save"]);
}
- (NSString *) viewActionName
@@ -647,216 +339,60 @@
return @"editAsContact";
}
- (BOOL) canCreateOrModify
- (BOOL) supportPhotos
{
SOGoObject *co;
co = [self clientObject];
return ([co isKindOfClass: [SOGoContentObject class]]
&& [super canCreateOrModify]);
return [[self clientObject] isKindOfClass: SOGoContactGCSEntryK];
}
- (NSArray *) photosURL
- (BOOL) hasPhoto
{
return [[self clientObject] hasPhoto];
}
- (NSString *) photoURL
{
NSArray *photoElements;
NSURL *soURL;
NSString *baseInlineURL, *photoURL;
NGVCardPhoto *photo;
int count, max;
if (!photosURL)
{
soURL = [[self clientObject] soURL];
baseInlineURL = [soURL absoluteString];
photoElements = [card childrenWithTag: @"photo"];
max = [photoElements count];
photosURL = [[NSMutableArray alloc] initWithCapacity: max];
for (count = 0; count < max; count++)
{
photo = [photoElements objectAtIndex: count];
if ([photo isInline])
photoURL = [NSString stringWithFormat: @"%@/photo%d",
baseInlineURL, count];
else
photoURL = [photo flattenedValuesForKey: @""];
[photosURL addObject: photoURL];
}
}
soURL = [[self clientObject] soURL];
return photosURL;
}
- (CardElement *) _elementWithTag: (NSString *) tag
ofType: (NSString *) type
{
NSArray *elements;
CardElement *element;
elements = [card childrenWithTag: tag
andAttribute: @"type" havingValue: type];
if ([elements count] > 0)
element = [elements objectAtIndex: 0];
else
{
element = [CardElement new];
[element autorelease];
[element setTag: tag];
[element addType: type];
[card addChild: element];
}
return element;
}
- (void) _savePhoneValues
{
CardElement *phone;
phone = [self _elementWithTag: @"tel" ofType: @"work"];
[phone setSingleValue: [snapshot objectForKey: @"telephoneNumber"] forKey: @""];
phone = [self _elementWithTag: @"tel" ofType: @"home"];
[phone setSingleValue: [snapshot objectForKey: @"homeTelephoneNumber"] forKey: @""];
phone = [self _elementWithTag: @"tel" ofType: @"cell"];
[phone setSingleValue: [snapshot objectForKey: @"mobile"] forKey: @""];
phone = [self _elementWithTag: @"tel" ofType: @"fax"];
[phone setSingleValue: [snapshot objectForKey: @"facsimileTelephoneNumber"]
forKey: @""];
phone = [self _elementWithTag: @"tel" ofType: @"pager"];
[phone setSingleValue: [snapshot objectForKey: @"pager"] forKey: @""];
}
- (void) _saveEmails
{
CardElement *workMail, *homeMail;
workMail = [self _elementWithTag: @"email" ofType: @"work"];
[workMail setSingleValue: [snapshot objectForKey: @"workMail"] forKey: @""];
homeMail = [self _elementWithTag: @"email" ofType: @"home"];
[homeMail setSingleValue: [snapshot objectForKey: @"homeMail"] forKey: @""];
if (preferredEmail)
{
if ([preferredEmail isEqualToString: @"work"])
[card setPreferred: workMail];
else
[card setPreferred: homeMail];
}
[[card uniqueChildWithTag: @"x-mozilla-html"]
setSingleValue: [snapshot objectForKey: @"mozillaUseHtmlMail"]
forKey: @""];
}
- (void) _saveSnapshot
{
CardElement *element;
NSArray *units;
[card setNWithFamily: [snapshot objectForKey: @"sn"]
given: [snapshot objectForKey: @"givenName"]
additional: nil
prefixes: nil
suffixes: nil];
[card setNickname: [snapshot objectForKey: @"nickname"]];
[card setFn: [snapshot objectForKey: @"fn"]];
[card setTitle: [snapshot objectForKey: @"title"]];
[card setBday: [snapshot objectForKey: @"bday"]];
[card setNote: [snapshot objectForKey: @"note"]];
[card setTz: [snapshot objectForKey: @"tz"]];
element = [self _elementWithTag: @"adr" ofType: @"home"];
[element setSingleValue: [snapshot objectForKey: @"homeExtendedAddress"]
atIndex: 1 forKey: @""];
[element setSingleValue: [snapshot objectForKey: @"homeStreetAddress"]
atIndex: 2 forKey: @""];
[element setSingleValue: [snapshot objectForKey: @"homeCity"]
atIndex: 3 forKey: @""];
[element setSingleValue: [snapshot objectForKey: @"homeState"]
atIndex: 4 forKey: @""];
[element setSingleValue: [snapshot objectForKey: @"homePostalCode"]
atIndex: 5 forKey: @""];
[element setSingleValue: [snapshot objectForKey: @"homeCountry"]
atIndex: 6 forKey: @""];
element = [self _elementWithTag: @"adr" ofType: @"work"];
[element setSingleValue: [snapshot objectForKey: @"workExtendedAddress"]
atIndex: 1 forKey: @""];
[element setSingleValue: [snapshot objectForKey: @"workStreetAddress"]
atIndex: 2 forKey: @""];
[element setSingleValue: [snapshot objectForKey: @"workCity"]
atIndex: 3 forKey: @""];
[element setSingleValue: [snapshot objectForKey: @"workState"]
atIndex: 4 forKey: @""];
[element setSingleValue: [snapshot objectForKey: @"workPostalCode"]
atIndex: 5 forKey: @""];
[element setSingleValue: [snapshot objectForKey: @"workCountry"]
atIndex: 6 forKey: @""];
element = [CardElement simpleElementWithTag: @"fburl"
value: [snapshot objectForKey: @"calFBURL"]];
[card setUniqueChild: element];
units = [NSArray arrayWithObject: [snapshot objectForKey: @"workService"]];
[card setOrg: [snapshot objectForKey: @"workCompany"]
units: units];
[self _savePhoneValues];
[self _saveEmails];
[[self _elementWithTag: @"url" ofType: @"home"]
setSingleValue: [snapshot objectForKey: @"homeURL"] forKey: @""];
[[self _elementWithTag: @"url" ofType: @"work"]
setSingleValue: [snapshot objectForKey: @"workURL"] forKey: @""];
[[card uniqueChildWithTag: @"x-aim"]
setSingleValue: [snapshot objectForKey: @"screenName"]
forKey: @""];
return [NSString stringWithFormat: @"%@/photo", [soURL absoluteString]];
}
- (id <WOActionResults>) saveAction
{
SOGoContactGCSEntry *contact;
SOGoObject <SOGoContactObject> *contact;
id result;
NSString *jsRefreshMethod;
SoSecurityManager *sm;
contact = [self clientObject];
card = [contact vCard];
if (card)
{
// [self _fixupSnapshot];
[self _saveSnapshot];
[card setCategories: contactCategories];
[self _fetchAndCombineCategoriesList: contactCategories];
[contact save];
[contact setLDIFRecord: ldifRecord];
[self _fetchAndCombineCategoriesList];
[contact save];
if (componentAddressBook && componentAddressBook != [self componentAddressBook])
{
sm = [SoSecurityManager sharedSecurityManager];
if (![sm validatePermission: SoPerm_DeleteObjects
onObject: componentAddressBook
inContext: context])
{
if (![sm validatePermission: SoPerm_AddDocumentsImagesAndFiles
onObject: componentAddressBook
inContext: context])
[contact moveToFolder: (SOGoGCSFolder *)componentAddressBook]; // TODO: handle exception
}
}
if ([[[[self context] request] formValueForKey: @"nojs"] intValue])
result = [self redirectToLocation: [self modulePath]];
else
if (componentAddressBook && componentAddressBook != [self componentAddressBook])
{
sm = [SoSecurityManager sharedSecurityManager];
if (![sm validatePermission: SoPerm_DeleteObjects
onObject: componentAddressBook
inContext: context])
{
jsRefreshMethod
= [NSString stringWithFormat: @"refreshContacts(\"%@\")",
[contact nameInContainer]];
result = [self jsCloseWithRefreshMethod: jsRefreshMethod];
if (![sm validatePermission: SoPerm_AddDocumentsImagesAndFiles
onObject: componentAddressBook
inContext: context])
[contact moveToFolder: (SOGoGCSFolder *)componentAddressBook]; // TODO: handle exception
}
}
if ([[[[self context] request] formValueForKey: @"nojs"] intValue])
result = [self redirectToLocation: [self modulePath]];
else
result = [NSException exceptionWithHTTPStatus: 400 /* Bad Request */
reason: @"method cannot be invoked on "
@"the specified object"];
{
jsRefreshMethod
= [NSString stringWithFormat: @"refreshContacts(\"%@\")",
[contact nameInContainer]];
result = [self jsCloseWithRefreshMethod: jsRefreshMethod];
}
return result;
}
@@ -866,17 +402,15 @@
NSString *email, *cn, *url;
NSMutableString *address;
card = [[self clientObject] vCard];
[self initSnapshot];
if ([preferredEmail isEqualToString: @"home"])
email = [snapshot objectForKey: @"homeMail"];
else
email = [snapshot objectForKey: @"workMail"];
[self ldifRecord];
email = [ldifRecord objectForKey: @"mail"];
if ([email length] == 0)
email = [ldifRecord objectForKey: @"mozillasecondemail"];
if (email)
{
address = [NSMutableString string];
cn = [card fn];
cn = [ldifRecord objectForKey: @"cn"];
if ([cn length] > 0)
[address appendFormat: @"%@ <%@>", cn, email];
else
+3 -1
View File
@@ -35,6 +35,7 @@
#import <Contacts/SOGoContactObject.h>
#import <Contacts/SOGoContactFolder.h>
#import <Contacts/SOGoContactFolders.h>
#import <Contacts/NSDictionary+LDIF.h>
#import <SoObjects/Contacts/NGVCard+SOGo.h>
#import <SoObjects/Contacts/NGVList+SOGo.h>
@@ -76,9 +77,10 @@
inContext: [self context]
acquire: NO];
if ([currentChild respondsToSelector: @selector (vCard)])
[content appendFormat: [[currentChild vCard] ldifString]];
[content appendFormat: [[currentChild ldifRecord] ldifRecordAsString]];
else if ([currentChild respondsToSelector: @selector (vList)])
[content appendFormat: [[currentChild vList] ldifString]];
[content appendString: @"\n"];
}
response = [context response];
+30 -7
View File
@@ -52,8 +52,16 @@
#import "UIxContactFoldersView.h"
Class SOGoContactSourceFolderK, SOGoGCSFolderK;
@implementation UIxContactFoldersView
+ (void) initialize
{
SOGoContactSourceFolderK = [SOGoContactSourceFolder class];
SOGoGCSFolderK = [SOGoGCSFolder class];
}
- (id) init
{
if ((self = [super init]))
@@ -110,11 +118,13 @@
folders = [self clientObject];
folder = [folders lookupPersonalFolder: @"personal" ignoringRights: YES];
contactInfos = [folder lookupContactsWithFilter: nil
onCriteria: nil
sortBy: @"c_cn"
ordering: NSOrderedAscending];
if (folder && [folder conformsToProtocol: @protocol (SOGoContactFolder)])
contactInfos = [folder lookupContactsWithFilter: nil
onCriteria: nil
sortBy: @"c_cn"
ordering: NSOrderedAscending];
else
contactInfos = nil;
return contactInfos;
}
@@ -183,7 +193,7 @@
{
folder = [folders objectAtIndex: i];
/* We first search in LDAP folders (in case of duplicated entries in GCS folders) */
if ([folder isKindOfClass: [SOGoContactSourceFolder class]])
if ([folder isKindOfClass: SOGoContactSourceFolderK])
[sortedFolders insertObject: folder atIndex: 0];
else
[sortedFolders addObject: folder];
@@ -287,10 +297,23 @@
- (NSString *) currentContactFolderClass
{
return ([currentFolder isKindOfClass: [SOGoContactSourceFolder class]]
return (([currentFolder isKindOfClass: SOGoContactSourceFolderK]
&& ![currentFolder isPersonalSource])
? @"remote" : @"local");
}
- (NSString *) currentContactFolderAclEditing
{
return ([currentFolder isKindOfClass: SOGoGCSFolderK]
? @"available": @"unavailable");
}
- (NSString *) currentContactFolderListEditing
{
return ([currentFolder isKindOfClass: SOGoGCSFolderK]
? @"available": @"unavailable");
}
- (NSString *) verticalDragHandleStyle
{
NSString *vertical;
+5 -22
View File
@@ -52,6 +52,7 @@
- (void) dealloc
{
[card release];
[photosURL release];
[super dealloc];
}
@@ -377,9 +378,7 @@
{
NSString *data;
data = nil;
if (url)
if ([url length] > 0)
{
if (![[url lowercaseString] rangeOfString: @"://"].length)
url = [NSString stringWithFormat: @"http://%@", url];
@@ -388,6 +387,8 @@
@"<a href=\"%@\" target=\"_blank\">%@</a>",
url, url];
}
else
data = nil;
return [self _cardStringWithLabel: nil value: data];
}
@@ -646,30 +647,12 @@
/* action */
- (id <WOActionResults>) vcardAction
{
#warning this method is unused
WOResponse *response;
card = [[self clientObject] vCard];
if (card)
{
response = [context response];
[response setHeader: @"text/vcard" forKey: @"Content-type"];
[response appendContentString: [card versitString]];
}
else
return [NSException exceptionWithHTTPStatus: 404 /* Not Found */
reason:@"could not locate contact"];
return response;
}
- (id <WOActionResults>) defaultAction
{
card = [[self clientObject] vCard];
if (card)
{
[card retain];
phones = nil;
homeAdr = nil;
workAdr = nil;
+21 -2
View File
@@ -139,6 +139,11 @@
pageName = "UIxContactEditor";
actionName = "new";
};
renameFolder = {
protectedBy = "Change Permissions";
actionClass = "UIxFolderActions";
actionName = "renameFolder";
};
mailer-contacts = {
protectedBy = "<public>";
pageName = "UIxContactFoldersView";
@@ -234,13 +239,27 @@
SOGoContactLDIFEntry = {
methods = {
view = {
protectedBy = "<public>";
protectedBy = "Access Contents Information";
pageName = "UIxContactView";
};
edit = {
protectedBy = "<public>";
protectedBy = "Access Contents Information";
pageName = "UIxContactEditor";
};
editAsContact = {
protectedBy = "Access Contents Information";
pageName = "UIxContactEditor";
};
save = {
protectedBy = "Change Images And Files";
pageName = "UIxContactEditor";
actionName = "save";
};
saveAsContact = {
protectedBy = "Change Images And Files";
pageName = "UIxContactEditor";
actionName = "save";
};
write = {
protectedBy = "<public>";
pageName = "UIxContactEditor";
+6 -52
View File
@@ -84,70 +84,24 @@
return response;
}
- (NSURL *) _urlOfFolder: (NSURL *) srcURL
renamedTo: (NSString *) folderName
{
NSString *path;
NSURL *destURL;
path = [[srcURL path] stringByDeletingLastPathComponent];
if (![path hasSuffix: @"/"])
path = [path stringByAppendingString: @"/"];
destURL = [[NSURL alloc] initWithScheme: [srcURL scheme]
host: [srcURL host]
path: [NSString stringWithFormat: @"%@%@",
path, folderName]];
[destURL autorelease];
return destURL;
}
- (WOResponse *) renameFolderAction
{
SOGoMailFolder *co, *inbox;
SOGoMailFolder *co;
WOResponse *response;
NGImap4Connection *connection;
NSException *error;
NSString *folderName;
NSURL *srcURL, *destURL;
co = [self clientObject];
folderName = [[context request] formValueForKey: @"name"];
if ([folderName length] > 0)
{
srcURL = [co imap4URL];
destURL = [self _urlOfFolder: srcURL renamedTo: folderName];
connection = [co imap4Connection];
inbox = [[co mailAccountFolder] inboxFolderInContext: context];
[[connection client] select: [inbox absoluteImap4Name]];
error = [connection moveMailboxAtURL: srcURL
toURL: destURL];
if (error)
{
response = [self responseWithStatus: 500];
[response appendContentString: @"Unable to rename folder."];
}
else
{
// We unsubscribe to the old one, and subscribe back to the new one
if ([[[context activeUser] userDefaults]
mailShowSubscribedFoldersOnly])
{
[[connection client] subscribe: [destURL path]];
[[connection client] unsubscribe: [srcURL path]];
}
response = [self responseWith204];
}
}
else
error = [co renameTo: folderName];
if (error)
{
response = [self responseWithStatus: 500];
[response appendContentString: @"Missing 'name' parameter."];
[response appendContentString: @"Unable to rename folder."];
}
else
response = [self responseWith204];
return response;
}
+138 -153
View File
@@ -1,4 +1,4 @@
<?xml version='1.0' standalone='yes'?>
<?xml version='1.0'?>
<!DOCTYPE var:component>
<var:component
xmlns="http://www.w3.org/1999/xhtml"
@@ -30,12 +30,16 @@
<li target="baseInfos">
<span><var:string label:value="Contact" /></span>
</li>
<li target="categoryInfos">
<span><var:string label:value="Categories" /></span></li>
<var:if condition="supportCategories"
><li target="categoryInfos">
<span><var:string label:value="Categories" /></span></li
></var:if>
<li target="addressesInfos">
<span><var:string label:value="Address" /></span></li>
<li target="photos">
<span><var:string label:value="Photos" /></span></li>
<var:if condition="supportPhotos"
><li target="photos">
<span><var:string label:value="Photos" /></span></li
></var:if>
<li target="otherInfos">
<span><var:string label:value="Other" /></span></li>
</ul>
@@ -46,34 +50,34 @@
<tr>
<td>
<label><var:string label:value="First:" />
<input type="text" class="textField" name="givenName"
id="givenName"
var:value="snapshot.givenName" />
</label>
<input type="text" class="textField" name="givenname"
id="givenname"
var:value="ldifRecord.givenname"
/></label>
</td>
</tr>
<tr>
<td>
<label><var:string label:value="Last:" />
<input type="text" class="textField" name="sn" id="sn"
var:value="snapshot.sn" />
</label>
var:value="ldifRecord.sn"
/></label>
</td>
</tr>
<tr>
<td>
<label><var:string label:value="Display:" />
<input type="text" class="textField" name="fn" id="fn"
var:value="snapshot.fn" />
</label>
<input type="text" class="textField" name="displayname" id="displayname"
var:value="ldifRecord.displayname"
/></label>
</td>
</tr>
<tr>
<td>
<label><var:string label:value="Nickname:" />
<input type="text" class="textField" name="nickname" id="nickname"
var:value="snapshot.nickname" />
</label>
<input type="text" class="textField" name="mozillanickname" id="mozillanickname"
var:value="ldifRecord.mozillanickname"
/></label>
</td>
</tr>
</table>
@@ -82,26 +86,26 @@
<tr>
<td>
<label><var:string label:value="Email:" />
<input type="text" class="textField" name="workMail" id="workMail"
var:value="snapshot.workMail" />
</label>
<input type="text" class="textField" name="mail" id="mail"
var:value="ldifRecord.mail"
/></label>
</td>
</tr>
<tr>
<td>
<label><var:string label:value="Additional Email:" />
<input type="text" class="textField" name="homeMail"
id="homeMail" var:value="snapshot.homeMail" />
</label>
<input type="text" class="textField" name="mozillasecondemail"
id="mozillasecondemail" var:value="ldifRecord.mozillasecondemail"
/></label>
</td>
</tr>
<tr>
<td>
<label><var:string label:value="Screen Name:"
/>
<input type="text" class="textField" name="screenName"
id="screenName" var:value="snapshot.screenName" />
</label>
<input type="text" class="textField" name="nsaimid"
id="nsaimid" var:value="ldifRecord.nsaimid"
/></label>
</td>
</tr>
<tr>
@@ -111,9 +115,8 @@
<var:popup list="htmlMailFormatList" item="item"
label:noSelectionString="htmlMailFormat_UNKNOWN"
string="itemHtmlMailFormatText"
selection="snapshot.mozillaUseHtmlMail"
/>
</label>
selection="ldifRecord.mozillausehtmlmail"
/></label>
</td>
</tr>
</table>
@@ -123,9 +126,9 @@
<td>
<label><var:string label:value="Work:" />
<input type="text" class="textField"
name="telephoneNumber"
id="telephoneNumber"
var:value="snapshot.telephoneNumber"
name="telephonenumber"
id="telephonenumber"
var:value="ldifRecord.telephonenumber"
/></label>
</td>
</tr>
@@ -133,24 +136,19 @@
<td>
<label><var:string label:value="Home:" />
<input type="text" class="textField"
name="homeTelephoneNumber"
id="homeTelephoneNumber"
var:value="snapshot.homeTelephoneNumber"
/>
</label>
name="homephone" id="homephone"
var:value="ldifRecord.homephone"
/></label>
</td>
</tr>
<tr>
<td>
<label><var:string label:value="Fax:" />
<input type="text" class="textField"
name="facsimileTelephoneNumber"
id="facsimileTelephoneNumber"
var:value="snapshot.facsimileTelephoneNumber"
/>
</label>
name="facsimiletelephonenumber"
id="facsimiletelephonenumber"
var:value="ldifRecord.facsimiletelephonenumber"
/></label>
</td>
</tr>
<tr>
@@ -159,38 +157,37 @@
<input type="text" class="textField"
name="pager"
id="pager"
var:value="snapshot.pager"
/>
</label>
var:value="ldifRecord.pager"
/></label>
</td>
</tr>
<tr>
<td>
<label><var:string label:value="Mobile:" />
<input type="text" class="textField" name="mobile" id="mobile"
var:value="snapshot.mobile" />
</label>
var:value="ldifRecord.mobile"
/></label>
</td>
</tr>
</table>
</div>
<div id="categoryInfos" class="tab">
<div id="categoryContainer">
</div>
<var:if condition="canCreateOrModify"
><input type="text" class="textField" id="emptyCategory"
const:readonly="readonly"
const:name="emptyCategory"
<var:if condition="supportCategories"
><div id="categoryInfos" class="tab">
<div id="categoryContainer">
</div>
<var:if condition="canCreateOrModify"
><input type="text" class="textField" id="emptyCategory"
const:readonly="readonly"
const:name="emptyCategory"
const:value="" /></var:if>
<script type="text/javascript">
var gCategories = <var:string value="contactCategoriesList" const:escapeHTML="NO"/>;
</script>
<input type="hidden" id="contactCategories"
const:name="contactCategories"
var:value="contactCategories" />
</div>
<script type="text/javascript">
var gCategories = <var:string value="contactCategoriesList" const:escapeHTML="NO"/>;
</script>
<input type="hidden" id="jsonContactCategories"
const:name="jsonContactCategories"
var:value="jsonContactCategories" />
</div></var:if>
<div id="addressesInfos" class="tab">
<span class="caption"><var:string label:value="Home" /></span>
@@ -198,64 +195,64 @@
<tr>
<td colspan="2">
<label><var:string label:value="Address:" />
<input type="text" class="textField" name="homeStreetAddress"
id="homeStreetAddress"
var:value="snapshot.homeStreetAddress" />
</label>
<input type="text" class="textField" name="mozillahomestreet"
id="mozillahomestreet"
var:value="ldifRecord.mozillahomestreet"
/></label>
</td>
</tr>
<tr>
<td colspan="2">
<label>
<input type="text" class="textField" name="homeExtendedAddress"
id="homeExtendedAddress"
var:value="snapshot.homeExtendedAddress" />
</label>
<input type="text" class="textField" namCe="mozillahomestreet2"
id="mozillahomestreet2"
var:value="ldifRecord.mozillahomestreet2"
/></label>
</td>
</tr>
<tr>
<td colspan="2">
<label><var:string label:value="City:" />
<input type="text" class="textField" name="homeCity"
id="homeCity"
var:value="snapshot.homeCity" />
</label>
<input type="text" class="textField" name="mozillahomelocalityname"
id="mozillahomelocalityname"
var:value="ldifRecord.mozillahomelocalityname"
/></label>
</td>
</tr>
<tr>
<td class="firstColumn">
<label><var:string label:value="State_Province:" />
<input type="text" class="textField" name="homeState"
id="homeState"
var:value="snapshot.homeState" />
</label>
<input type="text" class="textField" name="mozillahomestate"
id="mozillahomestate"
var:value="ldifRecord.mozillahomestate"
/></label>
</td>
<td class="secondColumn">
<label><var:string
label:value="ZIP_Postal Code:"
/>
<input type="text" class="textField" name="homePostalCode"
id="homePostalCode"
var:value="snapshot.homePostalCode" />
</label>
<input type="text" class="textField" name="mozillahomepostalcode"
id="mozillahomepostalcode"
var:value="ldifRecord.mozillahomepostalcode"
/></label>
</td>
</tr>
<tr>
<td colspan="2">
<label><var:string label:value="Country:" />
<input type="text" class="textField" name="homeCountry"
id="homeCountry"
var:value="snapshot.homeCountry" />
</label>
<input type="text" class="textField" name="mozillahomecountryname"
id="mozillahomecountryname"
var:value="ldifRecord.mozillahomecountryname"
/></label>
</td>
</tr>
<tr>
<td colspan="2">
<label>
<var:string label:value="Web Page:" />
<input type="text" class="textField" name="homeURL"
var:value="snapshot.homeURL" />
</label>
<input type="text" class="textField" name="mozillahomeurl"
var:value="ldifRecord.mozillahomeurl"
/></label>
</td>
</tr>
</table>
@@ -267,128 +264,116 @@
<var:string label:value="Title:" />
<input type="text" class="textField" name="title"
id="title"
var:value="snapshot.title" />
</label>
var:value="ldifRecord.title"
/></label>
</td>
</tr>
<tr>
<td colspan="2">
<label>
<var:string label:value="Department:" />
<input type="text" class="textField" name="workService"
id="workService"
var:value="snapshot.workService" />
</label>
<input type="text" class="textField" name="ou"
id="ou"
var:value="ldifRecord.ou"
/></label>
</td>
</tr>
<tr>
<td colspan="2">
<label><var:string label:value="Organization:" />
<input type="text" class="textField" name="workCompany"
id="workCompany"
var:value="snapshot.workCompany" />
</label>
<input type="text" class="textField" name="o"
id="o" var:value="ldifRecord.o"
/></label>
</td>
</tr>
<tr>
<td colspan="2">
<label><var:string label:value="Address:" />
<input type="text" class="textField" name="workStreetAddress"
id="workStreetAddress"
var:value="snapshot.workStreetAddress" />
</label>
<input type="text" class="textField" name="street"
id="street"
var:value="ldifRecord.street"
/></label>
</td>
</tr>
<tr>
<td colspan="2">
<label>
<input type="text" class="textField" name="workExtendedAddress"
id="workExtendedAddress"
var:value="snapshot.workExtendedAddress" />
</label>
<input type="text" class="textField" name="mozillaworkstreet2"
id="mozillaworkstreet2" var:value="ldifRecord.mozillaworkstreet2"
/></label>
</td>
</tr>
<tr>
<td colspan="2">
<label><var:string label:value="City:" />
<input type="text" class="textField" name="workCity"
id="workCity"
var:value="snapshot.workCity" />
</label>
<input type="text" class="textField" name="l"
id="l" var:value="ldifRecord.l"
/></label>
</td>
</tr>
<tr>
<td class="firstColumn">
<label><var:string label:value="State_Province:" />
<input type="text" class="textField" name="workState"
id="workState"
var:value="snapshot.workState" />
</label>
<input type="text" class="textField" name="st"
id="st" var:value="ldifRecord.st"
/></label>
</td>
<td class="secondColumn">
<label><var:string
label:value="ZIP_Postal Code:"
/>
<input type="text" class="textField" name="workPostalCode"
id="workPostalCode"
var:value="snapshot.workPostalCode" />
</label>
<input type="text" class="textField" name="postalcode"
id="postalcode" var:value="ldifRecord.postalcode"
/></label>
</td>
</tr>
<tr>
<td colspan="2">
<label><var:string label:value="Country:" />
<input type="text" class="textField" name="workCountry"
id="workCountry"
var:value="snapshot.workCountry" />
</label>
<input type="text" class="textField" name="c"
id="c" var:value="ldifRecord.c"
/></label>
</td>
</tr>
<tr>
<td colspan="2">
<label><var:string label:value="Web Page:" />
<input type="text" class="textField" name="workURL"
var:value="snapshot.workURL" />
</label>
<input type="text" class="textField" name="mozillaworkurl"
var:value="ldifRecord.mozillaworkurl"
/></label>
</td>
</tr>
</table>
</div>
<div id="photos" class="tab">
<var:foreach list="photosURL" item="currentPhotoURL">
<img var:src="currentPhotoURL" class="contactPhoto"/><br
/></var:foreach>
</div>
<var:if condition="supportPhotos"
><div id="photos" class="tab">
<var:if condition="hasPhoto"
><img var:src="photoURL" class="contactPhoto"
/></var:if>
</div
></var:if>
<div id="otherInfos" class="tab">
<table class="framenocaption">
<tr>
<td class="firstColumn">
<label><var:string label:value="Birthday (yyyy-mm-dd):" />
<td>
<label><var:string label:value="Birthday (yyyy-mm-dd):"/>
<input type="text" class="textField" name="birthyear" id="birthyear"
var:value="ldifRecord.birthyear"
/></label>
-
<input type="text" class="textField" name="birthmonth" id="birthmonth"
var:value="ldifRecord.birthmonth" />
-
<input type="text" class="textField" name="birthday" id="birthday"
var:value="snapshot.bday" />
</label>
</td>
<td class="secondColumn">
<label><var:string label:value="Timezone:" />
<input type="text" class="textField" name="tz" id="tz"
var:value="snapshot.tz" />
</label>
var:value="ldifRecord.birthday"/>
</td>
</tr>
<tr>
<td colspan="2">
<label><var:string label:value="Freebusy URL:" />
<input type="text" class="textField" name="calFBURL" id="calFBURL"
var:value="snapshot.calFBURL" />
</label>
</td>
</tr>
<tr>
<td colspan="2">
<td>
<label><var:string label:value="Note:" />
<textarea var:value="snapshot.note" name="note" id="note"></textarea>
<textarea var:value="ldifRecord.description" name="note" id="note"></textarea>
</label>
</td>
</tr>
@@ -121,6 +121,8 @@
><li var:id="currentContactFolderId"
var:owner="currentContactFolderOwner"
var:class="currentContactFolderClass"
var:acl-editing="currentContactFolderAclEditing"
var:list-editing="currentContactFolderListEditing"
><var:string value="currentContactFolderName"/></li
></var:foreach
>
+44 -27
View File
@@ -258,17 +258,6 @@ function onContactContextMenuHide(event) {
this.stopObserving("contextmenu:hide", onContactContextMenuHide);
}
function onFolderMenuHide(event) {
var topNode = $('d');
if (topNode.menuSelectedEntry) {
topNode.menuSelectedEntry.deselect();
topNode.menuSelectedEntry = null;
}
if (topNode.selectedEntry)
topNode.selectedEntry.selectElement();
}
function _onContactMenuAction(folderItem, action, refresh) {
var selectedFolders = $("contactFolders").getSelectedNodes();
var folderId = $(folderItem).readAttribute("folderId");
@@ -308,8 +297,9 @@ function onContactMenuMove(event) {
function onMenuExportContact (event) {
var selectedFolders = $("contactFolders").getSelectedNodes();
var selectedFolderId = $(selectedFolders[0]).readAttribute("id");
if (selectedFolderId != "/shared") {
var canExport = (selectedFolders[0].getAttribute("owner") != "nobody");
if (canExport) {
var selectedFolderId = $(selectedFolders[0]).readAttribute("id");
var contactIds = $(document.menuTarget).collect(function(row) {
return row.getAttribute("id");
});
@@ -512,9 +502,6 @@ function onToolbarDeleteSelectedContactsConfirm(dialogId) {
var contactsList = $('contactsList');
var rows = contactsList.getSelectedRowsId();
for (var i = 0; i < rows.length; i++) {
var row = $(rows[i]);
row.deselect();
row.hide();
delete cachedContacts[Contact.currentAddressBook + "/" + rows[i]];
var urlstr = (URLForFolderID(Contact.currentAddressBook) + "/"
+ rows[i] + "/delete");
@@ -532,6 +519,7 @@ function onContactDeleteEventCallback(http) {
$("contactView").update();
Contact.currentContact = null;
}
Contact.deleteContactsRequestCount--;
if (Contact.deleteContactsRequestCount == 0) {
var nextRow = row.next("tr");
@@ -543,7 +531,10 @@ function onContactDeleteEventCallback(http) {
loadContact(Contact.currentContact);
}
}
row.parentNode.removeChild(row);
if (row) {
row.deselect();
row.parentNode.removeChild(row);
}
}
else if (parseInt(http.status) == 403) {
var row = $(http.callbackData);
@@ -598,10 +589,11 @@ function newContact(sender) {
function newList(sender) {
var li = $(Contact.currentAddressBook);
if (li.hasClassName("remote"))
showAlertDialog(_("You cannot create a list in a shared address book."));
else
var listEditing = li.getAttribute("list-editing");
if (listEditing && listEditing == "available")
openContactWindow(URLForFolderID(Contact.currentAddressBook) + "/newlist");
else
showAlertDialog(_("You cannot create a list in a shared address book."));
return false;
}
@@ -1068,15 +1060,15 @@ function onMenuSharing(event) {
var folders = $("contactFolders");
var selected = folders.getSelectedNodes()[0];
var owner = selected.getAttribute("owner");
if (owner == "nobody")
showAlertDialog(_("The user rights cannot be edited for this object!"));
else {
var aclEditing = selected.getAttribute("acl-editing");
if (aclEditing && aclEditing == "available") {
var title = this.innerHTML;
var url = URLForFolderID(selected.getAttribute("id"));
openAclWindow(url + "/acls", title);
}
else
showAlertDialog(_("The user rights cannot be edited for this object!"));
}
function onAddressBooksMenuPrepareVisibility() {
@@ -1089,30 +1081,55 @@ function onAddressBooksMenuPrepareVisibility() {
var menu = $("contactFoldersMenu").down("ul");;
var listElements = menu.childNodesWithTag("li");
var modifyOption = listElements[0];
var newListOption = listElements[3];
var removeOption = listElements[5];
var exportOption = listElements[7];
var importOption = listElements[8];
var sharingOption = listElements[listElements.length - 1];
// Disable the "Sharing" and "Modify" options when address book
// is not owned by user
if (folderOwner == UserLogin || IsSuperUser) {
modifyOption.removeClassName("disabled"); // WARNING: will fail for super users anyway
sharingOption.removeClassName("disabled");
modifyOption.removeClassName("disabled"); // WARNING: will fail
// for super users
// anyway
var aclEditing = selected[0].getAttribute("acl-editing");
if (aclEditing && aclEditing == "available") {
sharingOption.removeClassName("disabled");
}
else {
sharingOption.addClassName("disabled");
}
}
else {
modifyOption.addClassName("disabled");
sharingOption.addClassName("disabled");
}
var listEditing = selected[0].getAttribute("list-editing");
if (listEditing && listEditing == "available") {
newListOption.removeClassName("disabled");
}
else {
newListOption.addClassName("disabled");
}
/* Disable the "remove" and "export ab" options when address book is
public */
if (folderOwner == "nobody") {
exportOption.addClassName("disabled");
importOption.addClassName("disabled");
removeOption.addClassName("disabled");
}
else {
exportOption.removeClassName("disabled");
removeOption.removeClassName("disabled");
importOption.removeClassName("disabled");
if (selected[0].getAttribute("id") == "/personal") {
removeOption.addClassName("disabled");
}
else {
removeOption.removeClassName("disabled");
}
}
return true;
@@ -69,3 +69,9 @@ INPUT.comboBoxField, #emptyCategory
#otherInfos TEXTAREA
{ width: 70%; }
#birthday, #birthmonth
{ width: 18px; }
#birthyear
{ width: 36px; }
+53 -49
View File
@@ -22,9 +22,9 @@
02111-1307, USA.
*/
var dateRegex = /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/;
var dateRegex = /^(([0-9]{2})?[0-9])?[0-9]-[0-9]?[0-9]-[0-9]?[0-9]$/;
var displayNameChanged = false;
var displaynameChanged = false;
var tabIndex = 0;
@@ -37,43 +37,43 @@ function unescapeCallbackParameter(s) {
}
function copyContact(type, email, uid, sn,
cn, givenName, telephoneNumber, facsimileTelephoneNumber,
mobile, postalAddress, homePostalAddress,
departmentNumber, l)
displayname, givenname, telephonenumber, facsimiletelephonenumber,
mobile, postalAddress, homePostalAddress,
departmentnumber, l)
{
// var type = arguments[0];
// var email = arguments[1];
// var uid = arguments[2];
// var sn = arguments[3];
// var givenName = arguments[4];
// var telephoneNumber = arguments[5];
// var facsimileTelephoneNumber = arguments[6];
// var givenname = arguments[4];
// var telephonenumber = arguments[5];
// var facsimiletelephonenumber = arguments[6];
// var mobile = arguments[7];
// var postalAddress = arguments[8];
// var homePostalAddress = arguments[9];
// var departmentNumber = arguments[10];
// var postaladdress = arguments[8];
// var homepostaladdress = arguments[9];
// var departmentnumber = arguments[10];
// var l = arguments[11];
var e;
e = $('cn');
e.setAttribute('value', unescapeCallbackParameter(cn));
e = $('displayname');
e.setAttribute('value', unescapeCallbackParameter(displayname));
e = $('email');
e.setAttribute('value', email);
e = $('sn');
e.setAttribute('value', unescapeCallbackParameter(sn));
e = $('givenName');
e.setAttribute('value', unescapeCallbackParameter(givenName));
e = $('telephoneNumber');
e.setAttribute('value', telephoneNumber);
e = $('facsimileTelephoneNumber');
e.setAttribute('value', facsimileTelephoneNumber);
e = $('givenname');
e.setAttribute('value', unescapeCallbackParameter(givenname));
e = $('telephonenumber');
e.setAttribute('value', telephonenumber);
e = $('facsimiletelephonenumber');
e.setAttribute('value', facsimileTelephonenumber);
e = $('mobile');
e.setAttribute('value', mobile);
e = $('postalAddress');
e = $('postaladdress');
e.setAttribute('value', unescapeCallbackParameter(postalAddress));
e = $('homePostalAddress');
e = $('homepostaladdress');
e.setAttribute('value', unescapeCallbackParameter(homePostalAddress));
e = $('departmentNumber');
e.setAttribute('value', unescapeCallbackParameter(departmentNumber));
e = $('departmentnumber');
e.setAttribute('value', unescapeCallbackParameter(departmentnumber));
e = $('l');
e.setAttribute('value', unescapeCallbackParameter(l));
};
@@ -81,23 +81,25 @@ function copyContact(type, email, uid, sn,
function validateContactEditor() {
var rc = true;
var e = $('workMail');
var e = $('mail');
if (e.value.length > 0
&& !emailRE.test(e.value)) {
alert(_("invalidemailwarn"));
rc = false;
}
e = $('homeMail');
e = $('mozillasecondemail');
if (e.value.length > 0
&& !emailRE.test(e.value)) {
alert(_("invalidemailwarn"));
rc = false;
}
e = $('birthday');
if (e.value.length > 0
&& !dateRegex.test(e.value)) {
var byear = $('birthyear');
var bmonth = $('birthmonth');
var bday = $('birthday');
var bdayValue = byear.value + "-" + bmonth.value + "-" + bday.value;
if (bdayValue != "--" && !dateRegex.test(bdayValue)) {
alert(_("invaliddatewarn"));
rc = false;
}
@@ -105,25 +107,25 @@ function validateContactEditor() {
return rc;
}
function onFnKeyDown() {
var fn = $("fn");
function onDisplaynameKeyDown() {
var fn = $("displayname");
fn.onkeydown = null;
displayNameChanged = true;
displaynameChanged = true;
return true;
}
function onFnNewValue(event) {
if (!displayNameChanged) {
function onDisplaynameNewValue(event) {
if (!displaynameChanged) {
var sn = $("sn").value.trim();
var givenName = $("givenName").value.trim();
var givenname = $("givenname").value.trim();
var fullName = givenName;
if (fullName && sn)
fullName += ' ';
fullName += sn;
var fullname = givenname;
if (fullname && sn)
fullname += ' ';
fullname += sn;
$("fn").value = fullName;
$("displayname").value = fullname;
}
return true;
@@ -144,7 +146,7 @@ function onEditorSubmitClick(event) {
function saveCategories() {
var container = $("categoryContainer");
var catsInput = $("contactCategories");
var catsInput = $("jsonContactCategories");
if (container && catsInput) {
var newCategories = $([]);
var inputs = container.select("INPUT");
@@ -164,8 +166,8 @@ function onDocumentKeydown(event) {
var target = Event.element(event);
if (target.tagName == "INPUT" || target.tagName == "SELECT") {
if (event.keyCode == Event.KEY_RETURN) {
var fcn = onEditorSubmitClick.bind($("submitButton"));
fcn();
var fdisplayname = onEditorSubmitClick.bind($("submitButton"));
fdisplayname();
Event.stop(event);
}
}
@@ -267,10 +269,10 @@ function initEditorForm() {
var controller = new SOGoTabsController();
controller.attachToTabsContainer(tabsContainer);
displayNameChanged = ($("fn").value.length > 0);
$("fn").onkeydown = onFnKeyDown;
$("sn").onkeyup = onFnNewValue;
$("givenName").onkeyup = onFnNewValue;
displaynameChanged = ($("displayname").value.length > 0);
$("displayname").onkeydown = onDisplaynameKeyDown;
$("sn").onkeyup = onDisplaynameNewValue;
$("givenname").onkeyup = onDisplaynameNewValue;
$("cancelButton").observe("click", onEditorCancelClick);
var submitButton = $("submitButton");
@@ -280,8 +282,10 @@ function initEditorForm() {
Event.observe(document, "keydown", onDocumentKeydown);
regenerateCategoriesMenu();
var catsInput = $("contactCategories");
if (typeof(gCategories) != "undefined") {
regenerateCategoriesMenu();
}
var catsInput = $("jsonContactCategories");
if (catsInput && catsInput.value.length > 0) {
var contactCats = $(catsInput.value.evalJSON(false));
for (var i = 0; i < contactCats.length; i++) {
@@ -294,6 +298,6 @@ function initEditorForm() {
emptyCategory.tabIndex = 10000;
emptyCategory.observe("click", onEmptyCategoryClick);
}
}
}
document.observe("dom:loaded", initEditorForm);