163 lines
3.2 KiB
PHP
163 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace Aerex\TaskwarriorPlugin\Taskwarrior;
|
|
|
|
use Aerex\TaskwarriorPlugin\Taskwarrior\Taskwarrior;
|
|
use Aerex\TaskwarriorPlugin\Taskwarrior\Task;
|
|
use Sabre\VObject\Component\VTodo;
|
|
|
|
class TaskwarriorManager {
|
|
|
|
const DESCRIPTION = 'description';
|
|
const CATEGORIES = 'categories';
|
|
const TASK_UUID = 'uuid';
|
|
const ICAL_UID = 'uid';
|
|
|
|
private $tasks;
|
|
|
|
const ENTRY = 'entry';
|
|
const START = 'start';
|
|
const MODIFIED = 'modified';
|
|
const END = 'end';
|
|
|
|
public function __construct($taskwarrior){
|
|
if(!isset($taskwarrior)){
|
|
$this->taskwarrior = new Taskwarrior();
|
|
} else {
|
|
$this->taskwarrior = $taskwarrior;
|
|
}
|
|
}
|
|
|
|
public function createTask($UUID){
|
|
$task = new Task();
|
|
}
|
|
|
|
public function export(VTodo $document){
|
|
|
|
}
|
|
|
|
public function addTask(VTodo $document){
|
|
|
|
$task = $this->taskwarrior->createTask($document->UID);
|
|
|
|
$task->setDescription($document);
|
|
|
|
$task->setEntry($document);
|
|
|
|
$task->setStartTime($document);
|
|
|
|
$task->setModifiedTime($document);
|
|
|
|
$task->setStopTime($document);
|
|
|
|
$task->setDue($document);
|
|
|
|
$task->setCategories($document);
|
|
|
|
$task->setStatus($document);
|
|
|
|
$task->setRecurrence($document);
|
|
|
|
return $this->taskwarrior->add($task);
|
|
|
|
}
|
|
|
|
public function updateTask(VTodo $document){
|
|
|
|
$task = $this->taskwarrior->get($document->UID);
|
|
|
|
$task->setDescription($document);
|
|
|
|
$task->setEntry($document);
|
|
|
|
$task->setStartTime($document);
|
|
|
|
$task->setModifiedTime($document);
|
|
|
|
$task->setStopTime($document);
|
|
|
|
$task->setDue($document);
|
|
|
|
$task->setCategories($document);
|
|
|
|
$task->setStatus($document);
|
|
|
|
$task->setRecurrence($document);
|
|
|
|
$updatedTask = $this->taskwarrior->modify($task);
|
|
|
|
return $upatedTask;
|
|
}
|
|
|
|
|
|
function setEntryTime($entry){
|
|
}
|
|
|
|
function exists($UUID){}
|
|
|
|
function setEndTime($end){}
|
|
function setModifiedTime($modifiedTime){}
|
|
function setSummary($description){
|
|
if(!isset($description)){
|
|
return;
|
|
}
|
|
$this->taskWarriorJSON[self::DESCRIPTION] = $description;
|
|
}
|
|
|
|
function setStartTime($startTime){}
|
|
function setCategories($categories){
|
|
if(!isset($categories)){
|
|
return;
|
|
}
|
|
|
|
if(!is_array($catergories)){
|
|
return;
|
|
}
|
|
|
|
$this->taskWarriorJSON[self::CATEGORIES] = $categories;
|
|
}
|
|
|
|
|
|
|
|
public function taskExists($taskUuid){
|
|
$taskIsInCache = isset($this->cachedTasks[$taskUuid]);
|
|
|
|
if($taskIsInCache){
|
|
return true;
|
|
}
|
|
|
|
$jsonArray = $this->taskwarrior->export($taskUuid);
|
|
$taskWithUuidExists = count($jsonArray) > 0;
|
|
|
|
return $taskWithUuidExists;
|
|
|
|
}
|
|
|
|
public function save(){
|
|
|
|
}
|
|
public function build(){
|
|
|
|
}
|
|
/**
|
|
* @param Task $task
|
|
* @param string $attr
|
|
* @param mixed $value
|
|
*/
|
|
public function setValue(Task $task, $attr, $value)
|
|
{
|
|
$refClass = new \ReflectionClass(Task::class);
|
|
$refProp = $refClass->getProperty($attr);
|
|
$refProp->setAccessible(true);
|
|
$refProp->setValue($task, $value);
|
|
}
|
|
|
|
|
|
function setDescription($description){}
|
|
function parseiCalDateTime($iCalDateTime){}
|
|
function convertToStringArray($categories){}
|
|
}
|
|
|
|
?>
|
|
|