Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/tasks.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorraimund-schluessler <raimund.schluessler@googlemail.com>2014-07-19 11:54:15 +0400
committerraimund-schluessler <raimund.schluessler@googlemail.com>2014-07-19 11:54:15 +0400
commitbb0ddc1751ed8b0c54e516cec2f27de2a595e1fd (patch)
treef47085318dacda89c570bf6ee76790bcbc1657a6 /lib
parent65978357c0279930efeac3cbb90aa9323e923813 (diff)
First working implementation of commenting
Diffstat (limited to 'lib')
-rw-r--r--lib/controller/taskscontroller.php30
-rw-r--r--lib/helper.php16
2 files changed, 36 insertions, 10 deletions
diff --git a/lib/controller/taskscontroller.php b/lib/controller/taskscontroller.php
index 4a071079..bfaea758 100644
--- a/lib/controller/taskscontroller.php
+++ b/lib/controller/taskscontroller.php
@@ -439,8 +439,6 @@ class TasksController extends Controller {
}
}
-
-
return $response;
}
@@ -500,17 +498,30 @@ class TasksController extends Controller {
$commentId = 1+max($commentIds);
$now = new \DateTime();
- $now = $now->format('Ymd\THis\Z');
- $tmp = $vtodo->addProperty('COMMENT',$comment,
+ $vtodo->addProperty('COMMENT',$comment,
array(
'ID' => $commentId,
'USERID' => $userId,
- 'DATE-TIME' => $now
+ 'DATE-TIME' => $now->format('Ymd\THis\Z')
)
);
\OC_Calendar_Object::edit($taskId, $vcalendar->serialize());
- $response->setData();
-
+ $user_timezone = \OC_Calendar_App::getTimezone();
+ $now->setTimezone(new \DateTimeZone($user_timezone));
+ $comment = array(
+ 'taskID' => $taskId,
+ 'id' => $commentId,
+ 'tmpID' => $this->params('tmpID'),
+ 'userID' => $userId,
+ 'comment' => $comment,
+ 'time' => $now->format('Ymd\THis')
+ );
+ $result = array(
+ 'data' => array(
+ 'comment' => $comment
+ )
+ );
+ $response->setData($result);
} catch(\Exception $e) {
// throw new BusinessLayerException($e->getMessage());
}
@@ -520,12 +531,11 @@ class TasksController extends Controller {
/**
* @NoAdminRequired
*/
- public function deleteCommentById(){
+ public function deleteComment(){
$taskId = $this->params('taskID');
$commentId = $this->params('commentID');
$userId = $this->api->getUserId();
$response = new JSONResponse();
- $test = array();
try {
$vcalendar = \OC_Calendar_App::getVCalendar($taskId);
$vtodo = $vcalendar->VTODO;
@@ -535,7 +545,7 @@ class TasksController extends Controller {
} catch(\Exception $e) {
// throw new BusinessLayerException($e->getMessage());
}
- $response->setData($test);
+ $response->setData();
return $response;
}
diff --git a/lib/helper.php b/lib/helper.php
index aabecbf7..ca7c8bcb 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -169,6 +169,22 @@ Class helper {
$task['completed'] = false;
}
$task['complete'] = $vtodo->getAsString('PERCENT-COMPLETE')==''?'0':$vtodo->getAsString('PERCENT-COMPLETE');
+ $comments = $vtodo->COMMENT;
+ if($comments){
+ $comments_parsed = array();
+ foreach($comments as $com) {
+ $time = new \DateTime($com['DATE-TIME']->value);
+ $time->setTimezone(new \DateTimeZone($user_timezone));
+ $time = $time->format('Ymd\THis');
+ $comments_parsed[] = array(
+ 'id' => (int)$com['ID']->value,
+ 'userID' => $com['USERID']->value,
+ 'comment' => $com->value,
+ 'time' => $time
+ );
+ }
+ }
+ $task['comments'] = $comments_parsed;
return $task;
}