(feat) handle links to addressbooks like we do for calendars
also included missing template commit for calendarpull/100/head
parent
7b5541b5d1
commit
20bf66d931
|
@ -1,6 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 2006-2014 Inverse inc.
|
||||
Copyright (C) 2004-2005 SKYRIX Software AG
|
||||
Copyright (C) 2006-2015 Inverse inc.
|
||||
|
||||
This file is part of SOGo.
|
||||
|
||||
|
@ -32,9 +31,13 @@
|
|||
@class NSString;
|
||||
|
||||
@interface SOGoContactGCSFolder : SOGoGCSFolder <SOGoContactFolder>
|
||||
|
||||
{
|
||||
NSString *baseCardDAVURL, *basePublicCardDAVURL;
|
||||
}
|
||||
- (void) fixupContactRecord: (NSMutableDictionary *) contactRecord;
|
||||
- (NSDictionary *) lookupContactWithName: (NSString *) aName;
|
||||
- (NSString *) cardDavURL;
|
||||
- (NSString *) publicCardDavURL;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 2006-2013 Inverse inc.
|
||||
Copyright (C) 2004-2005 SKYRIX Software AG
|
||||
Copyright (C) 2006-2013-2015 Inverse inc.
|
||||
|
||||
This file is part of SOGo.
|
||||
|
||||
|
@ -67,6 +66,24 @@ static NSArray *folderListingFields = nil;
|
|||
@"c_component", nil];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
baseCardDAVURL = nil;
|
||||
basePublicCardDAVURL = nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[baseCardDAVURL release];
|
||||
[basePublicCardDAVURL release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (Class) objectClassForContent: (NSString *) content
|
||||
{
|
||||
CardGroup *cardEntry;
|
||||
|
@ -436,4 +453,48 @@ static NSArray *folderListingFields = nil;
|
|||
return [NSString stringWithFormat: @"%@:%@", nsRep, nodeName];
|
||||
}
|
||||
|
||||
- (NSString *) _baseCardDAVURL
|
||||
{
|
||||
NSString *davURL;
|
||||
|
||||
if (!baseCardDAVURL)
|
||||
{
|
||||
davURL = [[self realDavURL] absoluteString];
|
||||
if ([davURL hasSuffix: @"/"])
|
||||
baseCardDAVURL = [davURL substringToIndex: [davURL length] - 1];
|
||||
else
|
||||
baseCardDAVURL = davURL;
|
||||
[baseCardDAVURL retain];
|
||||
}
|
||||
|
||||
return baseCardDAVURL;
|
||||
}
|
||||
|
||||
- (NSString *) cardDavURL
|
||||
{
|
||||
return [NSString stringWithFormat: @"%@/", [self _baseCardDAVURL]];
|
||||
}
|
||||
|
||||
- (NSString *) _basePublicCardDAVURL
|
||||
{
|
||||
NSString *davURL;
|
||||
|
||||
if (!basePublicCardDAVURL)
|
||||
{
|
||||
davURL = [[self publicDavURL] absoluteString];
|
||||
if ([davURL hasSuffix: @"/"])
|
||||
basePublicCardDAVURL = [davURL substringToIndex: [davURL length] - 1];
|
||||
else
|
||||
basePublicCardDAVURL = davURL;
|
||||
[basePublicCardDAVURL retain];
|
||||
}
|
||||
|
||||
return basePublicCardDAVURL;
|
||||
}
|
||||
|
||||
- (NSString *) publicCardDavURL
|
||||
{
|
||||
return [NSString stringWithFormat: @"%@/", [self _basePublicCardDAVURL]];
|
||||
}
|
||||
|
||||
@end /* SOGoContactGCSFolder */
|
||||
|
|
|
@ -20,14 +20,6 @@
|
|||
|
||||
#import <SOGoUI/UIxComponent.h>
|
||||
|
||||
@class NSString;
|
||||
|
||||
@class SOGoContactGCSFolder;
|
||||
|
||||
@interface UIxContactFolderLinksTemplate : UIxComponent
|
||||
{
|
||||
SOGoContactGCSFolder *addressBook;
|
||||
NSString *baseCardDAVURL, *basePublicCardDAVURL;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -24,69 +24,6 @@
|
|||
|
||||
@implementation UIxContactFolderLinksTemplate
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
addressBook = [self clientObject];
|
||||
baseCardDAVURL = nil;
|
||||
basePublicCardDAVURL = nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[baseCardDAVURL release];
|
||||
[basePublicCardDAVURL release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSString *) _baseCardDAVURL
|
||||
{
|
||||
NSString *davURL;
|
||||
|
||||
if (!baseCardDAVURL)
|
||||
{
|
||||
davURL = [[addressBook realDavURL] absoluteString];
|
||||
if ([davURL hasSuffix: @"/"])
|
||||
baseCardDAVURL = [davURL substringToIndex: [davURL length] - 1];
|
||||
else
|
||||
baseCardDAVURL = davURL;
|
||||
[baseCardDAVURL retain];
|
||||
}
|
||||
|
||||
return baseCardDAVURL;
|
||||
}
|
||||
|
||||
- (NSString *) cardDavURL
|
||||
{
|
||||
return [NSString stringWithFormat: @"%@/", [self _baseCardDAVURL]];
|
||||
}
|
||||
|
||||
- (NSString *) _basePublicCardDAVURL
|
||||
{
|
||||
NSString *davURL;
|
||||
|
||||
if (!basePublicCardDAVURL)
|
||||
{
|
||||
davURL = [[addressBook publicDavURL] absoluteString];
|
||||
if ([davURL hasSuffix: @"/"])
|
||||
basePublicCardDAVURL = [davURL substringToIndex: [davURL length] - 1];
|
||||
else
|
||||
basePublicCardDAVURL = davURL;
|
||||
[basePublicCardDAVURL retain];
|
||||
}
|
||||
|
||||
return basePublicCardDAVURL;
|
||||
}
|
||||
|
||||
- (NSString *) publicCardDavURL
|
||||
{
|
||||
return [NSString stringWithFormat: @"%@/", [self _basePublicCardDAVURL]];
|
||||
}
|
||||
|
||||
- (BOOL) isPublicAccessEnabled
|
||||
{
|
||||
// NOTE: This method is the same found in Common/UIxAclEditor.m
|
||||
|
|
|
@ -275,12 +275,19 @@ Class SOGoContactSourceFolderK, SOGoGCSFolderK;
|
|||
return [[self queryParameterForKey: @"popup"] boolValue];
|
||||
}
|
||||
|
||||
- (BOOL) isPublicAccessEnabled
|
||||
{
|
||||
// NOTE: This method is the same found in Common/UIxAclEditor.m
|
||||
return [[SOGoSystemDefaults sharedSystemDefaults] enablePublicAccess];
|
||||
}
|
||||
|
||||
- (NSString *) contactFolders
|
||||
{
|
||||
SOGoContactFolders *folderContainer;
|
||||
NSArray *folders;
|
||||
NSMutableArray *foldersAttrs;
|
||||
NSMutableDictionary *urls;
|
||||
NSDictionary *folderAttrs;
|
||||
NSArray *folders;
|
||||
id currentFolder;
|
||||
int max, i;
|
||||
|
||||
|
@ -291,9 +298,25 @@ Class SOGoContactSourceFolderK, SOGoGCSFolderK;
|
|||
folders = [folderContainer subFolders];
|
||||
max = [folders count];
|
||||
foldersAttrs = [NSMutableArray arrayWithCapacity: max];
|
||||
urls = nil;
|
||||
|
||||
for (i = 0; i < max; i++)
|
||||
{
|
||||
currentFolder = [folders objectAtIndex: i];
|
||||
|
||||
if ([currentFolder respondsToSelector: @selector(cardDavURL)])
|
||||
{
|
||||
urls = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||
[currentFolder cardDavURL], @"cardDavURL",
|
||||
nil];
|
||||
if ([self isPublicAccessEnabled])
|
||||
{
|
||||
[urls setObject: [currentFolder publicCardDavURL] forKey: @"publicCardDavURL"];
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: keep urls as the last key/value here, to avoid chopping the dictionary
|
||||
// if it is not a GCS folder
|
||||
folderAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSString stringWithFormat: @"%@", [currentFolder nameInContainer]], @"id",
|
||||
[currentFolder displayName], @"name",
|
||||
|
@ -301,6 +324,7 @@ Class SOGoContactSourceFolderK, SOGoGCSFolderK;
|
|||
[NSNumber numberWithBool: [currentFolder isKindOfClass: SOGoGCSFolderK]], @"isEditable",
|
||||
[NSNumber numberWithBool: [currentFolder isKindOfClass: SOGoContactSourceFolderK]
|
||||
&& ![currentFolder isPersonalSource]], @"isRemote",
|
||||
urls, @"urls",
|
||||
nil];
|
||||
[foldersAttrs addObject: folderAttrs];
|
||||
}
|
||||
|
@ -419,12 +443,6 @@ Class SOGoContactSourceFolderK, SOGoGCSFolderK;
|
|||
return [super defaultAction];
|
||||
}
|
||||
|
||||
- (BOOL) isPublicAccessEnabled
|
||||
{
|
||||
// NOTE: This method is the same found in Common/UIxAclEditor.m
|
||||
return [[SOGoSystemDefaults sharedSystemDefaults] enablePublicAccess];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface UIxContactViewTemplate : UIxComponent
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
<div class="md-toolbar-tools">
|
||||
<div class="pseudo-input-container md-flex">
|
||||
<label class="pseudo-input-label"><var:string label:value="Links to this Address Book"/></label>
|
||||
<div class="pseudo-input-field sg-md-title"><var:string value="addressBook.displayName"/></div>
|
||||
<div class="pseudo-input-field sg-md-title">{{links.addressbook.name}}</div>
|
||||
</div>
|
||||
<md-button class="md-icon-button" ng-click="close()">
|
||||
<md-button class="md-icon-button" ng-click="links.close()">
|
||||
<md-icon aria-label="Close dialog">close</md-icon>
|
||||
</md-button>
|
||||
</div>
|
||||
|
@ -25,7 +25,7 @@
|
|||
<div class="sg-md-title"><var:string label:value="Authenticated User Access"/></div>
|
||||
<md-input-container>
|
||||
<label><var:string label:value="CardDAV URL"/></label>
|
||||
<input var:value="cardDavURL" ng-readonly="true"/>
|
||||
<input type="text" ng-model="links.addressbook.urls.cardDavURL" ng-readonly="true"/>
|
||||
</md-input-container>
|
||||
</div>
|
||||
<var:if condition="isPublicAccessEnabled">
|
||||
|
@ -33,7 +33,7 @@
|
|||
<div class="sg-md-title"><var:string label:value="Public Access"/></div>
|
||||
<md-input-container>
|
||||
<label><var:string label:value="CardDAV URL"/></label>
|
||||
<input var:value="publicCardDavURL" ng-readonly="true"/>
|
||||
<input type="text" ng-model="links.addressbook.urls.publicCardDavURL" ng-readonly="true"/>
|
||||
</md-input-container>
|
||||
</div>
|
||||
</var:if>
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
<div class="md-toolbar-tools">
|
||||
<div class="pseudo-input-container md-flex">
|
||||
<label class="pseudo-input-label"><var:string label:value="Links to this Calendar"/></label>
|
||||
<div class="pseudo-input-field sg-md-title"><var:string value="calendar.displayName"/></div>
|
||||
<div class="pseudo-input-field sg-md-title">{{links.calendar.name}}</div>
|
||||
</div>
|
||||
<md-button class="md-icon-button" ng-click="close()">
|
||||
<md-button class="md-icon-button" ng-click="links.close()">
|
||||
<md-icon label:aria-label="Close">close</md-icon>
|
||||
</md-button>
|
||||
</div>
|
||||
|
@ -25,50 +25,45 @@
|
|||
<div layout="column" layout-padding="layout-padding">
|
||||
|
||||
<div layout="column" layout-padding="layout-padding">
|
||||
|
||||
<var:if condition="isWebCalendar">
|
||||
<md-input-container>
|
||||
<md-input-container ng-show="links.calendar.isWebCalendar">
|
||||
<label><var:string label:value="URL"/></label>
|
||||
<input var:value="webCalendarURL" ng-readonly="true"/>
|
||||
<input type="text" ng-model="links.calendar.urls.webCalendarURL" ng-readonly="true"/>
|
||||
</md-input-container>
|
||||
</var:if>
|
||||
<var:if condition="isWebCalendar" const:negate="YES">
|
||||
<div class="sg-md-title"><var:string label:value="Authenticated User Access"/></div>
|
||||
|
||||
<div ng-hide="links.calendar.isWebCalendar">
|
||||
<div class="sg-md-title"><var:string label:value="Authenticated User Access"/></div>
|
||||
<md-input-container>
|
||||
<label><var:string label:value="CalDAV URL"/></label>
|
||||
<input var:value="calDavURL" ng-readonly="true"/>
|
||||
<input type="text" ng-model="links.calendar.urls.calDavURL" ng-readonly="true"/>
|
||||
</md-input-container>
|
||||
<md-input-container>
|
||||
<label><var:string label:value="WebDAV ICS URL"/></label>
|
||||
<input var:value="webDavICSURL" ng-readonly="true"/>
|
||||
<input type="text" ng-model="links.calendar.urls.webDavICSURL" ng-readonly="true"/>
|
||||
</md-input-container>
|
||||
<md-input-container>
|
||||
<label><var:string label:value="WebDAV XML URL"/></label>
|
||||
<input var:value="webDavXMLURL" ng-readonly="true"/>
|
||||
<input type="text" ng-model="links.calendar.urls.webDavXMLURL" ng-readonly="true"/>
|
||||
</md-input-container>
|
||||
</var:if>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<var:if condition="isPublicAccessEnabled">
|
||||
<var:if condition="isWebCalendar" const:negate="YES">
|
||||
<div layout="column" layout-padding="layout-padding">
|
||||
<div layout="column" layout-padding="layout-padding" ng-hide="links.calendar.isWebCalendar">
|
||||
<div class="sg-md-title"><var:string label:value="Public Access"/></div>
|
||||
<md-input-container>
|
||||
<label><var:string label:value="CalDAV URL"/></label>
|
||||
<input var:value="publicCalDavURL" ng-readonly="true"/>
|
||||
<input type="text" ng-model="links.calendar.urls.publicCalDavURL" ng-readonly="true"/>
|
||||
</md-input-container>
|
||||
<md-input-container>
|
||||
<label><var:string label:value="WebDAV ICS URL"/></label>
|
||||
<input var:value="publicWebDavICSURL" ng-readonly="true"/>
|
||||
<input type="text" ng-model="links.calendar.urls.publicWebDavICSURL" ng-readonly="true"/>
|
||||
</md-input-container>
|
||||
<md-input-container>
|
||||
<label><var:string label:value="WebDAV XML URL"/></label>
|
||||
<input var:value="publicWebDavXMLURL" ng-readonly="true"/>
|
||||
<input type="text" ng-model="links.calendar.urls.publicWebDavXMLURL" ng-readonly="true"/>
|
||||
</md-input-container>
|
||||
</div>
|
||||
</var:if>
|
||||
</var:if>
|
||||
</div>
|
||||
|
||||
</md-dialog-content>
|
||||
|
|
|
@ -109,25 +109,31 @@
|
|||
window.location.href = ApplicationBaseURL + '/' + vm.service.selectedFolder.id + '/exportFolder';
|
||||
}
|
||||
|
||||
function showLinks(selectedFolder) {
|
||||
function showLinks(addressbook) {
|
||||
$mdDialog.show({
|
||||
parent: angular.element(document.body),
|
||||
clickOutsideToClose: true,
|
||||
escapeToClose: true,
|
||||
templateUrl: selectedFolder.id + '/links',
|
||||
templateUrl: addressbook.id + '/links',
|
||||
controller: LinksDialogController,
|
||||
controllerAs: 'links',
|
||||
locals: {
|
||||
},
|
||||
controller: LinksDialogController
|
||||
addressbook: addressbook
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
LinksDialogController.$inject = ['scope', '$mdDialog'];
|
||||
function LinksDialogController(scope, $mdDialog) {
|
||||
scope.close = function() {
|
||||
LinksDialogController.$inject = ['$mdDialog', 'addressbook'];
|
||||
function LinksDialogController($mdDialog, addressbook) {
|
||||
var vm = this;
|
||||
this.addressbook = addressbook;
|
||||
this.close = close;
|
||||
|
||||
function close() {
|
||||
$mdDialog.hide();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue