Add "newguid" action accessible from any folder

pull/91/head
Francis Lachapelle 2014-08-20 15:18:35 -04:00
parent c0eac04437
commit a2460f9368
3 changed files with 46 additions and 2 deletions

View File

@ -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

View File

@ -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;

View File

@ -74,6 +74,15 @@
};
};
};
SOGoFolder = {
methods = {
newguid = {
protectedBy = "<public>";
actionClass = "UIxFolderActions";
actionName = "newguid";
};
};
};
SOGoGCSFolder = {
methods = {
subscribe = {