* InfoLog/CalDAV: fixed not working toggeling of completed from iOS reminder app (only sets COMPLETED, but never STATUS or PERCENT-COMPLETED)

not returning etag for modified entries, as client then keeps not updated X-INFOLOG-STATUS, sending no etag we force him to update from server
This commit is contained in:
Ralf Becker 2012-03-22 12:15:18 +00:00
parent 0fb77619a8
commit 76d566d137
2 changed files with 32 additions and 9 deletions

View File

@ -474,8 +474,13 @@ class infolog_groupdav extends groupdav_handler
}
// send evtl. necessary respose headers: Location, etag, ...
$this->put_response_headers($infoId, $options['path'], $retval, self::$path_attr == 'caldav_name');
// but only for new entries, as X-INFOLOG-STATUS get's not updated on client, if we confirm with an etag
if ($retval !== true && (!$path_attr_is_name ||
// POST with add-member query parameter
$_SERVER['REQUEST_METHOD'] == 'POST' && isset($_GET['add-member'])))
{
$this->put_response_headers($infoId, $options['path'], $retval, self::$path_attr == 'caldav_name');
}
return $retval;
}

View File

@ -589,14 +589,32 @@ class infolog_ical extends infolog_bo
{
$taskData['info_id'] = $_taskID;
}
// if we have no STATUS, set STATUS by existence of COMPLETED and/or PERCENT-COMPLETED
// iOS reminder app only sets COMPLETED, but never STATUS
if (!($attr = $component->getAttribute('STATUS')) || !is_scalar($attr))
// iOS reminder app only sets COMPLETED, but never STATUS nor PERCENT-COMPLETED
// if we have no STATUS, set STATUS by existence of COMPLETED and/or PERCENT-COMPLETE and X-INFOLOG-STATUS
// if we have no PERCENT-COMPLETE set it from STATUS: 0=NEEDS-ACTION, 10=IN-PROCESS, 100=COMPLETED
if (!($status = $component->getAttribute('STATUS')) || !is_scalar($status))
{
$status = ($attr=$component->getAttribute('COMPLETED')) && is_scalar($attr) ? 'COMPLETED' :
(($attr=$component->getAttribute('COMPLETED-PERCENT')) && is_scalar($attr) && $attr > 0 ? 'IN-PROCESS' : 'NEEDS-ACTION');
$component->setAttribute('STATUS', $status);
if ($this->log) error_log(__METHOD__."() setting STATUS='$status' from COMPLETED(-PERCENT)\n",3,$this->logfile);
$completed = $component->getAttribute('COMPLETED');
$x_infolog_status = $component->getAttribute('X-INFOLOG-STATUS');
// check if we have a X-INFOLOG-STATUS and it's completed state is different from given COMPLETED attr
if (is_scalar($x_infolog_status) &&
($this->_status2vtodo[$x_infolog_status] === 'COMPLETED') != is_scalar($completed))
{
$percent_completed = $component->getAttribute('PERCENT-COMPLETE');
$status = $completed && is_scalar($completed) ? 'COMPLETED' :
($percent_completed && is_scalar($percent_completed) && $percent_completed > 0 ? 'IN-PROCESS' : 'NEEDS-ACTION');
$component->setAttribute('STATUS', $status);
if (!is_scalar($percent_completed))
{
$component->setAttribute('PERCENT-COMPLETE', $percent_completed = $status == 'COMPLETED' ?
100 : ($status == 'NEEDS-ACTION' ? 0 : 10));
}
if ($this->log) error_log(__METHOD__."() setting STATUS='$status' and PERCENT-COMPLETE=$percent_completed from COMPLETED and X-INFOLOG-STATUS='$x_infolog_status'\n",3,$this->logfile);
}
else
{
if ($this->log) error_log(__METHOD__."() no STATUS, X-INFOLOG-STATUS='$x_infolog_status', COMPLETED".(is_scalar($completed)?'='.$completed:' not set')." --> leaving status and percent unchanged",3,$this->logfile);
}
}
foreach ($component->getAllAttributes() as $attribute)
{