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