server side code to integrate the whitelist
parent
16d02455bd
commit
f0b8eb8dfb
|
@ -1,3 +1,4 @@
|
|||
"This or these persons cannot be invited:" = "This or these persons cannot be invited:";
|
||||
"Personal Calendar" = "Personal Calendar";
|
||||
vevent_class0 = "(Public event)";
|
||||
vevent_class1 = "(Private event)";
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#import <Foundation/NSEnumerator.h>
|
||||
#import <Foundation/NSTimeZone.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
#import <Foundation/NSPredicate.h>
|
||||
|
||||
#import <NGObjWeb/NSException+HTTP.h>
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
|
@ -52,6 +53,7 @@
|
|||
#import <SOGo/SOGoPermissions.h>
|
||||
#import <SOGo/SOGoGroup.h>
|
||||
#import <SOGo/SOGoUser.h>
|
||||
#import <SOGo/SOGoUserSettings.h>
|
||||
#import <SOGo/SOGoDomainDefaults.h>
|
||||
#import <SOGo/SOGoWebDAVValue.h>
|
||||
#import <SOGo/WORequest+SOGo.h>
|
||||
|
@ -424,51 +426,56 @@
|
|||
NSDictionary *values;
|
||||
NSMutableDictionary *value;
|
||||
SOGoUser *user, *currentUser, *ownerUser;
|
||||
SOGoUserSettings *us;
|
||||
NSException *e;
|
||||
int count = 0, i = 0;
|
||||
NSMutableArray *whiteList;
|
||||
NSPredicate *predicate;
|
||||
|
||||
// Build a list of the attendees uids without the ressources
|
||||
// Build list of the attendees uids without ressources
|
||||
attendees = [NSMutableArray arrayWithCapacity: [theAttendees count]];
|
||||
unavailableAttendees = [[NSMutableArray alloc] init];
|
||||
enumerator = [theAttendees objectEnumerator];
|
||||
|
||||
while ((currentAttendee = [enumerator nextObject]))
|
||||
{
|
||||
currentUID = [currentAttendee uid];
|
||||
if (currentUID)
|
||||
{
|
||||
user = [SOGoUser userWithLogin: currentUID];
|
||||
us = [user userSettings];
|
||||
if (![user isResource])
|
||||
{
|
||||
// Check if the user can be invited to an event.
|
||||
if ([[user userSettings] objectForKey:@"PreventInvitations"])
|
||||
// Check if the user prevented his account from beeing invited to events
|
||||
if ([[us objectForKey:@"PreventInvitations"] boolValue])
|
||||
{
|
||||
values = [NSDictionary dictionaryWithObject:[user cn] forKey:@"Cn"];
|
||||
[unavailableAttendees addObject:values];
|
||||
// Check if the user have a whiteList
|
||||
whiteList = [NSMutableArray arrayWithObject:[us objectForKey:@"whiteListInvitations"]];
|
||||
predicate = [NSPredicate predicateWithFormat:@"SELF CONTAINS[cd] %@", @"sogo1"];
|
||||
[whiteList filterUsingPredicate:predicate];
|
||||
|
||||
// If the filter have a hit, do not add the currentUID to the unavailableAttendees array
|
||||
if ([whiteList count] == 0)
|
||||
{
|
||||
values = [NSDictionary dictionaryWithObject:[user cn] forKey:@"Cn"];
|
||||
[unavailableAttendees addObject:values];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
count = [unavailableAttendees count];
|
||||
if (count > 0)
|
||||
if ([unavailableAttendees count] > 0)
|
||||
{
|
||||
if (count > 1)
|
||||
reason = [NSMutableString stringWithString:[self labelForKey: @"This or these persons cannot be invited:"]];
|
||||
// Add all the unavailable users in the warning message
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
reason = [NSMutableString stringWithString:[self labelForKey: @"These persons cannot be invited :"]];
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
value = [unavailableAttendees objectAtIndex:i];
|
||||
[reason appendString:[value keysWithFormat: @"\n %{Cn}"]];
|
||||
if (!(i == (count - 1)))
|
||||
{
|
||||
[reason appendString:@" &"];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = [unavailableAttendees objectAtIndex:0];
|
||||
reason = [self labelForKey: @"This person cannot be invited:"];
|
||||
value = [unavailableAttendees objectAtIndex:i];
|
||||
[reason appendString:[value keysWithFormat: @"\n %{Cn}"]];
|
||||
if (!(i == (count - 1)))
|
||||
[reason appendString:@" &"];
|
||||
}
|
||||
[unavailableAttendees release];
|
||||
return [NSException exceptionWithHTTPStatus:403 reason: reason];
|
||||
|
|
|
@ -639,10 +639,10 @@ static NSArray *reminderValues = nil;
|
|||
return [userDefaults busyOffHours];
|
||||
}
|
||||
|
||||
- (NSString *) whiteListValue
|
||||
- (NSArray *) whiteListValue
|
||||
{
|
||||
SOGoUserSettings *us;
|
||||
id *whiteListValue;
|
||||
NSArray *whiteListValue;
|
||||
|
||||
us = [user userSettings];
|
||||
whiteListValue = [us objectForKey:@"whiteListInvitations"];
|
||||
|
|
|
@ -229,10 +229,42 @@ function initPreferences() {
|
|||
// Calendar whiteList
|
||||
var whiteList = $("appointmentsWhiteListWrapper");
|
||||
if(whiteList) {
|
||||
var whiteListValue = $("whiteListValue").getValue().split(",");
|
||||
if (whiteListValue.length != 0)
|
||||
{
|
||||
var tablebody = $("appointmentsWhiteListWrapper").childNodesWithTag("table")[0].tBodies[0];
|
||||
for (i = 0; i < whiteListValue.length; i++)
|
||||
{
|
||||
var elements = whiteListValue[i].split("=");
|
||||
var row = new Element("tr");
|
||||
var td = new Element("td").update("");
|
||||
var textField = new Element("input");
|
||||
var span = new Element("span");
|
||||
|
||||
row.addClassName("whiteListRow");
|
||||
row.observe("mousedown", onRowClick);
|
||||
td.addClassName ("whiteListCell");
|
||||
td.observe("mousedown", endAllEditables);
|
||||
td.observe("dblclick", onNameEdit);
|
||||
textField.addInterface(SOGoAutoCompletionInterface);
|
||||
textField.SOGoUsersSearch = true;
|
||||
textField.observe("autocompletion:changed", endEditable);
|
||||
textField.addClassName("textField");
|
||||
textField.value = elements[1];
|
||||
textField.setAttribute("uid", elements[0]);
|
||||
textField.hide();
|
||||
span.innerText = elements[1];
|
||||
|
||||
td.appendChild(textField);
|
||||
td.appendChild(span);
|
||||
row.appendChild (td);
|
||||
tablebody.appendChild(row);
|
||||
$(tablebody).deselectAll();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
var table = whiteList.childNodesWithTag("table")[0];
|
||||
var r = $$("#appointmentsWhiteListWrapper tbody tr");
|
||||
for (var i= 0; i < r.length; i++)
|
||||
r[i].identify();
|
||||
table.multiselect = true;
|
||||
$("appointmentsWhiteListAdd").observe("click", onAppointmentsWhiteListAdd);
|
||||
$("appointmentsWhiteListDelete").observe("click", onAppointmentsWhiteListDelete);
|
||||
|
@ -1076,6 +1108,7 @@ function onAppointmentsWhiteListAdd(e) {
|
|||
row.selectElement();
|
||||
|
||||
makeEditable(td);
|
||||
|
||||
}
|
||||
|
||||
function onAppointmentsWhiteListDelete(e) {
|
||||
|
@ -1096,7 +1129,9 @@ function serializeAppointmentsWhiteList() {
|
|||
for (var i = 0; i < r.length; i++) {
|
||||
var tds = r[i].childElements().first().down("INPUT");
|
||||
var uid = tds.getAttribute("uid");
|
||||
values.push(uid);
|
||||
var value = tds.getValue();
|
||||
var user = uid + "=" + value;
|
||||
values.push(user);
|
||||
}
|
||||
|
||||
$("whiteListValue").value = values;
|
||||
|
|
Loading…
Reference in New Issue