This commit is contained in:
Raimund Schlüßler 2015-02-28 20:53:12 +01:00
parent a2fdd1df3d
commit 0ff6acec9e

View file

@ -201,7 +201,6 @@ class TasksController extends Controller {
private function setPercentComplete($percent_complete){
$taskId = (int) $this->params('taskID');
$isCompleted = null;
try {
$vcalendar = \OC_Calendar_App::getVCalendar($taskId);
$vtodo = $vcalendar->VTODO;
@ -210,20 +209,14 @@ class TasksController extends Controller {
}else{
$vtodo->__unset('PERCENT-COMPLETE');
}
if ($percent_complete == 100) {
if (!$isCompleted) {
$isCompleted = 'now';
}
} else {
$isCompleted = null;
}
if ($isCompleted) {
$timezone = \OC_Calendar_App::getTimezone();
$timezone = new \DateTimeZone($timezone);
$isCompleted = new \DateTime($isCompleted, $timezone);
$vtodo->setDateTime('COMPLETED', $isCompleted);
} else {
$vtodo->setString('STATUS', 'COMPLETED');
$vtodo->setDateTime('COMPLETED', 'now', \Sabre\VObject\Property\DateTime::UTC);
} elseif ($percent_complete != 0) {
$vtodo->setString('STATUS', 'IN-PROCESS');
unset($vtodo->COMPLETED);
} else{
$vtodo->setString('STATUS', 'NEEDS-ACTION');
unset($vtodo->COMPLETED);
}
\OC_Calendar_Object::edit($taskId, $vcalendar->serialize());