diff --git a/composer.json b/composer.json index 5c596e4..9861d09 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,8 @@ "php": ">=5.5", "sabre/dav": "~3.1.2", "sabre/vobject": "^4.0", - "easycorp/easy-log-handler": "^1.0" + "easycorp/easy-log-handler": "^1.0", + "zendframework/zend-validator": "^2.10" }, "require-dev": { "phpunit/phpunit" : "> 4.8, <=6.0.0" diff --git a/src/CalendarProcessor.php b/src/CalendarProcessor.php index 696d28b..8b20f18 100644 --- a/src/CalendarProcessor.php +++ b/src/CalendarProcessor.php @@ -1,11 +1,11 @@ + diff --git a/src/Config.php b/src/Config.php index 13cbff7..c1dfa70 100644 --- a/src/Config.php +++ b/src/Config.php @@ -1,9 +1,9 @@ twCalManager = $TWCalManager; + function __construct(Taskwarrior $taskwarrior = null){ + if(!is_null($taskwarrior)){ + $this->twCalManager = new CalendarProcessor(new TaskwarriorManager($taskwarrior)); } else { - $this->twCalManager = new CalendarProcessor(); + $this->twCalManager = new CalendarProcessor(new TaskwarriorManager()); } } @@ -75,9 +71,10 @@ class Plugin extends ServerPlugin { $server->on('propPatch', [$this, 'propPatchProtectedPropertyCheck'], 90); $server->on('propPatch', [$this, 'propPatchNodeUpdate'], 200); - $server->on('propFind', [$this, 'propFind']); - $server->on('propFind', [$this, 'propFindNode'], 120); - $server->on('propFind', [$this, 'propFindLate'], 200); + $server->on('calendarObjectChange', [$this, 'calendarObjectChange']); + //$server->on('propFind', [$this, 'propFind']); + //$server->on('propFind', [$this, 'propFindNode'], 120); + //$server->on('propFind', [$this, 'propFindLate'], 200); } @@ -100,7 +97,7 @@ class Plugin extends ServerPlugin { * * @param VCalendar $vCal parsed calendar object */ - function processCalendarEventForTaskwarrior(VCalendar $vCal){ + function processCalendarEventForTaskwarrior(Document $vCal){ try { $this->twCalManager->importTask($vCal->VTODO); } catch(BadRequest $e){ @@ -123,9 +120,6 @@ class Plugin extends ServerPlugin { * */ function calendarObjectChange(RequestInterface $request, ResponseInterface $response, Document $vCal, $calendarPath, &$modified, $isNew) { $calendarNode = $this->server->tree->getNodeForPath($calendarPath); - $addresses = $this->getAddressesForPrincipal( - $calendarNode->getOwner() - ); if ($isNew) { try { $this->processCalendarEventForTaskwarrior($vCal); @@ -747,48 +741,6 @@ class Plugin extends ServerPlugin { */ function propFind(PropFind $propFind, INode $node) { - $propFind->handle('{DAV:}getlastmodified', function() use ($node) { - $lm = $node->getLastModified(); - if ($lm) { - return new Xml\Property\GetLastModified($lm); - } - }); - - if ($node instanceof IFile) { - $propFind->handle('{DAV:}getcontentlength', [$node, 'getSize']); - $propFind->handle('{DAV:}getetag', [$node, 'getETag']); - $propFind->handle('{DAV:}getcontenttype', [$node, 'getContentType']); - } - - if ($node instanceof IQuota) { - $quotaInfo = null; - $propFind->handle('{DAV:}quota-used-bytes', function() use (&$quotaInfo, $node) { - $quotaInfo = $node->getQuotaInfo(); - return $quotaInfo[0]; - }); - $propFind->handle('{DAV:}quota-available-bytes', function() use (&$quotaInfo, $node) { - if (!$quotaInfo) { - $quotaInfo = $node->getQuotaInfo(); - } - return $quotaInfo[1]; - }); - } - - $propFind->handle('{DAV:}supported-report-set', function() use ($propFind) { - $reports = []; - foreach ($this->server->getPlugins() as $plugin) { - $reports = array_merge($reports, $plugin->getSupportedReportSet($propFind->getPath())); - } - return new Xml\Property\SupportedReportSet($reports); - }); - $propFind->handle('{DAV:}resourcetype', function() use ($node) { - return new Xml\Property\ResourceType($this->server->getResourceTypeForNode($node)); - }); - $propFind->handle('{DAV:}supported-method-set', function() use ($propFind) { - return new Xml\Property\SupportedMethodSet( - $this->server->getAllowedMethods($propFind->getPath()) - ); - }); } diff --git a/src/Taskwarrior/Taskwarrior.php b/src/Taskwarrior/Taskwarrior.php index b7873fc..3f1bba2 100644 --- a/src/Taskwarrior/Taskwarrior.php +++ b/src/Taskwarrior/Taskwarrior.php @@ -3,6 +3,7 @@ namespace Aerex\TaskwarriorPlugin\Taskwarrior; use Symfony\Component\Process\Process; use Aerex\TaskwarriorPlugin\Commands\IStrategy; +use Aerex\TaskwarriorPlugin\Config; class Taskwarrior { @@ -39,9 +40,9 @@ class Taskwarrior { * @var string */ - public function __construct(TaskwarriorConfig $config){ + public function __construct(Config $config){ if(!isset($config)){ - $this->config = new TaskwarriorConfig(); + $this->config = new Configwg(); } $this->config = $config; } @@ -64,3 +65,4 @@ class Taskwarrior { ?> + diff --git a/src/Taskwarrior/TaskwarriorManager.php b/src/Taskwarrior/TaskwarriorManager.php index fd2dd08..1ec5dc2 100644 --- a/src/Taskwarrior/TaskwarriorManager.php +++ b/src/Taskwarrior/TaskwarriorManager.php @@ -1,11 +1,10 @@ taskwarrior = new Taskwarrior(); + } else { + $this->taskwarrior = $taskwarrior; + } } public function createTask($UUID){ @@ -156,3 +159,4 @@ class TaskwarriorManager { } ?> +