Monotone-Parent: 796c6bb92f7f6f97be354aeb3b35c39751605e50

Monotone-Revision: 3b018c57691598e10f6e73b0f7fc31137f869040

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2009-06-17T18:07:23
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2009-06-17 18:07:23 +00:00
parent 6a58d17252
commit 71fe9f878b
2 changed files with 41 additions and 60 deletions

View File

@ -2,6 +2,9 @@
* SoObjects/Appointments/SOGoAppointmentFolder.m
(-fetchFields:...): don't use the privacySqlString twice.
The component parameter MUST be a NSString from now on. Fixed a
syntax problem in the where clause occuring when vtodo components
were requested.
* UI/MailPartViewers/UIxMailPartICalViewer.m (-storedEventObject):
use the new "storedEventFetched" bool ivar to specify whether we

View File

@ -389,28 +389,6 @@ static NSArray *reducedReportQueryFields = nil;
/* fetching */
- (NSString *) _sqlStringForComponent: (id) _component
{
NSString *sqlString;
NSArray *components;
if (_component)
{
if ([_component isKindOfClass: [NSArray class]])
components = _component;
else
components = [NSArray arrayWithObject: _component];
sqlString
= [NSString stringWithFormat: @"AND (c_component = '%@')",
[components componentsJoinedByString: @"' OR c_component = '"]];
}
else
sqlString = @"";
return sqlString;
}
- (NSString *) _sqlStringRangeFrom: (NSCalendarDate *) _startDate
to: (NSCalendarDate *) _endDate
{
@ -495,7 +473,7 @@ static NSArray *reducedReportQueryFields = nil;
from: (NSCalendarDate *) startDate
to: (NSCalendarDate *) endDate
title: (NSString *) title
component: (id) component
component: (NSString *) component
additionalFilters: (NSString *) filters
{
EOQualifier *qualifier;
@ -516,7 +494,11 @@ static NSArray *reducedReportQueryFields = nil;
else
titleSqlString = @"";
componentSqlString = [self _sqlStringForComponent: component];
if (component)
componentSqlString = [NSString stringWithFormat: @"AND c_component = '%@'",
component];
else
componentSqlString = @"";
filterSqlString = [NSMutableString string];
if ([filters length])
[filterSqlString appendFormat: @"AND (%@)", filters];
@ -934,16 +916,16 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
{
EOQualifier *qualifier;
GCSFolder *folder;
NSMutableArray *fields, *ma = nil;
NSMutableArray *fields, *ma;
NSArray *records;
NSString *sql, *dateSqlString, *titleSqlString, *componentSqlString,
*privacySqlString, *currentLogin;
NSMutableString *filterSqlString;
NSMutableString *baseWhere;
NSString *where, *dateSqlString, *privacySqlString, *currentLogin;
NSCalendarDate *endDate;
NGCalendarDateRange *r;
BOOL rememberRecords;
BOOL rememberRecords, canCycle;
rememberRecords = [self _checkIfWeCanRememberRecords: _fields];
canCycle = [_component isEqualToString: @"vevent"];
// if (rememberRecords)
// NSLog (@"we will remember those records!");
@ -955,6 +937,12 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
return nil;
}
if (_component)
baseWhere = [NSMutableString stringWithFormat: @"AND c_component = '%@'",
_component];
else
baseWhere = [NSMutableString string];
if (_startDate)
{
if (_endDate)
@ -971,22 +959,16 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
dateSqlString = @"";
}
if ([title length])
titleSqlString = [NSString stringWithFormat: @"AND (c_title"
@" isCaseInsensitiveLike: '%%%@%%')",
[title stringByReplacingString: @"'" withString: @"\\'\\'"]];
else
titleSqlString = @"";
componentSqlString = [self _sqlStringForComponent: _component];
filterSqlString = [NSMutableString string];
if ([filters length])
[filterSqlString appendFormat: @"AND (%@)", filters];
privacySqlString = [self _privacySqlString];
if ([privacySqlString length])
[filterSqlString appendFormat: @"AND (%@)", privacySqlString];
[baseWhere appendFormat: @"AND %@", privacySqlString];
if ([title length])
[baseWhere appendFormat: @"AND c_title isCaseInsensitiveLike: '%%%@%%'",
[title stringByReplacingString: @"'" withString: @"\\'\\'"]];
if ([filters length])
[baseWhere appendFormat: @"AND (%@)", filters];
/* prepare mandatory fields */
@ -1000,19 +982,15 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
if (logger)
[self debugWithFormat:@"should fetch (%@=>%@) ...", _startDate, endDate];
// We treat recurrent tasks as normal components
if ([_component caseInsensitiveCompare: @"vtodo"] == NSOrderedSame)
sql = @"";
if (canCycle)
where = [NSString stringWithFormat: @"%@ %@ AND c_iscycle = 0",
baseWhere, dateSqlString];
else
sql = @"(c_iscycle = 0) ";
sql = [sql stringByAppendingFormat: @"%@ %@ %@ %@",
dateSqlString, titleSqlString, componentSqlString,
filterSqlString];
/* fetch non-recurrent apts first */
qualifier = [EOQualifier qualifierWithQualifierFormat: sql];
where = baseWhere;
/* fetch non-recurrent apts first */
qualifier = [EOQualifier qualifierWithQualifierFormat:
[where substringFromIndex: 4]];
records = [folder fetchFields: fields matchingQualifier: qualifier];
if (records)
{
@ -1023,15 +1001,15 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
[records count], records];
ma = [NSMutableArray arrayWithArray: records];
}
else
ma = nil;
/* fetch recurrent apts now. we do NOT consider events with no cycle end. */
if (_endDate || filters)
// || _endDate || filters)
if (canCycle)
{
sql = [NSString stringWithFormat: @"(c_iscycle = 1) %@ %@ %@", titleSqlString,
componentSqlString, filterSqlString];
qualifier = [EOQualifier qualifierWithQualifierFormat: sql];
where = [NSString stringWithFormat: @"%@ AND c_iscycle = 1", baseWhere];
qualifier = [EOQualifier qualifierWithQualifierFormat: [where substringFromIndex: 4]];
records = [folder fetchFields: fields matchingQualifier: qualifier];
if (records)
{