2007-05-19 02:29:50 +02:00
|
|
|
/* UIxMailUserRightsEditor.m - this file is part of SOGo
|
|
|
|
*
|
2015-01-22 15:21:21 +01:00
|
|
|
* Copyright (C) 2007-2015 Inverse inc.
|
2007-05-19 02:29:50 +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.
|
|
|
|
*/
|
|
|
|
|
2015-01-23 02:55:11 +01:00
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
#import <Foundation/NSValue.h>
|
2009-11-29 05:19:32 +01:00
|
|
|
#import <Mailer/SOGoMailAccount.h>
|
|
|
|
#import <SOGo/SOGoPermissions.h>
|
2007-05-19 02:29:50 +02:00
|
|
|
|
|
|
|
#import "UIxMailUserRightsEditor.h"
|
|
|
|
|
|
|
|
@implementation UIxMailUserRightsEditor
|
|
|
|
|
2008-05-31 23:04:56 +02:00
|
|
|
- (BOOL) conformsToRFC4314
|
|
|
|
{
|
2020-03-02 20:04:47 +01:00
|
|
|
SOGoMailAccount *account;
|
2008-05-31 23:04:56 +02:00
|
|
|
|
2020-03-02 20:04:47 +01:00
|
|
|
account = [[self clientObject] lookupName: @"0" inContext: context acquire: NO];
|
|
|
|
|
|
|
|
return ([account imapAclStyle] == rfc4314);
|
2008-05-31 23:04:56 +02:00
|
|
|
}
|
|
|
|
|
2007-11-28 00:18:17 +01:00
|
|
|
- (void) setUserCanReadMails: (BOOL) userCanReadMails
|
2007-05-22 20:38:49 +02:00
|
|
|
{
|
2007-11-28 00:18:17 +01:00
|
|
|
if (userCanReadMails)
|
2007-05-22 20:38:49 +02:00
|
|
|
[self appendRight: SOGoRole_ObjectViewer];
|
|
|
|
else
|
|
|
|
[self removeRight: SOGoRole_ObjectViewer];
|
|
|
|
}
|
|
|
|
|
2007-11-28 00:18:17 +01:00
|
|
|
- (BOOL) userCanReadMails
|
2007-05-22 20:38:49 +02:00
|
|
|
{
|
|
|
|
return [userRights containsObject: SOGoRole_ObjectViewer];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserCanMarkMailsRead: (BOOL) userCanMarkMailsRead
|
|
|
|
{
|
|
|
|
if (userCanMarkMailsRead)
|
|
|
|
[self appendRight: SOGoMailRole_SeenKeeper];
|
|
|
|
else
|
|
|
|
[self removeRight: SOGoMailRole_SeenKeeper];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) userCanMarkMailsRead
|
|
|
|
{
|
|
|
|
return [userRights containsObject: SOGoMailRole_SeenKeeper];
|
|
|
|
}
|
|
|
|
|
2007-05-19 02:29:50 +02:00
|
|
|
- (void) setUserCanWriteMails: (BOOL) userCanWriteMails
|
|
|
|
{
|
|
|
|
if (userCanWriteMails)
|
|
|
|
[self appendRight: SOGoMailRole_Writer];
|
|
|
|
else
|
|
|
|
[self removeRight: SOGoMailRole_Writer];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) userCanWriteMails
|
|
|
|
{
|
|
|
|
return [userRights containsObject: SOGoMailRole_Writer];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserCanInsertMails: (BOOL) userCanInsertMails
|
|
|
|
{
|
|
|
|
if (userCanInsertMails)
|
|
|
|
[self appendRight: SOGoRole_ObjectCreator];
|
|
|
|
else
|
|
|
|
[self removeRight: SOGoRole_ObjectCreator];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) userCanInsertMails
|
|
|
|
{
|
|
|
|
return [userRights containsObject: SOGoRole_ObjectCreator];
|
|
|
|
}
|
|
|
|
|
2007-05-22 20:38:49 +02:00
|
|
|
- (void) setUserCanPostMails: (BOOL) userCanPostMails
|
2007-05-19 02:29:50 +02:00
|
|
|
{
|
2007-05-22 20:38:49 +02:00
|
|
|
if (userCanPostMails)
|
|
|
|
[self appendRight: SOGoMailRole_Poster];
|
2007-05-19 02:29:50 +02:00
|
|
|
else
|
2007-05-22 20:38:49 +02:00
|
|
|
[self removeRight: SOGoMailRole_Poster];
|
2007-05-19 02:29:50 +02:00
|
|
|
}
|
|
|
|
|
2007-05-22 20:38:49 +02:00
|
|
|
- (BOOL) userCanPostMails
|
2007-05-19 02:29:50 +02:00
|
|
|
{
|
2007-05-22 20:38:49 +02:00
|
|
|
return [userRights containsObject: SOGoMailRole_Poster];
|
2007-05-19 02:29:50 +02:00
|
|
|
}
|
|
|
|
|
2007-05-22 20:38:49 +02:00
|
|
|
- (void) setUserCanCreateSubfolders: (BOOL) userCanCreateSubfolders
|
2007-05-19 02:29:50 +02:00
|
|
|
{
|
2007-05-22 20:38:49 +02:00
|
|
|
if (userCanCreateSubfolders)
|
|
|
|
[self appendRight: SOGoRole_FolderCreator];
|
|
|
|
else
|
|
|
|
[self removeRight: SOGoRole_FolderCreator];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) userCanCreateSubfolders
|
|
|
|
{
|
|
|
|
return [userRights containsObject: SOGoRole_FolderCreator];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserCanRemoveFolder: (BOOL) userCanRemoveFolder
|
|
|
|
{
|
|
|
|
if (userCanRemoveFolder)
|
2007-06-01 22:54:07 +02:00
|
|
|
[self appendRight: SOGoRole_FolderEraser];
|
2007-05-19 02:29:50 +02:00
|
|
|
else
|
2007-06-01 22:54:07 +02:00
|
|
|
[self removeRight: SOGoRole_FolderEraser];
|
2007-05-19 02:29:50 +02:00
|
|
|
}
|
|
|
|
|
2007-05-22 20:38:49 +02:00
|
|
|
- (BOOL) userCanRemoveFolder
|
2007-05-19 02:29:50 +02:00
|
|
|
{
|
2007-06-01 22:54:07 +02:00
|
|
|
return [userRights containsObject: SOGoRole_FolderEraser];
|
2007-05-19 02:29:50 +02:00
|
|
|
}
|
|
|
|
|
2007-05-22 20:38:49 +02:00
|
|
|
- (void) setUserCanEraseMails: (BOOL) userCanEraseMails
|
2007-05-19 02:29:50 +02:00
|
|
|
{
|
2007-05-22 20:38:49 +02:00
|
|
|
if (userCanEraseMails)
|
2007-06-01 22:54:07 +02:00
|
|
|
[self appendRight: SOGoRole_ObjectEraser];
|
2007-05-19 02:29:50 +02:00
|
|
|
else
|
2007-06-01 22:54:07 +02:00
|
|
|
[self removeRight: SOGoRole_ObjectEraser];
|
2007-05-19 02:29:50 +02:00
|
|
|
}
|
|
|
|
|
2007-05-22 20:38:49 +02:00
|
|
|
- (BOOL) userCanEraseMails
|
2007-05-19 02:29:50 +02:00
|
|
|
{
|
2007-06-01 22:54:07 +02:00
|
|
|
return [userRights containsObject: SOGoRole_ObjectEraser];
|
2007-05-19 02:29:50 +02:00
|
|
|
}
|
|
|
|
|
2007-05-22 20:38:49 +02:00
|
|
|
- (void) setUserCanExpungeFolder: (BOOL) userCanExpungeFolder
|
2007-05-19 02:29:50 +02:00
|
|
|
{
|
2007-05-22 20:38:49 +02:00
|
|
|
if (userCanExpungeFolder)
|
|
|
|
[self appendRight: SOGoMailRole_Expunger];
|
2007-05-19 02:29:50 +02:00
|
|
|
else
|
2007-05-22 20:38:49 +02:00
|
|
|
[self removeRight: SOGoMailRole_Expunger];
|
2007-05-19 02:29:50 +02:00
|
|
|
}
|
|
|
|
|
2007-05-22 20:38:49 +02:00
|
|
|
- (BOOL) userCanExpungeFolder
|
2007-05-19 02:29:50 +02:00
|
|
|
{
|
2007-05-22 20:38:49 +02:00
|
|
|
return [userRights containsObject: SOGoMailRole_Expunger];
|
2007-05-19 02:29:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserIsAdministrator: (BOOL) userIsAdministrator
|
|
|
|
{
|
|
|
|
if (userIsAdministrator)
|
|
|
|
[self appendRight: SOGoMailRole_Administrator];
|
|
|
|
else
|
|
|
|
[self removeRight: SOGoMailRole_Administrator];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) userIsAdministrator
|
|
|
|
{
|
|
|
|
return [userRights containsObject: SOGoMailRole_Administrator];
|
|
|
|
}
|
|
|
|
|
2015-01-22 15:21:21 +01:00
|
|
|
- (NSDictionary *) userRightsForObject
|
|
|
|
{
|
|
|
|
return [NSDictionary dictionaryWithObjectsAndKeys:
|
|
|
|
[NSNumber numberWithBool:[self userCanReadMails]], @"userCanReadMails",
|
|
|
|
[NSNumber numberWithBool:[self userCanMarkMailsRead]], @"userCanMarkMailsRead",
|
|
|
|
[NSNumber numberWithBool:[self userCanWriteMails]], @"userCanWriteMails",
|
|
|
|
[NSNumber numberWithBool:[self userCanInsertMails]], @"userCanInsertMails",
|
|
|
|
[NSNumber numberWithBool:[self userCanPostMails]], @"userCanPostMails",
|
|
|
|
[NSNumber numberWithBool:[self userCanCreateSubfolders]], @"userCanCreateSubfolders",
|
|
|
|
[NSNumber numberWithBool:[self userCanEraseMails]], @"userCanEraseMails",
|
|
|
|
[NSNumber numberWithBool:[self userCanRemoveFolder]], @"userCanRemoveFolder",
|
|
|
|
[NSNumber numberWithBool:[self userCanExpungeFolder]], @"userCanExpungeFolder",
|
|
|
|
[NSNumber numberWithBool:[self userIsAdministrator]], @"userIsAdministrator",
|
|
|
|
nil];
|
|
|
|
}
|
|
|
|
|
2015-06-26 19:13:25 +02:00
|
|
|
- (void) updateRights: (NSDictionary *) newRights
|
2007-05-19 02:29:50 +02:00
|
|
|
{
|
2015-06-26 19:13:25 +02:00
|
|
|
if ([[newRights objectForKey: @"userCanReadMails"] boolValue])
|
2007-05-22 20:38:49 +02:00
|
|
|
[self appendRight: SOGoRole_ObjectViewer];
|
|
|
|
else
|
|
|
|
[self removeRight: SOGoRole_ObjectViewer];
|
|
|
|
|
2015-06-26 19:13:25 +02:00
|
|
|
if ([[newRights objectForKey: @"userCanMarkMailsRead"] boolValue])
|
2007-05-22 20:38:49 +02:00
|
|
|
[self appendRight: SOGoMailRole_SeenKeeper];
|
|
|
|
else
|
|
|
|
[self removeRight: SOGoMailRole_SeenKeeper];
|
|
|
|
|
2015-06-26 19:13:25 +02:00
|
|
|
if ([[newRights objectForKey: @"userCanWriteMails"] boolValue])
|
2007-05-22 20:38:49 +02:00
|
|
|
[self appendRight: SOGoMailRole_Writer];
|
|
|
|
else
|
|
|
|
[self removeRight: SOGoMailRole_Writer];
|
|
|
|
|
2015-06-26 19:13:25 +02:00
|
|
|
if ([[newRights objectForKey: @"userCanInsertMails"] boolValue])
|
2007-05-19 02:29:50 +02:00
|
|
|
[self appendRight: SOGoRole_ObjectCreator];
|
|
|
|
else
|
|
|
|
[self removeRight: SOGoRole_ObjectCreator];
|
|
|
|
|
2015-06-26 19:13:25 +02:00
|
|
|
if ([[newRights objectForKey: @"userCanPostMails"] boolValue])
|
2007-05-22 20:38:49 +02:00
|
|
|
[self appendRight: SOGoMailRole_Poster];
|
2007-05-19 02:29:50 +02:00
|
|
|
else
|
2007-05-22 20:38:49 +02:00
|
|
|
[self removeRight: SOGoMailRole_Poster];
|
2007-05-19 02:29:50 +02:00
|
|
|
|
2015-06-26 19:13:25 +02:00
|
|
|
if ([[newRights objectForKey: @"userCanCreateSubfolders"] boolValue])
|
2007-05-22 20:38:49 +02:00
|
|
|
[self appendRight: SOGoRole_FolderCreator];
|
2007-05-19 02:29:50 +02:00
|
|
|
else
|
2007-05-22 20:38:49 +02:00
|
|
|
[self removeRight: SOGoRole_FolderCreator];
|
2007-05-19 02:29:50 +02:00
|
|
|
|
2015-06-26 19:13:25 +02:00
|
|
|
if ([[newRights objectForKey: @"userCanRemoveFolder"] boolValue])
|
2007-06-01 22:54:07 +02:00
|
|
|
[self appendRight: SOGoRole_FolderEraser];
|
|
|
|
else
|
|
|
|
[self removeRight: SOGoRole_FolderEraser];
|
|
|
|
|
2015-06-26 19:13:25 +02:00
|
|
|
if ([[newRights objectForKey: @"userCanEraseMails"] boolValue])
|
2007-05-19 02:29:50 +02:00
|
|
|
[self appendRight: SOGoRole_ObjectEraser];
|
|
|
|
else
|
|
|
|
[self removeRight: SOGoRole_ObjectEraser];
|
2007-05-22 20:38:49 +02:00
|
|
|
|
2015-06-26 19:13:25 +02:00
|
|
|
if ([[newRights objectForKey: @"userCanExpungeFolder"] boolValue])
|
2007-05-22 20:38:49 +02:00
|
|
|
[self appendRight: SOGoMailRole_Expunger];
|
|
|
|
else
|
|
|
|
[self removeRight: SOGoMailRole_Expunger];
|
|
|
|
|
2015-06-26 19:13:25 +02:00
|
|
|
if ([[newRights objectForKey: @"userIsAdministrator"] boolValue])
|
2007-05-22 20:38:49 +02:00
|
|
|
[self appendRight: SOGoMailRole_Administrator];
|
|
|
|
else
|
|
|
|
[self removeRight: SOGoMailRole_Administrator];
|
2007-05-19 02:29:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
2007-05-22 20:38:49 +02:00
|
|
|
|