mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-07-12 20:05:08 +00:00
feat(core): Add message of the day
This commit is contained in:
@@ -25,3 +25,7 @@
|
||||
"No resource" = "No resource";
|
||||
"Any Authenticated User" = "Any Authenticated User";
|
||||
"Public Access" = "Public Access";
|
||||
"Save" = "Save";
|
||||
"Clear" = "Clear";
|
||||
"Message of the day" = "Message of the day";
|
||||
"Message of the day has been saved" = "Message of the day has been saved";
|
||||
|
||||
@@ -25,3 +25,7 @@
|
||||
"No resource" = "Aucune ressource";
|
||||
"Any Authenticated User" = "Tout utilisateur authentifié";
|
||||
"Public Access" = "Accès public";
|
||||
"Save" = "Sauvegarder";
|
||||
"Clear" = "Effacer";
|
||||
"Message of the day" = "Message du jour";
|
||||
"Message of the day has been saved" = "Le message du jour a été sauvegardé";
|
||||
@@ -13,7 +13,8 @@ AdministrationUI_OBJC_FILES = \
|
||||
\
|
||||
UIxAdministration.m \
|
||||
UIxAdministrationAclEditor.m \
|
||||
UIxAdministrationFilterPanel.m
|
||||
UIxAdministrationFilterPanel.m \
|
||||
UIxAdministrationMotd.m
|
||||
|
||||
AdministrationUI_RESOURCE_FILES += \
|
||||
product.plist
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#import <SoObjects/SOGo/SOGoUser.h>
|
||||
//#import "../../Main/SOGo.h"
|
||||
|
||||
#import <SOGo/SOGoAdmin.h>
|
||||
|
||||
#import "UIxAdministration.h"
|
||||
|
||||
@implementation UIxAdministration
|
||||
@@ -53,12 +55,18 @@
|
||||
return @"Administration";
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) shouldTakeValuesFromRequest: (WORequest *) request
|
||||
inContext: (WOContext*) context
|
||||
{
|
||||
return [[request method] isEqualToString: @"POST"];
|
||||
}
|
||||
|
||||
- (BOOL) isAdminTableConfigured
|
||||
{
|
||||
return [[SOGoAdmin sharedInstance] isConfigured];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/* Theme Preview */
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/* UIxAdministrationMotd.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2023 Alinto
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef UIXMOTD_H
|
||||
#define UIXMOTD_H
|
||||
|
||||
#import <SOGoUI/UIxComponent.h>
|
||||
|
||||
@interface UIxAdministrationMotd : UIxComponent
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif /* UIXMOTD_H */
|
||||
@@ -0,0 +1,110 @@
|
||||
/* UIxAdministrationMotd.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2023 Alinto
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import "UIxAdministrationMotd.h"
|
||||
|
||||
#import <SOGo/SOGoUser.h>
|
||||
#import <SOGo/SOGoAdmin.h>
|
||||
|
||||
@implementation UIxAdministrationMotd
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (WOResponse *) getAction
|
||||
{
|
||||
WOResponse *response;
|
||||
SOGoAdmin *admin;
|
||||
NSDictionary *jsonResponse;
|
||||
|
||||
admin = [SOGoAdmin sharedInstance];
|
||||
if ([admin isConfigured]) {
|
||||
jsonResponse = [NSDictionary dictionaryWithObject: nil != [admin getMotd] ? [admin getMotd] : @""
|
||||
forKey: @"motd"];
|
||||
response = [self responseWithStatus: 200
|
||||
andJSONRepresentation: jsonResponse];
|
||||
} else {
|
||||
response = [self responseWithStatus: 500
|
||||
andString: @"Missing folder configuration"];
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
- (WOResponse *) saveAction
|
||||
{
|
||||
WORequest *request;
|
||||
WOResponse *response;
|
||||
SOGoUser *user;
|
||||
NSException *error;
|
||||
NSDictionary *data;
|
||||
SOGoAdmin *admin;
|
||||
|
||||
error = nil;
|
||||
admin = [SOGoAdmin sharedInstance];
|
||||
user = [context activeUser];
|
||||
|
||||
if ([user isSuperUser]) {
|
||||
if ([admin isConfigured]) {
|
||||
data = [[[context request] contentAsString] objectFromJSONString];
|
||||
if ([data objectForKey: @"motd"]
|
||||
&& [[data objectForKey: @"motd"] isKindOfClass: [NSString class]]
|
||||
&& [[data objectForKey: @"motd"] length] > 0) {
|
||||
error = [admin saveMotd: [data objectForKey: @"motd"]];
|
||||
} else {
|
||||
error = [admin deleteMotd];
|
||||
}
|
||||
|
||||
if (!error) {
|
||||
response = [self responseWithStatus: 200
|
||||
andString: @"OK"];
|
||||
} else {
|
||||
response = [self responseWithStatus: 500
|
||||
andString: @"Error while storing information"];
|
||||
}
|
||||
|
||||
} else {
|
||||
response = [self responseWithStatus: 500
|
||||
andString: @"Missing folder configuration"];
|
||||
}
|
||||
} else {
|
||||
response = [self responseWithStatus: 503
|
||||
andString: @"Forbidden"];
|
||||
}
|
||||
|
||||
response = [self responseWithStatus: 200
|
||||
andString: @"OK"];
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -22,6 +22,20 @@
|
||||
protectedBy = "View";
|
||||
pageName = "UIxThemePreview";
|
||||
};
|
||||
UIxAdministrationMotd = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxAdministrationMotd";
|
||||
};
|
||||
getMotd = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxAdministrationMotd";
|
||||
actionName = "get";
|
||||
};
|
||||
saveMotd = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxAdministrationMotd";
|
||||
actionName = "save";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user