2007-04-17 16:02:07 +02:00
|
|
|
/* UIxObjectActions.m - this file is part of SOGo
|
|
|
|
*
|
2016-01-08 19:41:04 +01:00
|
|
|
* Copyright (C) 2007-2016 Inverse inc.
|
2007-04-17 16:02:07 +02:00
|
|
|
*
|
2016-01-08 19:41:04 +01:00
|
|
|
* Author: Inverse <info@inverse.ca>
|
2007-04-17 16:02:07 +02:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This file is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2007-11-05 20:44:03 +01:00
|
|
|
|
2014-09-10 22:20:52 +02:00
|
|
|
#import <NGObjWeb/NSException+HTTP.h>
|
2007-04-17 16:02:07 +02:00
|
|
|
#import <NGObjWeb/WOContext+SoObjects.h>
|
|
|
|
#import <NGObjWeb/WORequest.h>
|
|
|
|
#import <NGObjWeb/WOResponse.h>
|
2014-09-10 22:20:52 +02:00
|
|
|
|
2016-01-08 19:41:04 +01:00
|
|
|
#import <SoObjects/SOGo/SOGoContentObject.h>
|
2007-04-17 16:02:07 +02:00
|
|
|
|
2014-09-10 22:20:52 +02:00
|
|
|
#import <SOGo/NSDictionary+Utilities.h>
|
|
|
|
|
2008-07-17 23:12:43 +02:00
|
|
|
#import "WODirectAction+SOGo.h"
|
|
|
|
|
2007-04-17 16:02:07 +02:00
|
|
|
#import "UIxObjectActions.h"
|
|
|
|
|
|
|
|
@implementation UIxObjectActions
|
|
|
|
|
2015-01-13 17:30:23 +01:00
|
|
|
/**
|
|
|
|
* @api {get} /so/:username/:folderPath/addUserInAcls?uid=:uid Add user to ACLs
|
|
|
|
* @apiVersion 1.0.0
|
|
|
|
* @apiName GetAddUserInAcls
|
|
|
|
* @apiGroup Common
|
|
|
|
* @apiExample {curl} Example usage:
|
|
|
|
* curl -i http://localhost/SOGo/so/sogo1/Calendar/personal/addUserInAcls?uid=sogo2
|
|
|
|
*
|
|
|
|
* @apiParam {String} uid User ID
|
|
|
|
*/
|
2007-04-17 16:02:07 +02:00
|
|
|
- (WOResponse *) addUserInAclsAction
|
|
|
|
{
|
|
|
|
WOResponse *response;
|
2007-05-11 23:45:33 +02:00
|
|
|
NSString *uid;
|
2007-04-17 16:02:07 +02:00
|
|
|
unsigned int code;
|
|
|
|
|
2008-02-22 22:19:29 +01:00
|
|
|
uid = [[context request] formValueForKey: @"uid"];
|
|
|
|
if ([[self clientObject] addUserInAcls: uid])
|
|
|
|
code = 204;
|
|
|
|
else
|
|
|
|
code = 403;
|
2007-04-17 16:02:07 +02:00
|
|
|
|
|
|
|
response = [context response];
|
|
|
|
[response setStatus: code];
|
|
|
|
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2015-01-13 17:30:23 +01:00
|
|
|
/**
|
|
|
|
* @api {get} /so/:username/:folderPath/removeUserFromAcls?uid=:uid Remove user from ACLs
|
|
|
|
* @apiVersion 1.0.0
|
|
|
|
* @apiName GetRemoveUserFromAcls
|
|
|
|
* @apiGroup Common
|
|
|
|
* @apiExample {curl} Example usage:
|
|
|
|
* curl -i http://localhost/SOGo/so/sogo1/Calendar/personal/removeUserInAcls?uid=sogo2
|
|
|
|
*
|
|
|
|
* @apiParam {String} uid User ID
|
|
|
|
*/
|
2007-05-11 23:45:33 +02:00
|
|
|
- (WOResponse *) removeUserFromAclsAction
|
|
|
|
{
|
|
|
|
WOResponse *response;
|
|
|
|
NSString *uid;
|
|
|
|
unsigned int code;
|
|
|
|
|
2008-02-22 22:19:29 +01:00
|
|
|
uid = [[context request] formValueForKey: @"uid"];
|
|
|
|
if ([[self clientObject] removeUserFromAcls: uid])
|
|
|
|
code = 204;
|
|
|
|
else
|
|
|
|
code = 403;
|
2007-05-11 23:45:33 +02:00
|
|
|
|
|
|
|
response = [context response];
|
|
|
|
[response setStatus: code];
|
|
|
|
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2008-07-17 23:12:43 +02:00
|
|
|
- (WOResponse *) deleteAction
|
|
|
|
{
|
|
|
|
WOResponse *response;
|
2014-09-10 22:20:52 +02:00
|
|
|
NSDictionary *data;
|
2016-01-08 19:41:04 +01:00
|
|
|
SOGoContentObject *deleteObject;
|
|
|
|
|
|
|
|
deleteObject = [self clientObject];
|
|
|
|
if ([deleteObject respondsToSelector: @selector (prepareDelete)])
|
|
|
|
[deleteObject prepareDelete];
|
|
|
|
response = (WOResponse *) [deleteObject delete];
|
2008-07-17 23:12:43 +02:00
|
|
|
|
2014-09-10 22:20:52 +02:00
|
|
|
if (response)
|
|
|
|
{
|
|
|
|
data = [NSDictionary dictionaryWithObjectsAndKeys: [(NSException *) response reason], @"error", nil];
|
|
|
|
response = [self responseWithStatus: 403
|
2016-01-08 19:41:04 +01:00
|
|
|
andJSONRepresentation: data];
|
2014-09-10 22:20:52 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
response = [self responseWithStatus: 204];
|
|
|
|
}
|
2008-07-17 23:12:43 +02:00
|
|
|
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2007-04-17 16:02:07 +02:00
|
|
|
@end
|