From 6d91430ee48756502c1263b5f999b3465faa6660 Mon Sep 17 00:00:00 2001 From: wolfgang Date: Tue, 24 Jul 2007 20:31:48 +0000 Subject: [PATCH] git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1120 d1b88da0-ebda-0310-925b-ed51d893ca5b --- ChangeLog | 32 ++++++++ Main/SOGo.m | 3 - OGoContentStore/OCSContactFieldExtractor.m | 18 ++-- OGoContentStore/OCSiCalFieldExtractor.m | 76 ++++++++--------- OGoContentStore/appointment.ocs | 38 ++++----- OGoContentStore/contact.ocs | 18 ++-- Scripts/sogo | 50 ----------- Scripts/sogo-init.d-debian | 21 +++++ Scripts/sogo-init.d-redhat | 21 +++++ Scripts/sogod-0.9 | 22 ++++- Scripts/sql-update-20070724.sh | 65 +++++++++++++++ .../Appointments/SOGoAppointmentFolder.m | 61 +++++++------- SoObjects/Contacts/SOGoContactGCSFolder.m | 82 ++++++++++++++++--- SoObjects/Contacts/SOGoContactLDAPFolder.m | 77 ++++++++++++++--- SoObjects/SOGo/AgenorUserDefaults.m | 2 +- SoObjects/SOGo/LDAPSource.m | 14 ++++ SoObjects/SOGo/SOGoUser.m | 4 +- UI/Contacts/UIxContactsListView.m | 22 ++--- UI/MainUI/AgenorProfile.sql | 6 +- UI/Scheduler/UIxCalListingActions.m | 18 ++-- .../ContactsUI/UIxContactsListView.wox | 8 +- 21 files changed, 439 insertions(+), 219 deletions(-) delete mode 100755 Scripts/sogo create mode 100755 Scripts/sql-update-20070724.sh diff --git a/ChangeLog b/ChangeLog index 8c87a945..2cfff954 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,35 @@ +2007-07-24 Wolfgang Sourdeau + + * UI/Contacts/UIxContactsListView.m ([-displayName]): removed + method. + ([UIxContactsListView -defaultSortKey]): changed to "displayName". + + * SoObjects/Contacts/SOGoContactLDAPFolder.m + ([SOGoContactLDAPFolder + -lookupContactsWithFilter:filtersortBy:sortKeyordering:sortOrdering]): + translate the returned records to a normalized form. + + * SoObjects/Contacts/SOGoContactGCSFolder.m ([SOGoContactGCSFolder + -lookupContactsWithFilter:filtersortBy:sortKeyordering:sortOrdering]): + translate the returned records to a normalized form. + + * UI/Scheduler/UIxCalListingActions.m, + UI/Contacts/UIxContactsListView.m, SoObjects/SOGo/SOGoUser.m, + SoObjects/SOGo/AgenorUserDefaults.m, + SoObjects/Contacts/SOGoContactGCSFolder.m, + SoObjects/Appointments/SOGoAppointmentFolder.m, + OGoContentStore/OCSiCalFieldExtractor.m, + OGoContentStore/OCSContactFieldExtractor.m: prefixed all quick + table fields with "c_". + +2007-07-23 Wolfgang Sourdeau + + * SoObjects/SOGo/LDAPSource.m ([LDAPSource +initialize]): query + the values for SOGoLDAPQueryLimit and SOGoLDAPQueryTimeout from + the application settings. If set, both limit will influence the + maximum size of the resultsets and the time taken to solve them. + ([LDAPSource -_initLDAPConnection]): initialize the limits. + 2007-07-22 Wolfgang Sourdeau * SoObjects/Contacts/SOGoContactGCSFolder.m ([SOGoContactGCSFolder -davNamespaces]): added new overriden diff --git a/Main/SOGo.m b/Main/SOGo.m index 0ee12f43..527d082b 100644 --- a/Main/SOGo.m +++ b/Main/SOGo.m @@ -174,9 +174,6 @@ static BOOL debugObjectAllocation = NO; [tc cancelFetch]; [cm releaseChannel: tc]; - -// [self terminate]; -// NSLog (@"not yet"); } - (BOOL) _checkMandatoryTables diff --git a/OGoContentStore/OCSContactFieldExtractor.m b/OGoContentStore/OCSContactFieldExtractor.m index f1f6a56b..b52b567e 100644 --- a/OGoContentStore/OCSContactFieldExtractor.m +++ b/OGoContentStore/OCSContactFieldExtractor.m @@ -43,38 +43,38 @@ value = [vCard fn]; if (value) - [fields setObject: value forKey: @"cn"]; + [fields setObject: value forKey: @"c_cn"]; values = [vCard n]; if (values) { max = [values count]; if (max > 0) { - [fields setObject: [values objectAtIndex: 0] forKey: @"sn"]; + [fields setObject: [values objectAtIndex: 0] forKey: @"c_sn"]; if (max > 1) [fields setObject: [values objectAtIndex: 1] - forKey: @"givenName"]; + forKey: @"c_givenName"]; } } value = [vCard preferredTel]; if (value) - [fields setObject: value forKey: @"telephoneNumber"]; + [fields setObject: value forKey: @"c_telephoneNumber"]; value = [vCard preferredEMail]; if (value) - [fields setObject: value forKey: @"mail"]; + [fields setObject: value forKey: @"c_mail"]; values = [vCard org]; max = [values count]; if (max > 0) { - [fields setObject: [values objectAtIndex: 0] forKey: @"o"]; + [fields setObject: [values objectAtIndex: 0] forKey: @"c_o"]; if (max > 1) - [fields setObject: [values objectAtIndex: 1] forKey: @"ou"]; + [fields setObject: [values objectAtIndex: 1] forKey: @"c_ou"]; } adr = [vCard preferredAdr]; if (adr) - [fields setObject: [adr value: 3] forKey: @"l"]; + [fields setObject: [adr value: 3] forKey: @"c_l"]; value = [[vCard uniqueChildWithTag: @"X-AIM"] value: 0]; - [fields setObject: value forKey: @"screenname"]; + [fields setObject: value forKey: @"c_screenname"]; return fields; } diff --git a/OGoContentStore/OCSiCalFieldExtractor.m b/OGoContentStore/OCSiCalFieldExtractor.m index 9a6188d1..1c929713 100644 --- a/OGoContentStore/OCSiCalFieldExtractor.m +++ b/OGoContentStore/OCSiCalFieldExtractor.m @@ -105,30 +105,30 @@ static NSNumber *distantFutureNumber = nil; row = [NSMutableDictionary dictionaryWithCapacity:8]; - [row setObject: @"vevent" forKey: @"component"]; + [row setObject: @"vevent" forKey: @"c_component"]; if ([uid isNotNull]) - [row setObject:uid forKey: @"uid"]; + [row setObject:uid forKey: @"c_uid"]; else [self logWithFormat: @"WARNING: could not extract a uid from event!"]; [row setObject: [NSNumber numberWithBool: isAllDay] - forKey: @"isallday"]; + forKey: @"c_isallday"]; [row setObject: [NSNumber numberWithBool: [_event isRecurrent]] - forKey: @"iscycle"]; + forKey: @"c_iscycle"]; [row setObject: [NSNumber numberWithBool: [_event isOpaque]] - forKey: @"isopaque"]; + forKey: @"c_isopaque"]; [row setObject: [NSNumber numberWithInt: [_event priorityNumber]] - forKey: @"priority"]; + forKey: @"c_priority"]; - if ([title isNotNull]) [row setObject: title forKey: @"title"]; - if ([location isNotNull]) [row setObject: location forKey: @"location"]; - if ([sequence isNotNull]) [row setObject: sequence forKey: @"sequence"]; + if ([title isNotNull]) [row setObject: title forKey: @"c_title"]; + if ([location isNotNull]) [row setObject: location forKey: @"c_location"]; + if ([sequence isNotNull]) [row setObject: sequence forKey: @"c_sequence"]; if ([startDate isNotNull]) [row setObject: [self numberForDate: startDate] - forKey: @"startdate"]; + forKey: @"c_startdate"]; if ([endDate isNotNull]) { if (endDate == distantFuture) @@ -143,7 +143,7 @@ static NSNumber *distantFutureNumber = nil; = [NSNumber numberWithUnsignedInt: [endDate timeIntervalSince1970] - i]; } - [row setObject: dateNumber forKey: @"enddate"]; + [row setObject: dateNumber forKey: @"c_enddate"]; } if ([_event isRecurrent]) { @@ -155,14 +155,14 @@ static NSNumber *distantFutureNumber = nil; more complex - thus we set it to a "reasonable" distant future */ date = distantFuture; } - [row setObject:[self numberForDate:date] forKey: @"cycleenddate"]; - [row setObject:[_event cycleInfo] forKey: @"cycleinfo"]; + [row setObject:[self numberForDate:date] forKey: @"c_cycleenddate"]; + [row setObject:[_event cycleInfo] forKey: @"c_cycleinfo"]; } if ([participants length] > 0) - [row setObject: participants forKey: @"participants"]; + [row setObject: participants forKey: @"c_participants"]; if ([partmails length] > 0) - [row setObject: partmails forKey: @"partmails"]; + [row setObject: partmails forKey: @"c_partmails"]; if ([status isNotNull]) { int code = 1; @@ -171,15 +171,15 @@ static NSNumber *distantFutureNumber = nil; code = 2; else if ([status isEqualToString: @"CANCELLED"]) code = 0; - [row setObject:[NSNumber numberWithInt:code] forKey: @"status"]; + [row setObject:[NSNumber numberWithInt:code] forKey: @"c_status"]; } else { /* confirmed by default */ - [row setObject: [NSNumber numberWithInt:1] forKey: @"status"]; + [row setObject: [NSNumber numberWithInt:1] forKey: @"c_status"]; } [row setObject: [NSNumber numberWithUnsignedInt: accessClass] - forKey: @"classification"]; + forKey: @"c_classification"]; organizer = [_event organizer]; if (organizer) { @@ -187,7 +187,7 @@ static NSNumber *distantFutureNumber = nil; email = [organizer valueForKey: @"rfc822Email"]; if (email) - [row setObject:email forKey: @"orgmail"]; + [row setObject:email forKey: @"c_orgmail"]; } /* construct partstates */ @@ -203,7 +203,7 @@ static NSNumber *distantFutureNumber = nil; [partstates appendString: @"\n"]; [partstates appendFormat: @"%d", stat]; } - [row setObject:partstates forKey: @"partstates"]; + [row setObject:partstates forKey: @"c_partstates"]; [partstates release]; return row; } @@ -245,43 +245,43 @@ static NSNumber *distantFutureNumber = nil; row = [NSMutableDictionary dictionaryWithCapacity:8]; - [row setObject: @"vtodo" forKey: @"component"]; + [row setObject: @"vtodo" forKey: @"c_component"]; if ([uid isNotNull]) - [row setObject:uid forKey: @"uid"]; + [row setObject:uid forKey: @"c_uid"]; else [self logWithFormat: @"WARNING: could not extract a uid from event!"]; [row setObject:[NSNumber numberWithBool:[_task isRecurrent]] - forKey: @"iscycle"]; + forKey: @"c_iscycle"]; [row setObject:[NSNumber numberWithInt:[_task priorityNumber]] - forKey: @"priority"]; + forKey: @"c_priority"]; [row setObject: [NSNumber numberWithBool: NO] - forKey: @"isallday"]; + forKey: @"c_isallday"]; [row setObject: [NSNumber numberWithBool: NO] - forKey: @"isopaque"]; + forKey: @"c_isopaque"]; - if ([title isNotNull]) [row setObject: title forKey: @"title"]; - if ([location isNotNull]) [row setObject: location forKey: @"location"]; - if ([sequence isNotNull]) [row setObject: sequence forKey: @"sequence"]; + if ([title isNotNull]) [row setObject: title forKey: @"c_title"]; + if ([location isNotNull]) [row setObject: location forKey: @"c_location"]; + if ([sequence isNotNull]) [row setObject: sequence forKey: @"c_sequence"]; if ([startDate isNotNull]) date = [self numberForDate: startDate]; else date = [NSNull null]; - [row setObject: date forKey: @"startdate"]; + [row setObject: date forKey: @"c_startdate"]; if ([dueDate isNotNull]) date = [self numberForDate: dueDate]; else date = [NSNull null]; - [row setObject: date forKey: @"enddate"]; + [row setObject: date forKey: @"c_enddate"]; if ([participants length] > 0) - [row setObject:participants forKey: @"participants"]; + [row setObject:participants forKey: @"c_participants"]; if ([partmails length] > 0) - [row setObject:partmails forKey: @"partmails"]; + [row setObject:partmails forKey: @"c_partmails"]; if ([status isNotNull]) { code = 0; /* NEEDS-ACTION */ @@ -291,15 +291,15 @@ static NSNumber *distantFutureNumber = nil; code = 2; else if ([status isEqualToString: @"CANCELLED"]) code = 3; - [row setObject: [NSNumber numberWithInt: code] forKey: @"status"]; + [row setObject: [NSNumber numberWithInt: code] forKey: @"c_status"]; } else { /* confirmed by default */ - [row setObject:[NSNumber numberWithInt:1] forKey: @"status"]; + [row setObject:[NSNumber numberWithInt:1] forKey: @"c_status"]; } [row setObject: [NSNumber numberWithUnsignedInt: accessClass] - forKey: @"classification"]; + forKey: @"c_classification"]; organizer = [_task organizer]; if (organizer) { @@ -307,7 +307,7 @@ static NSNumber *distantFutureNumber = nil; email = [organizer valueForKey: @"rfc822Email"]; if (email) - [row setObject:email forKey: @"orgmail"]; + [row setObject:email forKey: @"c_orgmail"]; } /* construct partstates */ @@ -323,7 +323,7 @@ static NSNumber *distantFutureNumber = nil; [partstates appendString: @"\n"]; [partstates appendFormat: @"%d", stat]; } - [row setObject:partstates forKey: @"partstates"]; + [row setObject:partstates forKey: @"c_partstates"]; [partstates release]; return row; } diff --git a/OGoContentStore/appointment.ocs b/OGoContentStore/appointment.ocs index 0b6c1e7a..9f4ab505 100644 --- a/OGoContentStore/appointment.ocs +++ b/OGoContentStore/appointment.ocs @@ -10,97 +10,97 @@ allowsNull = NO; }, { - columnName = uid; + columnName = c_uid; sqlType = "VARCHAR(256)"; allowsNull = NO; }, { - columnName = startdate; + columnName = c_startdate; sqlType = "INT"; allowsNull = YES; }, { - columnName = enddate; + columnName = c_enddate; sqlType = "INT"; allowsNull = YES; }, { - columnName = cycleenddate; + columnName = c_cycleenddate; sqlType = "INT"; allowsNull = YES; }, { - columnName = title; + columnName = c_title; sqlType = "VARCHAR(1000)"; allowsNull = NO; }, { - columnName = participants; + columnName = c_participants; sqlType = "VARCHAR(1000000)"; allowsNull = YES; }, { - columnName = isallday; + columnName = c_isallday; sqlType = "INT"; allowsNull = YES; }, { - columnName = iscycle; + columnName = c_iscycle; sqlType = "INT"; allowsNull = YES; }, { - columnName = cycleinfo; + columnName = c_cycleinfo; sqlType = "VARCHAR(1000)"; allowsNull = YES; }, { - columnName = classification; + columnName = c_classification; sqlType = "INT"; allowsNull = NO; }, { - columnName = isopaque; + columnName = c_isopaque; sqlType = "INT"; allowsNull = NO; }, { - columnName = status; + columnName = c_status; sqlType = "INT"; allowsNull = NO; }, { - columnName = priority; + columnName = c_priority; sqlType = "INT"; allowsNull = YES; }, { - columnName = location; + columnName = c_location; sqlType = "VARCHAR(256)"; allowsNull = YES; }, { - columnName = orgmail; + columnName = c_orgmail; sqlType = "VARCHAR(256)"; allowsNull = YES; }, { - columnName = partmails; + columnName = c_partmails; sqlType = "VARCHAR(100000)"; allowsNull = YES; }, { - columnName = partstates; + columnName = c_partstates; sqlType = "VARCHAR(256)"; allowsNull = YES; }, { - columnName = sequence; + columnName = c_sequence; sqlType = "INT"; allowsNull = YES; }, { - columnName = component; + columnName = c_component; sqlType = "VARCHAR(10)"; allowsNull = NO; }, diff --git a/OGoContentStore/contact.ocs b/OGoContentStore/contact.ocs index d1372447..d51c6e70 100644 --- a/OGoContentStore/contact.ocs +++ b/OGoContentStore/contact.ocs @@ -10,47 +10,47 @@ allowsNull = NO; }, { - columnName = givenname; + columnName = c_givenname; sqlType = "VARCHAR(256)"; allowsNull = YES; }, { - columnName = cn; + columnName = c_cn; sqlType = "VARCHAR(256)"; allowsNull = YES; }, { - columnName = sn; + columnName = c_sn; sqlType = "VARCHAR(256)"; allowsNull = YES; }, { - columnName = screenname; + columnName = c_screenname; sqlType = "VARCHAR(256)"; allowsNull = YES; }, { - columnName = l; + columnName = c_l; sqlType = "VARCHAR(256)"; allowsNull = YES; }, { - columnName = mail; + columnName = c_mail; sqlType = "VARCHAR(256)"; allowsNull = YES; }, { - columnName = o; + columnName = c_o; sqlType = "VARCHAR(256)"; allowsNull = YES; }, { - columnName = ou; + columnName = c_ou; sqlType = "VARCHAR(256)"; allowsNull = YES; }, { - columnName = telephoneNumber; + columnName = c_telephoneNumber; sqlType = "VARCHAR(256)"; allowsNull = YES; }, diff --git a/Scripts/sogo b/Scripts/sogo deleted file mode 100755 index 5514064a..00000000 --- a/Scripts/sogo +++ /dev/null @@ -1,50 +0,0 @@ -#! /bin/sh - -PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin - -DAEMON=/usr/local/sbin/sogod-0.9 -NAME=sogo -DESC="Scalable OpenGroupware.Org" - -PIDFILE=/var/run/sogo/sogod.pid - -SOGO_ARGS="" - -if [ -f /etc/default/sogo ]; then - . /etc/default/sogo -fi - -test -x $DAEMON || exit 0 - -#set -e - -case "$1" in - start) - echo -n "Starting $DESC: " - start-stop-daemon -c sogo --pidfile $PIDFILE \ - -b --start --quiet --exec $DAEMON - echo "$NAME." - ;; - stop) - echo -n "Stopping $DESC: " - killall sogod-0.9 2> /dev/null - rm -f $PIDFILE - echo "$NAME." - ;; - restart|force-reload) - echo -n "Restarting $DESC: " - killall sogod-0.9 2> /dev/null - rm -f $PIDFILE - sleep 1 - start-stop-daemon -c sogo --pidfile $PIDFILE \ - -b --start --quiet --exec $DAEMON - echo "$NAME." - ;; - *) - N=/etc/init.d/$NAME - echo "Usage: $N {start|stop|restart|force-reload}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/Scripts/sogo-init.d-debian b/Scripts/sogo-init.d-debian index 2044a40a..db2a939b 100755 --- a/Scripts/sogo-init.d-debian +++ b/Scripts/sogo-init.d-debian @@ -1,5 +1,26 @@ #! /bin/sh +# SOGo init script for Debian GNU/Linux +# +# Copyright (C) 2007 Inverse groupe conseil +# +# Author: Wolfgang Sourdeau +# +# 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. + PATH=/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/sbin/sogod-0.9 diff --git a/Scripts/sogo-init.d-redhat b/Scripts/sogo-init.d-redhat index ad94d06b..68ac60d7 100755 --- a/Scripts/sogo-init.d-redhat +++ b/Scripts/sogo-init.d-redhat @@ -1,5 +1,26 @@ #!/bin/bash + +# SOGo init script for RedHat +# +# Copyright (C) 2007 Inverse groupe conseil +# +# Author: Wolfgang Sourdeau # +# 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. + # sogod Scalable OpenGroupware.org (Inverse edition) # # chkconfig: - 85 15 diff --git a/Scripts/sogod-0.9 b/Scripts/sogod-0.9 index 99584cec..d2a326b2 100755 --- a/Scripts/sogod-0.9 +++ b/Scripts/sogod-0.9 @@ -1,9 +1,29 @@ #!/bin/sh +# SOGo daemon wrapper +# +# Copyright (C) 2007 Inverse groupe conseil +# +# Author: Wolfgang Sourdeau +# +# 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. + PIDFILE=/var/run/sogo/sogod.pid . /usr/lib/GNUstep/System/Library/Makefiles/GNUstep.sh echo $$ > $PIDFILE exec $GNUSTEP_LOCAL_ROOT/Tools/sogod-0.9 >& /var/log/sogo/sogod.log - diff --git a/Scripts/sql-update-20070724.sh b/Scripts/sql-update-20070724.sh new file mode 100755 index 00000000..65bd6893 --- /dev/null +++ b/Scripts/sql-update-20070724.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# this script only work with PostgreSQL, which at this time is the only +# database really supported by SOGo/SOPE + +defaultusername=$USER +defaulthostname=localhost +defaultdatabase=$USER + +read -p "Username ($defaultusername): " username +read -p "Hostname ($defaulthostname): " hostname +read -p "Database ($defaultdatabase): " database + +if [ -z "$username" ] +then + username=$defaultusername +fi +if [ -z "$hostname" ] +then + hostname=$defaulthostname +fi +if [ -z "$database" ] +then + database=$defaultdatabase +fi + +echo "" +echo "You will now be requested your password thrice..." +echo "After that, a list of SQL operations will scroll." +echo "" + +sqlscript="" + +function renameFields() { + oldIFS="$IFS" + IFS=" " + set $fields + for field in $@ + do + part="`echo -e \"ALTER TABLE $table RENAME $field TO c_${field};\\n\"`"; + sqlscript="$sqlscript$part" + done + IFS="$oldIFS" +} + +table=sogo_user_profile +fields="uid defaults settings" +renameFields + +fields="uid startdate enddate cycleenddate title cycleinfo participants isallday iscycle classification status priority isopaque location orgmail partmails partstates sequence component" +tables=`psql -U $username -h $hostname $database -c "select split_part(c_quick_location, '/', 5) from sogo_folder_info where c_folder_type ilike 'Appointment';" | grep _quick` +for table in $tables; +do + renameFields +done + +fields="givenname cn sn l mail o ou telephonenumber screenname" +tables=`psql -U $username -h $hostname $database -c "select split_part(c_quick_location, '/', 5) from sogo_folder_info where c_folder_type ilike 'Contact';" | grep _quick` +for table in $tables; +do + renameFields +done + +sqlscript="$sqlscript;" +echo "$sqlscript" | psql -e -U $username -h $hostname $database diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 8cc9c45d..af7370d5 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -143,7 +143,7 @@ static NSNumber *sharedYes = nil; c_name = [object objectForKey: @"c_name"]; - if ([[object objectForKey: @"component"] isEqualToString: @"vevent"]) + if ([[object objectForKey: @"c_component"] isEqualToString: @"vevent"]) componentClass = [SOGoAppointmentObject class]; else componentClass = [SOGoTaskObject class]; @@ -497,12 +497,12 @@ static NSNumber *sharedYes = nil; Class objectClass; qualifier = [EOQualifier qualifierWithQualifierFormat:@"c_name = %@", c_name]; - records = [[self ocsFolder] fetchFields: [NSArray arrayWithObject: @"component"] + records = [[self ocsFolder] fetchFields: [NSArray arrayWithObject: @"c_component"] matchingQualifier: qualifier]; if ([records count]) { - component = [[records objectAtIndex:0] valueForKey: @"component"]; + component = [[records objectAtIndex:0] valueForKey: @"c_component"]; if ([component isEqualToString: @"vevent"]) objectClass = [SOGoAppointmentObject class]; else if ([component isEqualToString: @"vtodo"]) @@ -526,7 +526,7 @@ static NSNumber *sharedYes = nil; md = [[_record mutableCopy] autorelease]; - if ((tmp = [_record objectForKey:@"startdate"])) { + if ((tmp = [_record objectForKey:@"c_startdate"])) { tmp = [[NSCalendarDate alloc] initWithTimeIntervalSince1970: (NSTimeInterval)[tmp unsignedIntValue]]; [tmp setTimeZone: timeZone]; @@ -536,7 +536,7 @@ static NSNumber *sharedYes = nil; else [self logWithFormat:@"missing 'startdate' in record?"]; - if ((tmp = [_record objectForKey:@"enddate"])) { + if ((tmp = [_record objectForKey:@"c_enddate"])) { tmp = [[NSCalendarDate alloc] initWithTimeIntervalSince1970: (NSTimeInterval)[tmp unsignedIntValue]]; [tmp setTimeZone: timeZone]; @@ -605,23 +605,23 @@ static NSNumber *sharedYes = nil; NSArray *rules, *exRules, *exDates, *ranges; unsigned i, count; - cycleinfo = [[_row objectForKey:@"cycleinfo"] propertyList]; + cycleinfo = [[_row objectForKey:@"c_cycleinfo"] propertyList]; if (cycleinfo == nil) { [self errorWithFormat:@"cyclic record doesn't have cycleinfo -> %@", _row]; return; } row = [self fixupRecord:_row fetchRange: _r]; - [row removeObjectForKey:@"cycleinfo"]; - [row setObject:sharedYes forKey:@"isRecurrentEvent"]; + [row removeObjectForKey: @"c_cycleinfo"]; + [row setObject: sharedYes forKey:@"isRecurrentEvent"]; - startDate = [row objectForKey:@"startDate"]; - endDate = [row objectForKey:@"endDate"]; + startDate = [row objectForKey:@"c_startDate"]; + endDate = [row objectForKey:@"c_endDate"]; fir = [NGCalendarDateRange calendarDateRangeWithStartDate:startDate endDate:endDate]; - rules = [cycleinfo objectForKey:@"rules"]; - exRules = [cycleinfo objectForKey:@"exRules"]; - exDates = [cycleinfo objectForKey:@"exDates"]; + rules = [cycleinfo objectForKey:@"c_rules"]; + exRules = [cycleinfo objectForKey:@"c_exRules"]; + exDates = [cycleinfo objectForKey:@"c_exDates"]; ranges = [iCalRecurrenceCalculator recurrenceRangesWithinCalendarDateRange:_r firstInstanceCalendarDateRange:fir @@ -673,8 +673,8 @@ static NSNumber *sharedYes = nil; components = [NSArray arrayWithObject: _component]; sqlString - = [NSString stringWithFormat: @" AND (component = '%@')", - [components componentsJoinedByString: @"' OR component = '"]]; + = [NSString stringWithFormat: @" AND (c_component = '%@')", + [components componentsJoinedByString: @"' OR c_component = '"]]; } else sqlString = @""; @@ -691,7 +691,7 @@ static NSNumber *sharedYes = nil; end = (unsigned int) [_endDate timeIntervalSince1970]; return [NSString stringWithFormat: - @" AND (startdate <= %u) AND (enddate >= %u)", + @" AND (c_startdate <= %u) AND (c_enddate >= %u)", end, start]; } @@ -809,14 +809,14 @@ static NSNumber *sharedYes = nil; /* prepare mandatory fields */ fields = [NSMutableArray arrayWithArray: _fields]; - [fields addObject: @"uid"]; - [fields addObject: @"startdate"]; - [fields addObject: @"enddate"]; + [fields addObject: @"c_uid"]; + [fields addObject: @"c_startdate"]; + [fields addObject: @"c_enddate"]; if (logger) [self debugWithFormat:@"should fetch (%@=>%@) ...", _startDate, _endDate]; - sql = [NSString stringWithFormat: @"(iscycle = 0)%@%@%@", + sql = [NSString stringWithFormat: @"(c_iscycle = 0)%@%@%@", dateSqlString, componentSqlString, privacySqlString]; /* fetch non-recurrent apts first */ @@ -834,11 +834,11 @@ static NSNumber *sharedYes = nil; } /* fetch recurrent apts now */ - sql = [NSString stringWithFormat: @"(iscycle = 1)%@%@%@", + sql = [NSString stringWithFormat: @"(c_iscycle = 1)%@%@%@", dateSqlString, componentSqlString, privacySqlString]; qualifier = [EOQualifier qualifierWithQualifierFormat: sql]; - [fields addObject: @"cycleinfo"]; + [fields addObject: @"c_cycleinfo"]; records = [_folder fetchFields: fields matchingQualifier: qualifier]; if (records) @@ -895,8 +895,8 @@ static NSNumber *sharedYes = nil; static NSArray *infos = nil; // TODO: move to a plist file if (!infos) - infos = [[NSArray alloc] initWithObjects: @"partmails", @"partstates", - @"isopaque", @"status", nil]; + infos = [[NSArray alloc] initWithObjects: @"c_partmails", @"c_partstates", + @"c_isopaque", @"c_status", nil]; return [self fetchFields: infos from: _startDate to: _endDate component: @"vevent"]; @@ -910,12 +910,13 @@ static NSNumber *sharedYes = nil; if (!infos) infos = [[NSArray alloc] initWithObjects: - @"c_name", @"component", - @"title", @"location", @"orgmail", - @"status", @"classification", - @"isallday", @"isopaque", - @"participants", @"partmails", - @"partstates", @"sequence", @"priority", nil]; + @"c_name", @"c_component", + @"c_title", @"c_location", @"c_orgmail", + @"c_status", @"c_classification", + @"c_isallday", @"c_isopaque", + @"c_participants", @"c_partmails", + @"c_partstates", @"c_sequence", @"c_priority", + nil]; return [self fetchFields: infos from: _startDate to: _endDate component: _component]; diff --git a/SoObjects/Contacts/SOGoContactGCSFolder.m b/SoObjects/Contacts/SOGoContactGCSFolder.m index df3f0834..23444abd 100644 --- a/SoObjects/Contacts/SOGoContactGCSFolder.m +++ b/SoObjects/Contacts/SOGoContactGCSFolder.m @@ -33,9 +33,9 @@ #import "SOGoContactGCSEntry.h" #import "SOGoContactGCSFolder.h" -#define folderListingFields [NSArray arrayWithObjects: @"c_name", @"cn", \ - @"givenname", @"screenname", \ - @"o", @"mail", @"telephonenumber", \ +#define folderListingFields [NSArray arrayWithObjects: @"c_name", @"c_cn", \ + @"c_givenname", @"c_screenname", \ + @"c_o", @"c_mail", @"c_telephonenumber", \ nil] @implementation SOGoContactGCSFolder @@ -141,10 +141,10 @@ if (filter && [filter length] > 0) { qs = [NSString stringWithFormat: - @"(sn isCaseInsensitiveLike: '%@%%') OR " - @"(givenname isCaseInsensitiveLike: '%@%%') OR " - @"(mail isCaseInsensitiveLike: '%@%%') OR " - @"(telephonenumber isCaseInsensitiveLike: '%%%@%%')", + @"(c_sn isCaseInsensitiveLike: '%@%%') OR " + @"(c_givenname isCaseInsensitiveLike: '%@%%') OR " + @"(c_mail isCaseInsensitiveLike: '%@%%') OR " + @"(c_telephonenumber isCaseInsensitiveLike: '%%%@%%')", filter, filter, filter, filter]; qualifier = [EOQualifier qualifierWithQualifierFormat: qs]; } @@ -154,11 +154,66 @@ return qualifier; } +- (NSArray *) _flattenedRecords: (NSArray *) records +{ + NSMutableArray *newRecords; + NSEnumerator *oldRecords; + NSDictionary *oldRecord; + NSMutableDictionary *newRecord; + NSString *data; + + newRecords = [NSMutableArray arrayWithCapacity: [records count]]; + + oldRecords = [records objectEnumerator]; + oldRecord = [oldRecords nextObject]; + while (oldRecord) + { + newRecord = [NSMutableDictionary new]; + [newRecord autorelease]; + + [newRecord setObject: [oldRecord objectForKey: @"c_name"] + forKey: @"c_uid"]; + [newRecord setObject: [oldRecord objectForKey: @"c_name"] + forKey: @"c_name"]; + + data = [oldRecord objectForKey: @"c_cn"]; + if (!data) + data = @""; + [newRecord setObject: data + forKey: @"displayName"]; + + data = [oldRecord objectForKey: @"c_mail"]; + if (!data) + data = @""; + [newRecord setObject: data forKey: @"mail"]; + + data = [oldRecord objectForKey: @"c_screenname"]; + if (!data) + data = @""; + [newRecord setObject: data forKey: @"screenName"]; + + data = [oldRecord objectForKey: @"c_o"]; + if (!data) + data = @""; + [newRecord setObject: data forKey: @"org"]; + + data = [oldRecord objectForKey: @"c_telephonenumber"]; + if (![data length]) + data = @""; + [newRecord setObject: data forKey: @"phone"]; + + [newRecords addObject: newRecord]; + oldRecord = [oldRecords nextObject]; + } + + return newRecords; +} + - (NSArray *) lookupContactsWithFilter: (NSString *) filter sortBy: (NSString *) sortKey ordering: (NSComparisonResult) sortOrdering { - NSArray *fields, *records; + NSArray *fields, *dbRecords, *records; EOQualifier *qualifier; EOSortOrdering *ordering; @@ -167,10 +222,11 @@ fields = folderListingFields; qualifier = [self _qualifierForFilter: filter]; - records = [[self ocsFolder] fetchFields: fields - matchingQualifier: qualifier]; - if ([records count] > 1) + dbRecords = [[self ocsFolder] fetchFields: fields + matchingQualifier: qualifier]; + if ([dbRecords count] > 1) { + records = [self _flattenedRecords: dbRecords]; ordering = [EOSortOrdering sortOrderingWithKey: sortKey selector: ((sortOrdering == NSOrderedDescending) @@ -181,7 +237,9 @@ [NSArray arrayWithObject: ordering]]; } else - [self errorWithFormat:@"(%s): fetch failed!", __PRETTY_FUNCTION__]; + records = nil; +// else +// [self errorWithFormat:@"(%s): fetch failed!", __PRETTY_FUNCTION__]; //[self debugWithFormat:@"fetched %i records.", [records count]]; return records; diff --git a/SoObjects/Contacts/SOGoContactLDAPFolder.m b/SoObjects/Contacts/SOGoContactLDAPFolder.m index 60e4ee98..2704be33 100644 --- a/SoObjects/Contacts/SOGoContactLDAPFolder.m +++ b/SoObjects/Contacts/SOGoContactLDAPFolder.m @@ -37,17 +37,6 @@ #import "SOGoContactLDIFEntry.h" #import "SOGoContactLDAPFolder.h" -#define folderListingFields [NSArray arrayWithObjects: @"c_name", @"cn", \ - @"displayName", \ - @"streetAddress", \ - @"o", \ - @"sn", @"givenname", @"l", \ - @"mail", @"telephonenumber", \ - @"mailNickname", \ - @"sAMAccountName", \ - @"uid", \ - nil] - @class WOContext; @implementation SOGoContactLDAPFolder @@ -148,6 +137,68 @@ return keys; } +- (NSArray *) _flattenedRecords: (NSArray *) records +{ + NSMutableArray *newRecords; + NSEnumerator *oldRecords; + NSDictionary *oldRecord; + NSMutableDictionary *newRecord; + NSString *data; + + newRecords = [[NSMutableArray alloc] initWithCapacity: [records count]]; + [newRecords autorelease]; + + oldRecords = [records objectEnumerator]; + oldRecord = [oldRecords nextObject]; + while (oldRecord) + { + newRecord = [NSMutableDictionary new]; + [newRecord autorelease]; + + [newRecord setObject: [oldRecord objectForKey: @"c_uid"] + forKey: @"c_uid"]; + [newRecord setObject: [oldRecord objectForKey: @"c_name"] + forKey: @"c_name"]; + + data = [oldRecord objectForKey: @"displayName"]; + if (!data) + data = @""; + [newRecord setObject: data + forKey: @"displayName"]; + + data = [oldRecord objectForKey: @"mail"]; + if (!data) + data = @""; + [newRecord setObject: data forKey: @"mail"]; + + data = [oldRecord objectForKey: @"nsAIMid"]; + if (![data length]) + data = [oldRecord objectForKey: @"nscpaimscreenname"]; + if (![data length]) + data = @""; + [newRecord setObject: data forKey: @"screenName"]; + + data = [oldRecord objectForKey: @"o"]; + if (!data) + data = @""; + [newRecord setObject: data forKey: @"org"]; + + data = [oldRecord objectForKey: @"telephoneNumber"]; + if (![data length]) + data = [oldRecord objectForKey: @"cellphone"]; + if (![data length]) + data = [oldRecord objectForKey: @"homePhone"]; + if (![data length]) + data = @""; + [newRecord setObject: data forKey: @"phone"]; + + [newRecords addObject: newRecord]; + oldRecord = [oldRecords nextObject]; + } + + return newRecords; +} + - (NSArray *) lookupContactsWithFilter: (NSString *) filter sortBy: (NSString *) sortKey ordering: (NSComparisonResult) sortOrdering @@ -159,7 +210,8 @@ if (filter && [filter length] > 0) { - records = [ldapSource fetchContactsMatching: filter]; + records = [self _flattenedRecords: + [ldapSource fetchContactsMatching: filter]]; ordering = [EOSortOrdering sortOrderingWithKey: sortKey selector: ((sortOrdering == NSOrderedDescending) @@ -170,7 +222,6 @@ [NSArray arrayWithObject: ordering]]; } - //[self debugWithFormat:@"fetched %i records.", [records count]]; return result; } diff --git a/SoObjects/SOGo/AgenorUserDefaults.m b/SoObjects/SOGo/AgenorUserDefaults.m index 10b88155..15743275 100644 --- a/SoObjects/SOGo/AgenorUserDefaults.m +++ b/SoObjects/SOGo/AgenorUserDefaults.m @@ -38,7 +38,7 @@ @implementation AgenorUserDefaults -static NSString *uidColumnName = @"uid"; +static NSString *uidColumnName = @"c_uid"; - (id) initWithTableURL: (NSURL *) tableURL uid: (NSString *) userID diff --git a/SoObjects/SOGo/LDAPSource.m b/SoObjects/SOGo/LDAPSource.m index 75fe64d4..eeb0a14a 100644 --- a/SoObjects/SOGo/LDAPSource.m +++ b/SoObjects/SOGo/LDAPSource.m @@ -32,13 +32,21 @@ #import "LDAPSource.h" static NSArray *commonSearchFields; +static int timeLimit; +static int sizeLimit; @implementation LDAPSource + (void) initialize { + NSUserDefaults *ud; + if (!commonSearchFields) { + ud = [NSUserDefaults standardUserDefaults]; + sizeLimit = [ud integerForKey: @"SOGoLDAPQueryLimit"]; + timeLimit = [ud integerForKey: @"SOGoLDAPQueryTimeout"]; + commonSearchFields = [NSArray arrayWithObjects: @"title", @"company", @@ -211,6 +219,10 @@ static NSArray *commonSearchFields; [ldapConnection bindWithMethod: @"simple" binddn: bindDN credentials: password]; + if (sizeLimit > 0) + [ldapConnection setQuerySizeLimit: sizeLimit]; + if (timeLimit > 0) + [ldapConnection setQueryTimeLimit: timeLimit]; } /* user management */ @@ -264,6 +276,8 @@ static NSArray *commonSearchFields; { bindConnection = [[NGLdapConnection alloc] initWithHostName: hostname port: port]; + if (timeLimit > 0) + [ldapConnection setQueryTimeLimit: timeLimit]; if (bindFields) userDN = [self _fetchUserDNForLogin: loginToCheck]; else diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index 00d9b3f3..d212d2c1 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -296,7 +296,7 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; userDefaults = [[AgenorUserDefaults alloc] initWithTableURL: AgenorProfileURL uid: login - fieldName: @"defaults"]; + fieldName: @"c_defaults"]; return userDefaults; } @@ -307,7 +307,7 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; userSettings = [[AgenorUserDefaults alloc] initWithTableURL: AgenorProfileURL uid: login - fieldName: @"settings"]; + fieldName: @"c_settings"]; return userSettings; } diff --git a/UI/Contacts/UIxContactsListView.m b/UI/Contacts/UIxContactsListView.m index 4803bba0..940cbaa5 100644 --- a/UI/Contacts/UIxContactsListView.m +++ b/UI/Contacts/UIxContactsListView.m @@ -92,18 +92,7 @@ - (NSString *) defaultSortKey { - return @"fn"; -} - -- (NSString *) displayName -{ - NSString *displayName; - - displayName = [currentContact objectForKey: @"displayName"]; - if (!(displayName && [displayName length] > 0)) - displayName = [currentContact objectForKey: @"cn"]; - - return displayName; + return @"displayName"; } - (NSString *) sortKey @@ -137,10 +126,11 @@ else valueText = nil; - ASSIGN (contactInfos, - [folder lookupContactsWithFilter: valueText - sortBy: [self sortKey] - ordering: ordering]); + [contactInfos release]; + contactInfos = [folder lookupContactsWithFilter: valueText + sortBy: [self sortKey] + ordering: ordering]; + [contactInfos retain]; } return contactInfos; diff --git a/UI/MainUI/AgenorProfile.sql b/UI/MainUI/AgenorProfile.sql index 2012e7dd..1849425b 100644 --- a/UI/MainUI/AgenorProfile.sql +++ b/UI/MainUI/AgenorProfile.sql @@ -4,7 +4,7 @@ -- CREATE TABLE SOGo_user_profile ( - uid VARCHAR(255) NOT NULL PRIMARY KEY, - defaults TEXT, - settings TEXT + c_uid VARCHAR(255) NOT NULL PRIMARY KEY, + c_defaults TEXT, + c_settings TEXT ); diff --git a/UI/Scheduler/UIxCalListingActions.m b/UI/Scheduler/UIxCalListingActions.m index bcbb66bc..03f647f9 100644 --- a/UI/Scheduler/UIxCalListingActions.m +++ b/UI/Scheduler/UIxCalListingActions.m @@ -188,8 +188,8 @@ forUser: userLogin]; if ([roleString isEqualToString: @"ComponentDAndTViewer"]) { - [component setObject: @"" forKey: @"title"]; - [component setObject: @"" forKey: @"location"]; + [component setObject: @"" forKey: @"c_title"]; + [component setObject: @"" forKey: @"c_location"]; } } @@ -265,14 +265,14 @@ newInfo = [currentInfos nextObject]; while (newInfo) { - uid = [newInfo objectForKey: @"uid"]; + uid = [newInfo objectForKey: @"c_uid"]; currentInfo = [infos objectForKey: uid]; if (!currentInfo || [owner isEqualToString: userLogin]) { [self _updatePrivacyInComponent: newInfo fromFolder: currentFolder]; - [newInfo setObject: owner forKey: @"owner"]; + [newInfo setObject: owner forKey: @"c_owner"]; [infos setObject: [newInfo objectsForKeys: fields notFoundMarker: marker] forKey: uid]; @@ -325,9 +325,9 @@ [self _setupContext]; newEvents = [NSMutableArray array]; - fields = [NSArray arrayWithObjects: @"c_name", @"owner", @"status", - @"title", @"startdate", @"enddate", @"location", - @"isallday", nil]; + fields = [NSArray arrayWithObjects: @"c_name", @"c_owner", @"c_status", + @"c_title", @"c_startdate", @"c_enddate", @"c_location", + @"c_isallday", nil]; events = [[self _fetchFields: fields forComponentOfType: @"vevent"] objectEnumerator]; oldEvent = [events nextObject]; @@ -396,8 +396,8 @@ [self _setupContext]; - fields = [NSArray arrayWithObjects: @"c_name", @"owner", @"status", - @"title", @"enddate", nil]; + fields = [NSArray arrayWithObjects: @"c_name", @"c_owner", @"c_status", + @"c_title", @"c_enddate", nil]; tasks = [[self _fetchFields: fields forComponentOfType: @"vtodo"] objectEnumerator]; diff --git a/UI/Templates/ContactsUI/UIxContactsListView.wox b/UI/Templates/ContactsUI/UIxContactsListView.wox index 7d4836e5..79df8ddf 100644 --- a/UI/Templates/ContactsUI/UIxContactsListView.wox +++ b/UI/Templates/ContactsUI/UIxContactsListView.wox @@ -35,11 +35,11 @@ ondblclick="return onContactRowDblClick(event, this);" oncontextmenu="return onContactContextMenu(event, this);"> + /> - - - + + + -- 2.39.5