added (optional) modified parameter to xmlrpc search method (bocalendar::store_to_cache, socalendar::list_events, socalendar::list_repeated_events) as requested by Espen Laursen and Ian Smith-Heisters for a better sync support

This commit is contained in:
Ralf Becker 2005-01-29 10:19:10 +00:00
parent 59392b4087
commit 116c51fcd3
2 changed files with 19 additions and 12 deletions

View File

@ -2094,6 +2094,10 @@
} }
$edate = mktime(23,59,59,$emonth,$eday,$eyear); $edate = mktime(23,59,59,$emonth,$eday,$eyear);
} }
if (isset($params['modified']) && @$this->xmlrpc)
{
$params['modified'] = $GLOBALS['server']->iso86012date($params['modified'],true);
}
//echo "<p>bocalendar::store_to_cache(".print_r($params,True).") syear=$syear, smonth=$smonth, sday=$sday, eyear=$eyear, emonth=$emonth, eday=$eday, xmlrpc='$param[xmlrpc]'</p>\n"; //echo "<p>bocalendar::store_to_cache(".print_r($params,True).") syear=$syear, smonth=$smonth, sday=$sday, eyear=$eyear, emonth=$emonth, eday=$eday, xmlrpc='$param[xmlrpc]'</p>\n";
if($this->debug) if($this->debug)
{ {
@ -2101,16 +2105,8 @@
echo '<!-- End Date : '.sprintf("%04d%02d%02d",$eyear,$emonth,$eday).' -->'."\n"; echo '<!-- End Date : '.sprintf("%04d%02d%02d",$eyear,$emonth,$eday).' -->'."\n";
} }
if($owner_id) $cached_event_ids = $this->so->list_events($syear,$smonth,$sday,$eyear,$emonth,$eday,(int)$owner_id,(int)$params['modified']);
{ $cached_event_ids_repeating = $this->so->list_repeated_events($syear,$smonth,$sday,$eyear,$emonth,$eday,(int)$owner_id,(int)$params['modified']);
$cached_event_ids = $this->so->list_events($syear,$smonth,$sday,$eyear,$emonth,$eday,$owner_id);
$cached_event_ids_repeating = $this->so->list_repeated_events($syear,$smonth,$sday,$eyear,$emonth,$eday,$owner_id);
}
else
{
$cached_event_ids = $this->so->list_events($syear,$smonth,$sday,$eyear,$emonth,$eday);
$cached_event_ids_repeating = $this->so->list_repeated_events($syear,$smonth,$sday,$eyear,$emonth,$eday);
}
$c_cached_ids = count($cached_event_ids); $c_cached_ids = count($cached_event_ids);
$c_cached_ids_repeating = count($cached_event_ids_repeating); $c_cached_ids_repeating = count($cached_event_ids_repeating);

View File

@ -102,7 +102,7 @@
return $extra; return $extra;
} }
function list_events($startYear,$startMonth,$startDay,$endYear=0,$endMonth=0,$endDay=0,$owner_id=0) function list_events($startYear,$startMonth,$startDay,$endYear=0,$endMonth=0,$endDay=0,$owner_id=0,$modified=0)
{ {
$extra = ''; $extra = '';
$extra .= strpos($this->filter,'private') ? "AND $this->table.cal_public=0 " : ''; $extra .= strpos($this->filter,'private') ? "AND $this->table.cal_public=0 " : '';
@ -111,6 +111,11 @@
{ {
$extra .= ' AND '.$this->cat_filter($this->cat_id); $extra .= ' AND '.$this->cat_filter($this->cat_id);
} }
if ((int) $modified > 0)
{
$modified -= $GLOBALS['phpgw']->datetime->tz_offset;
$extra .= " AND $this->table.cal_modified >= ".(int) $modified;
}
if($owner_id) if($owner_id)
{ {
return $this->cal->list_events($startYear,$startMonth,$startDay,$endYear,$endMonth,$endDay,$extra,$GLOBALS['phpgw']->datetime->tz_offset,$owner_id); return $this->cal->list_events($startYear,$startMonth,$startDay,$endYear,$endMonth,$endDay,$extra,$GLOBALS['phpgw']->datetime->tz_offset,$owner_id);
@ -127,7 +132,7 @@
* The startdate of an repeating events is the regular event-startdate. * The startdate of an repeating events is the regular event-startdate.
* Events are "still running" if no recur-enddate is set or its after e{year,month,day} * Events are "still running" if no recur-enddate is set or its after e{year,month,day}
*/ */
function list_repeated_events($syear,$smonth,$sday,$eyear,$emonth,$eday,$owner_id=0) function list_repeated_events($syear,$smonth,$sday,$eyear,$emonth,$eday,$owner_id=0,$modified=0)
{ {
if(!$owner_id) if(!$owner_id)
{ {
@ -143,6 +148,12 @@
$sql = "AND $this->table.cal_type='M' AND $this->user_table.cal_user_id IN (". $sql = "AND $this->table.cal_type='M' AND $this->user_table.cal_user_id IN (".
(is_array($owner_id) ? implode(',',$owner_id) : $owner_id).')'; (is_array($owner_id) ? implode(',',$owner_id) : $owner_id).')';
if ((int) $modified > 0)
{
$modified -= $GLOBALS['phpgw']->datetime->tz_offset;
$sql .= " AND $this->table.cal_modified >= ".(int) $modified;
}
/* why ??? /* why ???
$member_groups = $GLOBALS['phpgw']->accounts->membership($this->user); $member_groups = $GLOBALS['phpgw']->accounts->membership($this->user);
@reset($member_groups); @reset($member_groups);