fix: Retrieved displayname using getProperties from server obj

- chore: Cleaned up comments and plugin info
This commit is contained in:
Aerex 2020-10-09 01:12:57 -05:00
parent a875bd8e2b
commit 357531d329
1 changed files with 10 additions and 12 deletions

View File

@ -12,7 +12,6 @@ use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface; use Sabre\HTTP\ResponseInterface;
use Sabre\DAV\ServerPlugin; use Sabre\DAV\ServerPlugin;
use Sabre\DAV\Server; use Sabre\DAV\Server;
use Sabre\DAV\PropFind;
/** /**
* The plugin to interact with Baikal and external storages * The plugin to interact with Baikal and external storages
@ -34,9 +33,10 @@ class Plugin extends ServerPlugin {
*/ */
protected $storageManager; protected $storageManager;
/**
* @var $rawconfigs
*/
protected $rawConfigs; protected $rawConfigs;
/** /**
* Creates the Storage plugin * Creates the Storage plugin
@ -51,15 +51,13 @@ class Plugin extends ServerPlugin {
} }
private function getDisplayName($path) { private function getDisplayName($path) {
// Remove filepath // Remove filepath (e.g Remove xxxx.ics from calendars/collection_name/xxxx.ics)
$urlParts = explode('/', $path); $urlParts = explode('/', $path);
$calendarUrl = implode('/', array_slice($urlParts, 0, count($urlParts)-1)); $calendarUrl = implode('/', array_slice($urlParts, 0, sizeof($urlParts)-1));
$node = $this->server->tree->getNodeForPath($calendarUrl);
$propFind = new PropFind($calendarUrl, []);
$properties = $this->server->getPropertiesByNode($propFind, $node);
return $properties['d:displayname'] ?? '';
// Get displayname from collection
$properties = $this->server->getProperties($calendarUrl, ['{DAV:}displayname']);
return $properties['{DAV:}displayname'] ?? '';
} }
public function buildConfigurations($configFile) { public function buildConfigurations($configFile) {
@ -303,8 +301,8 @@ class Plugin extends ServerPlugin {
return [ return [
'name' => $this->getPluginName(), 'name' => $this->getPluginName(),
'description' => 'The plugin provides synchronization between remote storages and iCAL todo events', 'description' => 'The plugin provides synchronization between remote storages and iCal todo events',
'link' => null, 'link' => 'https://git.aerex.me/Aerex/baikal-storage-plugin',
'config' => true 'config' => true
]; ];