From a2460f93684adfa1ed92f015dcdd9b0b51c43cad Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Wed, 20 Aug 2014 15:18:35 -0400 Subject: [PATCH] Add "newguid" action accessible from any folder --- UI/Common/UIxFolderActions.h | 3 ++- UI/Common/UIxFolderActions.m | 36 +++++++++++++++++++++++++++++++++++- UI/Common/product.plist | 9 +++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/UI/Common/UIxFolderActions.h b/UI/Common/UIxFolderActions.h index 8d77775ec..83d1a34c9 100644 --- a/UI/Common/UIxFolderActions.h +++ b/UI/Common/UIxFolderActions.h @@ -1,6 +1,6 @@ /* UIxFolderActions.h - this file is part of SOGo * - * Copyright (C) 2007-2013 Inverse inc. + * Copyright (C) 2007-2014 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -48,6 +48,7 @@ - (WOResponse *) canAccessContentAction; - (WOResponse *) activateFolderAction; - (WOResponse *) deactivateFolderAction; +- (WOResponse *) newguidAction; @end diff --git a/UI/Common/UIxFolderActions.m b/UI/Common/UIxFolderActions.m index 48c684ac0..332c98b9e 100644 --- a/UI/Common/UIxFolderActions.m +++ b/UI/Common/UIxFolderActions.m @@ -1,6 +1,6 @@ /* UIxFolderActions.m - this file is part of SOGo * - * Copyright (C) 2007-2013 Inverse inc. + * Copyright (C) 2007-2014 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -192,6 +192,40 @@ return [self _realFolderActivation: NO]; } +- (WOResponse *) newguidAction +{ + NSString *objectId, *folderId; + NSDictionary *data; + WOResponse *response; + SOGoFolder *co; + SoSecurityManager *sm; + + co = [self clientObject]; + objectId = [co globallyUniqueObjectId]; + if ([objectId length] > 0) + { + sm = [SoSecurityManager sharedSecurityManager]; + if (![sm validatePermission: SoPerm_AddDocumentsImagesAndFiles + onObject: co + inContext: context]) + { + folderId = [co nameInContainer]; + } + else + { + folderId = @"personal"; + } + data = [NSDictionary dictionaryWithObjectsAndKeys: objectId, @"id", folderId, @"pid", nil]; + response = [self responseWithStatus: 200 + andString: [data jsonRepresentation]]; + } + else + response = [NSException exceptionWithHTTPStatus: 500 /* Internal Error */ + reason: @"could not create a unique ID"]; + + return response; +} + - (WOResponse *) renameFolderAction { WOResponse *response; diff --git a/UI/Common/product.plist b/UI/Common/product.plist index d5d6936a1..d1ad5c1fd 100644 --- a/UI/Common/product.plist +++ b/UI/Common/product.plist @@ -74,6 +74,15 @@ }; }; }; + SOGoFolder = { + methods = { + newguid = { + protectedBy = ""; + actionClass = "UIxFolderActions"; + actionName = "newguid"; + }; + }; + }; SOGoGCSFolder = { methods = { subscribe = {