From 76d566d13786f6c6571cecc9f482204840adc2f4 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 22 Mar 2012 12:15:18 +0000 Subject: [PATCH] * 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 --- infolog/inc/class.infolog_groupdav.inc.php | 9 ++++-- infolog/inc/class.infolog_ical.inc.php | 32 +++++++++++++++++----- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/infolog/inc/class.infolog_groupdav.inc.php b/infolog/inc/class.infolog_groupdav.inc.php index cf36f10e61..6dda0072cd 100644 --- a/infolog/inc/class.infolog_groupdav.inc.php +++ b/infolog/inc/class.infolog_groupdav.inc.php @@ -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; } diff --git a/infolog/inc/class.infolog_ical.inc.php b/infolog/inc/class.infolog_ical.inc.php index 4ba7e0b611..b4404ffa3d 100644 --- a/infolog/inc/class.infolog_ical.inc.php +++ b/infolog/inc/class.infolog_ical.inc.php @@ -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) {